Thursday, March 25, 2010

Expanding rpool

Today I switched to a bigger disk in my OpenSolaris laptop, it was fairly easy to have rpool expand on the new disk without reinstallation. Here is the general procedure for resizing an existing rpool or migrating the pool to a larger disk:
  • Create a new Solaris partition with fdisk on the new disk (or resize the existing one) covering the same space as the old but with extra space in the end.
  • If switching to a new disk, copy all blocks from the old partition into the new (dd if=c1d0p1 of=c2d0p1 bs=131072).
  • Switch disks, remove the original and rebooted to verify that the transfer worked.
$ zpool list                                           
NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT
rpool 40G 27.8G 12.2G 69% 1.00x ONLINE -
  • Use format and resize the slice used by ZFS to cover additional cylinders.
  • Use zpool online -e rpool c1d0s0 to make rpool use added space.
$ zpool list                                           
NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT
rpool 264G 28.0G 236G 10% 1.00x ONLINE -

Update:
As a reader pointed out, this could and probably should have been done with zpool attach/detach given that only OpenSolaris on ZFS was present on the disk. I did not mention that I also had another partition that I needed to transfer. If using attach/detach you need to use installgrub afterwards to make it bootable. All information on how to perform the mirroring with attach/detach is here.

3 comments:

Anonymous said...

Just curious: Why not zpool attach NEWDISK followed by a zpool detach OLDDISK ?

Henkis said...

Very good question, that would also have worked (and probably would be the preferred way) if I only had OSOL on the disk. And I would need to use installgrub also. I had another partition that I also wanted to move so this was a good solution for me.

Tor Nilsen said...

I tried it with zpool replace. It seemed to work fine, all the way to the point where I rebooted :)

One of these days I'm going to try again (after backing up my virtual disks) to see what went wrong and why.