BOOT DEBIAN on and from a USB-harddisk. How I did it.
Only newer computers allow this. I used a ?ThinkPad-T42, sometimes with original harddisk in DVD/CD bay. This will not work with 600e, T20, 240 or 240x thinkpads, too old.
Several months ago, DSL(DamnSmallLinux) and RIP(?RecoveryIsPossible) mini-Linux distributions allowed for booting from USB-flash-cards. I did it with RIP, located on USB-sda2-vfat. This involves a boot image containing all files booted into memory and run from memory. USB can be removed after boot.
I also tried to do it with full SUSE and Debian but failed initially.
Lately I noticed that when I copied a Debian partition to a different partition, the kernel would boot completely due to partition info stored in initrd.img by mkinitrd.yaird which is executed at install time.
However, if I temporarily changed /etc/fstab to point to another partition and executed mkinitrd.yaird, I could create a new initrd.img that would work. That gave me the idea that perhaps that was what needed to run on USB as well.
I spent many hours on this and failed until I realized that somehow Debian's annoying change opened up a way of fully executing the kernel from USB.
This will not work with RIP, nor probably with SUSE, I did not try SUSE again after sucess with Debian.
ALTERNATE DIRECTIONS using initramfs-tools:
(1) You can use Debian Stock Kernel(s) on USB, but the problem is waiting in initrd until the USB device info has arrived: the default wait is not long enough! (True on March 3 2007 with initramfs-tools_0.85e: in the future the 'rootdelay' kernel cmdline option may make step 3 unnecessary.)
(2) Create a partition with a Debian Stock Kernel and an initrd image created by initramfs-tools.
(3) Change /usr/share/initramfs-tools/scripts/local after line 9 with:
echo "Self-imposed wait of 15s..." /bin/sleep 15.0
(4) copy that partition to the USB disk (with rsync, mondo, etc.). Be sure to change /etc/fstab! It will have your changed initrd image.
(5) Boot into the partition: Grub will do it an order of magnitude faster than Lilo. There will be a 15 second wait and the USB device info will show up and boot will continue.
DIRECTIONS using yaird:
(0) connect and partition USB flashcard or harddisk
(1) copy a working partition of debian onto a partition
(2) make temp change to your working debian /etc/fstab e.g. " /dev/hda6 / reiserfs noatime 0 1 " change hda6 to sda6 or whatever you want
RUN: mkinitrd.yaird -o /initrd.img.USB
UNDO YOUR CHANGE ON SOURCE PARTITION TO /etc/fstab MAKE /etc/fstab changes to USB PARTITION, e.g. -> sdax
THIS IS A KEY POINT TO GETTING THE INITRD TO LOAD RIGHT!
(3) move this /initrd.img.USB to USB partition in / or /boot You may want to browse this img, go to bottom and see fstab information.
This is done with: zcat /boot/initrd.img.USB | cpio -i and it will put the tree in the current directory.
Look at the end of the init script.
(4) install grub-boot programs onto USB or go to (7) to run lilo!
- create device.map (BELOW) creat menu.lst (BELOW)
(5) BE CAREFUL: RUN:
- grub root (hdx,y) setup (hdx) quit
- where x= 1 if you have 1 hard disk in addition to USB
- x= 2 2 x= 0 is what you are using for main/only disk
(6) try booting, if it does not work, check to see if you have allowed
- for boot from USB, GOOD LUCK
(7) If you run lilo, add an entry for the USB disk, very similar to the one that you copied the Debian system from, like so:
image=/sda3/boot/vmlinuz-188.8.131.52-ck1 <==== this is the Debian system
- label=SDA3-617UN+ root=/dev/sda3 append="apm=on ddcon=1 video=vesafb:ypan,1024x768-32@85 network quiet"
initrd=/sda3/boot/initrd.img.USB <==== this is the initrd you created read-only
- label=B3-617UN+ root=/dev/hdc3 append="apm=on ddcon=1 video=vesafb:ypan,1024x768-32@85 network quiet" initrd=/boot/initrd.img-184.108.40.206-ck1 read-only
as you can see they are almost the same, except for the root and the initrd that is used. Mount /sda3 and run lilo. That's all there is to it!
To explain my GRUB-MENU-LIST which I put on hda4,hdb4,sda4:
I have several PC's + extra drives. I have them mostly setup as: hda1- ?WinJunk hda2- spare hda4- backup data and RIP bootable for emergency (I bkup this to DVD) hda5- swap hda6- Debian-test hda7- data hda8- Debian-test or Debian-Sid-unstable ...
#/boot/grub/device.map for USB
(hd0) /dev/sda (hd1) /dev/hda (hd2) /dev/hdc
#/boot/grub/menu.lst for USB on sda4
# grub.conf: grub : root (hd1,3) : setup (hd1) GRUB_PARTION=hda4/BKUP # #timeout 8 color black/cyan yellow/cyan #default 3 #fallback 2
title W2K-vfat (USB-SDA1) executable, marked hidden from other ?WinJunk # rootnoverify (hd0,0) does not work # chainloader +1 does not work
- chainloader --edx=0x0080 (hd0,0)/ntldr
title RIP-linux-vfat (USB-SDA2->memory)
- rootnoverify (hd0,1) chainloader +1
title FIX-RIP-reiserfs (USB-SDA4-Locus_of_GRUB-BOOT) [kernel locks up]
- kernel (hd0,3)/boot/kernel root=/dev/sda4 vga=2 acpi=off
title Debian-reiserfs (USB-SDA6)
- kernel (hd0,5)/vmlinuz root=/dev/sda6 ro vga=791 selinux=0 noresume pci=assign-busses initrd (hd0,5)/initrd.img.USB # or rename it title RIP-linux-reiserfs-(HDA4) kernel (hd1,3)/boot/kernel root=/dev/sda4 vga=2 acpi=off title Debian-reiserfs -(HDA6) kernel (hd1,5)/vmlinuz root=/dev/hda6 ro vga=791 selinux=0 noresume initrd (hd1,5)/initrd.img title Debian-reirserfs +(HDC6) kernel (hd2,5)/vmlinuz root=/dev/hdc6 ro vga=791 noresume initrd (hd2,5)/initrd.img
SOME NOTES ON THE BOOTED SYSTEM
(1) I generated yaird with the following changes to /etc/Default.cfg:
< MODULE usbcore
< MODULE ehci-hcd
< MODULE usb-storage
Those were the only changes to the Sid install of yaird. That is what is used to create initrd.img.USB. You'll notice usbhid is not in there. Because... on the originating system that caused X not to start. And usbhid always showed up later
However... on the USB system that was not the case! Usbhid was absent and X failed again (because I have USB mice).
So... I had to put usbhid in /etc/modules and now everything starts normally, the only difference with the originating system being that the initrd load is sloooow...
(2) The USB system was copied from an existing Debian Sid system with rsync, thus:
rsync -av --delete --exclude /home --exclude /usr/local --exclude /hda10 --exclude /sda3 --exclude /proc --exclu de /sys / /sda3
The excludes are because those dirs are on other partitions and because /proc + /sys are never copied but regen'd at boot.
(3) To that copy, I made the change to initrd that was detailed in DIRECTIONS (2) above. I also changed /etc/fstab and /etc/lilo of course. And I added usbhid to /etc/modules.