BigAdmin System Administration Portal
Community-Submitted Article
Print-friendly VersionPrint-friendly Version
This content is submitted by a BigAdmin user. It has not been reviewed for technical accuracy by Sun Microsystems, though it may have been lightly edited to improve readability. If you find an error or would like to comment on the article, please contact the submitter or use the comment field at the bottom of the article. Community submissions may not follow Sun trademark guidelines. For information on Sun trademarks, please see http://www.sun.com/suntrademarks/.
 
 

Using a USB Flash Drive to Boot and Load the Solaris OS for x86 Platforms

James Whitlatch, Technologent; September 2007

Abstract: Here are steps to format and copy the Solaris 10 OS for x86 platforms from a boot DVD or ISO image to a USB flash drive. The article also shows which files to modify to make the miniroot mount the flash drive as the CD-ROM for an interactive installation of the Solaris OS. Additional steps show how to fully automate the OS installation.

Contents


Overview

This document covers how to format and copy the Solaris OS for x86 platforms from a boot DVD or ISO image to a USB flash drive. It then shows which files to modify to make the miniroot mount the flash disk as the CD-ROM for an interactive install. Then additional steps to fully automate the OS install are given.

In testing with my USB flash drives, I was only able to test on a Sun Java Workstation W2100z and Sun Fire X4100 and X4200 servers. I used only the Solaris 10 11/06 OS (also known as Update 3). I'm sure it will work the same on any x86 system that is supported by the Solaris 10 release, and is capable of booting from an USB flash drive.

This procedure requires an x86 system running the Solaris 10 OS to set up the flash drive as described here. The minimum USB flash drive size to hold the complete OS is 4GB. I used an 8GB size for this document.

With this procedure, I don't have to find a MAC address of the client, and it is flexible enough to customize the OS load for many different clients through the sysidcfg and profile files. Current flash drives may not offer the speed of network OS loads, but they do offer flexibility that was found before only using JumpStart.


Partitioning and Formatting the Flash Drive

So, to start, vold needs to be disabled for most of this process, so we will do that now. Then to discover the device name assigned to the USB flash drive, run the rmformat command.

  
# svcadm disable volfs
# rmformat -l
Looking for devices...
     1. Logical Node: /dev/rdsk/c2t0d0p0
        Physical Node: /pci@0,0/pci-ide@6/ide@0/sd@0,0
        Connected Device: MATSHITA CD-RW  CW-8124   DZ13
        Device Type: DVD Reader
     2. Logical Node: /dev/rdsk/c2t0d0p0
        Physical Node: /pci@0,0/pci-ide@6/ide@0/sd@0,0
        Connected Device: MATSHITA CD-RW  CW-8124   DZ13
        Device Type: DVD Reader
     3. Logical Node: /dev/rdsk/c5t0d0p0
        Physical Node: /pci@0,0/pci108e,cb84@2,1/storage@6/disk@0,0
        Connected Device: UDISK    PDU01_8G 76C2.0  0.00
        Device Type: Removable

My flash drive is number 3. In this case the logical device name is /dev/rdsk/c5t0d0p0.

Now to create the partition, use the fdisk command.

  
# fdisk /dev/rdsk/c5t0d0p0
        Total disk size is 3935 cylinders
        Cylinder size is 4096 (512 byte) blocks

                                          Cylinders
      Partition   Status    Type          Start   End   Length    %
      =========   ======    ============  =====   ===   ======   ===
          1       Active    Solaris2          1  3934    3934    100



SELECT ONE OF THE FOLLOWING:
   1. Create a partition
   2. Specify the active partition
   3. Delete a partition
   4. Change between Solaris and Solaris2 Partition IDs
   5. Exit (update disk configuration and exit)
   6. Cancel (exit without updating disk configuration)
Enter Selection:

Select the proper menu options and create a partition to consume 100 percent of the flash drive.

Create the partition to be of type Solaris2, and Active. Now that it is partitioned, it needs to have the slices laid out. To do this, we need to find the size of the partition in megabytes. Execute the fdisk command below, and take the value from Numsect.

  
# fdisk -W - /dev/rdsk/c5t0d0p0

