navigation, content, portlets

Frugal Install How-To

This is a guide to doing a “frugal install” of Ultima Linux to hard disk – in other words, rather than doing a normal installation through the Wolvix Control Panel, we’re actually copying the LiveCD structure itself to hard disk (and modifying it so it can boot properly).

Important: Read the “Background/Notes” section before attempting this procedure!

Note: This procedure is still being refined and tested. See http://www.ultimalinux.com/forum/viewtopic.php?t=1207 for more information and various corrections that haven’t yet made it to the wiki.

Contents

Background/Notes

This is based on the procedure I used for my own Micron laptop after its CD-ROM drive died, but it’s been modified significantly. For this procedure, I’m assuming the conditions are something like this:

  • You have a laptop that you want to run Ultima Linux, but that can’t boot directly from the LiveCD.
  • The laptop’s hard drive is IDE, but you’re installing from another machine, using a laptop IDE→USB converter.
    • Because of this, the laptop sees the drive as hda, but the desktop sees the drive as sda (because of USB-SCSI emulation).
  • You are performing the installation while running the LiveCD, or else have the disc already mounted at /mnt/cdrom.

(Why such an arbitrary set of conditions? Because that’s how Blue60, the first user to attempt following this, wanted to set up his laptop.)

This is an insidiously complex procedure, and there are lots of places where things could go wrong. I recommend this for advanced users only (well, and new users who want to learn advanced Linux stuff very very quickly). DO NOT COPY AND PASTE THE COMMANDS AS-IS. Type them out individually, modifying them as necessary for your setup. If something goes wrong, do not proceed to the next step (unless you are 100% sure you know what you’re doing), but take exact note of the problem and post something on the forums!

Compatibility

The information in this article is specific to Ultima Linux 8.3, x86 Edition LiveCD, and may not be valid for other versions.

This will not work as given on previous versions, because of changes in the LiveCD code. Expect to do extensive modification if you’re running AMD64 edition and/or the LiveDVD.

Procedure

NOTE: The procedure assumes your desktop machine has an IDE drive. If you have an SATA drive, the laptop disk will probably be sdb.

Boot the LiveCD on your desktop machine, and log in as root.

Partitioning

Start QtParted by running this command:

qtparted

In the QtParted window, select the laptop hard drive (/dev/sda) from the list on the left. The partition map should appear.

I’m assuming that there’s a Windows partition already at /dev/sda1, and that you have another partition of some sort on sda2. For simplicity, we’re going to create two new partitions:

  • /dev/sda3 should be at least 1GB. Format it as ext2.
  • /dev/sda4 should be around 128MB. Format it as linux-swap.

Write the changes to disk, and exit QtParted.

Formatting the filesystems

Even though QtParted already formatted the filesystems, it’s better to re-format them manually (you can optimize them more efficiently). First, re-format your future / partition, /dev/sda3:

mke2fs -i 1024 -m 1 /dev/sda3

Now format /dev/sda4 as your swap partition:

mkswap -v1 /dev/sda4

If everything proceeds without error, continue to the next phase of installation.

Modding the LiveCD code

Mount your new partition at a convenient mount point:

mount -t ext2 /dev/sda3 /mnt/hd

Change to that directory:

cd /mnt/hd

We need to get some files from the LiveCD’s initrd, which is a gzip-compressed file called rootfs.img. First, decompress it so it’s usable as a filesystem:

zcat /mnt/cdrom/isolinux/rootfs.img >rootfs

Now mount rootfs as a loopback filesystem:

mount -t ext2 -o loop rootfs /mnt/floppy

Copy the entire rootfs directory tree:

