Adding a Live CD Distribution to an existing Solaris installation

by Bernd Schemmer, June 2009

Homepage: http://www.bnsmb.de/

Last Update: 17.04.2012/bs - checked and corrected the links

Table of contents

  1. Adding a Live CD Distribution to an existing Solaris installation
    1. Introduction
      1. Purpose
      2. Scope
      3. Prerequisites
      4. References
    2. Installation
      1. Add MilaX to an existing Solaris installation on a secondary disk
      2. Add MilaX to an existing Solaris installation on plain slices with UFS
      3. Add MilaX to an existing Solaris installation in a ZFS pool
        1. Add MilaX to an existing Solaris installation in a ZFS pool: Install in the existing ZFS pool
          1. Copy an existing MilaX installation to the ZFS pool
          2. Install a fresh MilaX into the ZFS pool
        2. Add MilaX to an existing Solaris installation in a ZFS pool: Create second ZFS pool
    3. Troubleshooting
      1. Message: libshare SMF initialization problem: entity not found
    4. Appendix
      1. Which GRUB to use
      2. add_milax.sh


Introduction

Purpose

MilaX is a small size Live CD distribution which runs completely off a CD . MilaX is the perfect tool for troubleshooting a not booting Solaris installation. But there's one disadvantage of using a Live CD: You can't change the config files on the Live CD nor can you add new programs without creating a new Live CD. MilaX can also be installed on an USB stick. But even if you install MilaX on an USB stick it's rather difficult to change or add files to the image on the USB stick. Therefore it's useful to install MilaX on the hard disk in parallel to the main Solaris installation.

This article describes some techniques how to do that – install MilaX on a hard disk in parallel to an existing Solaris installation.

Note:

The techniques described in this article should also work to add other Solaris distributions to an existing Solaris installation, for example Belenix.

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

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

Scope

This article only describes how to add MilaX to an existing Solaris installation – it does not talk about how to use MilaX to repair a not-booting Solaris installation. It also does not talk about customizations for MilaX – for this task you might take a look at the article Solaris and Linux on one USB stick - dual usage.

This article only talks about installing MilaX on x86 systems, but the methods should also work for installing MilaX on SPARC systems.

Prerequisites

It is strongly recommended that you back up an existing Solaris installation before adding MilaX to the installation!

References

Milax Homepage

Solaris and Linux on one USB stick - dual usage

ZFS Troubleshooting Guide

How to Add GRUB Menu Entries That Use the findroot Command

x86: New GRUB findroot Command

Using the MilaX Live CD for failsafe booting

Installation

The method to install MilaX depends on the type of Solaris environment that is already installed. So this section is divided in subsections for the various configurations.

Add MilaX to an existing Solaris installation on a secondary disk

If the target machine with the existing Solaris installation has a secondary disk you can install MilaX on a slice of the secondary disk using the hard disk install script that is part of MilaX.

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):

(root@milax)# zfsinstall c4d1s0
Starting to copy data from UFS root to /zfsroot - this may take some time.
...
stage1 written to partition 0 sector 0 (abs 16065)
stage2 written to partition 0, 272 sectors starting at 50 (abs 16115)
 ###################################################################

       		MilaX now installed on c4d1s0

 ###################################################################

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:

title Boot 2nd Disk
	root (hd1,0)
	chainloader +1
	makeactive

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:

title Boot 1st Disk
	root (hd0,0)
	chainloader +1
	makeactive

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):

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

Or if you're using a findroot enabled GRUB, you can also use the findroot command, for example:

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

(root@milax)# touch /tank/boot/grub/bootsign pool_milax

And add the following entry to the GRUB menu of the first disk:

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

Add MilaX to an existing Solaris installation on plain slices with UFS

To add MilaX to an existing Solaris installation installed on slices, just install MilaX on a free slice.

Boot from the MilaX Live CD and open a root shell. If not already done, use format to create a slice for MilaX on the disk. If the slice already exists, while booting MilaX, umount the slice before starting the zfsinstall script.

Then execute zfsinstall to install MilaX (c4d0s6 is the free slice for MilaX in this example):

(root@milax)# zfsinstall c4d0s6
Starting to copy data from UFS root to /zfsroot - this may take some time.
...
stage1 written to partition 0 sector 0 (abs 16065)
stage2 written to partition 0, 272 sectors starting at 50 (abs 16115)
 ###################################################################

       		MilaX now installed on c4d0s6

 ###################################################################

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:

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