* /dev/rdsk/c5t0d0p0 default fdisk table
* Dimensions:
*    512 bytes/sector
*     32 sectors/track
*    128 tracks/cylinder
*   3935 cylinders
....
* Id   Act   Bhead  Bsect  Bcyl  Ehead  Esect  Ecyl   Rsect  Numsect
  191  128   65     2      0     72     29     1003   4096   16113664

This flash drive has 16113664 as Numsect (the number of sectors). Dividing this number by 2048 gives us total megabytes (7868MB). The slice info will be placed into a file we need to create, similar to below (called x86slice), which will then be loaded on the flash drive with the rmformat command. We need to configure three slices, 0, 2, and 8. The backup partition (slice 2 below) spans the entire flash drive. The size of it is total megabytes (7868MB) minus 1, since we start at 0. The boot partition is on slice 8; it starts at the beginning of the drive and is 2MB. The root partition starts at offset 2MB, and takes the rest of the drive, which is 7867MB minus 2 (7865MB).

  
# cat x86slice
slices: 0 = 2MB, 7865MB, "wm", "root" :
         2 = 0, 7867MB, "wm", "backup":
         8 = 0, 2MB, "wu", "boot" 

Load the slices into the flash drive:

  
# rmformat  -s x86slice  /dev/rdsk/c5t0d0p0

Place a file system on the s0 slice just created, and then mount it. Note the s0 at the end of the device name instead of p0. Also, since volfs is turned off, now would be a good time to mount the media DVD. Its device name can be found from the rmformat -l command above (/dev/rdsk/c2t0d0p0).

  
# newfs  /dev/rdsk/c5t0d0s0
newfs: construct a new file system /dev/rdsk/c5t0d0s0: (y/n)? y
....
# mount  /dev/dsk/c5t0d0s0  /usbdrv

Mount the CD-ROM or if using an ISO image, mount it now. Mounting an ISO is beyond the scope of this document, but doing a man lofiadm is a good starting point.

  
# mount -F hsfs /dev/dsk/c2t0d0s0 /cdrom

Copying the OS DVD to the Flash Drive

Now to copy the OS files from the DVD media (whether DVD or ISO) to the flash drive. Change the working directory to the OS media base. You should find Solaris_10 and boot directories there. Then execute a command similar to the following to copy the media to /usbdrv.

  
# cd /cdrom
# ls
Copyright                    Solaris_10                   installer
JDS-THIRDPARTYLICENSEREADME  boot
# find .  -print | cpio -pudm /usbdrv

This may take a while, so you have time for a break.

Now that the copying is complete, the boot area of the master boot record needs to be loaded.

  
# /sbin/installgrub  /boot/grub/stage1 /boot/grub/stage2 \ 
/dev/rdsk/c5t0d0s0

Configuring to Mount the USB Drive as CD-ROM

If we boot off the flash drive now, it will boot the mini-root OS and start to load the new operating system and then stop because it can't mount the CD-ROM. We need to modify an install script so it will not stop. The file we need to modify is in the /boot/x86.miniroot file. To get to it, we need to use the root_archive command. Here is a quick command summary:

  
/boot/solaris/bin/root_archive  unpack  archive root

The archive in the command for this example is on the install media (/cdrom). The term root is where we temporarily mount the image. Then we edit the install-discovery file.

  
# /boot/solaris/bin/root_archive unpack /cdrom/boot/x86.miniroot \
  /tmp/Boot
# vi /tmp/Boot/sbin/install-discovery

