Howto resize or shrink UFS partitions

A friend of mine asked me the other day if there was such a thing as Partition Magic for Solaris. Apparently, someone had installed a system on a single slice and they’re security team was requiring a separate partition for the DB.

Here are the givens:

  • Sunfire V210
  • Solaris 8 (Otherwise we’d be using zfs)
  • 2 73GB disks
  • 1 slice on disk1
  • Disk 2 is supposed to be a mirror of disk 1 but it isn’t used yet
  • Downtime is allowed
  • Reinstalling is not an option

I personally don’t know of any tool that lets you shrink UFS partitions but that doesn’t mean that we can’t perform some Partition Magic of our own.

I have not tested this procedure. I think it is logical and should work and it should do no harm as the first disk remains fully intact.

  1. Go into single user mode
  2. Partition the second disk as required.
  3. newfs the partitions on the second disk
  4. Mount the second disk’s partitions
  5. Use ufsdump/ufsrestore to copy the filesystem into it’s smaller home

    ufsdump 0f - / | ( cd /mnt/newroot ;ufsrestore xvf - )

  6. When all the partitions are done, use installboot to make the second disk bootable.

    installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk /dev/rdsk/c1t2d0s0

  7. Shutdown the system, physically swap the disks, and do a reconfiguration reboot.

If rebooting goes smoothly, test your new system thoroughly and then build your mirrors.

Be Sociable, Share!
  • Twitter
  • Facebook
  • email
  • LinkedIn
  • HackerNews
  • Reddit

5 comments for “Howto resize or shrink UFS partitions

  1. Anonymous
    August 17, 2007 at 10:22 am

    This works, thanks for the hint. I did a Google search on resize Solaris partitions and your page came up. Solaris defaults to woefully inadequate /var partition size and fortunately there was a second unused drive in the machine. I have done this on two servers and it works great.

  2. Alfred J. Fazio
    August 3, 2008 at 12:18 am

    Worked great for me, too.

    For Solaris 10, be sure to substitute installboot command with installgrub:

    installgrub -m /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c1d0s0

  3. John
    October 29, 2011 at 11:26 am

    For that one reference with installgrub, that is specifically for x86.

    The stated procedure works for solaris 9 and earlier. I have done it too many times.

    My issue is that I have done this with Solaris 10 and /usr does not get mounted. Can someone help?

  4. Paul M
    December 15, 2011 at 2:57 am

    I came here hoping for a shrinkfs (like linux’s resize2fs command), since I knew about growfs on solaris.
    Sadly, the situation is what I expected, it’s a case of copying the file system to a smaller partition ;-(

Leave a Reply

Your email address will not be published.