Tuesday, May 19, 2009

Creating a customized Solaris boot DVD

Starting with Solaris 10u6 and Solaris Nevada build 80, the mechanics of booting have changed drastically for SPARC. Without going into the details, suffice it to say that the boot process has become very similar to that in Solaris x86. Because of this, the process of creating a customized boot DVD is also radically different. The good news is that the process is much simpler now, and there are utilities in Solaris to do large chunks of the work. In addition, the procedure is essentially the same for SPARC and x86, the only difference being the mkisofs command line used to recreate the ISO image at the end.

I will attempt to give a detailed description here on how to extract and rebuild the DVD image. I'll also go through the steps needed to set the customized image up to do a hands-off jumpstart installation. It will be necessary to perform this procedure on a system running Solaris 10u6 or newer as there are a number of utilities needed that didn't exist prior to this release.

Extracting the image

Previous versions lesser thans10u6 of the SPARC Solaris installation DVD had a number of VTOC slices on it. The first slice was a High Sierra File System (HSFS) and contained all the installation packages along with the jumpstart tools. The second slice contained a bootable UFS miniroot. Slice 2,3,4,5, and 6 contained the boot blocks for the sun4c, sun4m, sun4d, sun4u, and sun4v architectures respectively. This scheme is no longer used as of Solaris 10u6. There are still eight slices on the DVD, but this is merely maintained for backward compatibility with OpenBoot PROM and all eight slices point to the entire contents of the DVD.

Because of this, extraction of the contents of the DVD is much simpler. A cpio of the mounted DVD will suffice. Assuming that vold is running, it has mounted the DVD as /cdrom/cdrom0, and we want to copy it to /var/tmp/dvd, you can issue the following commands to copy the image:

# mkdir /var/tmp/dvd
# cd /cdrom/cdrom0
# find . -depth -print | cpio -pdm /var/tmp/dvd

When the copy is done, you will have effectively staged the DVD image for customization.

One note about vold. I mentioned before that the new form of the SPARC Solaris DVD contains eight slices. However, vold will not show you this. The vold has code in it to compare all the slices on a removable medium and ignore any duplicates, opting to only mount the first unique slice it finds. In fact, there is a bug in this code that causes vold to core dump when trying to calculate which slices are duplicates. The effect is that when you place a SPARC Solaris 10u6 DVD in the drive on a SPARC system with vold running, vold will go into a core dump loop as SMF continually tries to restart the vold service. This bug is fixed in patch 138130-01.

If using an ISO image file instead of a physical DVD, the entire contents of the DVD can be accessed by using lofiadm and mounting the lofi device:

# lofiadm -a `pwd`/sol-10-u6-ga1-sparc-dvd.iso
/dev/lofi/1

# mount -F hsfs -o ro /dev/lofi/1 /mnt

At this point, you can extract the DVD contents to a directory

# mkdir /var/tmp/dvd
# cd /mnt
# find . -depth -print | cpio -pdm /var/tmp/dvd

Unmount and remove your lofi device as it's no longer needed

# cd /
# umount /mnt
lofiadm -d /dev/lofi/1

Extracting the miniroot

As mentioned, the SPARC miniroot was previously maintained as a separate UFS slice on the DVD. It is now maintained as a single file in the /boot directory, just like x86. By convention, the file name for the sparc miniroot is (cleverly enough) sparc.miniroot. Extracting this miniroot is a simple matter. There is a new utility in SPARC Solaris as of S10u6 to do this called root_archive. The root_archive script has four options to it:

  • pack - take a root directory and pack it into a miniroot image file
  • unpack - take a miniroot image file and extract it to a directory
  • packmedia - same as pack, except that the package database and other data not necessary for booting is stripped out of the miniroot and bundled together in a compressed tar file to the Solaris_10/Tools/Boot directory
  • unpackmedia - same as unpack except that the package database and other data is also extracted from the Solaris_10/Tools/Boot directory on the DVD image

We will be using the packmedia and unpackmedia options here.

To use root_archive to extract your miniroot, perform the steps below. This assumes that you staged your DVD copy in /var/tmp/dvd and you are staging your miniroot copy to /var/tmp/mrdir.

# /boot/solaris/bin/root_archive unpackmedia /var/tmp/dvd /var/tmp/mrdir

Before we go further, I need to mention bug 6738836 which causes the umount and lofiadm -d in the root_archive script to fail to clean up after itself correctly. When I ran this command for this example, this is what I got:

