LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 02-14-2011, 04:45 PM   #1
ljones0
Member
 
Registered: Dec 2007
Posts: 100

Rep: Reputation: 17
Booting a USB stick with GRUB2 and Labels


Hello all

Ok, this may sound a bit of a weird thing to do. Actually this is my attempt at a continuation of this thread.

(Unfortunatly that thread above only works with slackware 13 and older).

Here's the idea -- be able to boot slackware 13.1 DVD from a USB stick, but without using anything like an initrd or loading the contents of the slackware install all into memory first. So the USB stick is behaving like a hard drive (but with one disadvantage, just don't take the usb stick out while you're using it!). It has the advantage of saving on memory though .

In the above thread I had this idea working ok but only with slackware 13 and earlier. In fact I still have the CF card with it on, and it works fine. Only snag is it won't work with the newer 13.1.


Right now, I'm trying to use qemu for the following (not what I wrote above!). The idea is to use qemu to install a minimum slackware 13.1 to the USB stick, set it up and then boot from the USB stick itself (so I'm using the USB stick as the storage medium as opposed to say a hard drive image file).

So let's say (this is what I'm doing) I boot slackware 13.1 (32 bit) and make two partitions;

Code:
/dev/sda1 - fat32 partition
/dev/sda2 - ext3 linux partition
I then do a minimal installation of slackware (just "A" and jed from "AP"). Lilo is not installed as later I'll be using GRUB2 to try to boot.

(Note: I'm using a slackware package, grub-1.97-beta4-i486-1.tgz for slackware 13.1/GRUB2).

I then boot off the slackware 13.1 DVD but at the boot screen I choose to boot from /dev/sda2 which is the linux install I created earlier. Success, it boots ok and I can get into the slackware 13.1 install on the USB disk (which is /dev/sda2).

I then label the ext3 partition by using e2label;
Code:
e2label /dev/sda2 USB
And also change /etc/fstab;
Code:
/dev/root             /          ext3        defaults 1 1
Now I need some sort of bootloader to put onto the USB stick so I don't need the DVD any more. To do this, I'm trying to use GRUB2.

But here's the problem I need to solve!

When I install slackware onto the USB stick using qemu, that partition is /dev/sda2. It's the first usb/storage medium that slackware detects so it gets the name sdaX. (X=1, fat partition, X=2 EXT3 linux).

But here's the problem. Suppose I take the USB stick over to another PC with a hard drive already inside it. Slackware would see the hard drive installed in that PC as (say) /dev/sda1 and the USB stick would then become the second drive, so /dev/sdbX (X=1, fat partition, X=2 EXT3 linux).

If I specify a specific device (lets say /dev/sda2) then it won't work in another system because if I take the example above, another PC with a hard drive installed in it the USB stick becomes /dev/sdb2 and the GRUB2 boot program would be expecting /dev/sda2 which won't work. What I need to do is to somehow find the install, the root on the USB stick automatically without having to specify it manually.

So here's what I've tried with grub (First thing I did was to install grub with grub-install /dev/sda).

/boot/grub/grub.cfg
Code:
set default=0
set timeout=5

menuentry "Linux" {
 insmod ext2
 search --no-floppy --label --set USB
 linux /boot/vmlinuz-huge-smp-2.6.33.4-smp root=/dev/disk/by-label/USB/
}
Snag is it dosen't work :-( I get this booting from the USB stick:

Code:
md: Autodetecting RAID arrays
md: Scanned 0 and added 0 devices.
md: autorun ...
md: ... autorun DONE.
VFS: Cannot open root device "disk/by-label/USB" or unknown-block(0,0)
Please append a correct "root=" boot option; here are the avaliable partitions
0800    2000880 sda driver:sd
 0801   97185 sda1
 0802   1902656 sda2
 0b00   1048575 sr0 driver: sr
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown block(0,0)
Pid: 1,comm: swapper Not tainted 2.6.33.4-smp #2
If I try this:
/boot/grub/grub.cfg
Code:
set default=0
set timeout=5

menuentry "Linux" {
 insmod ext2
 search --no-floppy --label --set USB
 linux /boot/vmlinuz-huge-smp-2.6.33.4-smp root=LABEL=USB
}
I get a very similar result ....

Code:
md: Autodetecting RAID arrays
md: Scanned 0 and added 0 devices.
md: autorun ...
md: ... autorun DONE.
VFS: Cannot open root device "LABEL=USB" or unknown-block(0,0)
Please append a correct "root=" boot option; here are the avaliable partitions
0800    2000880 sda driver:sd
 0801   97185 sda1
 0802   1902656 sda2
 0b00   1048575 sr0 driver: sr
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown block(0,0)
Pid: 1,comm: swapper Not tainted 2.6.33.4-smp #2
So what I'm wondering is .... if the "search" line in grub is doing the searching for the root GRUB2 needs to use to boot from - how can I tell the next line, "linux /boot/vmlinuz-huge-smp-2.6.33.4-smp root=...." where to boot from? I can't use /dev/sda2 or /dev/sdb2 because if I try the usb stick in a different PC the stick will be a different device name. Trying to use LABEL= or /dev/disk/by-label/USB/ also dosen't work .

Can anyone help out at all with this booting problem?

ljones

Last edited by ljones0; 02-14-2011 at 04:58 PM.
 
Old 02-14-2011, 07:53 PM   #2
andrewthomas
Senior Member
 
Registered: May 2010
Location: Chicago Metro
Distribution: Arch, Gentoo, Slackware
Posts: 1,690

Rep: Reputation: 312Reputation: 312Reputation: 312Reputation: 312
As far as I know, when using either labels or uuid's you need to use an initrd.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to boot from an USB stick without BIOS support using Grub2? vimico Linux - Laptop and Netbook 11 02-25-2012 05:19 PM
[SOLVED] Create independent Grub2 boot loader menu in USB stick. cr4321 Linux - General 27 07-18-2010 12:48 PM
[SOLVED] using labels in grub2. How? Mountain Linux - Software 2 07-13-2010 06:00 PM
GRUB: Booting from USB; Creating the Ultimate Bootable USB Stick Jinouchi Linux - Software 2 04-07-2010 04:17 PM
Grub2 (1.96) loopback problem on usb-stick ganimo Linux - General 4 10-01-2009 07:26 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 01:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration