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.

5 thoughts on “Resizing a Solaris partition

  1. Reply
    Terry D - August 31, 2011


    Stumbled upon your site, as I have run out of /tmp for a Solaris Studio install.

    You guide looks like it would help, but I cannot get past

    fdisk -W ptbl.tmp && vi ptbl.tmp

    fdisk says I am not using the parameters correctly.

    (Just to add, I am using VMWare Workstation 7, with Oracle Solaris 10)



  2. Reply
    Thomas M - March 25, 2013


    I stumbled on that too. His command is missing the raw disk entry.

    Try fdisk -W ptbl.tmp c1t0d0p0 – c1t0d0p0 was my raw disk. Run format to find your raw disk entries.

  3. Reply
    srikanth - June 2, 2015

    i guess with S option we need to use fdisk -g out put

    with w o/p

    fdisk -F ptbl.tmp /dev/rdsk/c1t1d0p0

  4. Reply
    Jose Reda - April 18, 2016

    I have a system Sun Solaris 8 installed on a Sun ultra with to 36GB, c0t0d0 for the operative system and c0t1d0 as database.
    The system it’s working fine for 4 hour but after that the machine it is getting slow because the partition /var c0t0d0s1 it get to 80 % to 90 % of the capacity. because of the temporary file.We need to reboot the system and the machine works OK or wait until the next day and the problem does not exit anymore.
    I would like to get space from

  5. Reply
    Jose Reda - April 18, 2016

    The last partition
    format> verify
    Primary label contents:
    volume name =
    ascii name =
    pcyl =24622
    ncyl =24620
    1acyyl = 2
    nheads = 27
    nhesect = 107
    Part Tag Flag Cylinders Size Blocks
    0 root wm 0 – 354 500.78MB (355/0/0) 1025595
    1 var wm 355- 1080 1.00.GB (726/0/0) 2097414
    2 backup wm 0- 24619 33.92GB (24620/0/0) 71127180
    3 swap wu 1081- 1806 1.00GB (726/0/0) 2097414
    4 usr wm 1087- 3984 3.00GB (2178/0/0) 6292242
    5 home wm 3985- 5436 2.00GB (1452/0/0) 4194128
    6 unassigned wm 5437- 13409 10.98GB (7973/0/0) 23033997
    7 home wm 13410- 24619 15.44GB (11210/0/0) 32385690

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