Sign in to follow this  
Followers 0
zachman123

[How To]Boot from a USB drive without BIOS support

29 posts in this topic

Since it seemed to be such a common issue with barely any resources available, I decided to write a tutorial on how to achieve booting Linux, from an external USB drive, on a computer that can't boot from USB (Using a boot CD). I'll get right to the point.

I used Windows for the CD burning steps just because it was easier for me, but feel free to use linux.

1. Start off by installing the distro of your choice to the USB drive. For the rest of the tutorial I'm going to be using Mandrake 10.1 just becuase I've already made the initrd for it. All the defualt settings should be fine.

2. Using a rescue/LiveCD, mount your USB drive and steal the kernel off it (from /boot). Copy the kernel to somewhere that you can access from Windows, like a NTFS/FAT partition on the disk.

3. Here comes the fun part. If you plan on installing Mandrake 10.1 (I've found it to be pretty nice), you can just use my initrd file, which will save you A LOT of time. If you plan to use a distro, hop over to my section on editing my initrd to fit your system.

4. Now, from Windows, proceed to create your CD bootloader. I've convienently made an isolinux boot cd, so all you have to do is insert your kernel. Use MagicIso or a similar program to put your kernel and initrd.img into the isolinux directory on the cd. Check the isolinux.cfg and make sure it's pointing to the kernel and initrd, and that root is set to /dev/sda1.

5. Burn your Boot CD. I've been looking for buisness card cd's so I could put my bootloader in my wallet, but none of the major retail stores have them. Tell me if you find a good deal on them somewhere.

6. This is the first test. Put in the boot CD, and plug in the USB drive. The system should boot up and get to the startup script, and it'll probably get hung at the fsck step (At least for Mandrake 10.1). If you didn't get that far, you have a problem with the bootloader on the cd, the kernel, or the initrd. Fix it, or if you can't figure out what's wrong, contact me.

7. If you made it this far, you're pretty much done, and you can smile now. Just use a rescue/live cd and mount your usb drive again. Delete/modify the lines in your rc script that the boot is getting stuck at. Keep trying to boot/fixing the script until it's happy and you can boot.

8. That's it! You're done. Hope this guide helped you. If there are any bugs/errors/you can't figure it out, PLEASE contact me so I can change it.

Initrd Editing:

So, you chose to use a different disto. That's fine and all, but it's going to require some work.

Basically, here are the steps.

Boot using a rescue/live cd. Mount your usb drive. Also, mount the directory containing my initrd image (Have it on a cd or something). Gunzip the initrd.img (rename it to initrd.gz first) if it needs it. Mkdir /mnt/initrd Then mount it using mount -o loop initrd /mnt/initrd.

From /mnt/initrd, view the linuxrc file and get a feel for what it's doing. Then, replace all of the modules currently in the initrd (The Mandrake 10.1 modules) with the modules from the usb drive, the system you wish to boot from usb.

Unmount the initrd image, gzip it back up, rename it to initrd.img, and copy it back to a Windows accessable partition.

Continue on with the rest of the steps.

usbboot.zip

initrd.zip

Edited by zachman123

Share this post


Link to post
Share on other sites
5.  Burn your Boot CD.  I've been looking for buisness card cd's  so I could put my bootloader in my wallet, but none of the major retail stores have them.  Tell me if you find a good deal on them somewhere.

585264239[/snapback]

thank you!!!! this is SO cool!!!! i'm gonna try it soon (i hope!).

anyhoo...you might try supermediastore for your business card cds. i've ordered stuff from them before and they seem to be ok. i'd swear that i saw the cds in compusa but can't find anything about them on the site.

Share this post


Link to post
Share on other sites

Thanks but your two files looks corrupted . I can't unzip them neither under Windows (tried winzip, 7zip) nor under Linux (tried unzip, tar xzpvf, bzip2).

Share this post


Link to post
Share on other sites

Try again, they seem to be working fine for me.

Share this post


Link to post
Share on other sites

Not better...

For both files:

With Winzip : "File is not in the standard Zip 2.0 format"

With 7-Zip : file broken

With unzip under Linux : error uncompressing

Inspite of these errors, I get some files:

usbboot.iso :120 KO

initrd.img : 129KO

but when I try to open them under MapgicIso, it tells me that these files don't contain image...

Share this post


Link to post
Share on other sites

yes i can confirm they are broken in a way winrar is giving me errors

Share this post


Link to post
Share on other sites

Files Fixed.

Stuffit apparently hates me, it wouldn't zip files correctly AND it didn't give an error trying to unzip the old files (but they were still messed up)

Anyways Winzip did the trick, and I may be reinstalling/killing stuffit soon.

If you have ANY problems AT ALL, please let me know. Feel free to

E-mail zachman123@gmail.com

AIM zachman123

MSN zachman123@gmail.com **Not on often

YAHOO zachdude123@sbcglobal.net **Not on often

Share this post


Link to post
Share on other sites

Hi again, indeed your files are fixed. Unfortunatly, I can't boot yet. What I did:

Using winimage:

- I opened the usbboot.iso file and I found an isolinux dir.

- I put my MDK 10.1 vmlinuz-2.6.8.1-12mdk-i586-up-1GB from my USB install /boot to isolinux directory

- I put the initrd.img file in the isolinux directory as well

- I edited initrd.cfg file :

*********************

default linux

timeout 0

label linux

kernel vmlinuz-2.6.8.1-12mdk-i586-up-1GB

append initrd=initrd.img root=/dev/sda1

*********************

- I burned the image and tried to boot : my bios can't boot it. I have none message.

Questions:

- Do I have to leave "vmlinuz' in initrd.cfg file?

- Is it realated with lilo.conf of USB drive ?

- I have 2 installs : one one sda1 and another one sda3. Should it work I have set root=/dev/sda3 in initrd.cfg ?

thanks again.

Share this post


Link to post
Share on other sites

You mean the CD won't boot? Make sure winimage is keeping it as a bootable CD, to test that try burning my exact iso just to see if that'll boot.

And I assume you mean isolinux.cfg, everything in there looks fine. root just needs to point to the root partition of your linux install...

Share this post


Link to post
Share on other sites

Yes, it won't boot at all, I just have the BIOS message 'Boot from CD:', the CD is read for 5 secs and then, nothing...

I tried to brun the usbboot.iso : it boots and tell me it can't find the vmlinuz kernel (normal). So it should be your initrd.img that freeze the boot? I use an external USB CD Reader.

Questions:

- Do I have to set kernel to kernel (link) or the full kernel name ?

- Why don't your provide a full iso pour sda1 with provided kernel ?

Thanks.

Share this post


Link to post
Share on other sites

Yea, it must be your editing of the iso messing up it's burnable-ness.

I'll put them together and test it and post it, I'll put it up in a few min.

Edited by zachman123

Share this post


Link to post
Share on other sites

Yea, it must be your editing of the iso messing up it's burnable-ness.

I'll put them together and test it and post it, I'll put it up in a few min.

Neowin wouldn't upload it (it's 9 megs), and my website has (very) limited bandwidth so I can't upload it there.

Can anyone host it if I email it to them? Or if you want the file just email me (zachman123@gmail.com)

Share this post


Link to post
Share on other sites

Nervermind, I finally found another solution:

Book your MDK using your rescue disk (F1, then 'rescue').

mkdir sda1

mount /dev/sda1 sda1

chroot sda1

then, use the mkrescue command:

mkrescue --iso

that will geenrate a rescue.iso file.

Burn this image, boot on USB CDROM, that's all. It works for me for sda3.

Share this post


Link to post
Share on other sites

Oh yea, that would work too :D

Forgot mkrescue would take any modifications you made to the rescue system. Much easier, thanx for the tip. Some distros might not support something like that, so if you're trying some odd system, my instructions should help.

All that time I wasted... Nice solution tho, I was to lazy to make my own firewire initrd with my method, but I think I'll try it with yours.

Share this post


Link to post
Share on other sites
Oh yea, that would work too :D

Forgot mkrescue would take any modifications you made to the rescue system.  Much easier, thanx for the tip.  Some distros might not support something like that, so if you're trying some odd system, my instructions should help.

All that time I wasted... Nice solution tho, I was to lazy to make my own firewire initrd with my method, but I think I'll try it with yours.

585350512[/snapback]

It didn't work for me! :no:

I tried the mkrescue --iso script on MDK 10.2beta3 (that I installed on sda1) and booted on the CD but I've only seen L 99 99 99 ... on the screen, nothing more !