umount: /tmp/mnt3553 busy
rmdir: directory "/tmp/mnt3553": Directory is a mount point or in use
lofiadm: could not unmap file /var/tmp/dvd/boot/sparc.miniroot: Device busy
rmdir: directory "/tmp/mnt3553": Directory is a mount point or in use

The workaround to this is to forceably unmount the mount point and delete the lofi dev manually:

# lofiadm
Block Device
File
/dev/lofi/1
/var/tmp/dvd/boot/sparc.miniroot
# umount -f /tmp/mnt3553
# lofiadm -d /dev/lofi/1

This bug only affects SPARC Solaris.

Modifying the miniroot

At this point, modifications to the miniroot can be made to /var/tmp/mrdir. Since we used the unpackmedia option to root_archive, the package database is intact and packages and patches can be installed. Also, for jumpstart, you can place your sysidcfg file in /etc in the miniroot, after first removing the symbolic link that exists there.

Modifying the DVD image for jumpstart

If you're creating this DVD image to do a hands off installation using jumpstart, there are a number of modifications you'll need to make to the DVD image (/var/tmp/dvd). First, you'll need to tell jumpstart that the necessary files are available on the DVD itself. Do this by executing the following command:

# touch /var/tmp/mrdir/.tmp_proto/.preinstall

Next, you'll need to put your profile, rules files, begin and finish scripts in the directory /var/tmp/dvd/Solaris_10/Misc/.install_config. Once this is done, run check on your rules file to create the rules.ok file:

# cd /var/tmp/dvd/.install_config
#
/var/tmp/dvd/Solaris_10/Misc/jumpstart_sample/check
Validating rules...
Validating profile profile...
The custom JumpStart configuration is ok.

If performing a flash archive installation, you can put your flash archive anywhere on the DVD image - /var/tmp/dvd. When the system is booted off your custom DVD, the top-level directory will be /cdrom. The lines in your jumpstart profile that reference the flash archive would look something like this:

install_type flash_install
archive_location
local_file /cdrom/flasharchive

This assumes you put the flash archive in the top level directory of your DVD image.

Since flash archives take up a large amount of space, you'll most likely need to free some space up on the DVD to make room for it. Normally, a flash archive installation doesn't install packages from the Solaris medium so you can safely remove the Solaris_10/Product directory. Doing so should free up a sufficient amount of space to include the flash archive.

If you're performing a standard installation, then nothing else needs to be done other than to specify the metacluster you're installing in your profile.

Putting it back together

Once you've made all the necessary modifications to your miniroot, you'll need to reinstall the miniroot back on to the DVD image. Again, we'll use the root_archive program:

# /boot/solaris/bin/root_archive packmedia /var/tmp/dvd /var/tmp/mrdir

Once you run packmedia against your miniroot directory (/var/tmp/mrdir), do not reuse it. This is because packmedia makes modifications to it that can only be undone by unpackmedia against the miniroot image file, which is now in /var/tmp/dvd. The prudent thing to do at this point is to remove it:

# rm -r /var/tmp/mrdir

At this point, we have the directory structure needed to create our ISO image file. Use mkisofs to create the image for burning. For SPARC, the following can be used:

# /usr/bin/mkisofs -N -D -R -d -l -J \
-G /var/tmp/dvd/boot/hsfs.bootblock \
-B \
-graft-points \
-relaxed-filenames \
-V "My_DVD_Name" \
-o /var/tmp/newdvd.iso \
/var/tmp/dvd

As mentioned before, the Solaris DVD will contain 8 identical slices. It's the -B ... (dash B space dot dot dot) option that creates the VTOC structure this way.

For x86, the following command can be used to create the ISO image:

# /usr/bin/mkisofs -N -D -R -U -l -J \
-b boot/grub/stage2_eltorito \
-no-emul-boot \
-boot-load-size 4 \
-boot-info-table \
-c .catalog \
-V "My_DVD_Name" \
-o /var/tmp/newdvd.iso \
/var/tmp/dvd

You now have an ISO image that can be burned to DVD. In Solaris, this would be accomplished using cdrw:

# cdrw -i -d /dev/rdsk/cxtxdxs2 /var/tmp/newdvd.iso

Assuming you have the sysidcfg, profile, and rules.ok files populated correctly, booting this DVD should perform a hand-off installation on the system that it's booted on.

No comments:

Post a Comment