Jeff Taylor's Weblog

  • Sun
    July 26, 2010

Adding a hard drive for /export/home under ZFS

Summary: added a new hard drive to my "OpenSolaris 2009.06 snv_111b" system and attached it to /export/home. 

The first step was easy: my Sun Ultra 24 had a free drive bay, so I stuck the new drive into the running system, ran "devfsadm -C -v" and then from "format" I could see that the disk was available to OpenSolaris as "c9d0"

Next, a decision needed to be made with respect to how to utilize the drive. I considered using several approaches, such as adding the disk to the existing rpool.  After considering my potential future projects, I decided to attach the disk as a new zpool that would only contain /export/home.  Isolating /export/home should yield some flexibility when I play nasty games with the root drive.

The process was slightly complicated by the fact that logging into OpenSolaris as root is disabled by default. To allow root login, I removed "type=role;" from the root line in /etc/user_attr.  Then, the following commands were executed while logged in as root.


# zfs list
new 79K 685G 19K /new
rpool 26.2G 202G 82.5K /rpool
rpool/ROOT 16.4G 202G 19K legacy
rpool/ROOT/opensolaris 262M 202G 5.25G /
rpool/ROOT/opensolaris-1 25.0M 202G 5.65G /tmp/tmpOM0whB
rpool/ROOT/opensolaris-2 33.4M 202G 6.59G /
rpool/ROOT/opensolaris-3 171M 202G 6.59G /
rpool/ROOT/opensolaris-4 17.4M 202G 6.72G /
rpool/ROOT/opensolaris-5 106M 202G 6.72G /
rpool/ROOT/opensolaris-6 15.8G 202G 14.6G /
rpool/dump 3.97G 202G 3.97G -
rpool/export 1.82G 202G 21K /export
rpool/export/home 1.82G 202G 22K /export/home
rpool/export/home/jeff 1.82G 202G 1.82G /export/home/jeff
rpool/swap 3.97G 206G 101M -


# 1) Create a zpool on the new disk
zpool create new c9d0
# 2) Create a snapshot of the existing data
zfs snapshot -r rpool/export@July26
# 3) Copy the data to the new hard drive
zfs send rpool/export@July26 | zfs receive new/export
zfs send rpool/export/home@July26 | zfs receive new/export/home
zfs send rpool/export/home/jeff@July26 | zfs receive new/export/home/jeff
# 4) Rename the old dataset
zfs rename rpool/export rpool/export_old
# 5) Push the old dataset to a new mount point for archival
zfs unmount rpool/export_old/home/jeff
zfs unmount rpool/export_old/home
zfs set mountpoint=/export_old rpool/export_old
zfs set mountpoint=/export_old/home rpool/export_old/home
zfs set mountpoint=/export_old/home/jeff rpool/export_old/home/jeff
zfs mount rpool/export_old/home
zfs mount rpool/export_old/home/jeff
# 6) Put the new hard drive on /export
zfs set mountpoint=/export new/export

When I was satisfied that I could log in as "jeff" and see the data on the new disk, I cleaned up the old disk:

# 7) cleaned up the old disk
zfs destroy rpool/export_old/home/jeff@July26
zfs destroy rpool/export_old/home/jeff
zfs destroy rpool/export_old/home@July26
zfs destroy rpool/export_old/home
zfs destroy rpool/export_old@July26
zfs destroy rpool/export_old


# zpool status
pool: new
state: ONLINE
scrub: none requested


new ONLINE 0 0 0

c9d0 ONLINE 0 0 0
errors: No known data errors
pool: rpool
state: ONLINE
scrub: none requested


rpool ONLINE 0 0 0

c8d0s0 ONLINE 0 0 0
errors: No known data errors
# zfs list
new 1.86G 683G 19K /new
new/export 1.86G 683G 21K /export
new/export/home 1.86G 683G 22K /export/home
new/export/home/jeff 1.86G 683G 1.82G /export/home/jeff
rpool 24.4G 204G 82.5K /rpool
rpool/ROOT 16.4G 204G 19K legacy
rpool/ROOT/opensolaris 262M 204G 5.25G /
rpool/ROOT/opensolaris-1 25.0M 204G 5.65G /tmp/tmpOM0whB
rpool/ROOT/opensolaris-2 33.4M 204G 6.59G /
rpool/ROOT/opensolaris-3 171M 204G 6.59G /
rpool/ROOT/opensolaris-4 17.4M 204G 6.72G /
rpool/ROOT/opensolaris-5 106M 204G 6.72G /
rpool/ROOT/opensolaris-6 15.8G 204G 14.7G /
rpool/dump 3.97G 204G 3.97G -
rpool/swap 3.97G 208G 101M -

Mission accomplished without needing to reboot the system!

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.