7

I am moving from one server to another and want to bring some of the disks with me. Unfortunately, I do not have enough storage to back up all of the data on the old server.

Old server 4 disk RAID5
Bringing two disks from old server to:
New server 6 DISK RAID-Z2 (4+2)

Old server can take losing one disk but not two.

Could I set up the new server as RAID-Z2 (4+2) lacking one disk? Move all data and then add the last disk?

Or is there any other way around this?

  • This question has a straightforward answer: yes. The procedure is very well explained below which you should mark as the answer. – migle May 11 '17 at 12:06
9

Yes, it is possible by using fake file-backed disks for your redundant ones. Of course, not supported and you should have a backup, so simulate it first with small files on your old pool to see if everything works as expected.


For details see https://www.mail-archive.com/zfs-discuss@opensolaris.org/msg22993.html and https://www.mail-archive.com/zfs-discuss@opensolaris.org/msg23023.html for details. You can also search online for "create raidz2 degraded" if you have other systems like FreeNAS etc.

The important steps (taken from the mailing list archive thread by Tomas Ögren and Daniel Rock) are:

  1. Create sparse file with the size of the real disk (let's assume it is 1000 GB in this example):

    mkfile -n 1000g /tmp/fakedisk1
    
  2. Create a zpool with the real disks and the sparse file:

    zpool create -f newpool raidz2 disk1 disk2 disk3 disk4 disk5 /tmp/fakedisk1
    
  3. Immediately put the sparse files offline so that nobody tries to write on it:

    zpool offline newpool /tmp/fakedisk1
    
  4. Your pool will now be degraded, but functioning. Copy your files to the new pool (use ssh or netcat between send and recv if using network instead of directly attached pools):

    zfs snapshot -r oldpool@now
    zfs send -R oldpool@now | zfs recv -Fdu newpool
    
  5. Destroy the old one and replace the sparse files with the now freed up disks:

    zpool replace newpool /tmp/fakedisk1 disk6
    

Again, a word of caution depending on your redundancy level (if you use two fake disks on a Z2 or three fake disks on a Z3):

Remember: during data migration your are running without safety belts. If a disk fails during migration you will lose data.

| improve this answer | |
  • 1
    Great migration tutorial. Even better, change to: zfs snapshot -r oldpool@now – migle May 9 '17 at 16:44
  • @migle Thank you, that was an error on my side. I edited in your correction! – user121391 May 10 '17 at 6:56
  • 2
    BTW, this is fully tested, I just did this on a production system. I was migrating a RAID-Z1 to a bigger RAID-Z2. I didn't have enough bays and connectors to have all the disks in the old and new arrays connected. On the destination RAID-Z2, I still kept one disk of redundancy (I had N-1 disks connected). – migle May 11 '17 at 12:04
  • Awesome tutorial. I just tried this and it worked perfectly. Only difference is I used rsync to copy the file systems instead of zfs send since my source wasn't on ZFS. – Lily Finley Jun 11 '17 at 22:14
1

Can't commit on the first answer so I just make a new answer.

When you're on linux you can't use mkfile. The best alternative is probably truncate. First Get the (exact) size in bytes of your HDDs with fdisk:

root@OMV-NAS:~# fdisk  -l /dev/sda
Disk /dev/sda: 7,3 TiB, 8001563222016 bytes, 15628053168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes

In this case it is 8001563222016 bytes so 8,001... TB. Now we can create the fake file with:

truncate -s 8001563222016 /tmp/FD1.img

The rest is the exact same as in the original answer.

| improve this answer | |
  • I would suggest that you incorporate (with a reference!) the bits from the previous answer that would make this answer a complete one, just in case the other answer were to get deleted for any reason. – Jeff Schaller Mar 30 '18 at 1:05
  • Really overthinking it... Just make the sparse files roughly twice the size of the actual hard drives. – Grogi Aug 7 '18 at 20:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.