(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:

(root@milax)#  /usr/sbin/installgrub -m /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c4d0s0

(See the section "Which GRUB to use" below on how to decide which GRUB to use.)

Add MilaX to an existing Solaris installation in a ZFS pool

If Solaris is installed on a ZFS pool and this pool occupies the complete disk (as in OpenSolaris), you have two options:

Either install MilaX in the existing ZFS pool or create a new ZFS pool on a free slice. Both methods have advantages and disadvantages. I prefer the second method because using this method you can still boot MilaX even if the main ZFS pool is damaged.

Add MilaX to an existing Solaris installation in a ZFS pool: Install in the existing ZFS pool

Copy an existing MilaX installation to the ZFS pool

If you already have a MilaX hard disk installation, you can copy it to the ZFS pool.

First, create an image of the existing MilaX installation using "zfs send", for example:

(root@milax)# zfs snapshot tank/rootfs@initial

(root@milax)# zfs send tank/rootfs@initial >/mnt/solaris0/milax_rootfs.zfs

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:

bash-3.2# zfs receive rpool/milax </var/tmp/milax_rootfs_zfs

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

title MilaX 0.3.3 (32 bit)
        findroot (pool_rpool,0,a)
	bootfs rpool/milax
	kernel$ /platform/i86pc/kernel/unix -B $ZFS-BOOTFS,console=text
	module$ /platform/i86pc/boot_archive
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) to the machine, and make it executable using the chmod command.

Next import the ZFS pool on the machine, for example:

(root@milax)# zpool import -f rpool

And execute the script add_milax.sh to add MilaX to the ZFS pool:

(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
...
/rpool/milax_on_hd/sbin/rc6 linked to /rpool/milax_on_hd/sbin/rc0
194112 blocks
cp: /rpool/milax_on_hd/lib/libc.so: File exists
48 blocks
96 blocks
/rpool/milax_on_hd/usr/bin/bg linked to /rpool/milax_on_hd/usr/bin/alias
...
..
/rpool/milax_on_hd/usr/share/lib/zoneinfo/Zulu linked to /rpool/milax_on_hd/usr/share/lib/zoneinfo/Etc/UTC
450256 blocks
chmod: WARNING: can't access /rpool/milax_on_hd/etc/svc/volatile
chown: /rpool/milax_on_hd/etc/svc/volatile: No such file or directory
chgrp: /rpool/milax_on_hd/etc/svc/volatile: No such file or directory
tar: ./dev/.devfsadm_synch_door is not a file. Not dumped
tar: ./dev/.devname_lookup_door is not a file. Not dumped
tar: ./svc/volatile/repository_door is not a file. Not dumped
tar: ./svc/volatile/dladm/dlmgmt_door is not a file. Not dumped
tar: ./svc/volatile/kcfd_door is not a file. Not dumped
tar: ./sysevent/devfsadm_event_channel/1 is not a file. Not dumped
Updating vfstab
Creating boot_archive, don't worry about amd64 errors...
/rpool/milax_on_hd//boot/solaris/bin/create_ramdisk[453]: touch:  not found
/rpool/milax_on_hd//boot/solaris/bin/create_ramdisk[52]: /rpool/milax_on_hd/platform/i86pc/amd64/boot_archive-new: cannot create
/rpool/milax_on_hd/platform/i86pc/amd64/boot_archive-new: No such file or directory
/rpool/milax_on_hd//boot/solaris/bin/create_ramdisk[32]: test: argument expected
mv: cannot access /rpool/milax_on_hd/platform/i86pc/amd64/boot_archive-new
 ###################################################################

       		MilaX now installed on rpool

 ###################################################################

Add MilaX to an existing Solaris installation in a ZFS pool: Create second ZFS pool

If there is still an unused slice, you can install MilaX into that slice using the instructions listed above about installing MilaX in a plain slice.
If there is no free slice, you must first shrink the existing ZFS pool to get free space for a new ZFS pool. This is the case, for example, if you're using OpenSolaris, because the OpenSolaris installation program always creates one big ZFS pool for the whole disk (which is a partition in x86, of course).

So here is how to do that:

Boot the target machine from the MilaX Live CD and open a root shell.

First, check the current ZFS configuration, for example:

(root@milax)# zpool import -f rpool

(root@milax)# zfs list

NAME                 USED  AVAIL  REFER  MOUNTPOINT
rpool               13.0G  26.1G  36.5K  /rpool
rpool/ROOT          7.87G  26.1G    19K  legacy
rpool/ROOT/snv_111  7.87G  26.1G  7.87G  /
rpool/dump          2.00G  26.1G  2.00G  -
rpool/export         826K  26.1G    21K  /export
rpool/export/home    805K  26.1G   805K  /export/home
rpool/swap             2G  27.8G   267M  -

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:

# create a snapshot of all ZFS file systems
#
(root@milax)# zfs snapshot -r rpool@current

# save the ZFS file systems
#
(root@milax)# zfs send -v rpool@current >/mnt/solaris0/rpool
(root@milax)# zfs send -v rpool/ROOT@current >/mnt/solaris0/rpool_ROOT
(root@milax)# zfs send -v rpool/ROOT/snv_111@current >/mnt/solaris0/rpool_ROOT_snv111
(root@milax)# zfs send -v rpool/export@current >/mnt/solaris0/rpool_export
(root@milax)# zfs send -v rpool/export/home@current >/mnt/solaris0/rpool_export_home

# now umount and destroy the ZFS pool rpool
#
(root@milax)# zfs umount rpool
(root@milax)# zpool destroy rpool

# next use format to recreate the slice s0 with a smaller size and create
# an additional slice for MilaX
#
(root@milax)#  format

# now recreate the ZFS pool
#
(root@milax)# mkdir -p /a
(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

# and restore the ZFS file systems
#
(root@milax)# zfs receive -Fd rpool </mnt/solaris0/rpool
(root@milax)# zfs receive -Fd rpool </mnt/solaris0/rpool_ROOT
(root@milax)# zfs receive  -Fd rpool </mnt/solaris0/rpool_ROOT_snv111
(root@milax)# zfs receive  -Fd rpool</mnt/solaris0/rpool_export
(root@milax)# zfs receive  -Fd rpool </mnt/solaris0/rpool_export_home

# create the ZFS devices for swap and dump
#
(root@milax)# zfs create -V 2g -b 8k rpool/swap
(root@milax)# zfs create -V 2g  rpool/dump

# correct the mount points
#
(root@milax)# zfs set mountpoint=/export rpool/export
(root@milax)# zfs set mountpoint=/export/home rpool/export/home

# set the bootfs
#
(root@milax)#  zpool set bootfs=rpool/ROOT/snv_111 rpool

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.

It's a good idea to boot now from the disk to make sure that the backup/restore was successful.

If everything is okay, boot the machine again from the MilaX Live CD and start installing MilaX on the new free slice.

# 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
#
(root@milax)#  zfsinstall c4d0s1
Starting to copy data from UFS root to /zfsroot - this may take some time.
...
stage1 written to partition 0 sector 0 (abs 16065)
stage2 written to partition 0, 272 sectors starting at 50 (abs 16115)
 ###################################################################

       		MilaX now installed on c4d0s1

 ###################################################################

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:

(root@milax)#  zpool import -f rpool
(root@milax)#  mkdir -p /a
(root@milax)#  mount -F zfs rpool /a

Add the GRUB menu entry for MilaX to the existing GRUB menu, for example, add (for MilaX on slice 1):

(root@milax)#  vi  /a/boot/grub/menu.lst
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

Or for a findroot enabled GRUB, use this:

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

(root@milax)#  touch /tank/boot/grub/bootsign/tank_milax

And the new GRUB menu entry for MilaX is then this:

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

Then reinstall GRUB to boot from the correct slice, for example:

(root@milax)#  /usr/sbin/installgrub -m /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c4d0s0

(See the section "Which GRUB to use" below on how to decide which GRUB to use.)

Note:

Note that this method does not work with OpenSolaris 11.2008 -- in my tests, OpenSolaris did not work after restoring the ZFS file systems. It either did not find the GRUB menu or it found the GRUB menu but could not mount the root file system.

Troubleshooting

Message: libshare SMF initialization problem: entity not found

Problem:

In MilaX 3.3, the zfs commands sometime print the following message:

libshare SMF initialization problem: entity not found

Solution:

As far as I know, you can ignore this message.

Appendix

Which GRUB to use

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:

# 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

If the GRUB from MilaX is newer (for example, when you're using a Solaris 10 update), use the GRUB from MIlaX:

(root@milax)#  /usr/sbin/installgrub -m /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c4d0s0

Note:

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

add_milax.sh

#!/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 add MilaX to an existing ZFS pool
# by Bernd Schemmer
#
# based on the
# 	Script to install MilaX to ZFS
# 	By Alexander R. Eremin, April 4 2008.
# 	Thanks to Tim Foster for basic zfs-boot script
#
#

function die {
	typeset THISRC=$1
	[ $# -ne 0 ] && shift
	typeset THISMSG="$*"
	[ "${THISRC}"x = "0"x ]  && echo "${THISMSG}" ||  echo "${THISMSG}" >&2
	exit  ${THISRC}
 }


# Make sure only root can run our script
#
[ "$(id -u)" != "0" ] && die 1 "This script must be run as root"


# check arguments
#
[ "$#" -lt 1 ] || [ $1 == "-h" ] || [ $1 == "--help" ] && die 1 "Usage : zfsinstall zfspool"

#
# Examine memory requirements
#

# get total physical memory in megabytes
PHYSMEM=`/usr/sbin/prtconf | grep '^Memory size: ' | \
                sed -e 's/^Memory size: //' -e 's/ .*$//' `

MEMUNIT=`/usr/sbin/prtconf | grep '^Memory size: ' | \
                sed -e 's/^Memory size: [0-9][0-9]* //' `

case $MEMUNIT in
        Kilobytes) PHYSMEM=`expr $PHYSMEM / 1024` ;;
        Megabytes) ;;
        Gigabytes) PHYSMEM=`expr $PHYSMEM \* 1024` ;;
        Terabytes) PHYSMEM=`expr $PHYSMEM \* 1024 \* 1024` ;;
        *)         PHYSMEM=0 ;;
