CustomizeLiveInitrd

Differences between revisions 4 and 5
Revision 4 as of 2006-09-07 10:23:57
Size: 4658
Editor: 138
Comment: comments on scope
Revision 5 as of 2006-09-18 18:57:23
Size: 4937
Editor: 80-219-112-71
Comment: warning about installing to a mounted hard drive
Deletions are marked like this. Additions are marked like this.
Line 59: Line 59:
=== Live from hard drive ===
Line 68: Line 69:
Note: Don't try to run the live installer program and to install to the same hard drive as you are booting from. Since casper has that disk mounted, the disk detection and partitioning utilities in the normal installation sequence might get upset.

How to customize your initrd

The initrd contains all the programs and utilities the kernel needs in order to find the root partition. The initrd is "given" to the kernel by the boot loader (often isolinux on cds, or grub on hard drives).

Installed systems

The initrd used by an installed system is maintained by the mkinitramfs script, which is run automatically when for instance upgrading the kernel or any tool used inside the initrd. The correct and recommended way of modifying this initrd is to make hooks and scripts in the /etc/mkinitramfs directory tree. See /usr/share/initramfs for the scripts and hooks that are included by the system.

Live systems

You might find this information useful if you want to:

  • run the "Desktop" installer from a usb drive instead of from the cd
  • run the "Desktop" live system without using the cd player
  • debug and modify the live installer system
  • avoid burning all these cds
  • avoid using your slow and noisy cd player

The initrd used when booting a live cd ("Desktop CD") can be found in the casper directory of the cd. Below we will suppose you have the real cd mounted, but if you for instance have the iso-file mounted, adjust the /media/cdrom0 paths below accordingly.

Modify the initrd

  1. Extract the contents of the initrd:
    •   mkdir initrd-tmp
        cd initrd-tmp
        gzip -dc /media/cdrom0/casper/initrd.gz | cpio -id
  2. Modify the files
  3. Repack them into a new initrd:
    •   find . | cpio --quiet --dereference -o -H newc | gzip -9 > ~/new-initrd.gz

You can now remaster a cd with this new initrd.

However, it is easier to put the initrd on one of your drives, and let a bootloader find it. The bootloader used by the Desktop/live cd, isolinux, is not able to look anywhere else than on the cd it is started from, so we will therefore use another boot loader.

Boot using the HD grub loader

Since many of us already have grub installed on the hard drive, this is the easiest solution. You can also boot from a grub cd or grub usb drive, and manually enter the boot parameters.

As an example, we will put the kernel and modified initrd onto your normal linux partition on your hard drive. This can also be a vfat partition or anything else that grub is able to read.

sudo mkdir /boot-live
sudo cp /media/cdrom0/casper/vmlinuz /boot-live
sudo cp ~/new-initrd.gz /boot-live/initrd.gz

Additionally, you can add this to your /boot/grub/menu.lst:

# Live from hard drive
title           Edgy live snapshot
root            (hd0,1)
kernel          /boot-live/vmlinuz boot=casper initrd=initrd.gz ramdisk_size=1048576 root=/dev/ram rw --
initrd          /boot-live/initrd.gz
boot

Of course, replace (hd0,1) with the location of your partition where you put the kernel and initrd. The kernel boot parameters are taken from the APPEND line of the isolinux/isolinux.cfg configuration file on the cd.

The live filesystem

Once the kernel has booted, it will continue running the same way as if it had been running from the cd. During the "Mount root file system" step, it will search for the cd contents, or more precisely the /casper/filesystem.squashfs file. Normally it will search through all available disks to find this directory and file. Due to a bug in casper, it currently (Edgy Knot-2) looks only thorugh your cd drives, see [https://launchpad.net/distros/ubuntu/+source/casper/+bug/57620 bug #57620] which also has a patch, allowing it to look through usb drives as well.

Live from hard drive

If you apply this little patch (attachment:casper.all-disks.diff) to scripts/casper in your initrd, it will also look through your hard drives. Note that it any case, it will only look at iso9660, vfat and udf partitions, so your filesystem.squashfs can not reside on your ext2/ext3 partition (unless you hack scripts/casper a little, of course). To apply the patch, include the following in step 2 above.

patch scripts/casper ~/Desktop/casper.all-disks.diff

For instance, copy the casper directory from the cd over to the root directory of a vfat partition:

cp -r /media/cdrom0/casper /media/my_fat_disk

Note: Don't try to run the live installer program and to install to the same hard drive as you are booting from. Since casper has that disk mounted, the disk detection and partitioning utilities in the normal installation sequence might get upset.

That should be it. Happy booting!

Just remember, when there is a new cd out, to copy the new /casper tree as well as the new vmlinuz and your new initrd, and check for any new boot parameters in isolinux.cfg.

Comments

This page is basically about getting the Edgy Eft desktop/live installer to run from a USB device. The information here should probably be split and merged with some other Howtos.

CustomizeLiveInitrd (last edited 2012-03-28 22:12:29 by mrled)