Adding a Live CD Distribution to an existing Solaris installation

Version 4 by kperkins
on Jun 02, 2009 14:54.

compared with
Current by bnsmb
on Nov 14, 2009 01:45.

Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (119)

View page history
!http://www.sun.com/bigadmin/home/images/bigadminHeaderWikiThumb.jpg!
{section:border=false}
{section}

{column:width=20%}
 
{include:TOC for Tech Tips}
{column}

 
h1. Adding a Live CD Distribution to an existing Solaris installation

by Bernd Schemmer, June 2009
{toc}
Homepage: [http://www.bnsmb.de/]
 
*Table of contents*

{toc}
h2. Introduction
The techniques described in this article should also work to add other Solaris distributions to an existing Solaris installation, for example [Belenix|http://www.belenix.org/].
*Update 09.06.2009:*
 
Another method to add the MilaX Live CD to an existing Solaris installation is described here:

[Using the MilaX Live CD for failsafe booting|http://wikis.sun.com/display/BigAdmin/Using+the+MilaX+Live+CD+for+failsafe+booting]

*Update 08.11.2009:*

How to convert the MilaX Live CD to a WANBOOT image for SPARC machine is described here:

[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]


h3. Scope
[x86: New GRUB findroot Command|http://docs.sun.com/app/docs/doc/817-1985/ggvms?l=de&a=view]
[Using the MilaX Live CD for failsafe booting|http://wikis.sun.com/display/BigAdmin/Using+the+MilaX+Live+CD+for+failsafe+booting]
 
 
h2. Installation
To do this boot from the MilaX CDROM and open a root shell. If not already done, use format to create a slice for MilaX on the second disk. Then execute zfsinstall to install MilaX (c4d1 is the second disk in this example):
{code}
{code}(root@milax)# zfsinstall c4d1s0
Starting to copy data from UFS root to /zfsroot - this may take some time.
...

###################################################################
{code}
{code}The script zfsinstall installs GRUB on the target disk and ignores the existing GRUB menu on the first disk. Therefore you must add the GRUB menu entry for MilaX to the existing GRUB menu manually. Just add an entry to boot from the second disk to the GRUB menu:
 
The script zfsinstall installs GRUB on the target disk and ignores the existing GRUB menu on the first disk. Therefore you must add the GRUB menu entry for MilaX to the existing GRUB menu manually. Just add an entry to boot from the second disk to the GRUB menu:

{code}
{code}title Boot 2nd Disk
root (hd1,0)
chainloader +1
makeactive
{code}
{code}You should also add an entry like this to the GRUB menu on the second disk to be able to boot from the first disk if you accidentally activated the second disk:
 
{code}
{code}title Boot 1st Disk
root (hd0,0)
chainloader +1
makeactive
{code}
{code}To boot MilaX directly from within the GRUB on the first disk, add the following entry to the GRUB menu (assuming MilaX is installed in slice 0 of partition 1 on the second disk):
 
To boot MilaX directly from within the GRUB on the first disk, add the following entry to the GRUB menu (assuming MilaX is installed in slice 0 of partition 1 on the second disk):

{code}
{code}title MilaX 0.3.3 (32 bit)
root (hd1,0,a)
kernel$ /platform/i86pc/kernel/unix -B $ZFS-BOOTFS,console=text
module$ /platform/i86pc/boot_archive
{code}
{code}Or if you're using a findroot enabled GRUB, you can also use the findroot command, for example:
 
Or if you're using a findroot enabled GRUB, you can also use the findroot command, for example:

{code}
# {code}# create the bootsign file for GRUB
#
(root@milax)# mkdir /tank/boot/grub/bootsign

(root@milax)# touch /tank/boot/grub/bootsign pool_milax
{code}
{code}And add the following entry to the GRUB menu of the first disk:
 
And add the following entry to the GRUB menu of the first disk:

{code}
{code}title MilaX 0.3.3 (32 bit)
findroot pool_milax
kernel$ /platform/i86pc/kernel/unix -B $ZFS-BOOTFS,console=text
module$ /platform/i86pc/boot_archive
{code}

h3. Add MilaX to an existing Solaris installation on plain slices with UFS
Then execute zfsinstall to install MilaX (c4d0s6 is the free slice for MilaX in this example):
{code}
{code}(root@milax)# zfsinstall c4d0s6
Starting to copy data from UFS root to /zfsroot - this may take some time.
...

###################################################################
{code}
{code}The script zfsinstall installs a GRUB on the new slice, so you must correct this manually after the script finishes.
 
The script zfsinstall installs a GRUB on the new slice, so you must correct this manually after the script finishes.
First, add the GRUB menu entry to the existing GRUB menu, for example, add:
{code}
{code}title MilaX 0.3.3 (32 bit)
root (hd0,0,g)
kernel$ /platform/i86pc/kernel/unix -B $ZFS-BOOTFS,console=text
module$ /platform/i86pc/boot_archive
{code}
{code}(This entry is for MilaX installed in the slice 6 of the first hard disk.)
 
(This entry is for MilaX installed in the slice 6 of the first hard disk.)
Then reinstall GRUB to boot from the correct slice, for example:
{code}
{code}(root@milax)# /usr/sbin/installgrub -m /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c4d0s0
{code}
{code}(See the section [#Which GRUB to use] below on how to decide which GRUB to use.)
 
(See the section "Which GRUB to use" below on how to decide which GRUB to use.)
 
 
h3. Add MilaX to an existing Solaris installation in a ZFS pool
First, create an image of the existing MilaX installation using "zfs send", for example:
{code}
{code}(root@milax)# zfs snapshot tank/rootfs@initial

(root@milax)# zfs send tank/rootfs@initial >/mnt/solaris0/milax_rootfs.zfs
{code}
{code}Then boot the main Solaris installation on the target machine, copy the just-created file milax_rootfs.zfs to that machine, and install MilaX with zfs receive:
 
Then boot the main Solaris installation on the target machine, copy the just-created file milax_rootfs.zfs to that machine, and install MilaX with zfs receive:
{code}bash-3.2# zfs receive rpool/milax </var/tmp/milax_rootfs_zfs
{code}The last thing to do is to create a new GRUB menu entry for MilaX, for example:
 
{code}
bash-3.2# zfs receive rpool/milax </var/tmp/milax_rootfs_zfs
{code}

The last thing to do is to create a new GRUB menu entry for MilaX, for example:

{code}
{code}title MilaX 0.3.3 (32 bit)
findroot (pool_rpool,0,a)
bootfs rpool/milax
module$ /platform/i86pc/boot_archive
{code}

h5. Install a fresh MilaX into the ZFS pool

If you do not have an existing MilaX hard disk installation, use the following steps to add MilaX to the ZFS pool:
First boot the target machine from the MilaX Live CD. Then open a root shell, copy the script add_milax.sh (see the appendix) [add_milax.sh|#add_milax.sh]; to the machine, and make it executable using the chmod command.

Next import the ZFS pool on the machine, for example:
{code}
{code}(root@milax)# zpool import -f rpool
{code}
{code}And execute the script [add_milax.sh|#add_milax.sh] to add MilaX to the ZFS pool:
 
And execute the script add_milax.sh to add MilaX to the ZFS pool:

{code}
{code}(root@milax)# ./add_milax.sh rpool
Starting to copy data from UFS root to "/rpool/milax_on_hd" - this may take some time.
/rpool/milax_on_hd/etc/crypto/certs/SUNWObjectCA linked to /rpool/milax_on_hd/etc/certs/SUNWObjectCA
###################################################################
{code}

h4. Add MilaX to an existing Solaris installation in a ZFS pool: Create second ZFS pool
First, check the current ZFS configuration, for example:
{code}
{code}(root@milax)# zpool import -f rpool

(root@milax)# zfs list
rpool/export/home 805K 26.1G 805K /export/home
rpool/swap 2G 27.8G 267M -
{code}
{code}We only need to save the ZFS file systems rpool, rpool/ROOT, rpool/ROOT/snv_111, rpool/export, and rpool/export/home.
 
We only need to save the ZFS file systems rpool, rpool/ROOT, rpool/ROOT/snv_111, rpool/export, and rpool/export/home.
The other ZFS file systems, rpool/dump and rpool/swap, are ZFS volumes with temporary data that need not be saved.

To back up the file systems, use zfs send, for example:
{code}
# {code}# create a snapshot of all ZFS file systems
#
(root@milax)# zfs snapshot -r rpool@current
(root@milax)# zpool create -f -o failmode=continue -R /a -m legacy -o cachefile=/etc/zfs/zpool.cache rpool c4d0s0
# install GRUB again
#
(root@milax)# installgrub /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c4d0s0
#
(root@milax)# zpool set bootfs=rpool/ROOT/snv_111 rpool
{code}{*}Note:*
 
*Note:*
In my tests, zfs snapshot did not always work while booted from the MilaX Live CD -- so I had to reboot the machine from the hard disk to create the snapshots.
If everything is okay, boot the machine again from the MilaX Live CD and start installing MilaX on the new free slice.
{code}
# {code}# boot from the MilaX Live CD and open a root shell
#
# Then install MilaX using zfsinstall, for example, to install MilaX on the slice 1

###################################################################
{code}
{code}The script zfsinstall installs a GRUB on the new slice; therefore, you must correct this manually after the script is finished:
 
The script zfsinstall installs a GRUB on the new slice; therefore, you must correct this manually after the script is finished:
Import and mount the primary pool:
{code}
{code}(root@milax)# zpool import -f rpool
(root@milax)# mkdir -p /a
(root@milax)# mount -F zfs rpool /a
{code}
{code}Add the GRUB menu entry for MilaX to the existing GRUB menu, for example, add (for MilaX on slice 1):
 
Add the GRUB menu entry for MilaX to the existing GRUB menu, for example, add (for MilaX on slice 1):
{code}(root@milax)# vi /a/boot/grub/menu.lst
{code}
(root@milax)# vi /a/boot/grub/menu.lst
{code}

{code}
{code}title MilaX 0.3.3 (32 bit)
root (hd0,0,b)
bootfs tank/rootfs
kernel$ /platform/i86pc/kernel/unix -B $ZFS-BOOTFS,console=text
module$ /platform/i86pc/boot_archive
{code}
{code}Or for a findroot enabled GRUB, use this:
 
Or for a findroot enabled GRUB, use this:

{code}
# {code}# create the bootsign file for GRUB
#
(root@milax)# mkdir /tank/boot/grub/bootsign

(root@milax)# touch /tank/boot/grub/bootsign/tank_milax
{code}
{code}And the new GRUB menu entry for MilaX is then this:
 
And the new GRUB menu entry for MilaX is then this:

{code}
{code}title MilaX 0.3.3 (32 bit)
findroot tank_milax
kernel$ /platform/i86pc/kernel/unix -B $ZFS-BOOTFS,console=text
module$ /platform/i86pc/boot_archive
{code}
{code}Then reinstall GRUB to boot from the correct slice, for example:
 
Then reinstall GRUB to boot from the correct slice, for example:
{code}(root@milax)# /usr/sbin/installgrub -m /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c4d0s0
{code}(See the section [#Which GRUB to use] below on how to decide which GRUB to use.)
 
{code}
(root@milax)# /usr/sbin/installgrub -m /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c4d0s0
{code}

(See the section "Which GRUB to use" below on how to decide which GRUB to use.)
*Note:*
In MilaX 3.3, the zfs commands sometime print the following message:
{code}libshare SMF initialization problem: entity not found
{code}{*}Solution:*
libshare SMF initialization problem: entity not found
{code}
*Solution:*

As far as I know, you can ignore this message.
h3. Which GRUB to use
{anchor:which_grub}
{anchor:which_grub}When installing GRUB again, you must decide which GRUB to use: either the GRUB from the existing Solaris installation or the GRUB from the MilaX Live CD.
 
When installing GRUB again, you must decide which GRUB to use: either the GRUB from the existing Solaris installation or the GRUB from the MilaX Live CD.
The general rule of thumb is this:

If the GRUB from the existing Solaris installation is newer than the GRUB from MilaX, you should use the GRUB from the existing Solaris installation, for example:
{code}
# {code}# search the slice with the original Solaris (in this example, the slice is already mounted to /mnt/solaris0)
# and call installgrub from that slice:
#
(root@milax)# /mnt/solaris0/usr/sbin/installgrub -m /mnt/solaris0/boot/grub/stage1 /mnt/solaris0/boot/grub/stage2 /dev/rdsk/c4d0s0
{code}
{code}If the GRUB from MilaX is newer (for example, when you're using a Solaris 10 update), use the GRUB from MIlaX:
 
If the GRUB from MilaX is newer (for example, when you're using a Solaris 10 update), use the GRUB from MIlaX:
{code}(root@milax)# /usr/sbin/installgrub -m /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c4d0s0
{code}{*}Note:*
 
{code}
(root@milax)# /usr/sbin/installgrub -m /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c4d0s0
{code}

*Note:*
Note that Milax 0.3.3 is based on Solaris Express Community Edition Build 105.

{anchor:add_milax}
{code}#!/usr/bin/ksh
#!/usr/bin/ksh
#
# CDDL HEADER START
echo " ###################################################################"
{code}
 
{column}
{section}

The individuals who post here are part of the extended Sun Microsystems community and they might not be employed or in any way formally affiliated with Sun Microsystems. The opinions expressed here are their own, are not necessarily reviewed in advance by anyone but the individual authors, and neither Sun nor any other party necessarily agrees with them.

Copyright 1994-2009 Sun Microsystems, Inc.
Powered by Atlassian Confluence
Sun Guidelines on Public Discourse Privacy Policy Terms of Use Trademarks Site Map Employment Investor Relations Contact