In the install-discovery file find the trymountcd() subroutine. Modify the subroutine to be similar to below. The bold typeset needs to be added.

  
trymountcd()
{
   echo $Installfs | grep ramdisk > /dev/null
   if [ $? = 0 ] && [ ! -d /cdrom/Solaris_* ] ; then
ls -l /dev/dsk  | grep storage | grep 's0 -' \
| awk '{print $9}' | while read VAL
           do
             for Dev in /dev/dsk/${VAL}; do
                     Typ=`/usr/sbin/fstyp $Dev 2> /dev/null`

                     if [ "X${Typ}" = "Xufs" ] ; then     	
###  <:-- Note the ufs is bold
                             mount -o ro $Dev /cdrom
                             if [ -d /cdrom/Solaris_* ] ; then
                                     echo "Using install cd in $Dev"

                                     # save install cd for wizards
                                     echo  $Dev >> ${CDROOT}

                                     break
                             else
                                     umount /cdrom 2> /dev/null
                             fi
                     fi
             done
if [ -d /cdrom/Solaris_* ] ; then
        break
fi
done    ### <:-- don't forget this line too
     else
        if [ ! -d /cdrom/Solaris_* ] ; then
                # "this never happens" :-)
                echo "ERROR: The Solaris Distribution, ${Installfs} " \
                    "does not exist"
                echo "             Exiting to shell."
                /sbin/sh
        fi
   fi
}

Save the file.

If you do not want to automate the OS load, go to the Finishing Up section below. Because of the mechanism used to locate the flash drive (which is first locating a USB storage device, and then a UFS partition), it is advised to only have one USB drive (or disk) with a UFS partition connected to the system when booting. With more than one, the system could potentially mount either one as /cdrom.


Automating the OS Install

sysidcfg

To fully automate the install, the sysidcfg file needs to be populated and set in place. The following is a sample sysidcfg that can be used or modified as needed. For more help on sysidcfg, see the "sysidcfg File Keywords" section in Solaris 10 11/06 Installation Guide: Network-Based Installations.

  
network_interface=primary  { hostname=x86box
                         ip_address=192.168.2.101
                         netmask=255.255.255.0
                         default_route=none
                         protocol_ipv6=NO}
terminal=vt100
security_policy=NONE
service_profile=open
name_service=NONE
root_password=G97uk8nCahUjk  		##crypt password
timeserver=localhost
system_locale=en_US
timezone=US/Central
terminal=vt100
keyboard=US-English
pointer=MS-S

Remove the sysidcfg link, and copy the sysidcfg file to the etc directory. I happen to have a sysidcfg file in the root directory (/).

  
# rm /tmp/Boot/etc/sysidcfg
# cp /sysidcfg  /tmp/Boot/etc/sysidcfg

profind

Now we have to modify the profind file.

  
# vi /tmp/Boot/usr/sbin/install.d/profind

Find the cdrom() subroutine and update as below. Once again the inserted parts are in bold.

 
cdrom()
{
    # Factory JumpStart is only allowed with factory
    # stub images, indicated by the file /tmp/.preinstall
    #
    if [ -f /tmp/.preinstall ]; then
        mount -o ro -F lofs ${CD_CONFIG_DIR} ${SI_CONFIG_DIR} >/dev/null 2>&1

        if [ $? -eq 0 ]; then
            verify_config "CDROM"
        fi
    fi

gettext " <<< using CD default >>>"; echo 
rmdir ${SI_CONFIG_DIR} 
ln -s /cdrom/.install_config ${SI_CONFIG_DIR}

}

Save the file.

profile

From the profind file above, in which the last three lines were modified, we redirected the location of SI_CONFIG_DIR to be in /cdrom/.install_config. The next thing to do is copy a begin and finish script along with the rules.ok file to the .install_config directory. In this example, we will use the files located in the miniroot and place them externally, so they can be modified without having to use the root_archive command.

  
# cp /tmp/Boot/usr/sbin/install.d/install_config/* \
  /usbdrv/.install_config
# cd /usbdrv/.install_config
# ls 
Makefile        install_begin   medium_default      rules.ok
large_default   patch_finish     small_default 

Place a profile similar to the following (or copy the one below) into the file /usbdrv/.install_config/profile.

Note that the controller and target numbers for your systems may be different. For more information on the profile file, see the "Creating a Profile" section in Solaris 10 11/06 Installation Guide: Custom JumpStart and Advanced Installations.

  
# cat profile
install_type    initial_install
system_type     standalone
cluster         SUNWCXall
partitioning    explicit
#
fdisk c0t0d0    191     delete
fdisk c0t0d0    solaris maxfree
fdisk c0t2d0    191     delete
fdisk c0t2d0    solaris maxfree
filesys c0t0d0s0               free    /
filesys c0t0d0s1               10240   swap
filesys c0t0d0s3               10240   /var

