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.
NOTE: 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.
- Go into single user mode
- Partition the second disk as required.
- newfs the partitions on the second disk
- Mount the second disk’s partitions
-
Use ufsdump/ufsrestore to copy the filesystem into it’s smaller home
>ufsdump 0f - / | ( cd /mnt/newroot ;ufsrestore xvf - )
-
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
- 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.