Cloning a root-on-ZFS system drive

Metaluna

Limp Gawd
Joined
Jan 23, 2008
Messages
393
I'm currently running my server with FreeBSD 8.2 and ZFSGuru. The OS drive is a single 320GB laptop drive formatted with ZFS. It has been showing some reallocated sectors, so I'd like to replace it with a new 30GB SSD (Kingston 30GB SSDNow). The OS install is only using about 20GB of space so the SSD should be big enough.

Is there an easy way to clone a ZFS drive to a smaller drive? I've heard of people adding the second drive as a mirror, then removing the original drive, but I'm not sure if I can add a mirror drive that is 1/10th the size of the original.
 
From Oracle. More pertinent to Solaris but may have useful info for *BSD.

Q: Will there be a zfsdump similar to ufsdump? There is zfs send and zfs receive but I believe we need a bare metal restore, especially when the root file systems are placed under ZFS.
A: There are no plans for a zfsdump similar to ufsdump.

You can use zfs send to generate a backup of a file system. However, you have to be aware that the output of zfs send could change in future releases, so it's possible that you may not be able to restore such a backup if you upgrade ZFS in the future.

However you can use cpio(1) or pax(1) to generate a backup of a root file system to back up and restore data into ZFS file systems, including root file systems. Indeed the current method of creating a ZFS root file system involves using cpio(1) to copy a root file system into a ZFS file system.
 
Cloning to a smaller drive is rather complicated; i would just reinstall in that case. You will lose Samba settings and other stuff, but you can just import your data pool and setup things again as they were.

Cloning to a larger drive is described here:
http://zfsguru.com/forum/zfsgurusupport/102#565

But why panic over a few corrected bad sectors? If you don't trust the storage device, then use copies=2 or even copies=3 before Root-on-ZFS installation. So how does this work?

For new install:
- format disks, create pool
- visit Files page and select your pool filesystem (same name as the pool), now set copies=3, the maximum
- Install per normal on System->Install page

For existing install:
- visit Files page and select your pool filesystem, set copies=3
- now visit System->Install page and during step 2, choose a DIFFERENT system version than the one you are already running; this is important!
- continue installation per normal

Keep in mind that copies=3 only affects newly written files; existing files written with copies=1 setting would not gain the added protection. So that is why you need to do this before Root-on-ZFS installation. But as described above, you can do this from a running Root-on-ZFS system, assuming you can/want to install another system version. Like a new installation, you will lose settings like Samba and such.

Using copies=3, you should not fear that a bad sector could threaten your data, even on a single disk without redundancy. Metadata is already replicated this way, but data normally is not. With copies=3, the data would somewhat increase, but 250MB * 3 is still less than a gigabyte, so no big deal here. Another useful thing to note is that while ZFS has redundancy like this, it can automatically fix bad sectors by writing to them, allowing the HDD to replace it with a reserve one.

Reallocated Sector Count = passive factors that no longer cause harm but are defective and not used anymore
Current Pending Sector = number of sectors that are UNREADABLE but still active (visible by the OS/ZFS); these are dangerous! These will disappear when written to. If it was physical damage that caused the problem, then the Reallocated Sector Count will be increased.
 
Back
Top