esac

export PHYSMEM
MIN_INSTALL_PHYSMEM=256

if [ "$PHYSMEM" -lt "$MIN_INSTALL_PHYSMEM" ] ; then
	echo "This installer requires a minimum of $MIN_INSTALL_PHYSMEM MB of physical memory"
	echo "to install.  This system only has $PHYSMEM MB of physical memory."
	echo
	echo "Exiting to shell"
	exit
fi


# change these to use different pool/fs names
home=/usr/dss/share/hdinstall

ROOT_POOL="$1"
ROOT_FILESYSTEM=milax_on_hd

TARGET_FS="${ROOT_POOL}/${ROOT_FILESYSTEM}"


# check that the pool exists
#
POOL_MOUNTPOINT="$( /usr/sbin/zpool  list -H -o name "${ROOT_POOL}" 2>/dev/null   )"  || \
	die 1  "Sorry, it looks like the pool \"${ROOT_POOL}\" does not exist. Exiting now"

# check that the target file system does not exist
#
/usr/sbin/zfs list  "${TARGET_FS}" 2>/dev/null >/dev/null  && \
	die 1  "Sorry, the target filesystem  \"${TARGET_FS}\" already exists. Exiting now"

# create the new ZFS file system for MilaX
#
  /usr/sbin/zfs create "${TARGET_FS}" || \
	die 1 "Sorry, error creating the target filesystem \"${TARGET_FS}\". Exiting now"

TARGET_MOUNT_POINT="$( /usr/sbin/zfs list -H -o mountpoint "${TARGET_FS}" )"

# start copying main data over to it
#
echo "Starting to copy data from UFS root to \"${TARGET_MOUNT_POINT}\" - this may take some time."

cd /
find . -xdev -depth -print | cpio -pvdm "${TARGET_MOUNT_POINT}" 2>&1 > /dev/null

# libc!
cp -rP /lib/libc.so*  "${TARGET_MOUNT_POINT}/lib" 2>&1 > /dev/null

mkdir -p "${TARGET_MOUNT_POINT}/alex"
cd /alex
find . -xdev -depth -print | cpio -pvdm "${TARGET_MOUNT_POINT}/alex" 2>&1 > /dev/null

mkdir -p "${TARGET_MOUNT_POINT}/root"
cd /root
find . -xdev -depth -print | cpio -pvdm "${TARGET_MOUNT_POINT}/root" 2>&1 > /dev/null

mkdir -p "${TARGET_MOUNT_POINT}/usr"
cd /usr
find . -xdev -depth -print | cpio -pvdm "${TARGET_MOUNT_POINT}/usr" 2>&1 > /dev/null