rules

Create a rules file by using the rules.ok file.

  
# cd /usbdrv/.install_config
# cp rules.ok rules
# cat  rules
any   -                         install_begin      -  patch_finish
# version=2 checksum=4407

Edit the rules to be as follows. (Remove the version and checksum line.)

  
any   -                 install_begin      profile     patch_finish

Save the file.

Run check against it (while still in the /usbdrv/.install_config directory) from the install media.

  
# /cdrom/Solaris_10/Misc/jumpstart_sample/check
Validating rules...
Validating profile profile...
The custom JumpStart configuration is ok.

menu.lst

The last piece for full automation is setting up the GRUB menu list. We need to add a - install option to it. As before, add the bold characters to menu.lst. For added functionality, I have added the single user section for just that (booting single user). As a side note, since we are automating the install, the timeout value might be adjusted to a smaller value than 60.

  
# cd /usbdrv/boot/grub
# cat  menu.lst
#
#pragma ident   "@(#)install_menu       1.1     05/09/01 SMI"
#
default=0
timeout=60
title Solaris
   kernel /boot/multiboot kernel/unix - install -B \
install_media=cdrom
   module /boot/x86.miniroot
title Solaris Serial Console ttya
   kernel /boot/multiboot kernel/unix -B \
install_media=cdrom,console=ttya
   module /boot/x86.miniroot
title Solaris Serial Console ttyb (for lx50, v60x and v65x)
   kernel /boot/multiboot kernel/unix -B \
install_media=cdrom,console=ttyb
   module /boot/x86.miniroot
title Solaris Single User
   kernel /boot/multiboot kernel/unix -s
   module /boot/x86.miniroot

Saving the x86.miniroot File

Let's save the changes made to the miniroot file x86.miniroot. Once again we use the root_archive command, but this time we use the unpack option, and save the output as /x86.miniroot.new.

# cd /
# /boot/solaris/bin/root_archive pack /x86.miniroot.new /tmp/Boot

Wait a couple of minutes to complete, and copy the new miniroot file over the one on the flash drive.

# cp /x86.miniroot.new  /usbdrv/boot/x86.miniroot

Finishing Up

Unmount the flash disk, and restart volume management.

# cd /
# umount  /usbdrv
# svcadm enable volfs

Remove the flash drive and place it in an x86 system needing an OS. Set the system BIOS to boot from the USB flash drive, and watch it go.


Conclusions

Since the flash drive I am using is 8GB, and these drives are becoming larger and cheaper, it is quite possible to place a flash archive on it in addition, and create multiple profiles as needed as well as multiple x86.miniroot files, each with a unique sysidcfg.

Another thing that can be done is to take a 64MB (or larger) flash drive, format it as documented above and copy just the /boot directory (and subdirectories) from media to the flash drive. Modify the menu.lst file to have a single user menu option (as shown in the menu.lst section), and install the boot loader (installgrub). This will give a bootable miniroot with shell access. With specific sysidcfg information on it, I can boot to single user off the flash drive and have the host name and networking already loaded.

Using the flash drive to load the OS does not seem to be much faster than a conventional DVD load, but I don't have the fastest USB thumb drives available either. Here are two things I do like about it: I don't have to find a MAC address of the client, and this method is flexible enough to customize the OS load for many different clients through the sysidcfg and profile. Current flash drives may not offer the speed of network OS loads, but they do offer flexibility only before found in JumpStart.


About the Author

This subject was researched, tested, and written by James Whitlatch of Technologent, a Sun value-added reseller in Dallas, Texas. The author may be reached at james [at] technologent.com.


References
Discuss and comment on this resource in the BigAdmin Wiki


Unless otherwise licensed, code in all technical manuals herein (including articles, FAQs, samples) is provided under this License.


BigAdmin
  
 
 
 
 
Would you recommend this Sun site to a friend or colleague?
Contact About Sun News & Events Employment Site Map Privacy Terms of Use Trademarks Copyright Sun Microsystems, Inc.