So I didn’t originally go with zfs, instead using greyhole. However, I can’t help but want the advantages of using zfs. On Ubuntu, it is dead simple installing the zfsforlinux ppa:
sudo add-apt-repository ppa:zfs-native/stable sudo apt-get update sudo apt-get install ubuntu-zfs zfs-auto-snapshot
So I am going to create a degraded raidz with three drives. So I have to transfer any files currently stored on two of those three drives to the remaining disks. Greyhole handles this easily:
sudo greyhole --going=/mnt/wd2tb/gh sudo greyhole --going=/mnt/sam15tb/gh sudo umount /mnt/wd2tb sudo umount /mnt/sam15tb
Make sure that you had enough room and everything went smoothly for greyhole during those processes.
If so, we can proceed to make the degraded zfs raidz with those two drives and a third empty file. We will later remove the empty file from the raid, leaving it degraded, copy over all the files, and then replace the third missing “drive” file with the real drive that currently stores the data.
This command creates a file that is supposedly 2 terabytes in size, but takes only 1G space. My /tmp is in memory (tmpfs) so it would be deleted upon reboot.
dd if=/dev/zero of=/tmp/false2tb.zfs bs=1G count=1 seek=2000
Second, you shouldn’t use the short names for zfs drives, instead the device-ids. I chose to reference those using nice names by creating a vdev alias file in /etc/zfs/vdev_id.conf with the following:
# by-vdev # name fully qualified or base name of device link alias hit2tb scsi-some_disk_id alias sea15tb scsi-other_disk_id alias wd2tb scsi-another_disk_id
Then we make the raidz, using the file and two of the drives that don’t hold the data. Careful here, zfs will format the drives automatically.
sudo zpool create datapool raidz wd2tb sea15tb /tmp/false2tb.zfs -f sudo zpool status pool: datapool state: ONLINE scan: none requested config: NAME STATE READ WRITE CKSUM datapool ONLINE 0 0 0 raidz1-0 ONLINE 0 0 0 wd2tb ONLINE 0 0 0 sea15tb ONLINE 0 0 0 /tmp/false2tb.zfs ONLINE 0 0 0
It is made! Now we will immediately put the file “drive” offline, and check the status:
sudo zpool offline datapool /tmp/false2tb.zfs sudo zpool status pool: datapool state: DEGRADED status: One or more devices has been taken offline by the administrator. Sufficient replicas exist for the pool to continue functioning in a degraded state. action: Online the device using 'zpool online' or replace the device with 'zpool replace'. scan: none requested config: NAME STATE READ WRITE CKSUM datapool DEGRADED 0 0 0 raidz1-0 DEGRADED 0 0 0 wd2tb ONLINE 0 0 0 sea15tb ONLINE 0 0 0 /tmp/false2tb.zfs OFFLINE 0 0 0
I have an advanced format disk and so I want to check that zfs has the right 4k shift=12 setting:
sudo zdb | egrep 'ashift| name' name: 'datapool' ashift: 12
An ashift=12 value is what I want. If it was 9, zfs would be using 512b block size.
I want to change some settings and then make some additional sub-pools:
sudo zfs set compression=on datapool sudo zfs create datapool/ComputerBackups sudo zfs create datapool/Crashplan ...
The command sudo zfs list will show what was made.
Now we need to copy the files from the current location, which is /mnt/hit2tb/gh/ for me:
rsync -av --exclude=.gh* --log-file=~/Documents/copytodatapool.log /mnt/hit2tb/gh/ /datapool/
…and then wait a few hours…
Once you’ve checked that everything you want has copied over correctly, it is time to replace the empty file disk with the real remaining disk:
First I would stop greyhole. Personally I decided to not use it at all after this point. So I modified the greyhole.conf to remove all the
sudo service greyhole stop sudo umount /mnt/hit2tb sudo zpool replace datapool /tmp/false2tb.zfs hit2tb sudo zpool status pool: datapool state: DEGRADED status: One or more devices is currently being resilvered. The pool will continue to function, possibly in a degraded state. action: Wait for the resilver to complete. scan: resilver in progress since Sat Mar 9 20:39:10 2013 91.1M scanned out of 1.73T at 11.4M/s, 44h9m to go 28.1M resilvered, 0.01% done config: NAME STATE READ WRITE CKSUM datapool DEGRADED 0 0 0 raidz1-0 DEGRADED 0 0 0 wd2tb ONLINE 0 0 0 sea15tb ONLINE 0 0 0 replacing-2 OFFLINE 0 0 0 /tmp/false2tb.zfs OFFLINE 0 0 0 hit2tb ONLINE 0 0 0 (resilvering)
… and then wait for it to finish resilvering. Presto, your raidz is in place.
Now your data is secure and greyhole is no longer needed.
sudo apt-get remove greyhole sudo apt-get autoremove
Leave a Reply