Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

HowTo: CD redirected to USB boot.

Share your HowTo, Documentation, Tips and Tricks. Not for support questions!.
Post Reply
Message
Author
User avatar
Bro.Tiag
Posts: 1924
Joined: 2007-06-02 19:14

HowTo: CD redirected to USB boot.

#1 Post by Bro.Tiag »

So you have made that perfect custom LiveCD and you have added it to a USB device and are off on Holiday with your OS in hand. Only to discover that the Hostel you are staying in's computer does not support booting from a usb. Fear not their is a solution.

IN THEORY

In theory one should be able to boot a linux operating system on a CD and then redirected the boot process to a usb device.

This is done by setting up a cd with a linux kernel (I can say that without gnu right) and an "initial RAM disk" image (initrd). Since the kernel and initrd are copied into RAM during the boot up and run from there, it is not necessary for the CD to be in the drive for booting to finish. The thing now is to finish booting the operating system on the usb device.

0 - MODIFY YOUR TARGET KERNEL FOR USB SUPPORT

# A stock debian kernel will be missing the modules for including usb support. So they need to be added to the kernel use on the boot cd.
# The easiest thing to do (and the surest) is to use the kernel that is being used on the usb device.
# So boot into debian and mount the usb device partition that you have installed linux too.
# If this is a persistent configuration mount the partition labled home-rw, casper-rw or live-rw.
# These instructions will not work for a stock LiveCD imaged writen to a usb stick utilizing a squashfs setup.
Mind your root permission and the /mnt/sdX#
mkdir tmps
mount /dev/sdX# /tmps

# Edit the add the needed modules for your initrd.
cd tmps
vi etc/initramfs-tools/modules

Add the following, with i ;

Code: Select all

### This is a reminder that these modules have been added to allow a CD to boot a USB drive
usbcore
sd_mod
ehci_hcd
uhci_hcd
ohci_hcd
usb-storage
scsi_mod
# Save & exit.
:wq
# Edit etc/initramfs-tools/initramfs.conf to wait 15 seconds to allow the usb device to mount.
vi etc/initramfs-tools/initramfs.conf
Add the following, with i ;

Code: Select all

### This makes the bootup wait until any USB drives are ready
WAIT=15
# Save & exit.
:wq
# Now rebuild the initrd with the stuff just added.
# We are going to do this from chroot, but first must bind some mounted directories.
mount --bind /dev /tmps/dev
# Now chroot & re-build initrd
cd ..
chroot tmps
mount -a
ls /lib/modules
dpkg-reconfigure linux-image-<kernelversion_from _the_list_above>
exit


1 - MAKE A BOOTABLE CD

# We now need to use this new initrd image and the kernel on a boot cd and set up grub.
mkdir -p boot_tmps/grub
cp tmps/boot/initrd.img-<kernelversion> boot_tmps/boot/initrd.img
cp tmps/boot/vmlinuz-<kernelversion> boot_tmps/boot/vmlinuz
cp tmps/boot/grub/menu.lst boot_tmps/boot/grub/menu.lst
cp /usr/lib/grub/stage2_eltorito boot_tmps/boot/grub/stage2_eltorito

# Edit the menu.lst file.
vi boot_tmps/boot/grub/menu.lst
# It should lool something like this.
Mind the /mnt/sdX#

Code: Select all

title          Custom Name
root           (cd)
kernel         /boot/vmlinuz root=/dev/sdX# ro quiet splash
initrd         /boot/initrd.img
boot

title          Custom Name Recovery Mode
root           (cd)
kernel         /boot/vmlinuz root=/dev/sdX# ro single
initrd         /boot/initrd.img
boot
2 - CUSTOM STUFF
# I started out with a custom LiveCD added it to a USB device, so some more work needs to be done with the bootCD.
# The boot stuff for a LiveCD, and in my case a persistent install need to be included in the BootCD's menu.lst.
# Edit your boot_tmps/boot/grub/menu.lst to sute. Mine looks like this;

