SVM grow volume

This page describes how to grow your volume on SPARC if you are using Solaris Volume Manager ( SVM ) formerly called Solaris DiskSuite. If you read this you likely have one or more file systems full and need re-arrange your partitions to fit your needs.

I give no guarantees on this page. Read it if you want to, but all is up to you.

I had reason doing this and did the steps on a test system before. As the sync takes some time, I wrote this how-to during sync times. Work was done on Solaris 10-0508

I asume you are familiar with the format command and the sub-command label inside format. You also might want to safe-copy the partition layout using

root@server # prtvtoc /dev/dsk/c?t?d?s2 > /root/my-start-vtoc.txt

1. Complicate it

To complicate this guide I here add a ZFS file system and have it mounted at /export/vol0.
(Of course you do not need to do this step, but you might find it on a system and this guide includes the needed steps for this as well.)
Create the partitions using format to some small size just for the demo. Then create the ZFS file system via:

root@server # zpool create -m /export/vol0 vol0 raidz c1t0d0s5 c1t0d0s6 c1t0d0s7 c1t1d0s5 c1t1d0s6 spare c1t1d0s7

2. Background

For this guide I now have: A mirrored root, a mirrored swap, a mirrored /export and a ZFS file system mounted on /export/vol0. I want to increase size for root and will decrease the size for /export in order to free blocks. The decrease of size is not possible via SVM, so it must be done by un-mounting /export and copying the contents to the new /export file system.

root@server # df -lh | egrep "Filesystem|^/dev/md|vol0|/tmp"
Filesystem size used avail capacity Mounted on
/dev/md/dsk/d10 14G 13G 985M 94% /
swap 3.1G 32K 3.1G 1% /tmp
/dev/md/dsk/d30 14G 5.0G 9.3G 36% /export
vol0 19G 10.0G 9.0G 53% /export/vol0

root@server # swap -l
swapfile dev swaplo blocks free
/dev/md/dsk/d20 85,20 16 4100912 4100912
Showing how disk is formatted via format as prtvtoc output is harder to read.
( only showing the interesting part )

root@server # ( echo 0 ; echo par ; echo pr ; echo q ; echo q ) | format
Part Tag Flag Cylinders Size Blocks
0 root wm 403 - 3421 14.65GB (3019/0/0) 30721344
1 swap wu 0 - 402 1.96GB (403/0/0) 4100928
2 backup wm 0 - 14086 68.35GB (14087/0/0) 143349312
3 unassigned wm 3422 - 3424 14.91MB (3/0/0) 30528
4 unassigned wm 3425 - 6443 14.65GB (3019/0/0) 30721344
5 unassigned wm 11087 - 12086 4.85GB (1000/0/0) 10176000
6 unassigned wm 12087 - 13086 4.85GB (1000/0/0) 10176000
7 unassigned wm 13087 - 14086 4.85GB (1000/0/0) 10176000

root@server # metastat -c
d30 m 14GB d31 d32
d31 s 14GB c1t0d0s4
d32 s 14GB c1t1d0s4
d20 m 2.0GB d21 d22
d21 s 2.0GB c1t0d0s1
d22 s 2.0GB c1t1d0s1
d10 m 14GB d11 d12
d11 s 14GB c1t0d0s0
d12 s 14GB c1t1d0s0

root@server # egrep "^##|^d" /etc/lvm/md.tab
## ROOT ( / )
d10 -m d11 d12 1
d11 1 1 c1t0d0s0
d12 1 1 c1t1d0s0
## swap
d20 -m d21 d22 1
d21 1 1 c1t0d0s1
d22 1 1 c1t1d0s1
## /export
d30 -m d31 d32 1
d31 1 1 c1t0d0s4
d32 1 1 c1t1d0s4

root@server # metadb
flags first blk block count
a m p luo 16 8192 /dev/dsk/c1t0d0s3
a p luo 8208 8192 /dev/dsk/c1t0d0s3
a p luo 16400 8192 /dev/dsk/c1t0d0s3
a u 16 8192 /dev/dsk/c1t1d0s3
a u 8208 8192 /dev/dsk/c1t1d0s3
a u 16400 8192 /dev/dsk/c1t1d0s3

3. Description.

So now you know how it looks like when I start. You should notice that swap start on cylinder 0 in the format output above. For SVM, when mirroring devices, both sub-mirrors or none-of-them should start on cylinder 0. However, we need not move swap in this case as it sits good where it is. If you would like to move swap you could delete it with "swap -d" and then re-create it.

