My Partition Resizing Exercise

The other day I needed to install a non-Solaris operating system onto my Ultra 40 M2. But I still wanted Solaris and/or Nevada as my primary operating system. Even though there are a bunch of virtualization technologies out there including the newly aquired VirtualBox, I wanted to run the operating system on the "iron" as they say.

The only problem, I had allocated 100% of all my disks to Solaris. I needed to decrease the fdisk partition on a couple of disks to make space to install other operating systems on. My disk layout was roughly

c1t0d0s0  - boot environment #1 root (ufs)
c1t0d0s1  - boot environment #1 swap

c1t1d0s0  - boot environment #2 root (ufs)
c1t1d0s1  - boot environment #2 swap

And then a ZFS pool

        NAME         STATE     READ WRITE CKSUM
        storage      ONLINE       0     0     0
          mirror     ONLINE       0     0     0
            c1t2d0   ONLINE       0     0     0
            c1t3d0   ONLINE       0     0     0
          mirror     ONLINE       0     0     0
            c1t0d0s7 ONLINE       0     0     0
            c1t1d0s7 ONLINE       0     0     0

My thought was that since c1t0d0 and c1t1d0 were only partially allocated to the zpool (and the boot disks), that I would target those for repartitioning. Which meant, first step was to rebuild the zpool without them. I didn't really need them for more space in the zpool anyways.

First step, to break the mirror, on the partial space. This would allow me to make a "backup" of the pool while I rebuild it.

zfs detach c1t1d0s7
zpool create dataz c1t1d0s7
zfs snapshot -r storage@migration
zfs send -R storage@migration > /dataz/storage.zfs

Now, destroy and recreate the main pool without the partial devices, and restore the data

zpool destroy storage
zpool create storage mirror c1t2d0 c1t3d0
zfs receive -Fd storage < /dataz/storage.zfs

Easy enough. My pool no longer has the partial disks

          mirror    ONLINE       0     0     0
            c1t2d0  ONLINE       0     0     0
            c1t3d0  ONLINE       0     0     0

Now onto resizing the target disks. The goal was to do this without doing a reinstall at all. I have been using Live Upgrade for a while to continually keep my system up to date with Nevada/SXDE releases, so I figured I could use Live Upgrade while resizing the fdisk partitions to accomplish this.

Boot Environment           Is       Active Active    Can    Copy      
Name                       Complete Now    On Reboot Delete Status    
-------------------------- -------- ------ --------- ------ ----------
sol-nv-87                  yes      yes    yes       no     -         
sol-nv-85                  yes      no     no        yes    -         

So, first disk. First step remove the LU Boot Environment

ludelete sol-nv-85

Now, since nothing is using the disk, format and fdisk aren't going to complain. So, first thing, use fdisk to reduce the size of the Solaris partition. I just reduced it to 90% of the disk

fdisk c1t1d0p0

             Total disk size is 36472 cylinders
             Cylinder size is 16065 (512 byte) blocks

      Partition   Status    Type          Start   End   Length    %
      =========   ======    ============  =====   ===   ======   ===
          1                 Solaris           1  32824    32824     90

And then recreated the Solaris layout with format

Current partition table (original):
Total disk cylinders available: 32822 + 2 (reserved cylinders)

Part      Tag    Flag     Cylinders         Size            Blocks
  0       root    wm     132 -  1437       10.00GB    (1306/0/0)   20980890
  1       swap    wu       1 -   131        1.00GB    (131/0/0)     2104515
  2     backup    wu       0 - 32821      251.43GB    (32822/0/0) 527285430
  3 unassigned    wu       0                0         (0/0/0)             0
  4 unassigned    wu       0                0         (0/0/0)             0
  5 unassigned    wu       0                0         (0/0/0)             0
  6 unassigned    wu       0                0         (0/0/0)             0
  7       home    wm    1438 - 32821      240.41GB    (31384/0/0) 504183960
  8       boot    wu       0 -     0        7.84MB    (1/0/0)         16065
  9 unassigned    wu       0                0         (0/0/0)             0

And finally, recreate the Boot Environment. I just made the new Boot Environment a copy of the current Boot Envionment, which happens to be Nevada/SXDE Build 87

lucreate -m /:/dev/dsk/c1t1d0s0:ufs -m -:/dev/dsk/c1t1d0s1:swap -n sol-nv-87-copy

And activate it and boot into it

luactivate sol-nv-87-copy
init 6

All pretty straight forward so far. Now here comes what ends up being the sticky part. You would think that since I was booted into the new Boot Environment, that I could delete the old Boot Environment, and do to the same thing, but...

ludelete sol-nv-87
The boot environment  contains the GRUB menu.
Attempting to relocate the GRUB menu.
ERROR: No suitable candidate slice for GRUB menu on boot disk: 
INFORMATION: You will need to create a new Live Upgrade boot environment on the boot disk to find a new candidate for the GRUB menu.
ERROR: Cannot relocate the GRUB menu in boot environment .
ERROR: Cannot delete boot environment .
Unable to delete boot environment.

That's what I was afraid of. The GRUB boot menu is sitting on the disk still. I searched around but could not find any way to move it. I found Slava Leanovich's blog entry which included instructions for moving the GRUB menu, and even though I tried that, ludelete still complained.

Well, gulp, here goes nothing. I decided to try to trick Solaris and not tell it I messed with the Boot Environment. First I made a ufsdump of root on that disk

ufsdump 0f /extra/holding/root.dump /dev/dsk/c1t0d0s0

Now with everything backed up from the disk, a big leap of faith. I went into fdisk and resized the Solaris parition as just before.

And then into format to recreate the disk layout. Of course this time I get the warnings

format c1t0d0
selecting c1t0d0
[disk formatted]
/dev/dsk/c1t0d0s0 is in use for live upgrade /. Please see ludelete(1M).
/dev/dsk/c1t0d0s1 is in use for live upgrade -. Please see ludelete(1M).

Yeah, You might think so Solaris. I move along and setup the layout.

Then, ufsrestore the data

newfs /dev/rdsk/c1t0d0s0
mount /dev/rdsk/c1t0d0s0 /mnt
cd /mnt
ufsrestore rf /extra/holding/root.dump

Sensing that this might not be enough, I decide to do a comple of things. First, reinstall GRUB manually, as described in Slava's entry

installgrub /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c1t0d0s0
stage1 written to partition 2 sector 0
stage2 written to partition 2, 235 sectors starting at 50

And then, just for grins, update this Boot Environment to the New Boot Environment I created just a little while earlier. I figured this should ensure that anything possible that I missed with ufsdump would be restored correctly

lumake -n sol-nv-87

Well, lumake returned success at least. Here goes nothing. Lets activate the Boot Environment and cross our fingers

luactivate sol-nv-87
init 6

Tah-Dah! Yet another reason why I love Solaris. You flex it in weird ways and it responds logically.


Post a Comment:
  • HTML Syntax: NOT allowed



Top Tags
« July 2016

No bookmarks in folder