Projects and resources (En) > Tips and tricks

Make a bootable USB stick by hand with Grub legacy

(1/1)

melodie:
Hi,

The following example is with Ubuntu. You can adapt for other distributions, and it can work if their filesystem tree is in a squashfs archive.

Have a USB stick formatted to Fat32, and inside, create the directories:


--- Code: ---cd /path/to/usb/stick
--- Fin du code ---
 

let's say the USB stick is mounted to /media/ so you will change directory accordingly:

--- Code: ---cd /media/USB_stick
--- Fin du code ---
 

Where "USB_stick" is the label of your USB stick, unless it displays only the UUID (a large number).

Then you create subdirectories:

--- Code: ---mkdir -p boot/grub
--- Fin du code ---

And from there you change directory to be located inside the grub directory:

--- Code: ---cd boot/grub
--- Fin du code ---

in the /media/boot/grub, create a menu.lst file with this inside

--- Code: ---# general configuration:
timeout   5
default   0
color light-blue/black light-cyan/blue

title OBUbuntu i386
kernel /casper/vmlinuz boot=casper quiet splash --
initrd /casper/initrd.lz

title OBUbuntu i386 Safemode
kernel /casper/vmlinuz boot=casper safemode quiet splash --
initrd /casper/initrd.lz
 
title OBUbuntu i386 IDE Generic
kernel /casper/vmlinuz boot=casper quiet splash ide.all_generic.ide=1 --
initrd /casper/initrd.lz
--- Fin du code ---

have the following files besides it:
fat_stage1_5 stage1 stage2

if you don't have Grub in you system, you should install it (in Ubuntu 12.04 the package having for name just "grub" is the legacy one). Then you can copy the files listed above into /media/boot/grub.

Then comes the part where you install Grub to the USB stick. I generally have the stick not mounted for this part (and I can't remember now what happens if mounted, I think I never tried).

Check which number device it is, with the mount command.

here for now I get : "/dev/sdb1 on /run/media/melodie/VERBATIM type vfat ... " which will help not to make a mistake.

Install Grub. As root in console type:

--- Code: ---# grub

--- Fin du code ---
 

after a short text:

--- Code: ---Probing devices to guess BIOS drives. This may take a long time.

--- Fin du code ---
 

you will get the Grub prompt:

--- Code: ---    GNU GRUB  version 0.97  (640K lower / 3072K upper memory)   

[ Minimal BASH-like line editing is supported.  For the first word, TAB    lists possible command completions. 

Anywhere else TAB lists the possible    completions of a device/filename. ] 
grub>

--- Fin du code ---
 

after the Grub prompt, type:

--- Code: ---grub> root (hd<tab>

--- Fin du code ---
 

tab means you must press the tab key of the keyboard, which will trigger Grub to display the different possibilities:
 
--- Code: ---grub> root (hd  Possible disks are:  hd0 hd1

--- Fin du code ---
 

if you have only one hard drive in the machine. if you have more, it will present more, and the USB stick should be represented by the last one.

So your hard drive is the hd0 disk, (if it is connected as master on the first port), you will choose the second option and after:
grub> root (hd
[/code] 

you will add 1:

--- Code: ---grub> root (hd1<tab>

--- Fin du code ---
 

And grub will again complete:

--- Code: ---grub> root (hd1,0)

--- Fin du code ---
 

Then, hit "enter", and you will get the following information:

--- Code: ---grub> root (hd1,0)  Filesystem type is fat, partition type 0xc  grub>

--- Fin du code ---
 

You see "fat", there can't be any mistake.

Then type the following command to install Grub to the MBR of your USB stick:

--- Code: ---grub> setup (hd1)

--- Fin du code ---
 

Validate, and you should get the following message:

--- Code: ---grub> setup (hd1)  Checking if "/boot/grub/stage1" exists... yes  Checking if "/boot/grub/stage2" exists... yes  Checking if "/boot/grub/fat_stage1_5" exists... yes 

Running "embed /boot/grub/fat_stage1_5 (hd1)"...  15 sectors are embedded. succeeded  Running "install /boot/grub/stage1 (hd1) (hd1)1+15 p (hd1,0)/boot/grub/stage2 /boot/grub/menu.lst"... succeeded Done. 

grub>

--- Fin du code ---
 

If you get this success message in your console, it means that Grub is now installed on the MBR of the USB stick.
Quit:

--- Code: ---grub> quit

--- Fin du code ---
 

Now you will need to copy the content of the ISO to the USB key. Once the USB removed and inserted again (I suppose it was unmounted while installing Grub to it), you will be in console and move to the directory where you have your iso:

--- Code: ---cd /path/to/iso
--- Fin du code ---

As an example, we will say the ISO is in your home directory, so you move there:

--- Code: ---cd /home/your_login
--- Fin du code ---

and as root:


--- Code: ---mount -o loop file.iso /mnt
--- Fin du code ---

Where "file.iso" is the full name of your ISO image.

Then you move again there:

--- Code: ---cd /mnt
--- Fin du code ---

you will copy (cp -R) all the files from the mount point to the USB stick recursively, including a directory which is hidden: the directory ".disk" and it's content. All the directories might not be necessary, (the .disk is necessary, for instance) but this is the fast and sure method. You will get error messages about one or two symbolic links, you can ignore the messages about them and continue.

In the stick, once done, we can see:

--- Citer ---$ ls -A
.Trash-1000  casper  install   preseed
.disk  boot  dists   isolinux  pool
--- Fin de citation ---

these are directories.

If your machine can boot to USB, you are ready to start your Live USB ! If not, try to use the plop boot manager, available for floppy and for CD's from the plop boot manager website:
http://www.plop.at

Navigation

[0] Index des messages

Utiliser la version classique