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

Attachments

File name MIME type
booterr.txt text/plain

Replies

Subject Author
Re: [gentoo-user] Booting Gentoo from USB stick YoYo Siska <yoyo@××××××.sk>