3.1 Description. Change the /export size so that we have free space.

Un-mount the /export/vol0 and /export as we will copy and re-create /export. ( SVM can not shrink file systems )
root@server # umount /export/vol0
root@server # umount /export

Remove all SVM-config for /export
root@server # metadetach d30 d31
d30: submirror d31 is detached
root@server # metaclear d31
d31: Concat/Stripe is cleared
root@server # metaclear d30
d30: Mirror is cleared
root@server # metaclear d32
d32: Concat/Stripe is cleared
root@server # metastat -c
d20 m 2.0GB d21 d22
d21 s 2.0GB c1t0d0s1
d22 s 2.0GB c1t1d0s1
d10 m 14GB d11 d12
d11 s 14GB c1t0d0s0
d12 s 14GB c1t1d0s0

Using format, change partitions size for /export on first disc c1t0d0
from:
4 unassigned wm 3425 - 6443 14.65GB (3019/0/0) 30721344
to:
4 unassigned wm 4444 - 6443 9.70GB (2000/0/0) 20352000

Create file system on new partition and copy data there from second disc
root@server # newfs /dev/dsk/c1t0d0s4
root@server # mount /dev/dsk/c1t0d0s4 /mnt
root@server # ufsdump 0f - /dev/rdsk/c1t1d0s4 | ( cd /mnt; ufsrestore xf - )
root@server # umount /mnt

Make /export a SVM volume again
root@server # cp -p /etc/lvm/md.tab /etc/lvm/md.tab-original
Edit md.tab and remove d32 from d30 config. Like:
root@server # sdiff -s /etc/lvm/md.tab-original /etc/lvm/md.tab
d30 -m d31 d32 1 | #d30 -m d31 d32 1
> d30 -m d31 1

Setup SVM for /export
root@server # metainit d31
d31: Concat/Stripe is setup
root@server # metainit d30
d30: Mirror is setup

d30 is now approx 10GB. Mount /export and /export/vol0
root@server # metastat -c d30
d30 m 9.7GB d31
d31 s 9.7GB c1t0d0s4

root@server # mount /export
root@server # zfs mount vol0

Now it looks like.
root@server # df -lh | egrep "Filesystem|^/dev/md|vol0|/tmp"
Filesystem size used avail capacity Mounted on
/dev/md/dsk/d10 14G 13G 985M 94% /
swap 8.1G 32K 8.1G 1% /tmp
/dev/md/dsk/d30 9.6G 5.0G 4.4G 53% /export
vol0 19G 10.0G 9.0G 53% /export/vol0

Using format, change partitions size for /export on second disc c1t1d0 (Same as above but for the other disc)
from:
4 unassigned wm 3425 - 6443 14.65GB (3019/0/0) 30721344
to:
4 unassigned wm 4444 - 6443 9.70GB (2000/0/0) 20352000

Change back to old config in md.tab
root@server # sdiff -s /etc/lvm/md.tab-original /etc/lvm/md.tab

root@server # metainit d32
d32: Concat/Stripe is setup
root@server # metattach d30 d32
d30: submirror d32 is attached

Wait for the sync of /export going finished
root@server # metastat -c d30
d30 m 9.7GB d31 d32 (resync-4%)
d31 s 9.7GB c1t0d0s4
d32 s 9.7GB c1t1d0s4

You are then finished with /export

3.2 Description. Move the meta databases

The goal is still to increase size of root, but the meta databases occupy the disk block we want to use. So first we need move the meta databases

List and then delete the meta databases. We need do it in 2 steps or server will else panic root@server # metadb flags first blk block count a m p luo 16 8192 /dev/dsk/c1t0d0s3 a p luo 8208 8192 /dev/dsk/c1t0d0s3 a p luo 16400 8192 /dev/dsk/c1t0d0s3 a u 16 8192 /dev/dsk/c1t1d0s3 a u 8208 8192 /dev/dsk/c1t1d0s3 a u 16400 8192 /dev/dsk/c1t1d0s3 root@server # metadb -d /dev/dsk/c1t0d0s3 Using format, change partitions size for meta databases on first disc c1t0d0 from: 3 unassigned wm 3422 - 3424 14.91MB (3/0/0) 30528 to: 3 unassigned wm 4441 - 4443 14.91MB (3/0/0) 30528 Add back the meta databases to the first disc root@server # metadb -a -c 3 c1t0d0s3 Do the same for the second disk meta detabases root@server # metadb -d /dev/dsk/c1t1d0s3 Using format, change partitions size for meta databases on second disc c1t1d0 from: 3 unassigned wm 3422 - 3424 14.91MB (3/0/0) 30528 to: 3 unassigned wm 4441 - 4443 14.91MB (3/0/0) 30528 Add back the meta databases to the second disc root@server # metadb -a -c 3 c1t1d0s3 List the result root@server # metadb flags first blk block count a u 16 8192 /dev/dsk/c1t0d0s3 a u 8208 8192 /dev/dsk/c1t0d0s3 a u 16400 8192 /dev/dsk/c1t0d0s3 a u 16 8192 /dev/dsk/c1t1d0s3 a u 8208 8192 /dev/dsk/c1t1d0s3 a u 16400 8192 /dev/dsk/c1t1d0s3 You are now finished with moving meta databases

