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

Replies

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