Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Here's my scenario:

I have Ubuntu with native ZFS installed on a server with 2 x 500 GB SATA disks. I installed it following this guide:

So I have on disk 1 a 16 MB partition for /boot/grub and the rest of that disk and the entire second drive dedicated to ZFS in a mirroring zpool. Everything works fine.

The problem is that now I need to get rid of the 500 GB disks and replace them for 2 x 1.5 TB disks.

Is there any way that I can replicate everything (data, partition table, etc.) from my two 500 GB HDD to the two 1.GB TB HDD without having to re-install the system from the scratch?

I'm adding here the information requested by @jlliagre:


# fdisk -l

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xf4bfe018

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *          63       32129       16033+  be  Solaris boot
/dev/sda2           32130   976773167   488370519    5  Extended
/dev/sda5           32193   976773167   488370487+  bf  Solaris

Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I    /O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xf4bfe018

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1              63   976773167   488386552+   5  Extended
/dev/sdb5             126   976773167   488386521   bf  Solaris

zpool status:

# zpool status
  pool: labpool
 state: ONLINE
 scan: none requested

    labpool     ONLINE       0     0     0
      mirror-0  ONLINE       0     0     0
        sda5    ONLINE       0     0     0
        sdb5    ONLINE       0     0     0

errors: No known data errors

zpool list

# zpool list
labpool   464G  70.7G   393G    15%  1.00x  ONLINE  -

zpool history

# zpool history
History for 'labpool':
2012-02-17.19:23:39 zpool create labpool mirror /dev/disk/by-id/ata-WDC_WD5000AAKX-001CA0_WD-WCAYUFF66324-part5 /dev/disk/by-id/ata-WDC_WD5000AAKX-001CA0_WD-WCAYUFJ06204-part5
2012-02-17.19:26:39 zfs create labpool/ROOT
2012-02-17.19:26:44 zfs create labpool/ROOT/ubuntu-1
2012-02-17.19:27:15 zfs set mountpoint=/ labpool/ROOT/ubuntu-1
2012-02-17.19:27:36 zpool set bootfs=labpool/ROOT/ubuntu-1 labpool
2012-02-17.19:28:03 zpool export labpool
2012-02-17.19:28:30 zpool import -d /dev/disk/by-id/ -R /mnt labpool
2012-02-17.20:48:20 zpool export labpool
2012-02-17.21:03:30 zpool import -f -N labpool
2012-02-17.21:07:35 zpool import -f -N labpool
2012-02-17.21:42:09 zpool import -f -N labpool
2012-02-17.21:51:39 zpool import -f -N labpool
2012-02-17.21:55:49 zpool import -f -N labpool
2012-02-17.21:58:10 zpool import -f -N labpool
2012-02-22.13:25:26 zpool import -f -N labpool
2012-02-22.13:40:15 zpool import -f -N labpool
2012-02-22.12:50:38 zpool import -f -N labpool

I've been thinking: what if I boot from a LiveCD, follow the installation guide up to step 4 (partitioning and creating the ZFS pool on my new pair of disks), then mount the new filesystem on /mnt/new and the old one in /mnt/old and rsync from old to new? Would that be possible? Or will it mess everything up?

share|improve this question
BTW, I read this:… but that assumes that there are two servers with ZFS installed. I need to replace the disks on the same server. – El Barto Feb 22 '12 at 18:56
Please add the output of fdisk -l, zpool status, zpool list and zpool history to your question. – jlliagre Feb 22 '12 at 20:46

This should work:

  • Create a similar partition layout on the new disks, ZFS isn't going to do it for you.

  • Copy the boot partition and reinstall the boot loader.

  • set the autoexpand property on your root pool zpool set autoexpand=on labpool

  • Replace one of the disks, eg zpool replace labpool sda5 sdc5 and wait for the resilvering to mirror all the pool datasets using zpool status

  • Replace the second disk zpool replace labpool sdb5 sdd5.

  • Remove the old disks

share|improve this answer
Thanks for your answer. Unfortunately I saw it late. I did it in another way, which I posted as a different answer. – El Barto Feb 25 '12 at 17:43

You should be able to use zpool replace <pool> <old disk> <new disk> for each disk. This will keep all partitions, file attributes etc. I have used this successfully with zfs-fuse.

See the manpage.

share|improve this answer
zpool replace is indeed the right way but it won't handle the partition table. The pool isn't using whole disks but primary partitions so they must be created first on the target disks. – jlliagre Feb 25 '12 at 21:06
up vote 0 down vote accepted

I emailed the author of the guide I followed to install Ubuntu+ZFS and he gave me a solution which worked:

ZFS instances cannot be resized, so you must recreate the pool on larger disks to enlarge it. Do something like this:

  1. Install the new disks.
  2. Partition the new disks for /boot plus a larger pool area.
  3. Create a new pool, but give it a different name.
  4. zfs snapshot -r oldpool@now
  5. zfs send -R oldpool@now | zfs recv newpool
  6. Copy the old /boot into the new /boot.
  7. Repeat the GRUB installation.
  8. Remove the old disks.

If you want to keep the same pool name, then you must export the new pool and use zpool import -R after step 3, which is described in the man page.

I had some problems because I needed to change the sockets where the disks where connected, but I thought the answer could help others in my situation.

I didn't try @jlliagre's solution because I saw it afterwards, but I think there might have been a problem with what is mentioned in the email I'm quoting about ZFS instances not being able to be resized (remembering I wanted to pass from a 2x500 GB mirror to a 2x1.5 TB mirror).

share|improve this answer
You were given incorrect information. ZFS pools can definitely be resized as long as the new underlying devices size are larger than the older ones, which is definitely your case. Depending on the pool version, this is done automatically when the pool is imported, or on mor recent ones, the autoexpand property need to be set. I'm adding this latter information in my reply. – jlliagre Feb 25 '12 at 19:58
Thanks @jlliagre. It's a shame I didn't see your answer before making the changes, because your approach seems easier. I'll keep it in mind for the future and hope others can benefit from this Q&A. – El Barto Feb 25 '12 at 20:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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