3.3 Description. Increase the root volume

OK, so there were some steps in order to reach this step. But now we are here.

First list and see that all are in sync root@server # metastat -c d30 m 9.7GB d31 d32 d31 s 9.7GB c1t0d0s4 d32 s 9.7GB c1t1d0s4 d20 m 2.0GB d21 d22 d21 s 2.0GB c1t0d0s1 d22 s 2.0GB c1t1d0s1 d10 m 14GB d11 d12 d11 s 14GB c1t0d0s0 d12 s 14GB c1t1d0s0 Detach sub-mirror on first disc root@server # metadetach d10 d11 d10: submirror d11 is detached root@server # metaclear d11 d11: Concat/Stripe is cleared Using format, change partitions size for root partition on first disc c1t0d0 from: 0 root wm 403 - 3421 14.65GB (3019/0/0) 30721344 to: 0 root wm 403 - 4440 19.59GB (4038/0/0) 41090688 Create and attach sub-mirror on first disc and wait for it to sync root@server # metainit d11 d11: Concat/Stripe is setup root@server # metattach d10 d11 d10: submirror d11 is attached root@server # metastat -c d10 d10 m 14GB d12 d11 (resync-1%) d12 s 14GB c1t1d0s0 d11 s 19GB c1t0d0s0 Detach sub-mirror on second disc root@server # metadetach d10 d12 d10: submirror d12 is detached root@server # metaclear d12 d12: Concat/Stripe is cleared Using format, change partitions size for root partition on second disc c1t1d0 from: 0 root wm 403 - 3421 14.65GB (3019/0/0) 30721344 to: 0 root wm 403 - 4440 19.59GB (4038/0/0) 41090688 Create and attach sub-mirror on second disk and wait for it to sync root@server # metainit d12 d12: Concat/Stripe is setup root@server # metattach d10 d12 d10: submirror d12 is attached root@server # metastat -c d10 d10 m 14GB d11 d12 (resync-9%) d11 s 19GB c1t0d0s0 d12 s 19GB c1t1d0s0 Notice that d11 and d12 are both 19GB but d10 is still 14GB. We need attach the mirror to itself root@server # metattach d10 root@server # metastat -c d10 d10 m 19GB d11 d12 d11 s 19GB c1t0d0s0 d12 s 19GB c1t1d0s0 The mirror and sub-mirrors are now 19GB. The file system is still 14GB root@server # df -lh | egrep "Filesystem|^/dev/md|vol0|/tmp" Filesystem size used avail capacity Mounted on /dev/md/dsk/d10 14G 13G 982M 94% / swap 8.4G 32K 8.4G 1% /tmp /dev/md/dsk/d30 9.6G 5.0G 4.4G 53% /export vol0 19G 10.0G 9.0G 53% /export/vol0 Now grow the root file system. Note. all write actions are blocked until growth is done root@server # growfs -M / /dev/md/rdsk/d10 You are now finished and it looks like this root@server # df -lh | egrep "Filesystem|^/dev/md|vol0|/tmp" Filesystem size used avail capacity Mounted on /dev/md/dsk/d10 19G 13G 5.8G 70% / swap 8.4G 32K 8.4G 1% /tmp /dev/md/dsk/d30 9.6G 5.0G 4.4G 53% /export vol0 19G 10.0G 9.0G 53% /export/vol0 root@server # metastat -c d30 m 9.7GB d31 d32 d31 s 9.7GB c1t0d0s4 d32 s 9.7GB c1t1d0s4 d20 m 2.0GB d21 d22 d21 s 2.0GB c1t0d0s1 d22 s 2.0GB c1t1d0s1 d10 m 19GB d11 d12 d11 s 19GB c1t0d0s0 d12 s 19GB c1t1d0s0

End-of-page