Gentoo Archives: gentoo-user

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

Replies

Subject Author
Re: [gentoo-user] Booting Gentoo from USB stick Dale <rdalek1967@×××××.com>
Re: [gentoo-user] Booting Gentoo from USB stick Al <oss.elmar@××××××××××.com>