Monday, December 8, 2008

Minimal OpenSolaris 2008.11 Install

Using instructions from Edward Pilatowicz' blog I got small working OpenSolaris 2008.11 in the console version: without Xorg (and Gnome of course).
First of all the list of the core packages for normal work in the console is necessary. My computer has Realtek ethernet adapter and I also have added a SUNWrtls package. Here's example list (pkg.txt):
SUNWcsd
SUNWcs
SUNWzone
SUNWcsl
SUNWlibsasl
SUNWlibms
SUNWpr
SUNWlxml
SUNWzlib
SUNWtls
SUNWopenssl
SUNWpool
SUNWzfs
SUNWsmapi
SUNWtecla
SUNWckr
SUNWpicl
SUNWmd
SUNWinstall-libs
SUNWwbsup
SUNWgccruntime
SUNWcar
SUNWcakr
SUNWusbs
SUNWusb
SUNWaudd
SUNWkvm
SUNWos86r
SUNWrmodr
SUNWpsdcr
SUNWpsdir
SUNWcnetr
SUNWesu
SUNWkey
SUNWnfsckr
SUNWnfsc
SUNWgss
SUNWgssc
SUNWbip
SUNWbash
SUNWloc
SUNWsshcu
SUNWsshd
SUNWssh
SUNWtoo
SUNWzfskr
SUNWipf
SUNWrtls
SUNWipkg
SUNWpython-pyopenssl
SUNWpython-cherrypy
SUNWadmr
SUNWadmap
SUNWadmlib-sysid
SUNWPython
SUNWbzip
SUNWxwrtl
SUNWTk
SUNWTcl
SUNWlexpt
SUNWperl584core

As last versions of packages have dependences, for example SUNWcs is installing SUNWgccruntime, SUNWPython is installing packages SUNWTk and SUNWTcl. But finally I got installed system with size about 280 mb - it's a smaller than 3 Gb;)
I use the same commands as in Edward's blog (I'm running Solaris Express):
zpool create -f rpool c1t1d0s0
zfs set compression=on rpool
zfs create -p rpool/ROOT/indy/opt
zfs set canmount=noauto rpool/ROOT/indy
zfs set canmount=noauto rpool/ROOT/indy/opt
zfs set mountpoint=legacy rpool/ROOT/indy
zfs set mountpoint=legacy rpool/ROOT/indy/opt

# we're going to do our install in /a
PKG_IMAGE=/a; export PKG_IMAGE

# mount our zpool on /a
mkdir -p $PKG_IMAGE
mount -F zfs rpool/ROOT/indy $PKG_IMAGE
mkdir -p $PKG_IMAGE/opt
mount -F zfs rpool/ROOT/indy/opt $PKG_IMAGE/opt