Share this post


Link to post
Share on other sites

Then use my method. Try using my iso files, but if that doesn't work, do it from scratch like I did.

I'm no linux expert by any means, so someone else shouldn't have too much trouble with my steps...

edit: Just saw you're using 10.2beta3 ... Which is a different kernel than my iso. So you'll have to do my method from scratch.

Share this post


Link to post
Share on other sites
Then use my method.  Try using my iso files, but if that doesn't work, do it from scratch like I did.

I'm no linux expert by any means, so someone else shouldn't have too much trouble with my steps...

edit:  Just saw you're using 10.2beta3 ... Which is a different kernel than my iso.  So you'll have to do my method from scratch.

585559086[/snapback]

in fact I think I'm trying something simpler : installing 10.1 on my USB drive first to test your CD and then I will try MDK10.2!

By the way what was your version of MDK 10.1 it is normal MDK with or without last updates, 10.1 community?

one more question : the mandrake installed on the usb drive shoud or should not have a bootloader installed ?

Edited by manouchk

Share this post


Link to post
Share on other sites

Doesn't matter if a bootloader is on the drive (I had it on and then deleted it by mistake) as it's not used unless you plan on using the external drive with a computer that DOES support usb booting, in which case you won't need to use the cdrom to boot.

I'm not sure what version of mdk it was (It came with PC Format awhile ago). Anyways if the kernel is different you can see in the iso (Unless I renamed it, might've).

Anyways good luck, and feel free to instant message me if you want.

Share this post


Link to post
Share on other sites

Now it works!

Your module are for 2.6.8.1-10mdk. I have made a working boot CD for kernel 2.6.8.1-12mdk!

I can even put it on my website soon if someone is interested!

Cheers!

Emmanuel

Share this post


Link to post
Share on other sites

here is a script to build rapidly a booting CD from scratch :

It worked for me (be prudent it writes important files)

#!/bin/sh

#needs syslinux (tested with version 1.76)

d="CD_boot"

rm -rf $d

mkdir $d

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

#create initrd for USB boot

mkinitrd --preload=ehci-hcd --preload=usb-storage --preload=scsi_mod --preload=sd_mod /boot/usbinitrd.img `uname -r`

#copy kernel (vmlinuz) and initrd file in isolinux directory

cp /boot/vmlinuz $d

cp /boot/usbinitrd.img $d/initrd.img

#create file isolinux.cfg

#assuming kernel file is in isolinux/vmlinuz

#and initrd in file isolinux/initrd.img

cfg=$d/isolinux.cfg

echo "default linux" > $cfg

echo "timeout 0" >> $cfg

echo "label linux" >> $cfg

echo " kernel vmlinuz" >> $cfg

echo " append initrd=initrd.img root=/dev/sda1" >> $cfg

mkisofs -o boot_USB.iso -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table $d

echo "burn CD :"

echo "cdrecord dev=ATAPI:0,0,0 blank=fast"

echo "cdrecord dev=ATAPI:0,0,0 boot_USB.iso"

Share this post


Link to post
Share on other sites

