... !http://www.sun.com/bigadmin/home/images/bigadminHeaderWikiThumb.jpg!
|
|
| |
{section}
|
... |
|
|
{column:width=20%}
|
| |
{include:TOC for Tech Tips} {column} |
| |
{column:width=55%}
|
| |
h1. Using the MilaX Live CD for failsafe booting
by Bernd Schemmer, June 2009
|
| {toc} |
| Homepage: [http://www.bnsmb.de/] |
| |
*Table of contents*
{toc} |
h2. History
|
| || Version/Date ||
Changes \\
|| |
| | June 2009
v1.00/bs \\
| inital release for MilaX
0.3.3 \\
| |
| | 14.06.2009
v1.01/bs \\
| \- added support for MilaX 0.4 to the script
[copy_milax_to_img.sh|#copy_milax_to_img.sh] \\ |
|
\- corrected a spelling error: LOFI_DIEV instead of
LOFI_DEV \\
| |
| 15.06.2009 v1.02/bs \\ | \- corrected a synatx error (lofiadm without the \-a) \\ | | 08.11.2009 v1.03/bs \\ | \- added a link to the page with information about [how to convert the MilaX Live CD to a WANBOOT image|http://wikis.sun.com/display/BigAdmin/Converting+the+MilaX+Live+CD+for+SPARC+to+a+WANBOOT+image] \\ | | 14.11.2009 v1.04/bs\\ | \- added a link to the page with information about [how to use the MilaX Live CD for failsafe booting on SPARC machines|http://wikis.sun.com/display/BigAdmin/Using+the+MilaX+Live+CD+for+failsafe+booting+for+SPARC+machines] \\ | |
|
... h2. Introduction
h3. Purpose
MilaX is a small size Live CD distribution which runs completely off a CD . In addition to various other usages (see links) MilaX can also be used as failsafe image for the Solaris OS.
*Note:*
A failsafe image is an image for a ramdisk from which the Solaris OS can boot. This boot method is used, for example, if you do a "boot \-s" in newer Solaris versions.
This article describes how to create a failsafe image from the MilaX Live CD.
In the rest of the article, the failsafe image is simply called "the image."
h3. Scope
This article only describes how to create the image for the Solaris OS for x86 platforms.
h3. Prerequisites
A working Solaris installation (either Solaris, Solaris Nevada, or OpenSolaris); the MilaX image for x86 described here was tested with Solaris Express Community Edition Build 111, Solaris 10 10/08 OS, and OpenSolaris 2009.06 111a.
The MilaX Live CD; for this article, I used MilaX for x86 version 0.3.3 and version 0.4.
h3. References
[Milax Homepage|http://www.milax.org]
[Solaris and Linux on one USB stick - dual usage|http://www.sun.com/bigadmin/content/submitted/usbstick_milax_dsl.jsp]
|
[Adding a Live CD Distribution to an existing Solaris installation|http://wikis.sun.com/display/BigAdmin/Adding+a+Live+CD+Distribution+to+an+existing+Solaris+installation]
|
| [Converting the MilaX Live CD for SPARC to a WANBOOT image|http://wikis.sun.com/display/BigAdmin/Converting+the+MilaX+Live+CD+for+SPARC+to+a+WANBOOT+image] |
| |
[Using MilaX Live CD for failsafe booting for SPARC machines|http://wikis.sun.com/display/BigAdmin/Using+the+MilaX+Live+CD+for+failsafe+booting+for+SPARC+machines]
|
h2. Creating a failsafe image with MilaX for the Solaris OS on x86 Platforms
|
... h3. Preparation
To create the image with MilaX, boot from the MilaX Live CD and open a root shell.
|
The first step is to create a file for the image:
|
| {code} |
| #
{code}#
Note: /mnt/solaris0 is mounted to the internal hard disk in this example |
# (root@milax) # mkfile -n 500m /mnt/solaris0/milax_img |
| {code} |
|
{code}Next
lofi mount the image, create a filesystem on the lofi device, and mount the lofi device: |
| |
| {code} |
|
{code}(root@milax)
# LOFI_DEV=$( lofiadm -a /mnt/solaris0/milax_img ) && \ |
newfs ${LOFI_DEV}
|
... (root@milax) # mkdir /tmp/milax |
(root@milax) # mount ${LOFI_DEV} /tmp/milax |
| {code} |
|
{code}Then
copy the script
*copy_milax_to_img.sh* (see the appendix)
[copy_milax_to_img.sh|#copy_milax_to_img.sh]
to the machine, make it executable using chmod, and execute it, e .g |
| |
| {code} |
|
{code}(root@milax)
# ./copy_milax_to_img.sh /tmp/milax |
Starting to copy data from UFS root to /tmp/milax - this may take some time. /tmp/milax/etc/crypto/certs/SUNWObjectCA linked to /tmp/milax/etc/certs/SUNWObjectCA |
... /tmp/milax/etc/rc0.d/K50pppd linked to /tmp/milax/etc/init.d/pppd ... tar: ./svc/volatile/kcfd_door is not a file. Not dumped tar: ./sysevent/devfsadm_event_channel/1 is not a file. Not dumped ###################################################################
MilaX now installed on /tmp/milax |
################################################################### |
| {code} |
|
{code}After
the script is done, rename the kernel in the image. |
| |
| {code} |
|
{code}(root@milax)
# mv /tmp/milax/platform/i86pc/kernel/unix /tmp/milax/platform/i86pc/kernel/milax_unix |
| {code} |
|
{code}Then
umount the image and delete the lofi device: |
| |
| {code} |
|
{code}(root@milax)
# umount /tmp/milax |
(root@milax) # lofiadm -d ${LOFI_DEV} |
| {code} |
|
{code}Now
copy the image file, */mnt/solaris0/milax_img* in this example, to a save place. |
|
... h3. Installation
To install the image, execute these steps.
Log in as root to the target machine and copy the image to the machine; in this example, we assume the image is called milax_img and it is in the directory /milax.
|
Then lofi mount the image:
|
| {code} |
|
{code}bash-3.2#
mkdir /tmp/milax |
| |
| bash-3.2# mount $( lofiadm
-a
/milax/milax_img ) /tmp/milax |
| {code} |
|
{code}Copy
the kernel from the image to the hard disk. |
| |
| {code} |
|
{code}bash-3.2#
cp /tmp/milax/platform/i86pc/kernel/milax_unix /milax/platform/i86pc/kernel/milax_unix |
| {code} |
|
{code}And
umount the image and delete the lofi device: |
| |
| {code} |
|
{code}bash-3.2
# umount /tmp/milax |
bash-3.2# lofiadm -d /milax/milax_img |
| {code} |
|
{code}And
last, add an additional entry for MilaX failsafe to the GRUB boot menu: |
| |
| {code} |
|
{code}title
MilaX 0.3.3 (32 Bit) (failsafe) |
findroot (pool_rpool,0,a) kernel$ /platform/i86pc/kernel/milax_unix module$ /milax/milax.img |
| {code} |
|
{code}That's
it; now you can boot the failsafe image with MilaX for maintenance tasks on your main Solaris installation. |
| |
| Note that the MilaX failsafe image is not machine dependent; you can copy it to any x86 machine. |
| *Update 15.06.2009:* |
| |
| -Note that the MilaX failsafe image is not machine dependent; you can copy it to any x86 machine.- |
| |
| |
h2. Customizing the failsafe image
|
... To customize the Solaris OS in the image boot into the normal Solaris OS and lofi mount the image, do the following (in this example, we assume the image is called *milax_img* and it is in the directory */milax*).
|
Lofi mount the image:
|
| {code} |
|
{code}bash-3.2#
mkdir /tmp/milax |
| |
| bash-3.2# mount $( lofiadm
-a
/milax/milax_img ) /tmp/milax |
| {code} |
|
{code}Now
do your customizations. |
And finally, umount the image again:
|
| {code} |
|
{code}bash-3.2
# umount /tmp/milax |
bash-3.2# lofiadm -d /milax/milax_img {code} |
| |
h2. Troubleshooting
|
... h3. My changes to the failsafe image are not persistent.
To change the contents of the image, you must lofi mount the image (see above); changes made while the machine is booted from the image are not persistent.
h3. There's no network connection after booting from the failsafe image
The Solaris OS in the failsafe image needs a DHCP server to automatically configure the network adapter. If there is no DHCP server in your environment, you must either add a static IP configuration to the image (see above) or configure the network manually every time after the image is booted.
h3. The X Server starts automatically but not the Window manager
There's a bug in MilaX 0.4 that the Window manager does not start automatically every reboot. If this the case you only see the grey background from the X server and no menus.
|
To get around this bug simply kill the X Server (using CTRL-ALT-BACKSPACE) and restart the X Server using the command startx, e.g.
|
| {code}(alex@milx) # startx |
| {code} |
(alex@milx) # startx {code}
|
h3. How to use more than one MilaX failsafe image
|
... To use more than one MilaX failsafe image use unique names for the kernel and the image, e.g. milax040_img and milax040_unix. Note that the name of the kernel must be the same in your normal Solaris installation and in the MilaX failsafe image.
h2. Appendix
|
h3. copy_milax_to_img.sh
|
|
{code}#!/usr/bin/ksh |
| #!/usr/bin/ksh |
# # CDDL HEADER START |
... # # The contents of this file are subject to the terms of the # Common Development and Distribution License (the "License"). # You may not use this file except in compliance with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # Script to install MilaX into a boot image for failsafe booting # written by Bernd Schemmer # based on the sript to install MilaX to ZFS # By Alexander R. Eremin, April 4 2008. # Thanks to Tim Foster for basic zfs-boot script # # # History # v1.10 14.06.2009 /bs # added support for MilaX 0.4 #
# Make sure only root can run our script if [ "$(id -u)" != "0" ]; then echo "This script must be run as root" exit 1 fi
# check arguments if [ "$#" -lt 1 ] || [ $1 == "-h" ] || [ $1 == "--help" ] then echo "Usage : $0 targetfilesystem" echo "eg. $0 /mnt/milax" exit 1 fi TARGET_FS="$1"
# # get MiIaX version # if [ -f /etc/release ] ; then MILAX_VERSION="$( head -1 /etc/release | tr -s " " | cut -f3 -d " " )" RELEASE_FOUND=0 else MILAX_VERSION="$( uname -a | tr -s "_" " " | cut -f5 -d " " )" RELEASE_FOUND=1 fi
case ${MILAX_VERSION} in 0.4 ) echo "Using MilaX version ${MILAX_VERSION}" ;;
0.3.3 ) echo "Using MilaX version ${MILAX_VERSION}" ;;
* ) if [ ${RELEASE_FOUND} = 0 ] ; then echo "WARNING: Untested MilaX version found: ${MILAX_VERSION} -- assuming this version is compatible to MilaX version 0.4" MILAX_VERSION=0.4 else echo "WARNING: Untested MilaX version found: ${MILAX_VERSION} -- assuming this version is compatible to MilaX version 0.3.3" MILAX_VERSION=0.3.3 fi ;;
esac
# directory with the additional files # home=/usr/dss/share/hdinstall
# added 09.06.2009 22:11 /bs -- start umount /lib/libc.so.1 # added 09.06.2009 22:11 /bs -- end
# start copying main data over to it echo "Starting to copy data from UFS root to ${TARGET_FS} - this may take some time." cd / find . -xdev -depth -print | cpio -pvdm ${TARGET_FS} 2>&1 > /dev/null # libc! cp -rP /lib/libc.so* ${TARGET_FS}/lib 2>&1 > /dev/null
mkdir -p ${TARGET_FS}/alex cd /alex find . -xdev -depth -print | cpio -pvdm ${TARGET_FS}/alex 2>&1 > /dev/null mkdir -p ${TARGET_FS}/root cd /root find . -xdev -depth -print | cpio -pvdm ${TARGET_FS}/root 2>&1 > /dev/null
mkdir -p ${TARGET_FS}/usr cd /usr find . -xdev -depth -print | cpio -pvdm ${TARGET_FS}/usr 2>&1 > /dev/null
mkdir -p ${TARGET_FS}/system/object mkdir -p ${TARGET_FS}/system/contract mkdir -p ${TARGET_FS}/tmp mkdir -p ${TARGET_FS}/mnt mkdir -p ${TARGET_FS}/proc mkdir -p ${TARGET_FS}/var/run mkdir -p ${TARGET_FS}/dev/fd touch ${TARGET_FS}/etc/mnttab touch ${TARGET_FS}/etc/dfs/sharetab
chmod 555 ${TARGET_FS}/system/object chmod 555 ${TARGET_FS}/system/contract chmod 555 ${TARGET_FS}/proc chmod 777 ${TARGET_FS}/tmp chmod 755 ${TARGET_FS}/etc/svc/volatile chmod 755 ${TARGET_FS}/var/run chmod 555 ${TARGET_FS}/dev/fd chmod 444 ${TARGET_FS}/etc/mnttab chmod 755 ${TARGET_FS}/usr chmod 755 ${TARGET_FS}/alex chmod 755 ${TARGET_FS}/root chmod 755 ${TARGET_FS}/mnt chown -R alex:adm ${TARGET_FS}/alex chown root ${TARGET_FS}/system/object chown root ${TARGET_FS}/system/contract chown root ${TARGET_FS}/proc chown root ${TARGET_FS}/tmp chown root ${TARGET_FS}/etc/svc/volatile chown root ${TARGET_FS}/var/run chown root ${TARGET_FS}/dev/fd chown root ${TARGET_FS}/etc/mnttab
chgrp root ${TARGET_FS}/system/object chgrp root ${TARGET_FS}/system/contract chgrp sys ${TARGET_FS}/tmp chgrp root ${TARGET_FS}/proc chgrp sys ${TARGET_FS}/etc/svc/volatile chgrp sys ${TARGET_FS}/var/run chgrp root ${TARGET_FS}/dev/fd chgrp root ${TARGET_FS}/etc/mnttab
# now populate the devices and /dev directories in ${TARGET_FS} # do this by lofs mounting / and pulling the files directly mkdir -p /zfs-root-tmp.$$ mount -F lofs -o nosub / /zfs-root-tmp.$$ (cd /zfs-root-tmp.$$; tar cf - devices dev ) | (cd ${TARGET_FS}; tar xfp -) 2>&1 > /dev/null cd / umount /zfs-root-tmp.$$ rm -rf /zfs-root-tmp.$$
# copy last etc cd /etc tar cf - . | (cd ${TARGET_FS}/etc ; tar xfp -) 2>&1 > /dev/null
if [ "${MILAX_VERSION}"x = "0.3.3"x ] ; then cp $home/misc/xstart ${TARGET_FS}/usr/dss/sbin/ cp $home/misc/live-fs-root ${TARGET_FS}/lib/svc/method/ cp $home/misc/repository.db ${TARGET_FS}/etc/svc/ elif [ "${MILAX_VERSION}"x = "0.4"x ] ; then rm ${TARGET_FS}/lib/svc/method/live-fs-root cd ${TARGET_FS}/lib/svc/method/ ln -s fs-root live-fs-root cd / fi
# copy vfstab cp $home/misc/vfstab ${TARGET_FS}/etc/vfstab
echo "/devices/ramdisk:a - / ufs 1 no rw,notime">>${TARGET_FS}/etc/vfstab
echo " ###################################################################" echo echo " MilaX now copied to ${TARGET_FS}" echo echo " ###################################################################"
{code}
|
{column} |
| |
| {section} |