For Solaris Express you must install pkg (not required if you're booting from OpenSolaris or MilaX LiveCD):
hg clone ssh://anon@hg.opensolaris.org/hg/pkg/gate
cd gate/src
make install

# create the basic opensolaris install image..
pkg image-create -F -a opensolaris.org=http://pkg.opensolaris.org $PKG_IMAGE
pkg refresh


Note: I use here list of basic packages - pkg.txt (see above):
for pkg in `cat pkg.txt`; do pkg install $pkg; done

Next:
# seed the initial smf repository
cp $PKG_IMAGE/lib/svc/seed/global.db $PKG_IMAGE/etc/svc/repository.db
chmod 0600 $PKG_IMAGE/etc/svc/repository.db
chown root:sys $PKG_IMAGE/etc/svc/repository.db

# setup smf profiles
ln -s ns_files.xml $PKG_IMAGE/var/svc/profile/name_service.xml
ln -s generic_limited_net.xml $PKG_IMAGE/var/svc/profile/generic.xml
ln -s inetd_generic.xml $PKG_IMAGE/var/svc/profile/inetd_services.xml
ln -s platform_none.xml $PKG_IMAGE/var/svc/profile/platform.xml

# mark the new system image as uninstalled
sysidconfig -b $PKG_IMAGE -a /lib/svc/method/sshd
touch $PKG_IMAGE/etc/.UNCONFIGURED

# configure our new /etc/vfstab
printf "rpool/ROOT/indy -\t/\t\tzfs\t-\tno\t-\n" >> $PKG_IMAGE/etc/vfstab
chmod a+r $PKG_IMAGE/etc/vfstab

# turn off root as a role
printf "/^root::::type=role;\ns/^root::::type=role;/root::::/\nw" |\
ed -s $PKG_IMAGE/etc/user_attr

# delete the "jack" user
printf "/^jack:/d\nw" | ed -s $PKG_IMAGE/etc/passwd
chmod u+w $PKG_IMAGE/etc/shadow
printf "/^jack:/d\nw" | ed -s $PKG_IMAGE/etc/shadow
chmod u-w $PKG_IMAGE/etc/shadow

# copy of my existing host sshd keys
cp -p /etc/ssh/*key* $PKG_IMAGE/etc/ssh

# configure /dev in the new image
devfsadm -r $PKG_IMAGE
ln -s ../devices/pseudo/sysmsg@0:msglog $PKG_IMAGE/dev/msglog

# update the boot archive in the new image
bootadm update-archive -R $PKG_IMAGE

# update to the latest version of grub (this command generated
# some errors which i ignored).
$PKG_IMAGE/boot/solaris/bin/update_grub -R $PKG_IMAGE

# create an informational grub menu in the install image that
# points us to the real grub menu.
cat <<-eof> $PKG_IMAGE/boot/grub/menu.lst

#########################################################################
#                                                                       #
# For zfs root, menu.lst has moved to /rpool/boot/grub/menu.lst.        #
#                                                                       #
#########################################################################
EOF

# create the new real grub menu
cat <<-eof> /rpool/boot/grub/menu.lst
default 0
timeout 10
splashimage /boot/grub/splash.xpm.gz

title Solaris 2008.11 console
findroot (pool_rpool,0,a)
bootfs rpool/ROOT/indy
kernel\$ /platform/i86pc/kernel/\$ISADIR/unix -k -B \$ZFS-BOOTFS,console=ttya
module\$ /platform/i86pc/\$ISADIR/boot_archive

EOF

# make the grub menu files readable by everyone.
chmod a+r $PKG_IMAGE/boot/grub/menu.lst
chmod a+r /rpool/boot/grub/menu.lst

# setup /etc/bootsign so that grub can find this zpool
mkdir -p /rpool/etc
echo pool_rpool > /rpool/etc/bootsign

umount $PKG_IMAGE/opt
umount $PKG_IMAGE
reboot


After reboot you get the console version of OpenSolaris with which you can do all that you want. Next you can install only those packages which are necessary for you. For example it's useful to owners of old notebooks. This installation can be made from an OpenSolaris LiveCD in text mode or with help of a MilaX LiveCD (where's ipkg is included).

11 comments:

Kokoro said...

There are lots of old sparc machines (I have an unusual RDI/Tadpole Voyager IIi shoe-box server) about the place these days that could benefit from having a small distro like milax with IPS and perhaps ZFS (useful for storage options experimentation I guess -incidentally my machine boots Milax/SPARC successfully with some minor complaining about the "power driver") IPS doesn't appear to be available on the sparc version and there are some issues with blastwave because of the pkgrm program (on which operates their pkgutil utility for upgrades) depending on libwrs.so.1 or some such. Anyhow -pkgutil (or pkg-add) then cannot be used properly because of this. I tried using your getpkg.rb to install IPS but failed as it needs crypto.ssl from python which I am not expert enough to install I'm afraid. 8( Can you possibly give us SPARC newbies any hints on how to get IPS working on the SPARC version of milax? There might be a few people in cold countries that can use the 220R's and the like as decent heaters in their studies then! 8)

Unknown said...

I'm trying this step by step.
Maybe I did some error, but this command:
bootadm update-archive -R $PKG_IMAGE
complained that there was no /a/boot/grub directory
so I did an:
rsync -avr --progress /boot/grub /a/boot/
and then it worked

Unknown said...

I tried zfs boot from a live-cd of OpenSolaris2008.11

i used following script which i created referring
1. http://opensolaris.org/os/community/zfs/boot/zfsboot-manual/
2. http://alexeremin.blogspot.com/ (minimal solaris part)
3. http://src.opensolaris.org/source/xref/caiman/slim_prototype/bootcd_skel/root/installer/install_live
4. http://src.opensolaris.org/source/xref/caiman/slim_source/usr/src/cmd/slim-install/finish/install-finish

script :
========================================================
zpool create -f rootpool c3d0s0
zfs create rootpool/rootfs
zfs set mountpoint=legacy rootpool/rootfs
mkdir /zfsroot
mount -F zfs rootpool/rootfs /zfsroot

cd /.cdrom
find . -xdev -print | grep -v 'zlib$' | cpio -pmd /zfsroot

cd /
echo "Copying filesys"
find usr -print | cpio -pmd /zfsroot
find opt -print | cpio -pmd /zfsroot
find etc -print | cpio -pmd /zfsroot
find lib -print | cpio -pmd /zfsroot
find var -print | cpio -pmd /zfsroot

printf "rootpool/rootfs\t-\t/zfsroot\t\tzfs\t-\tno\t-\n" >> /zfsroot/etc/vfstab
echo "init done"

mkdir -p /zfsroot/etc/zfs
cp /etc/zfs/zpool.cache /zfsroot/etc/zfs

cp /zfsroot/lib/svc/seed/global.db /zfsroot/etc/svc/repository.db

mount -F lofs -o nosub / /mnt
(cd /mnt; tar cvf - devices dev ) | (cd /zfsroot; tar xvf -)


cp /zfsroot/lib/svc/seed/global.db /zfsroot/etc/svc/repository.db
chmod 0600 $PKG_IMAGE/etc/svc/repository.db
chown root:sys $PKG_IMAGE/etc/svc/repository.db

echo "setup smf profiles"

rm -f /zfsroot/var/svc/profile/generic.xml \
/zfsroot/var/svc/profile/name_service.xml \
/zfsroot/var/svc/profile/inetd_services.xml
ln -s ns_files.xml $PKG_IMAGE/var/svc/profile/name_service.xml
ln -s generic_limited_net.xml $PKG_IMAGE/var/svc/profile/generic.xml
ln -s inetd_generic.xml $PKG_IMAGE/var/svc/profile/inetd_services.xml
ln -s platform_none.xml $PKG_IMAGE/var/svc/profile/platform.xml

echo "setprop console text" >> /zfsroot/boot/solaris/bootenv.rc

echo "cache"
mkdir -p /zfsroot/etc/boot/solaris
echo "etc/zfs/zpool.cache" > /zfsroot/etc/boot/solaris/filelist.ramdisk
if [ $? != 0 ] ; then
echo "etc/zfs/zpool.cache" >> \
${BASEDIR}/boot/solaris/filelist.ramdisk
fi

echo "update-archive"
bootadm update-archive -R /zfsroot
rm -f /zfsroot/boot/solaris/filestat.ramdisk
echo "updated"

sed '/zpool.cache/d' /zfsroot/boot/solaris/filelist.ramdisk > \
/tmp/x.$$
rm -f /zfsroot/boot/solaris/filelist.ramdisk
cp /tmp/x.$$ /zfsroot/boot/solaris/filelist.ramdisk
rm -f /tmp/x.$$

zpool set bootfs=rootpool/rootfs rootpool

mkdir -p /rootpool/boot/grub
cp /zfsroot/boot/grub/menu.lst /rootpool/boot/grub/menu.lst
cp /zfsroot/boot/grub/splash.xpm.gz /rootpool/boot/grub/splash.xpm.gz

cat > /zfsroot/etc/.sysidconfig.apps << EOF
/lib/svc/method/sshd
/usr/sbin/sysidkbd
/usr/lib/cc-ccr/bin/eraseCCRRepository
/usr/sbin/sysidpm
/usr/lib/scn/bin/cleanup-scn-base
/lib/svc/method/net-nwam
EOF
touch /zfsroot/etc/.UNCONFIGURED

echo "Enable nwam"
SVCCFG_DTD=/zfsroot/usr/share/lib/xml/dtd/service_bundle.dtd.1
SVCCFG_REPOSITORY=/zfsroot/etc/svc/repository.db
export SVCCFG_DTD SVCCFG_REPOSITORY

/usr/sbin/svccfg apply /zfsroot/var/svc/profile/network_nwam.xml

cat <<-EOF> /zfsroot/var/svc/profile/upgrade
/usr/sbin/svcadm disable network/physical:default
/usr/sbin/svcadm enable network/physical:nwam
EOF

echo "reset image UUID"
pkg -R /zfsroot/ set-authority --reset-uuid --no-refresh opensolaris.org
pkg -R /zfsroot/ set-property send-uuid True

echo "create the new real grub menu"
cat <<-EOF > /rootpool/boot/grub/menu.lst
default 0
timeout 10
splashimage /boot/grub/splash.xpm.gz

title Solaris 2008.11 console
findroot (pool_rootpool,0,a)
bootfs rootpool/rootfs
kernel\$ /platform/i86pc/kernel/\$ISADIR/unix -k -B \$ZFS-BOOTFS,console=ttya
module\$ /platform/i86pc/\$ISADIR/boot_archive

EOF

chmod a+r /zfsroot/boot/grub/menu.lst
chmod a+r /rootpool/boot/grub/menu.lst

echo "setup /etc/bootsign so that grub can find this zpool"
mkdir -p /rootpool/boot/grub/bootsign
echo pool_rootpool > /rootpool/etc/bootsign/bootsign

bootadm update-menu -R /zfsroot/ -o /dev/rdsk/c3d0s0

/usr/sbin/installgrub /.cdrom/boot/grub/stage1 /.cdrom/boot/grub/stage2 /dev/rdsk/c3d0s0

echo "script complete"

========================================================

I get following error message on booting Solaris 2008.11 console:

========================================================
krtld : error during initial load/link phase

krtld could neither locate nor resolve symbols for:
/platform/i86pc/kernel/unix
in the boot archive. Please verify that this file
matches what is found in the boot archive.
You may need to boot using the Solaris failsafe to fix this
Unable to boot
========================================================

& then failsafe option hangs the machine.

have any clue... what is missing?

alhazred said...

To Kokoro: I hope that we will try the sparc version of OpenSolaris soon.
To Abhishek: I think that some important files have not been copied. Check up a copying stage.

Unknown said...

This is my new script where i have copied almost everything to zfsroot.
http://pastesite.com/4660

I don't understand what can be the problem; because system recognizes grub & even takes a choice but eventually it is failing to mount "/" according to me even though it is specified in the vfstab.

l8rz said...

Another minor correction is devfsadm uses lower-case -r to specify root unlike bootadm which uses uppercase -R:

devfsadm -r $PKG_IMAGE

Ildar said...

Is it possible to install from LiveCD? For offline installation?

alhazred said...

I am afraid it will be inconvenient and access to the Internet is required in any case..

Anonymous said...

u r blog Is very nice



web design company

ìgbàlonígbàńlò said...

I get the following when I run:

/a/boot/solaris/bin/update_grub -R /a

Creating GRUB menu in /a
bootadm: failed to open file: /a/etc/release: No such file or directory
bootadm: fstyp -a on device /dev/rdsk/c9d0 failed
bootadm: failed to get pool for device: /dev/rdsk/c9d0
bootadm: fstyp -a on device /dev/rdsk/c9d0 failed
bootadm: failed to get pool name from /dev/rdsk/c9d0
bootadm: failed to create GRUB boot signature for device: /dev/rdsk/c9d0
bootadm: failed to get grubsign for root: /a, device /dev/rdsk/c9d0
Installing grub on /dev/rdsk/c9d0
raw device must be a root slice (not s2)


Is there something I'm doing wrong?

alhazred said...

ìgbàlonígbàńlò:
c9d0 - you must use c9d0s0
Also now better to use DistroConstructor.

How to determine PXE mac address when booting illumos via PXELinux/iPXE

In illumos, if you need to determine the interface which was used for booting via PXE then it's possible to use "boot-mac" pro...