Gentoo Archives: gentoo-user

From: YoYo Siska <yoyo@××××××.sk>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Booting Gentoo from USB stick
Date: Wed, 15 Sep 2010 10:11:38
Message-Id: 20100915101013.GC9603@ksp.sk
In Reply to: Re: [gentoo-user] Booting Gentoo from USB stick by Jake Moe
1 On Wed, Sep 15, 2010 at 08:34:33AM +1000, Jake Moe wrote:
2 > On 15/09/10 04:28, YoYo Siska wrote:
3 > >On Fri, Sep 10, 2010 at 07:29:01AM -0400, David Relson wrote:
4 > >>On Fri, 10 Sep 2010 11:05:12 +0200
5 > >>J. Roeleveld wrote:
6 > >>
7 > >>>On Friday 10 September 2010 10:43:30 Jake Moe wrote:
8 > >>>> On 10/09/2010 5:27 PM, Maciej Grela wrote:
9 > >>>>>2010/9/10 Jake Moe<jakesaddress@×××××.com>:
10 > >>>>>> Hello all,
11 > >>>>>>
12 > >>>>>>I've been thinking about creating a Gentoo USB stick for install
13 > >>>>>>and rescue purposes (and, of course, just to see if I could).
14 > >>>>>>I've mostly followed the Gentoo handbook (I used a single 4GB
15 > >>>>>>partition for the whole system, and no swap). I've used
16 > >>>>>>genkernel for the kernel (so I can have a multi-system capable
17 > >>>>>>kernel). I've gotten GRUB installed and working. My problem
18 > >>>>>>comes in after what I believe is the init process:
19 > >>>>>> * Checking root filesystem ...
20 > >>>>>>
21 > >>>>>>fsck.ext2: No such file or directory while trying to
22 > >>>>>>open /dev/sda1 /dev/sda1:
23 > >>>>>>The superblock could not be read or does not describe a correct
24 > >>>>>>ext2 filesystem. If the device is valid and it really contains
25 > >>>>>>an ext2 filesystem (and not swap or ufs or something else), then
26 > >>>>>>the superblock
27 > >>>>>>
28 > >>>>>>is corrupt, and you might try running e2fsck with an alternate
29 > >>>superblock:
30 > >>>>>> e2fsck -b 8193<device>
31 > >>>>>>
32 > >>>>>> * Filesystem couldn't be
33 > >>>>>>fixed :( [
34 > >>>>>>
35 > >>>>>>!! ]
36 > >>>>>>Give root password for maintenance
37 > >>>>>>(or type Control-D to continue):
38 > >>>>>>
39 > >>>>>>
40 > >>>>>>If I give the root password, I can find no /dev/sda1. However,
41 > >>>>>>mount shows /dev/sda1 on /, and there *is* a /sys/block/sda
42 > >>>>>>folders, with a sda1 folder in that as well. It's almost like
43 > >>>>>>it had /dev/sda1, but then lost it somehow.
44 > >>>>>>
45 > >>>>>>Does anyone have any idea what's going on here? Any help would
46 > >>>>>>be appreciated.
47 > >>>>>Have you seen http://www.sysresccd.org/Main_Page ? It's based on
48 > >>>>>Gentoo, you could check what they did to boot from a usb stick.
49 > >>>>>
50 > >>>>>Br,
51 > >>>>>Maciej Grela
52 > >>>>Excellent, thanks for that, I hadn't found it in my previous
53 > >>>>searches. I'll have a look there.
54 > >>>>
55 > >>>>Jake Moe
56 > >>>Had a similar issue a while ago when I was playing around with this
57 > >>>myself.
58 > >>>
59 > >>>Take a look at the linux boot parameters.
60 > >>>
61 > >>>The 'theoretical' part is: You need to let the kernel initialize the
62 > >>>USB-stick before trying to access it. (This can take some time)
63 > >>>
64 > >>>There is a delay-option, just can't remember the proper name off-hand.
65 > >>>
66 > >>>--
67 > >>>Joost
68 > >>I've got USB booting working in a syslinux environment. A delay of 12
69 > >>seconds is working for me. The syslinux.cfg stanza I use is:
70 > >>
71 > >>LABEL usb
72 > >>KERNEL linux
73 > >>APPEND rootdelay=12 root=/dev/sda2
74 > >The usual way for linux on removable usb sticks / disks is to use LABEL
75 > >or UUID to identify the disks and not the device names, because they
76 > >will be different in different computers ;) The downside is that you
77 > >need an initrd to mount the root partition... I think that the usual
78 > >initrd generated by genkernel works...
79 > >
80 > >If you created the rootfs with:
81 > >mkfs.ext2 -j -LUSBGentoo /dev/sdXY
82 > >
83 > >then you can change the kernel parameter to
84 > >root=LABEL=USBGentoo
85 > >
86 > >and your fstab to:
87 > >LABEL=USBGentoo / ext3 ...
88 > >
89 > >You can also use the uuid of the filesystem, find it out with
90 > >dumpe2fs -h /dev/sdb2 | grep UUID
91 > >and then use UUID=XXX instead of LABEL=XXX
92 > >
93 > >I never really played around with grub and USB booting, so I use
94 > >syslinux. I create a small FAT partition with syslinux, kernel and
95 > >initrd image (it gets also pretty handy when you sometimes need to copy
96 > >something from a windows machine ;) and a second "regular" ext3
97 > >partition for the rootfs.
98 > >
99 > >Basically you would do:
100 > >- partition the stick, mark the FAT partition as bootable/active
101 > >- format the partitions:
102 > > - mkfs.vfat -nUSBData /dev/sdX1
103 > > - mkfs.ext2 -j -LUSBGentoo /dev/sdX2
104 > >- install syslinux (on the FAT partition):
105 > > - syslinux /dev/sdX1
106 > >- mount /dev/sdX2, install gentoo in the usual way
107 > >- compile the kernel and initrd, make sure required USB stuff is in the kernel
108 > > (theoretically it could be as modules in initrd... but in-kernel is safer :)
109 > > if you are in a hurry, or don't know how to create them, get them from
110 > > a gentoo livecd ;) don't forget to also copy the modules
111 > > (/lib/modules-XXX/...) from the livecd to the rootfs.
112 > >- put the kernel and initrd on the FAT partition (I name them vmlinuz.img
113 > > and initrd.img)
114 > >- edit syslinux.cfg (on the FAT partition), see
115 > > http://syslinux.zytor.com/wiki/index.php/SYSLINUX#How_do_I_Configure_SYSLINUX.3F
116 > > a very simple one from my USB disk:
117 > >
118 > >DEFAULT linux
119 > >LABEL linux
120 > >SAY Now booting USBGentoo
121 > >KERNEL vmlinuz.img
122 > >APPEND root=LABEL=USBGentoo initrd=initrd.img
123 > >
124 > >you might also add rootdelay=10 to the options if the usb stick/disk isn't
125 > >detected quick enough
126 > >
127 > >umount, reboot, set the computer to boot from usb, enjoy... ;)
128 > >Xorg without a config seems to work pretty well on most computers these
129 > >days, IIRC the alsa modules for soundcards are also autoloaded, so you
130 > >don't need any fancy hw detection to have a desktop running from USB
131 > >stick ;)
132 > >
133 > >
134 > >yoyo
135 > >
136 > >
137 > >
138 > >BTW there is also a "manual" way to boot even without an initrd: use
139 > >LABEL=XXX in your fstab, on the kernel command line use root=/dev/sda2
140 > >(or whatever you think will be more probable on you machines ;)
141 > >then try to boot it, if it is wrong, you can enter the corrent
142 > >"root=/dev/sdX2" param in the syslinux prompt (you can either look up the
143 > >correct device in the boot messages, or just try sda, sdb, sdc, ... ;)
144 > >You could also create menu options for the usual cases... (sda...sdf
145 > >shoud be more than enough... ;)
146 > >You can however accidentally mount a rootfs from one of the disks on the
147 > >computer and thus booting the system on the computer, just with your
148 > >kernel...
149 > >
150 > >
151 > >
152 > >
153 > Thanks for that. I originally tried with "LABEL=UsbRoot" in both
154 > GRUB and fstab, but it couldn't find it, so I put it in a system
155 > that I'd pulled the hard drive from, so I could test if it'd work
156 > with /dev/sda instead. Neither method works; it just doesn't seem
157 > to see the USB storage in /dev. When I try by label, I get what's
158 > in the attached error.
159 >
160 > I've had a quick look at SYSLINUX (and it's counterpart, EXTLINUX),
161 > and it appears to really be nothing more than another bootloader
162 > like LILO or GRUB. Is that the case? If so, I might try and
163 > overwrite GRUB with EXTLINUX and see if that works; it appears that
164 > it should be that easy. Most of the USB booting doco I can find
165 > seems to want SYSLINUX anyway; maybe I'll give it a try. I had
166 > thought that a USB storage device is storage like anything else, so
167 > a "standard" install should work. Maybe it doesn't...
168
169 Yes, syslinux is just another "bootloader" ;) It his however
170 specifically created for removable disks. I don't know how exactly grub
171 works and how it handles "removable" disk (ie when the disk appears at
172 different places) when finding devices for its root partition and the
173 root option for kernel...
174
175 >
176 > Jake Moe
177
178 > >> Activiating mdev
179 > >> Determining root device...
180 > /init: line 477: blkid: not found\
181
182 seems like your initrd is missing the blkid program (used to determine
183 the labels and uuids of disks...)
184 Looking at the genkernel help it seems to ethis option:
185 --disklabel Include disk label and uuid support in your
186 ramdisk
187
188 > !! Could not find the root block device in LABEL=UsbRoot.
189 > Please specify another value or: press Enter for hte same, type "shell" for a
190 > shell, or "q" to skip...
191 > root block device(LABEL=UsbRoot) :: /dev/sda1
192 > >> Mounting root...
193 > >> Booting (initramfs)..
194 > INIT: version 2.87 booting
195 >
196 > Gentoo Linux; http://www.gentoo.org/
197 > Copyright 1999-2009 Gentoo Foundation; Distributed under teh GPLv2
198 >
199 > Press I to enter interactive boot mode
200 >
201 > * Mounting proc at /proc ... [ ok ]
202 > * Mounting sysfs at /sys ... [ ok ]
203 > * Mounting /dev ... [ ok ]
204 > * Starting udevd ... [ ok ]
205 > * Populating /dev with existing devices through uevents ... [ ok ]
206 > * Waiting for uevents to be processed ... [ ok ]
207 > * Mounting devpts at /dev/pts ... [ ok ]
208 > * Checking root filesystem ...
209 > fsck.ext2: Unable to resolve 'LABEL=UsbRoot'
210 This means fsck was unable to find the filesystem with that label.
211 You can use dumpe2fs /dev/yourpartition to check if the filesystem
212 really has the cooret label (look for "Filesystem volume name" at the
213 top)
214
215 > * Filesystem couldn't be fixed :( [ !! ]
216 > Give root password for maintenance
217 > (or type Control-D to continue):
218
219 yoyo

Replies

Subject Author
Re: [gentoo-user] Booting Gentoo from USB stick Jake Moe <jakesaddress@×××××.com>