mkdir -p "${TARGET_MOUNT_POINT}/system/object"
mkdir -p "${TARGET_MOUNT_POINT}/system/contract"
mkdir -p "${TARGET_MOUNT_POINT}/tmp"
mkdir -p "${TARGET_MOUNT_POINT}/mnt"
mkdir -p "${TARGET_MOUNT_POINT}/proc"
mkdir -p "${TARGET_MOUNT_POINT}/var/run"
mkdir -p "${TARGET_MOUNT_POINT}/dev/fd"
mkdir -p "${TARGET_MOUNT_POINT}/etc/volatile"

touch "${TARGET_MOUNT_POINT}/etc/mnttab"
touch "${TARGET_MOUNT_POINT}/etc/dfs/sharetab"

chmod 555 "${TARGET_MOUNT_POINT}/system/object"
chmod 555 "${TARGET_MOUNT_POINT}/system/contract"
chmod 555 "${TARGET_MOUNT_POINT}/proc"
chmod 777 "${TARGET_MOUNT_POINT}/tmp"
chmod 755 "${TARGET_MOUNT_POINT}/etc/svc/volatile"
chmod 755 "${TARGET_MOUNT_POINT}/var/run"
chmod 555 "${TARGET_MOUNT_POINT}/dev/fd"
chmod 444 "${TARGET_MOUNT_POINT}/etc/mnttab"
chmod 755 "${TARGET_MOUNT_POINT}/usr"
chmod 755 "${TARGET_MOUNT_POINT}/alex"
chmod 755 "${TARGET_MOUNT_POINT}/root"
chmod 755 "${TARGET_MOUNT_POINT}/mnt"

chown -R alex:adm "${TARGET_MOUNT_POINT}/alex"

chown root "${TARGET_MOUNT_POINT}/system/object"
chown root "${TARGET_MOUNT_POINT}/system/contract"
chown root "${TARGET_MOUNT_POINT}/proc"
chown root "${TARGET_MOUNT_POINT}/tmp"
chown root "${TARGET_MOUNT_POINT}/etc/svc/volatile"
chown root "${TARGET_MOUNT_POINT}/var/run"
chown root "${TARGET_MOUNT_POINT}/dev/fd"
chown root "${TARGET_MOUNT_POINT}/etc/mnttab"

chgrp root "${TARGET_MOUNT_POINT}/system/object"
chgrp root "${TARGET_MOUNT_POINT}/system/contract"
chgrp sys "${TARGET_MOUNT_POINT}/tmp"
chgrp root "${TARGET_MOUNT_POINT}/proc"
chgrp sys "${TARGET_MOUNT_POINT}/etc/svc/volatile"
chgrp sys "${TARGET_MOUNT_POINT}/var/run"
chgrp root "${TARGET_MOUNT_POINT}/dev/fd"
chgrp root "${TARGET_MOUNT_POINT}/etc/mnttab"

# now populate the devices and /dev directories in ${TARGET_MOUNT_POINT}
# 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_MOUNT_POINT}"; 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_MOUNT_POINT}/etc" ; tar xfp -) 2>&1 > /dev/null


cp $home/misc/xstart "${TARGET_MOUNT_POINT}/usr/dss/sbin/"
cp $home/misc/live-fs-root "${TARGET_MOUNT_POINT}/lib/svc/method/"
cp $home/misc/repository.db "${TARGET_MOUNT_POINT}/etc/svc/"

# copy vfstab
#
cp $home/misc/vfstab "${TARGET_MOUNT_POINT}/etc/vfstab"


echo "Updating vfstab"
printf "${TARGET_FS}\t-\t/\tzfs\t-\tno\t-\n"  >> "${TARGET_MOUNT_POINT}/etc/vfstab"

# Update bootarchive,
#
echo "etc/zfs/zpool.cache" >>"${TARGET_MOUNT_POINT}/boot/solaris/filelist.ramdisk"

echo "Creating boot_archive, don't worry about amd64 errors..."
/usr/sbin/bootadm update-archive -R "${TARGET_MOUNT_POINT}" 2>&1 > /dev/null

# Put a grub menu.lst into the root pool
#
cat >>/${ROOT_POOL}/boot/grub/menu.lst <<EOT
title MilaX 0.3.3 (32 bit)
	bootfs ${TARGET_FS}
	kernel\$ /platform/i86pc/kernel/unix -B \$ZFS-BOOTFS,console=text
	module\$ /platform/i86pc/boot_archive
EOT

echo " ###################################################################"
echo
echo "       		MilaX now installed on ${TARGET_FS}"
echo
echo " ###################################################################"