西西河

主题:【原创】Install and boot linux on a USB external hard drive -- whoknows

共:💬4 🌺7 新:
全看分页树展 · 主题
家园 【原创】Install and boot linux on a USB external hard drive

Ok, ok, this is not a totally new stuff, we all know it. Here is only a record to show how I did it.

The story happened when we were doing unpacking and arranging our new apartment. A old, very old laptop was digged out from one of the boxes. The configuration is as following:

CPU: P-III 1GHz

Memory: 256M

HD: None

DVD-ROM

Floppy Drive

No support for USB boot (that's something different, right;) )

Fortunately I have a spare 80G hard disk and a hard drive enclosure. So I decided to make this old guy something useful - a Linux server for my car pc system develpment such that I do not have to do development on and mess up the target machine.

The Linux distributionn I chose is Ubuntu 6.06 LTS, which is downloanded from www.ubuntu.com, for its very good reputations and my pervious experiences with Ubuntu. Installation is very simple. Just follow the on screen instructions is good.

After installation, a boot cd will be created to boot the system since this old guy does not support boot via USB. After search using www.google.com, I got some very good references, which will be listed in the reference part below. Here is what is needed and how to make the boot cd.

The only necessary software package that one may have to install is syslinux 3.11. I use another computer that have the exactly same Ubuntu system installed to make/get another two important pieces: the linux kernel image and the ramdisk image. Following is a step-list of how to do to reach the point the old guy is booted:

(1) install the Ubuntu to the external hard drive through USB. In my case is /dev/sda1

(2) install the syslinux package. It can be installed via the Synaptic Package Manager automatically or downloaded from the syslinux.zytor.com.

(3) make the initial ramdisk you will need. The initial ramdisk wil at least include the USB drivers that will allow you to mount your USB external hard drive as your root file system after your kernel is started.

Using my Ubuntu, make such an initial ramdisk is just a piece of cake:

(a) edit the /etc/mkinitramfs/modules to add following lines:

ehci-hcd

ohci-hcd

uhci-hcd

usb-storage

scsi-mod

sd_mod

(b) make the new ramdisk image by running following command

mkinitramfs -o /boot/initrd_usb.img /lib/modules/<linux version>

For me, the command is like: mkinitramfs -o /boot/initrd_usb.img /lib/modules/2.6.15-23-386

For other Linux distributions, there are other means of create the initial ramdisk, yeah, even manually. I will discuss this in another post, maybe.

(4) Make the iso image for the boot cd

(a) create a directory to hold all the files that will be used to create the iso image, under my home directory.

$ mkdir bootcd

(b) copy the created initial ramdisk image to bootcd

$ cp /boot/initrd_usb.img bootcd/

(c) copy the desired linux kernel image to bootcd. For me, the command looks like

$ cp /boot/vmlinuz-2.6.15-23-386 /bootcd/linux

(d) copy the isolinux.bin of syslinux to bootcd directory. For me, the command looks like

$ cp /usr/lib/syslinux/isolinux.bin bootcd/

(e) create the isolinux.cfg file in the bootcd directory, which is the configuration fiile for the isolinux bootloader. Put following lines in the isolinux.cfg file:

DEFAULT linux initrd=<initial ramdisk image name> ro root=<your root device>

where <initial ramdisk image> is the name of the initial ramdisk image you want use. In my case, it is initrd_usg.img. The <your root device> is the device that you have installed your Linux. For me, it is /dev/sda1.

Thus my isolinux.cfg file looks like:

DEFAULT linux initrd=initrd_usb.img ro root=/dev/sda1

(f) create an iso image using following command

$ mkisofs -o bootcd.iso -b ioslinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -J -hide-rr-removed -R bootcd/

(g) burn the bood cd using the image

(5) Test it. And the external disk can be used. The boot cd and the external hard drive can be used anywhere as long as the boot from cd is supported and USB port presents.

Notes: The approach here can be used not only for the Ubuntu system but also any other linux distributions, as long as you can create the right initial ramdisk image and get the desired kernel image.

Enjoy:)

References:

[1] http://ubuntuforums.org/archive/index.php/t-19428.html

[2] http://ubuntuforums.org/showthread.php?t=80811

[3] http://www.freeos.com/guides/lsst/

[4] http://www-128.ibm.com/developerworks/linux/library/l-initrd.html?ca=dgr-lnxw01LinuxInitialRam

[5] http://librenix.com/?page=USB%20Drive

[6] http://yolinux.com/TUTORIALS/LinuxTutorialRecoveryAndBootDisk.html

[7] http://www.geocities.com/potato.geo/bootlinuxcd.html

and many many others, and great thanks to them.

元宝推荐:铁手,
全看分页树展 · 主题


有趣有益,互惠互利;开阔视野,博采众长。
虚拟的网络,真实的人。天南地北客,相逢皆朋友

Copyright © cchere 西西河