Wednesday Dec 10, 2008

Creating an dual-boot OpenSolaris 2008.11 / System Rescue USB Stick

While doing the Solaris InstallFest at CEC 2008, I started playing with creating a bootable OpenSolaris USB stick. Booting from CD was fine but, as we discovered, booting from USB is significantly faster.

I was disappointed to discover that though the USB image that was generated from the OpenSolaris iso was only 800MB or so in size, the usbcopy script took over the whole USB stick that I was using. That's fine if you only are using 1GB sticks, but since they gave out 4GB sticks at CEC this year (and 2GB sticks last year), you're wasting 3.2GB of space that could be used for something else.

Typically for the Solaris InstallFest we use either the System Rescue CD or a GParted Live image. This becomes a problem since we're either waiting for someone to finish up using the OpenSolaris CD, or the System Rescue CD, or the GParted Live CD instead of actually doing something... or someone accidentally walks off with one CD still in their drive.

While doing this from a USB key may make you think that they'd walk off with our USB keys, I'd like to think that they'd likely not accidentally do it since the USB keys tend to stick out a bit more than a CD in the drive. Plus, we can use their own USB key to put the image on if they wish.

So here's some hacks to be able to create a Dual-Boot USB stick and use the rest of the space on the USB stick for the System Rescue image.

1. Get the usb file for OpenSolaris from http://genunix.org/distributions/indiana/osol-0811.usb and download the ISO for the System Rescue CD from http://www.sysresccd.org/Download

2. Get the usbcopy by installing the OpenSolaris SUNWdistro-const package from IPS.

    pfexec pkg install SUNWdistro-const
3. Write the USB file to the stick.
    pfexec usbcopy osol-0811.usb
At this point, you will have "wasted" most of the space on the USB stick since you just wrote a 860MB image to a 4GB stick. You need to reclaim that space.

4. Repartition the USB stick.

    pfexec format -e
    Select the USB stick
    fdisk
    Note the total Cylinders
    Delete the Solaris Partition
    Create a new Solaris Partition in the size that will fit the
        860MB.  Solaris FDISK is braindead so this will be fun.
    Create a FAT partition (partition type "c") using the rest of
        the key.
    Exit and save.
    Re-Create slice 0 on the Solaris partition to start with
        cylinder 1 and use the rest of the space.
    Label it, selecting SMI label
5. Verify that you sized things correctly by running fsck against it.
    pfexec fsck /dev/rdsk/c6t0d0s0
If it isn't size correctly, you'll get a complaint saying it can't seek the last blocks. ie:
pfexec fsck /dev/rdsk/c6t0d0s0
\*\* /dev/rdsk/c6t0d0s0

CANNOT READ: DISK BLOCK 1680032: I/O error
CONTINUE? n

Program terminated
If you get that, resize the Solaris fdisk partition larger.

6. Grow out the UFS file system to the rest of the slice if you so desire.

    pfexec growfs /dev/rdsk/c6t0d0s0
7. Create a pcfs (FAT) filesystem on the other USB partition
    pfexec mkfs -F pcfs -o b=SYSRESCD,fat=32 /dev/rdsk/c6t0d0p0:c
8. At this point, if you yank the USB stick and re-insert it, both file systems should mount up under /media. If not, manually mount them.

9. Mount up the ISO of the System Rescue CD.

    pfexec lofiadm -a /somelocation/rescuecd.iso
    pfexec mount -F hsfs -o ro /dev/lofi/1 /mnt
10. Copy contents to USB partition. Don't do this as root though, for some reason it doesn't work as root.
    cp -r /mnt/\* /media/SYSRESCD
11. Add entries into menu.lst to point to rescueCD stuff.
    pfexec vi /media/Flash\\ Disk/boot/grub/menu.lst
Append the following:
title RescueCD
        root (hd0,1)
        kernel /isolinux/rescuecd
        initrd /isolinux/initram.igz

title Memtest
        root (hd0,1)
        kernel /isolinux/memtest86
12. Unmount all of the filesystems and you should be able to boot from the USB stick.

I generally don't like getting multiple boot menus so this utilizes the GRUB in OpenSolaris instead of doing a chainloader to boot the System Rescue CD. The steps outlined above only utilize two of the many options in the System Rescue CD. You could get the SYSLINUX loader to load into the FAT32 parition on the USB stick and then chainload to get the rest of the options or translate other options from the syslinux.cfg into the grub menu file to get the rest.

This seems to work pretty well.

We can probably do a chainload to the SysRescueCD and get all of the other options too, but I need to figure out how to get the bootblock loaded there.

About

Phil is an Area Technical Engineer in the Central Area of Oracle's Field Service in North America. He has 15 years of experience supporting Sun's entire product line.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today