Code: Select all

title          DebianLiveUSB Persistent
root           (cd)
kernel         /boot/vmlinuz root=/dev/sda3 boot=live union=aufs vga=791  persistent ro
initrd         /boot/initrd.img
boot
3 - MAKE CD BOOTABLE
# It is now time to make the cd bootable & to write the image to a cd.
mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o BootCD2UCB.iso boot_tmps
cdrecord -v BootCD2USB.iso


4 - TYR IT OUT
# Now before you head off on your Hitchhiking tour across Europe, reboot your computer with the new CD but without the usb device connected. When the cd stops spinning & the install seems to stall, plug in the usb device. If all went to plan, the usb will be detected, and the booting will continue into your operating system.

Cheers
Last edited by Bro.Tiag on 2009-06-05 16:11, edited 2 times in total.

jalu
Posts: 1389
Joined: 2008-11-19 23:26

#2 Post by jalu »

1 - MAKE A BOOTABLE CD

# We now need to use this new initrd image and the kernel on a boot cd and set up grub.
mkdir -p tmp_boot/grub
cp tmps/boot/initrd.img-<kernelversion> boot_tmps/boot/initrd.img


might it be there`s a typo?
you create the directory tmp_boot
and copy into boot_tmps.

I`m sorry if im wrong, but after i replaced

Code: Select all

cp tmps/boot/initrd.img-2.6.26-1-686 boot_tmps/boot/initrd.img
with

Code: Select all

cp tmps/boot/initrd.img-2.6.26-1-686 tmp_boot/boot/initrd.img
the error message vanished in the dark.

User avatar
Bro.Tiag
Posts: 1924
Joined: 2007-06-02 19:14

#3 Post by Bro.Tiag »

jalu wrote:
1 - MAKE A BOOTABLE CD

# We now need to use this new initrd image and the kernel on a boot cd and set up grub.
mkdir -p tmp_boot/grub
cp tmps/boot/initrd.img-<kernelversion> boot_tmps/boot/initrd.img


might it be there`s a typo?
you create the directory tmp_boot
and copy into boot_tmps.

I`m sorry if im wrong, but after i replaced

Code: Select all

cp tmps/boot/initrd.img-2.6.26-1-686 boot_tmps/boot/initrd.img
with

Code: Select all

cp tmps/boot/initrd.img-2.6.26-1-686 tmp_boot/boot/initrd.img
the error message vanished in the dark.
Aye, a typo, the ole dyslexia rearing it's head, or a flat out mistake, regardless thanks for picking that up and doing my proof reading for me. I've fixed it. Thanks again.

Cheers
ps - were you able to get the cd to boot the pendrive?

jalu
Posts: 1389
Joined: 2008-11-19 23:26

#4 Post by jalu »

hi Bro.Tiag,
for the last hour i tried to create a Boot-CD for my
external usb-hard-disk. finally i got it running.
(it`s just for fun and to check if it will work and for training,
as the pendrive is working fine and more easy to carry around).

[while copying the complete stuff to boot_tmps i had to create
boot_tmps/boot/grub
manually before i could copy the menu.lst to it.
(though the -p option of mkdir should have taken care of that, or not?)]


the first burned boot-CD gave me the error: file not found
(while i had root =(cd) in the menu.lst and boot-menu)
the second i burned without editing the menu.lst (root (hd1,1))and could boot
into the OS without further issues.

next test with the boot-CD will be on another PC, but i think i`ll get it running
sooner or later.



to make it short:
i could and can learn some usefull things by your howto and have some fun.

greetings jalu

User avatar
Bro.Tiag
Posts: 1924
Joined: 2007-06-02 19:14

#5 Post by Bro.Tiag »

jalu wrote: [while copying the complete stuff to boot_tmps i had to create
boot_tmps/boot/grub
manually before i could copy the menu.lst to it.
(though the -p option of mkdir should have taken care of that, or not?)]
Aye, -p should have made the parent directories.
jalu wrote:the first burned boot-CD gave me the error: file not found
(while i had root =(cd) in the menu.lst and boot-menu)
the second i burned without editing the menu.lst (root (hd1,1))and could boot
into the OS without further issues.

next test with the boot-CD will be on another PC, but i think i`ll get it running
sooner or later.
Did you set the computers bios to boot from the cd first?

Cheers

jalu
Posts: 1389
Joined: 2008-11-19 23:26

#6 Post by jalu »

Bro.Tiag wrote:
Did you set the computers bios to boot from the cd first?
Yes i got that (at home i may press F11 and may choose where to boot from: in this case from cd).

During the creation of the boot cd i get an error message,
as i`m logged in from my pendrive/usb-stick installation :-) right now
i got to edit this post later and send the exact message
( something like: run update-init~~~)

