CustomizeLiveInitrd

Differences between revisions 3 and 12 (spanning 9 versions)
Revision 3 as of 2006-09-01 21:00:00
Size: 4404
Editor: 80-219-112-71
Comment:
Revision 12 as of 2012-03-28 22:12:29
Size: 5682
Editor: mrled
Comment: Added note about grub-mkconfig for Grub 2.x
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
## page was renamed from CustomizedInitrd
Line 9: Line 10:
 * do the "Desktop" install from a usb drive instead of from the cd
 * run the live system without using the cd player
 * run the "Desktop" installer from a usb drive instead of from the cd
 * run the "Desktop" live system without using the cd player
Line 15: Line 16:
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. 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 downloaded an iso-file and mounted it with:
{{{ sudo mount -o loop edgy-desktop-i386.iso /mnt }}}. If you otherwise have the burnt the cd inserted it
, replace ''/mnt'' by ''/media/cdrom0''
Line 22: Line 24:
  gzip -dc /media/cdrom0/casper/initrd.gz | cpio -id   gzip -dc /mnt/casper/initrd.gz | cpio -id
  }}}
  or for Ubuntu 9.10 and later:
  {{{
  lzma -dc -S .lz /mnt/casper/initrd.lz | cpio -id
Line 29: Line 35:
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 on the 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.
  or, if you want an initrd.lz (for Ubuntu 9.10 and later):
  {{{
  find . | cpio --quiet --dereference -o -H newc | lzma -7 > ~/new-initrd.lz
  }}}
You can now remaster a cd with this new initrd.gz replacing the old /casper/initrd.gz.

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, ''grub''.
Line 36: Line 47:
As an example, we will put the kernel and modified initrd onto your normal linux partition on your hard drive. This can also be vfat partition or anything else that grub is able to read. 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 from.
Line 39: Line 50:
sudo cp /media/cdrom0/casper/vmlinuz /boot-live sudo cp /mnt/casper/vmlinuz /boot-live
Line 42: Line 53:
Additionally, you can add this to your ''/boot/grub/menu.lst'': You'll also have to modify your grub configuration. Whether you're using Grub 1.x or 2.x, make sure to replace ''(hd0,1)'' or ''(hd0,msdos2)'' text with the location of your partition where you put the kernel and initrd.
Also, for both 1.x and 2.x, the boot parameters are taken from the ''append'' line of the ''isolinux.cfg'' file from the cd.

=== For Grub 1.x ===

Add this to your ''/boot/grub/menu.lst'':
Line 51: Line 67:
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.

=== For Grub 2.x ===

Add this to your ''/etc/grub.d/40_custom'':
{{{
menuentry "Ubuntu LiveCD-on-HD" {
    set root=(hd0,msdos2)
    linux /boot-live/vmlinuz boot=casper initrd=initrd.gz noprompt textonly --
    initrd /boot-live/initrd.gz
}
}}}
You also must run {{{grub-mkconfig -o /boot/grub/grub.cfg}}} after you make your changes.
Line 55: Line 81:
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 looks only on your cd drive, 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.
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 cd/dvd drives and usb disks to find the /casper directory.
Line 58: Line 84:
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. === Live from hard drive ===
''The patch below is not needed in Feisty, since is_usb_device has been replaced by is_nice_device.''

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.
Line 63: Line 92:
For instance, copy the casper directory from the cd over to the root directory of a vfat partition: Now copy the casper directory from the cd over to the root directory of a vfat partition, e.g.
Line 65: Line 94:
cp -r /media/cdrom0/casper /media/my_fat_disk cp -r /mnt/casper /media/my_fat_disk
Line 67: Line 96:
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.
Line 70: Line 100:
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''. Just remember, when there is a new cd out, to update the new ''/casper'' tree as well as the new ''vmlinuz'' and your new ''initrd.gz'', 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.

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 downloaded an iso-file and mounted it with:  sudo mount -o loop edgy-desktop-i386.iso /mnt . If you otherwise have the burnt the cd inserted it, replace /mnt by /media/cdrom0

Modify the initrd

  1. Extract the contents of the initrd:
    •   mkdir initrd-tmp
        cd initrd-tmp
        gzip -dc /mnt/casper/initrd.gz | cpio -id
      or for Ubuntu 9.10 and later:
        lzma -dc -S .lz /mnt/casper/initrd.lz | 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
      or, if you want an initrd.lz (for Ubuntu 9.10 and later):
        find . | cpio --quiet --dereference -o -H newc | lzma -7 > ~/new-initrd.lz

You can now remaster a cd with this new initrd.gz replacing the old /casper/initrd.gz.

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, grub.

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 from.

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

You'll also have to modify your grub configuration. Whether you're using Grub 1.x or 2.x, make sure to replace (hd0,1) or (hd0,msdos2) text with the location of your partition where you put the kernel and initrd. Also, for both 1.x and 2.x, the boot parameters are taken from the append line of the isolinux.cfg file from the cd.

For Grub 1.x

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

For Grub 2.x

Add this to your /etc/grub.d/40_custom:

menuentry "Ubuntu LiveCD-on-HD" {
    set root=(hd0,msdos2)
    linux /boot-live/vmlinuz boot=casper initrd=initrd.gz noprompt textonly --
    initrd /boot-live/initrd.gz
}

You also must run grub-mkconfig -o /boot/grub/grub.cfg after you make your changes.

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 cd/dvd drives and usb disks to find the /casper directory.

Live from hard drive

The patch below is not needed in Feisty, since is_usb_device has been replaced by is_nice_device.

If you apply this little patch (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

Now copy the casper directory from the cd over to the root directory of a vfat partition, e.g.

cp -r /mnt/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 update the new /casper tree as well as the new vmlinuz and your new initrd.gz, 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)