Hi this is really exciting? Do you think I can use this method to boot DOS or Windows from USB drives? I am no expert at this at all and maybe this is a stupid question but your advice will be highly appreciated...

KC

Share this post


Link to post
Share on other sites

The question is only stupid if you meant using this EXACT method. Of course you're not going to run Windows using a Mandrake disk or linux bootloader... But running windows/dos is possible. If you feel lazy, check out BartPE (A limited version of windows xp that runs off a cd). You might be able to mess with it to make it use a usb disk.

Making Windows XP run from cd on your own would be very hard. Windows 9x/ME though I've managed to kind-of run, just by fooling around. Simpy use a dos bookdisk on cd along with a USB driver (that's the tricky part though...) and install on the usb disk. Then have fun making a bootloader from dos (load dos, init usb driver, then win.exe)

DOS USB resources... http://www.stefan2000.com/darkehorse/PC/DOS/Drivers/USB/

http://www.freedos.org/freedos/news/newsitem/149.html

Just search

Share this post


Link to post
Share on other sites

Thanks for your prompt reply. What I am really looking for is a solution similar to your scenario where USB boot is not supported by BIOS and I need to be able to use a bootable CD to do so. As it does seem that LILO can boot DOS/Windows 98, I was guessing it might be possible to do so with an approach similar to yours if my goal is to use a CD to boot DOS/Windows 98 from an external USB HDD. Any suggestion?

Share this post


Link to post
Share on other sites

Didn't think about LILO being able to do that, but it should be possible to at least boot ( I don't know if windows would like it).

edit: that's what I kinda tried, except booted from DOS. Windows started, but in messed resolution and didn't work quite right.

Edited by zachman123

Share this post


Link to post
Share on other sites
here is a script to build rapidly a booting CD from scratch  :

It worked for me (be prudent it writes important files)

#!/bin/sh

#needs syslinux (tested with version 1.76)

d="CD_boot"

rm -rf $d

mkdir $d

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

#create initrd for USB boot

mkinitrd --preload=ehci-hcd --preload=usb-storage --preload=scsi_mod --preload=sd_mod /boot/usbinitrd.img `uname -r`

#copy kernel (vmlinuz) and initrd file in isolinux directory

cp /boot/vmlinuz $d

cp /boot/usbinitrd.img $d/initrd.img

#create file isolinux.cfg

#assuming kernel file is in isolinux/vmlinuz

#and initrd in file isolinux/initrd.img

cfg=$d/isolinux.cfg

echo "default linux" > $cfg

echo "timeout 0" >> $cfg

echo "label linux" >> $cfg

echo " kernel vmlinuz" >> $cfg

echo " append initrd=initrd.img root=/dev/sda1" >> $cfg

mkisofs -o boot_USB.iso -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table $d

echo "burn CD :"

echo "cdrecord dev=ATAPI:0,0,0 blank=fast"

echo "cdrecord dev=ATAPI:0,0,0 boot_USB.iso"

585568604[/snapback]

Your script is perfect and that is what I have done. I am posting this because my problem is related booting from usb-cdrom. This is what is happening:

I am installing Linux (Suse) from my CD (customized) on IBM blade center (BIOS is capable of booting from usb) in which cdrom is a usb device. What exactly happens is this:

During boot, it says grub loading stage 2......

and then instead of loading the menu.lst , it launches the grub shell. Now when I try to set "root ( <tab>", no cd is listed. The only devices listed are fd0 and hd0 (hard disk already has Suse Linux on it (which was installed using standard Suse CD).

This is the command I used to create ISO

mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot \

-boot-load-size 4 -boot-info-table -o grub.iso

What I understand is that GRUB automatically sets the root device to (cd) when booted from a CD-ROM

Is there any option in mkisofs or grub in which we can change the default (cd) to usb-cdrom (whatever alias it has) so that stage2 could be loaded successfully.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.