~trisk/ (Albert Lee) "So I was at dinner with moot..." -Praem
etch-zone
~trisk/

Notes on installing Debian GNU/Linux 4.0 "Etch" (the current stable release) to a Solaris Express (OpenSolaris) Branded Zone (BrandZ) (with a nod to Nils' instructions for Debian on BrandZ). That means you can run Debian on your Solaris/OpenSolaris box without the overhead of hardware virtualisation. Yes, you can install Debian Etch with a Linux 2.4 personality, although you now have the option of using a Linux 2.6 branded zone.

Step 1
Create an lx-branded zone first. Choose a real network interface for this (here, I have my Atheros wireless card ath0; you might have something else -- dladm show-dev). It will create an alias for its virtual network card. You will need to specify a static IP address, since DHCP support isn't there yet:

[trisk@shamisen]% uname -a
SunOS shamisen 5.11 snv_81 i86pc i386 i86pc
[trisk@shamisen]% sudo zonecfg -z lunix
lunix: No such zone configured
Use 'create' to begin configuring a new zone.
zonecfg:lunix> create -t SUNWlx

The default version of the Linux kernel personality that a lx zone uses is 2.4. If you want a zone that pretends to be Linux 2.6, do the following instead:

zonecfg:lunix> create -t SUNWlx26
zonecfg:lunix> set zonepath=/export/zones/lunix
zonecfg:lunix> add net
zonecfg:lunix:net> set physical=ath0
zonecfg:lunix:net> set address=192.168.1.250
zonecfg:lunix:net> end

Now, verify and commit the zone configuration.

zonecfg:lunix> verify
zonecfg:lunix> commit
zonecfg:lunix> exit

Note: Updated the download on 2008-04-13 since the install script now checks for bin in the tarball as well. Thanks to Uwe Dippel for reporting the problem.
The "install" process for a BrandZ zone expects certain Red Hat/Fedora specific files to exist already in a tarball distribution. We'll fake it, just grab lx-brandz-base-20080413.tar.

[trisk@shamisen]% sudo zoneadm -z lunix install -d /tmp/lx-brandz-base-20080413.tar

The zone should now be marked as "installed".

Step 2
Now, do a debootstrap on an existing Debian (or Ubuntu, Nexenta...) system and tar up the results.

You can skip this step and use lx-brandz-etch-root.tar.gz, which is a snapshot of an install from around April 12, 2007 (soon after the etch release).

Note: You can actually run debootstrap on Solaris: http://grahame.angrygoats.net/moinmoin/Tips/Solaris_and_Ubuntu has a wrapper for it. It uses Python for an MD5 hash, instead of digest(1) though, which is yucky.

[trisk@shamisen]% ssh eridani.acm.jhu.edu # this is a remote Ubuntu system
[trisk@eridani]% uname -s
Linux
[trisk@eridani]% mkdir /tmp/lunix
[trisk@eridani]% sudo debootstrap --arch i386 etch /tmp/lunix http://mirrors.acm.jhu.edu/debian/

(Obviously substitute http://ftp.debian.org/debian/ or your favourite Debian mirror if you're not in Baltimore). This will take a couple of minutes on a fast system. The result is a minimal install of Debian in /tmp/lunix.

When the debootstrap finishes, tar up the resulting installation and copy it over.

[trisk@eridani]% cd /tmp/lunix
[trisk@eridani]% sudo tar cfz /tmp/lx-brandz-etch-root.tar.gz .

Step 3
Extract the archive over the zone's root directory (in our example, this is /export/zones/lunix/root).

[trisk@eridani]% exit
[trisk@shamisen]% scp eridani.acm.jhu.edu:/tmp/lx-brandz-etch-root.tar.gz /tmp
[trisk@shamisen]% sudo -s
[root@shamisen]# cd /export/zones/lunix/root
[root@shamisen]# gtar xfz /tmp/lx-brandz-etch-root.tar.gz

/etc/inittab needs to be modified to use a single system console rather than virtual terminals.

[root@shamisen]# cd /export/zones/lunix/root
[root@shamisen]# perl -pi -e "s,tty1,console,; s,^([23456]),#\1," etc/inittab

Step 4
Congratulations, we're ready to boot!

[root@shamisen]# zoneadm -z lunix boot

It's not quite done, though...

[root@shamisen]# zlogin lunix

It will boot into single-user mode (maintenance mode). This is the culprit:

lunix:~# /etc/rcS.d/S10checkroot.sh start
Activating swap...done.
mknod: `/lib/init/rw/rootdev': Operation not permitted
* The device node none for the root filesystem is missing or incorrect 
or there is no entry for the root filesystem listed in /etc/fstab. 
The system is also unable to create a temporary node in /lib/init/rw. 
This means you have to fix the problem manually.
* A maintenance shell will now be started. 
CONTROL-D will terminate this shell and restart the system.
Press enter for maintenance
(or type Control-D to continue): 

Restarting system.

To fix this:

[root@shamisen]# zlogin lunix
Press enter for maintenance
(or type Control-D to continue):
lunix:/# perl -pi -e "s,1 1,1 0," /etc/fstab
lunix:/# reboot

Success!

[root@shamisen]# zlogin lunix                                           ~
[已連線至區域 'lunix' pts/5]
Last login: Tue Jun 05 05:48:09 2007 from zone:global on pts/5
Linux lunix 2.4.21 BrandZ fake linux i686

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
lunix:~# 

Now for some slightly less obvious problems:

if{up,down} will fail because of /etc/network/run being a symlink to the non-existant shmfs /dev/shm directory.

lunix:/# ls -l /etc/network
lrwxrwxrwx 1 root root  16 Apr 12 16:56 /etc/network/run -> /dev/shm/network
lunix:/# ls /dev/shm
ls: /dev/shm: No such file or directory

This would be nice if we could touch /dev, but we can't:

lunix:/# ln -s /tmp /dev/shm
ln: creating symbolic link `/dev/shm' to `/tmp': Function not implemented

Instead, this works:

lunix:/# mkdir /var/run/network && rm /etc/network/run && ln -s /var/run/network /etc/network/run

For apt-get and aptitude to work correctly, comment out flock() calls in /usr/share/perl5/Debconf/DbDriver/File.pm, or apply this patch.

lunix:/# wget http://trisk.acm.jhu.edu/lx-brandz-File.pm.diff
lunix:/# patch -p0 < lx-brandz-File.pm.diff
> software
> zfs-demo
> etch-zone