cp -ar /mnt/floppy/* .

We should be done with rootfs now. Unmount it:

umount /mnt/floppy

And remove the temporary file:

rm rootfs

All the programs on the LiveCD are stored in compressed files such as squashfs.img (these are formatted with a read-only filesystem called SquashFS). We won’t be able to do much without them, so copy all the SquashFS loops to your new / partition:

cp -a /mnt/cdrom/*.img .

The last step is modifying the LiveCD’s boot code, which is contained in a script called linuxrc. The one contained on the LiveCD won’t work for booting from hard disk, so let’s just get rid of it:

rm linuxrc

Now create a new linuxrc script using vim (or your favorite text editor):

vim linuxrc

Copy and paste the example linuxrc from the Files section below into your text editor. Make sure to modify it as necessary if your / partition isn’t /dev/hda3! When you are finished, save the file and exit the editor.

The linuxrc script has to be executable to be of any use:

chmod a+x linuxrc

Excellent! If everything worked as planned, all that remains is getting a working kernel.

Installing the non-SMP kernel

At this point, the biggest remaining task is to install the system’s kernel. Now, you could just use the one straight off the LiveCD – it would work just fine, with no problems – but if you have an older machine, the default kernel will be incredibly slow because it’s built for faster systems with features such as symmetric multi-processing (SMP).

Now, I could just tell you to rebuild your own kernel – and really, it’s worth considering if you’re that obsessed with speed optimization – but I’m feeling nice, so I already prepared an optimized, non-SMP kernel that you can download and use. First, you need to download the kernel itself:

lynx -dump -source http://ultimapcs.dyndns.org/~multima/micron-xpe/vmlinuz >vmlinuz

Next you need the kernel modules, since the regular SMP ones won’t work. You can’t overwrite the default ones in squashfs.img, since SquashFS is a read-only filesystem, so these are in a separate SquashFS image:

lynx -dump -source http://ultimapcs.dyndns.org/~multima/micron-xpe/aakernel.img >aakernel.img

Note that this requires a major kludge in the linuxrc script to work correctly! This kludge is only enabled if a aakernel.img file is found. If the kludge is active, it will print a smiley-face :) during the Pivoting root filesystem... part of the boot procedure.

If the kernel installed without error, all you need now is to install a bootloader.

Installing the bootloader

Normally Ultima Linux uses GRUB to boot, but because of the size and complexity of the GRUB program, it would be unsuitable for the “frugal install”. Instead we’re going to use the older, simpler LILO. First, create a directory for LILO to go in:

mkdir sbin

The regular lilo executable from the Ultima LiveCD will not work here, because it’s dynamically linked (and the LiveCD rootfs doesn’t include dynamic libraries, because of size reasons). Instead, you need to install a special staticly-linked lilo:

lynx -dump -source http://ultimapcs.dyndns.org/~multima/floppies/lilo >sbin/lilo

And make it executable:

chmod a+x sbin/lilo

Now we need to create a configuration file for LILO:

mkdir etc
vim etc/lilo.conf

You can use my example lilo.conf as a base for yours. It includes entries for a Windows partition at /dev/hda1, as well as your Linux partition. Take especially close note of the third option, Ultima-sh; this is the same as the regular Ultima boot option, except that it drops you into a recovery shell rather than booting the LiveCD code (this is incredibly handy to have in case things go wrong).

Note that you have to create the lilo.conf by hand, since there’s no liloconfig on the initrd.

We’re nearly ready. You need to perform the next few steps within a chroot:

chroot /mnt/hd bin/ash

Note /bin/ash, with an “a”; we’re working within a BusyBox shell.

Install LILO to your master boot record (MBR):

lilo -M /dev/sda
lilo

OK, we’re done here. Exit the Busybox shell:

exit

Creating the fstab

The last step is to create an /etc/fstab for your new system. This needs to be where the system can see it after booting the LiveCD – you can’t just put it in /mnt/hd/etc/fstab, because that’s no longer the root filesystem once linuxrc runs.

Anyway, to make a long story short, all your files are stored in a directory called /.tmpfs. First create your /etc directory:

mkdir -p .tmpfs/etc

Now create the fstab based on the example below, modifying (of course) as necessary for your system:

vim .tmpfs/etc/fstab

Yay! We’re done. Change to a “safe” directory (i.e. not on your laptop disk):

cd

And unmount the laptop drive:

umount /mnt/hd

Congratulations. You’ve made it. Pop the disk back in the laptop, reboot, and enjoy.

Files

These are some examples of files needed in the procedure above. I based these on the ones for my Micron laptop, but the ones posted here are stripped down and modified slightly for the procedure above.

fstab

/dev/hda3        /                ext2        defaults         1   1
/dev/hda4        swap             swap        defaults         0   0
devpts           /dev/pts         devpts      gid=5,mode=620   0   0
proc             /proc            proc        defaults         0   0

# Use this for Windows 95/98/Me:
/dev/hda1 /mnt/windows_hda1 vfat defaults,umask=7000,fmask=7111,dmask=7000 0 0

## Use this for Windows NT/2000/XP:
#/dev/hda1 /mnt/windows_hda1 ntfs-3g defaults,umask=7000,fmask=7111,dmask=7000 0 0

lilo.conf

boot=/dev/hda
prompt
timeout=60
lba32
compact
vga=normal
default=Ultima
        
other=/dev/hda1
        label=Windows
        boot-as=0x80

image=/vmlinuz
        label=Ultima
        root=/dev/hda3
        append="init=/linuxrc"
        vga=normal
        read-write
        
image=/vmlinuz
        label=Ultima-sh
        root=/dev/hda3
        append="init=/bin/ash"
        vga=normal
        read-write

linuxrc

#!/bin/ash

mount -o remount,rw /dev/hda3 / >/dev/null 2>/dev/null

DIRS='/.tmpfs=rw'

echo -n 'Loading modules: '

SQUASHPATH=/
for i in ${SQUASHPATH}/*.img ; do
  j=$(basename ${i} .img)
  mkdir -p /.${j} >/dev/null 2>/dev/null || echo -n '-'
  mount -t squashfs -o loop,ro ${SQUASHPATH}/${j}.img /.${j}
  DIRS="${DIRS}:/.${j}=ro"
  echo -n "${j} "
done
echo

echo -n "Pivoting root filesystem... "

mkdir -p /.tmpfs /.union
mount -t unionfs -o dirs=${DIRS} none /.union

mkdir -p /.tmpfs/home ; mount --bind /.tmpfs/home /.union/home

mkdir -p /.union/mnt/cdrom ; mount --bind /mnt/cdrom /.union/mnt/cdrom

if [ -d /.aakernel ]; then
  echo -n ':) '
  mount --bind /.aakernel/lib/modules /.union/lib/modules
fi

cd /.union ; mkdir -p initrd

pivot_root . initrd

/sbin/depmod -a >/dev/null 2>/dev/null

/usr/bin/echo 'done.'

exec /sbin/init

Tips

Backing up the system

Back-ups are incredibly easy on a frugal install: After booting the system normally, just copy everything in /initrd/.tmpfs to a safe location. Everything you’ve saved is stored here – system configuration, your home directory, and any additional packages you may have installed.