LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   GRUB: Booting from USB; Creating the Ultimate Bootable USB Stick (https://www.linuxquestions.org/questions/linux-software-2/grub-booting-from-usb%3B-creating-the-ultimate-bootable-usb-stick-799372/)

Jinouchi 04-01-2010 08:58 AM

GRUB: Booting from USB; Creating the Ultimate Bootable USB Stick
 
Ok, so last week I was sick for a few days, and spent my down time working on creating a bootable USB flash drive with GRUB on it. Most everything is working great, but there's a few things I haven't figured out yet. To start out, here's my menu.lst:
Code:

title                Memtest86+ 4.00
kernel                /os/memtest/memtest86+-4.00.bin

title                Debian 5.0.4 i386 Installation
root                (hd0,0)
kernel                /os/debian/install.386/vmlinuz
initrd                /os/debian/install.386/initrd.gz

title                Gparted - Partition Editor
root                (hd0,0)
kernel                /os/gparted/live/vmlinuz1
initrd                /os/gparted/live/initrd1.img

title                Debian Live - Old ver (3.1 R8)
root                (hd0,0)
kernel                /os/debianliveold/install/vmlinuz
initrd                /os/debianliveold/install/initrd.gz

title                Debian Live - 5.0.4 i386 Gnome (from .img file)
root                (hd0,0)
kernel                /syslinux-3.85/memdisk/memdisk
initrd                /os/debianlive/debian-live-504-i386-gnome-desktop.img

title                Debian Live - 5.0.2 i386 Gnome
root                (hd0,0)
kernel                /os/debianlive/live/vmlinuz1 root=/dev/sda1
initrd                /os/debianlive/live/initrd1.img

title                Debian Lenny - Netinstall
root                (hd0,0)
kernel                /os/billix/lenny
initrd                /os/billix/lenny.img

title                Debian Etch - Netinstall
root                (hd0,0)
kernel                /os/billix/etch
initrd                /os/billix/etch.gz

title                CentOS 4.7 - Netinstall
root                (hd0,0)
kernel                /os/billix/centos
initrd                /os/billix/centos.img

title                CentOS 5.2 - Netinstall
root                (hd0,0)
kernel                /os/billix/centos5
initrd                /os/billix/centos5.img

title                DBAN - Darik's Boot and Nuke
root                (hd0,0)
kernel                /os/billix/dban
initrd                /os/billix/dban.bzi

title                DSL
root                (hd0,0)
kernel                /os/billix/linux24
initrd                /os/billix/DSL/KNOPPIX

title                Fedora 10 Netinstall
root                (hd0,0)
kernel                /os/billix/fedora
initrd                /os/billix/initrdf.img

title                Ubuntu Linux - Hardy Heron Desktop (8.04LTS)
root                (hd0,0)
kernel                /os/billix/hardy
initrd                /os/billix/hardy.gz

title                Ubuntu Linux - Intrepid Ibex Desktop (8.10LTS)
root                (hd0,0)
kernel                /os/billix/intrepid
initrd                /os/billix/intrepid.gz

title                Ubuntu Linux - Jaunty Jackalope Desktop (9.04)
root                (hd0,0)
kernel                /os/billix/jaunty
initrd                /os/billix/jaunty.gz

#NOTE: XP Install/Recovery Console are on a second FAT32 partition

title                Windows XP Pro SP2 Install
root                (hd0,1)/os/windows/xp/
makeactive
chainloader +1
boot

title                Windows XP Recovery Console
root                (hd0,1)/os/windows/xp_recovery_console/
makeactive
chainloader +1
boot

title                Windows Password Cracker
root                (hd0,0)
kernel                /os/billix/ntpwd
initrd                /os/billix/initrdnt.gz

(Yes, I cheated and got the netinstalls from the Billix .iso ;).)

Now, here's the ones that don't work:
Gparted
ALL Debian LiveCDs
DSL
Win XP Pro Installer
Win XP Recovery Console

Gparted and the Debian LiveCDs are the most important; I haven't tried to get the windows stuff working yet (I just guessed at what those entries should look like).

Anything obvious I'm missing? It seems to be only the LiveCDs I'm having trouble with... I'll report the exact error messages later. (I know the kernel/initrd paths are correct; I get errors from Linux during startup.)

Also, any more knowledge about GRUB in general is much appreciated; I'm aware I may have extra "root (hd0,0)" lines etc. in there.

linus72 04-01-2010 09:36 AM

OK

a couple pointers

1) you cant "hide" the debian live stuff inder alot of folders
the initrd gos looking for a folder named "live"

You should therefore edit the initrd for each debian based system
it's pretty easy

Basically, create a folder named "tree", cd into folder tree and open the initrd with cpio

assuming initrd.gz is in folder with tree folder
Code:

mkdir tree
cd tree

zcat ../initrd.gz | cpio -i -d

now, the initrd is uncompressed in tree folder
look in folder scripts and open the script "live" as root with text editor
it looks like this, just the top part
Code:

#!/bin/sh

# set -e

export PATH="/root/usr/bin:/root/usr/sbin:/root/bin:/root/sbin:/usr/bin:/usr/sbin:/bin:/sbin"

echo "/root/lib" >> /etc/ld.so.conf
echo "/root/usr/lib" >> /etc/ld.so.conf

mountpoint="/live/image"
LIVE_MEDIA_PATH="live"

