Resizing a Solaris partition

This was originally worked out when I had to resize a Solaris 10 partition under VMware, but it applies equally to native Solaris installs too!
WARNING: This only really works, if you have one partition. This should be true if you’re using VMware, and for the majority of Solaris installations. Partition, here, is in the true sense of the word: partitions as seen by fdisk, the BIOS and other disk management software, not the slices you mount as /usr, /home, and so on. Those are, errr, slices.
If you’re doing this for a VMware install, power off the virtual machine, and use vmware-vdiskmanager to resize the image file: vmware-vdiskmanager -x 20Gb solaris10_vmware.vmdk.
If the partition you are resizing is the root partition, you need to boot up in “failsafe” mode, or boot from a Solaris CD/DVD and choose the “shell” option at the first menu. You’ll be asked if you want to mount the hard drive install as /a. You do not. But you do want to remember the name of the disk (eg, c1t0d0p0).

Write out the current partition table to disk and edit the file:
# fdisk -W ptbl.tmp && vi ptbl.tmp

At the top of the file, you’ll see the actual current disk geometry, which should look somethign like this:

* Dimensions:
*    512 bytes/sector
*     63 sectors/track
*    255 tracks/cylinder
*   2610 cylinders

The sectors, tracks and cylinders numbers are important – write these down somewhere, and skip to the end of the file.

You’ll see a row of numbers, with words over them like Id, Act, Bhead etc. The two numbers you need to replace, correspond with Ecyl and Numsect.

Ecyl is the ending cylinder on the disk for this partition. The value for it, is the cylinders number that you wrote down in the previous step, MINUS ONE. The minus one is very important. While the total number of cylinders in my example is 2610, the ending cylinder number is actually 2609, because the numbering of cylinders on disk starts at zero, not one. This is the only time you need to worry about this.
You also need to change Numsect, which is the number of sectors on the disk. The value for this, is calculated as: sectors/track x tracks/cylinder x cylinders.
In our example, this is: 63 x 255 x 2610 = 41929650.

Save the file, and exit.

Now update the fdisk partition table on disk:
# fdisk -S ptbl.tmp -I /dev/rdsk/c1t0d0p0
Replace the partition name, with that of your disk. You’ll be presented with a little menu. The table at the top should indicate that 100% of the disk space is now used by the partition(s). Choose option 5, to save and exit fdisk.

Finally, we get to resize the actual partitions! Reboot into multiuser mode.

Look in /etc/vfstab to find the device that is mounted, to the slice you want to grow. In my case, this was the root slice mounted from /dev/dsk/c1t0d0s0.
We need to turn this into a metadevice (think: software raid), to be able to grow it. Don’t worry, this is perfectly (mostly) safe, and won’t hurt your performance (much, as far as I know!).

metainit -f d10 1 1 c1t0d0s0. This creates a metadevice named d10, from the given slice name. The -f causes this to be forced, which is needed if the slice is currently mounted.
Run metastat. This will give you the name of the new metadevice you created. For me, it was called d0.
If you are working on resizing the root filesystem, you need to run metaroot /dev/md/dsk/d0. This will update /etc/vfstab with the correct mount information. Otherwise, you need to update /etc/vfstab manually.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to top