Code: Select all

[b]Post-edit[/b]:
dpkg-reconfigure linux-image-2.6.26-1-686
running depmod
running mkinitramfs -kpkg
Depreciation WARNING: use update-initramfs
grep: /proc/module: no such file or directory
[b]end Post-edit[/b]
But i got another question:
i installed the hard-disk installation(including the new grub installation!)
after the external-disk installation.
might that have caused the problem?

i`ll do some other tries tonight :-)
as its not that urgent (cause i got my working pendrive) its merely dodgy and interesting.

greetings jalu
Last edited by jalu on 2009-02-26 18:46, edited 3 times in total.

User avatar
Bro.Tiag
Posts: 1924
Joined: 2007-06-02 19:14

#7 Post by Bro.Tiag »

jalu wrote:Bro.Tiag wrote:
Did you set the computers bios to boot from the cd first?
Yes i got that (at home i may press F11 and may choose where to boot from: in this case from cd).

During the creation of the boot cd i get an error message,
as i`m logged in from my pendrive/usb-stick installation :-) right now
i got to edit this post later and send the exact message
( something like: run update-init~~~)

But i got another question:
i installed the hard-disk installation(including the new grub installation!)
after the external-disk installation.
might that have caused the problem?

i`ll do some other tries tonight :-)
as its not that urgent (cause i got my working pendrive) its merely dodgy and interesting.

greetings jalu
It has been a while since I actually read the Grub Manual, so I forget a lot of stuff. Just be sure to test it on other computers (preferably ones without linux/grub) before you need it to work.

I do not think the install order has anything to do with things since you used it's grub installation.

Cheers

jalu
Posts: 1389
Joined: 2008-11-19 23:26

#8 Post by jalu »

well:
i didn`t sleep that much during the last two weeks
and had at minimum one typo in the first 3 CDs ( a / too much or too less: i forgot).

i did it again the way described in your howto and get it running on my main pc
with: `root (cd)` in the grub menu.
(the second pc got 233Mh and 192MB, usb1 and makes funny noices:
i`m able to boot with my new and correct typed boot-cd, the root-filesystem is mounting
but after

Code: Select all

vboxdrv successfully loaded
device-mapper uevent: ***
device-mapper ioctl *** redhad-com
it falls asleep.)

No big deal: i`m quite happy with my experience/learning curve
and the usb-stick-installation is a good choice for mobility (although quite slow).
in the long run i`ll try it with a live-cd/usb-stick/boot-cd
(at least i`ve earned some boot-cd`s: just in case...).

thanks for your help, answers and the good howto
jalu

User avatar
Bro.Tiag
Posts: 1924
Joined: 2007-06-02 19:14

#9 Post by Bro.Tiag »

jalu wrote:thanks for your help, answers and the good howto
jalu
Cheers

jalu
Posts: 1389
Joined: 2008-11-19 23:26

#10 Post by jalu »

just in case someone will hesistate i want to update the information:
finally i got the problems solved and am able to boot into the system
on my second pc :-)
(the last problem had nothing to do with the boot-cd but with the configuration,
it also occured while booting from harddisk - my fault)
greetings jalu

Post Reply