HOWTO LiveCD on disk
From Gentoo Linux Wiki
| Installation • Kernel & Hardware • Networks • Portage • Software • System • X Server • Gaming • Non-x86 • Emulators • Misc |
This HowTo teaches you how to put a working copy of the Gentoo Minimal LiveCD into the first partition of your harddrive. This is useful for installing servers remotely or for laptop users. I used this method to remotely install Gentoo on a Strato root server.
Contents |
[edit] Putting the LiveCD on disk
[edit] Creating a partition
Create a primary partition of 500MB (If you do not plan to modify the LiveCDs contents (or plan to repack the squashfs), 70MB will be enough) at the beginning of the disk (referred to as hda1) and mark it bootable. Format it as ext3, then mount it. Create the mount point first, if necessary.
cfdisk mke2fs -j /dev/hda1 mkdir /mnt/rescue mount /dev/hda1 /mnt/rescue
[edit] Unpacking the LiveCD
Next, get install-x86-minimal-2005.0.iso from one of the mirrors and mount it . Create the mount point first, if necessary. Then copy over the contents of the iso to disk. Finally unmount the iso.
mkdir /mnt/livecd mount -o loop install-x86-minimal-2006.0.iso /mnt/livecd cp -a /mnt/livecd/* /mnt/rescue umount /mnt/livecd
[edit] Installing grub
We will be using grub to boot the LiveCD off the harddisk. Let's install it:
grub-install --root-directory=/mnt/rescue --no-floppy hd0
Next, create /mnt/rescue/boot/grub/grub.conf:
| File: grub.conf |
default 0 timeout 150 title=LiveCD root (hd0,0) kernel /isolinux/gentoo root=/dev/ram0 init=/linuxrc looptype=squashfs loop=/image.squashfs udev nodevfs cdroot=/dev/hda1 initrd /isolinux/gentoo.igz |
| File: grub.conf for 2007.0 and 2008.0 |
default 0 timeout 150 title=LiveCD root (hd0,0) kernel /isolinux/gentoo root=/dev/ram0 init=/linuxrc dokeymap looptype=squashfs loop=/image.squashfs cdroot initrd=gentoo.igz udev nodevfs initrd /isolinux/gentoo.igz |
Then, link menu.lst to grub.conf.
cd /mnt/rescue/boot/grub ln grub.conf menu.lst
Thats it! Reboot the system and watch the LiveCD boot from your harddisk =)
Some other boot params which may be useful
- console=ttyS0,57600 - set serial mode console output
- keymap=uk - Set "uk" keymap (use appropriate keycodes for your country)
- docache - load the CD files into memory so that you can unmount the root partition again. Useful when you have EVMS or where you need to fsck the root partition
- dodmraid - turn on DM Raid
- doevms2 OR dolvm - turn on EITHER evms or lvm (pick only one!)
If you are using this on a remote server and need to log in on the remote console, continue...
[edit] Hacking away at the LiveCD environment
[edit] Unpacking the squashfs
Mount the squashfs. Create the mount point first, if necessary. Then copy its contents to /mnt/rescue/zisofs. Unmount and delete the squashfs.
mkdir /mnt/squashfs mount -o loop /mnt/rescue/livecd.squashfs /mnt/squashfs cp -a /mnt/squashfs /mnt/rescue/zisofs umount /mnt/squashfs rm /mnt/rescue/livecd.squashfs
[edit] Enabling serial console support in grub and switching from squashfs to zisofs
Edit grub.conf so that it reads
| File: grub.conf |
default 0 timeout 150 serial --unit=0 --speed=57600 --word=8 --parity=no --stop=1 terminal serial title=LiveCD root (hd0,0) kernel /isolinux/gentoo root=/dev/ram0 init=/linuxrc looptype=zisofs loop=/zisofs udev nodevfs cdroot=/dev/hda1 dokeymap console=tty1 console=ttyS0,57600 initrd /isolinux/gentoo.igz |
IF you cannot or do not want to see the boot messages on the physical terminal, you can leave out console=tty1 from the kernel command line.
This should give you kernel and boot messages on your serial console, but no login yet. Let's hack on...
[edit] Enabling login on serial console
At the end of /mnt/rescue/zisofs/etc/inittab, add:
| File: inittab |
|
S0:12345:respawn:/sbin/agetty -nl /bin/bashlogin 57600 ttyS0 linux
|
If you cannot or do not want to login on the physical terminal, you can comment out all lines starting with c[1..6]
That's it! The LiveCD now boots from disk, all boot messages will be visible on the serial terminal
[edit] Booting from EVMS/Raid partitions
The initrd supplied with 2007.0 scans only /dev/sdX and /dev/hdX for potential partitions to mount. Annoyingly if you use cdroot=/dev/md0 then it insists on trying to mount it with an explicit iso9660 filesystem. This means that it's not possible to boot your rescue distro from (say) a raid 1 boot partition (which is where you would really like it!), and also one of your partitions gets locked by the kernel during the boot process which generally puts an end to your chances of getting EVMS working afterwards
[edit] Modifying initrd
The fix is fairly simple. Grab the gentoo.igz file from the isolinux directory and apply the following small patche
| File: initrd.scripts.diff |
--- initrd.scripts.old 2007-06-21 20:25:25.000000000 +0100
+++ etc/initrd.scripts 2007-06-21 20:55:44.000000000 +0100
@@ -77,7 +77,7 @@
mount -r -t auto ${x} ${NEW_ROOT}/mnt/cdrom \
> /dev/null 2>&1
else
- mount -r -t iso9660 ${x} ${NEW_ROOT}/mnt/cdrom \
+ mount -r -t auto ${x} ${NEW_ROOT}/mnt/cdrom \
> /dev/null 2>&1
fi
if [ "$?" = '0' ]
@@ -362,6 +362,8 @@
DEVICES="$DEVICES /dev/ubd* /dev/ubd/*"
# iSeries devices
DEVICES="$DEVICES /dev/iseries/vcd*"
+ # MD and EVMS devices (eg Booting from HD partition)
+ DEVICES="$DEVICES /dev/evms/md/md* /dev/evms/sd* /dev/evms/hd* /dev/md*"
# The device was specified on the command line. Shold we even be doing a
# scan at this point? I think not.
[ -n "${CDROOT_DEV}" ] && DEVICES="$DEVICES ${CDROOT_DEV}"
|
There are two changes here. The first one allows us to use a specific boot device and not have it then forced to try and mount as iso9660. The second change increases the number of places that we look for the root file (which should hopefully work automatically for you). Add in any extra locations that you need to check for your setup, eg if you have some funny raid devices or USB devices then stick them in using the same technique
Now assuming you already downloaded the gentoo.igz to a machine where you can work on it:
mkdir initrd cd initrd gunzip -c ../gentoo.igz | cpio -idv patch -p0 < ../initrd.scripts.diff find . -print | cpio -o -H newc |gzip -9 -c - > ../gentoo.igz.new
Now upload that back to the original server and either rename it to gentoo.igz or ammend your grub command lines to point to the new file (notice that you have to change the name in two places)
[edit] Conclusions
After examining the linuxrc script contained in the LiveCDs initial ramdisk, I was able to get it running from disk. Adding serial console support was a bit harder, as I had to modify the squashfs. Current LiveCDs now include serial console support, so things will be much easier. As of yet, I have not discovered a way to directly boot the iso from disk. If this becomes possible, things will be much much easier =)
Concerns or Compliments? Please use the Discussion section.