root_persistence="live-rw"
home_persistence="home-rw"
root_snapshot_label="live-sn"
home_snapshot_label="home-sn"

editable parts are LIVE_MEDIA_PATH="live" and
root_persistence="live-rw"
home_persistence="home-rw"
root_snapshot_label="live-sn"
home_snapshot_label="home-sn"

dont change the mountpoint (mountpoint="/live/image")

you need to make each LIVE_MEDIA_PATH= different for debian live and gparted

so, for example; change the older debian live path to
LIVE_MEDIA_PATH="old"

and new to
LIVE_MEDIA_PATH="new"

if running persistent you also need to change the live-rw to whatever
root_persistence="old-rw"

I never use these
Code:

home_persistence="home-rw"
root_snapshot_label="live-sn"
home_snapshot_label="home-sn"

you can use any names you want, just dont make them very long

to edit the other initrds just make them .gz's instead of .img

Code:

mv initrd1.img initrd.gz
then do the above to them

so, your new grub menu.lst may be like


Code:

title                Gparted - Partition Editor
root                (hd0,0)
kernel                /gparted/vmlinuz1
initrd                /gparted/initrd1.img

title                Debian Live - Old ver (3.1 R8)
root                (hd0,0)
kernel                /os/debianliveold/install/vmlinuz
initrd                /os/debianliveold/install/initrd.gz

title                Debian Live - 5.0.4 i386 Gnome (from .img file)
root                (hd0,0)
kernel                /syslinux-3.85/memdisk/memdisk
initrd                /new/debian-live-504-i386-gnome-desktop.img

title                Debian Live - 5.0.2 i386 Gnome
root                (hd0,0)
kernel                /502/vmlinuz1 root=/dev/sda1
initrd                /502/initrd1.img

you also need to put proper kernel line boot parameters
see here
Boot Parameters for Debian Live
Quote:

-------------------------------

Updated for live-initramfs 1.156.1-1 on 2009-02-08.

These options (can be combined) work from the bootloader prompt:

live access=ACCESS
live console=TTY,SPEED
live debug
live fetch=URL
live hostname=HOSTNAME
live username=USER
live userfullname=USERFULLNAME
live integrity-check
live ip=[CLIENT_IP]:[SERVER_IP]:[GATEWAY_IP]:[NETMASK]:[HOSTNAME]:[DEVICE]:[AUTOCONF] [,[CLIENT_IP]:[SERVER_IP]:[GATEWAY_IP]:[NETMASK]:[HOSTNAME]:[DEVICE]:[AUTOCONF]]*
live ip[=frommedia]
live {keyb|kbd-chooser/method}=KEYBOARD
live {klayout|console-setup/layoutcode}=LAYOUT
live {kvariant|console-setup/variantcode}=VARIANT
live {kmodel|console-setup/modelcode}=CODE
live koptions=OPTIONS
live live-getty
live {live-media|bootfrom}=DEVICE
live {live-media-encryption|encryption}=TYPE
live live-media-offset=BYTES
live live-media-path=PATH
live live-media-timeout=SECONDS
live {locale|debian-installer/locale}=LOCALE
live module=NAME
live netboot[=nfs|cifs]
live nfsopts=
live noautologin
live noxautologin
live nofastboot
live nopersistent
live nosudo
live swapon
live nouser
live noxautoconfig
live persistent[=nofiles]
live persistent-path=PATH
live {preseed/file|file}=FILE
live package/question=VALUE
live quickreboot
live showmounts
live timezone=TIMEZONE
live todisk=DEVICE
live toram
live union=aufs|unionfs
live utc=yes|no
live xdebconf
live xvideomode=RESOLUTION

Values for the vga kernel parameter:

Colours 640x400 640x480 800x600 1024x768 1152x864 1280x1024 1600x1200
--------+--------------------------------------------------------------
4 bits | ? ? 0x302 ? ? ? ?
8 bits | 0x300 0x301 0x303 0x305 0x161 0x307 0x31C
15 bits | ? 0x310 0x313 0x316 0x162 0x319 0x31D
16 bits | ? 0x311 0x314 0x317 0x163 0x31A 0x31E
24 bits | ? 0x312 0x315 0x318 ? 0x31B 0x31F
32 bits | ? ? ? ? 0x164 ?

Colours 640x400 640x480 800x600 1024x768 1152x864 1280x1024 1600x1200
--------+--------------------------------------------------------------
4 bits | ? ? 770 ? ? ? ?
8 bits | 768 769 771 773 353 775 796
15 bits | ? 784 787 790 354 793 797
16 bits | ? 758 788 791 355 794 798
24 bits | ? 786 789 792 ? 795 799
32 bits | ? ? ? ? 356 ?
and heres the debian live persistence stuff
http://live.debian.net/manual/html/persistence.html


so, check that out and see if you have any more issues:)

Jinouchi 04-07-2010 04:17 PM

Wow, I envy your level of understanding!

Well, so far I've managed to get that far, I've edited the live script with the correct path. Now instead of being dumped into a shell, I get a kernel panic and no init found. I have a hunch that it may have something to do with the filesystem.squashfs, but that's just me. I've spent hours working on this but haven't been able to get any further. I noticed there's a 'run-init' file in /bin, and tried using init=/bin/run-init, as well as several other things, but that didn't work either. What's the next step?


All times are GMT -5. The time now is 03:23 AM.