Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Booting from a USB stick?

202 views
Skip to first unread message

>

unread,
Jun 22, 2006, 9:39:02 AM6/22/06
to


I have a 2GB USB stick and would like to boot and run Slackware
Linux 10.2 on it. Is this possible? How would I go about doing
the install?

If Slackware Linux 10.2 is not suitable, is there another distro
that is -- hopefully one with a slacklike philosophy?

I verified that my system can boot MS-DOS from the USB stick.

notbob

unread,
Jun 22, 2006, 11:17:04 AM6/22/06
to
On 2006-06-22, m...@privacy.net> <m...@privacy.net> wrote:

> I verified that my system can boot MS-DOS from the USB stick.

How about using DOS autoexec.bat file to execute lilo. May have to rename lilo to
lilo.exe and specify absolute path.

nb

William Park

unread,
Jun 22, 2006, 11:23:33 AM6/22/06
to

See my .sig :-)

--
William Park <openge...@yahoo.ca>, Toronto, Canada
ThinFlash: Linux thin-client on USB key (flash) drive
http://home.eol.ca/~parkw/thinflash.html
BashDiff: Super Bash shell
http://freshmeat.net/projects/bashdiff/

Douglas Mayne

unread,
Jun 22, 2006, 11:33:14 AM6/22/06
to

Caveat: I haven't done this using flash, but I plan to do so in the near
future. If these instructions don't help you, then maybe they'll help me.

Going back to fundamentals, four things are necessary to boot the Linux
kernel and a GNU/Linux distribution, such as Slackware:

1. Hardware compatibility to start bootloader.
2. A bootloader which can load the kernel and the initial ramdisk.
3. An initial ramdisk which includes modules necessary to mount root
filesystem.
4. A root filesystem.

If you want to fully encapsulate a Slackware setup to a 2G flash drive,
then you should be able to do it- if you take account for each of the
above requirements. It will be tight. Maybe, don't install KDE. You have
verified step 1 works. My discussion works backwards through these steps.

Step 4: root filesystem on target
Building a root filesystem on the USB stick is probably the easiest
step. That is, it is easiest if you start from a fully setup Slackware
system which includes the flash memory mounted in its filesystem. From
this environment, you can either clone an existing setup, or you can
install individual packages using syntax similar to this:

# P=a
# TARGET=/mnt/flash
# for i in $(find $P/. -type f | grep tgz$);do \
installpkg -root $TARGET $i \
done

The above installs just the "a" series, for example. It also assumes your
flash is freshly formatted and is ready to accept you setup.

Step 3: initrd. man mkinitrd.
You'll need an initrd. It is easiest to make an initrd for the running
kernel. If you plan to use a kernel on the stick which is different from
the kernel you are using to make this image, then you should probably
install the kernel you intend to use on the stick and boot your setup
platform with it. I recommend the latest 2.6.x kernel from -current
(testing), 2.6.16.21. When you have booted with the same kernel that you
intend to use on the stick, then go ahead and make the initrd. BTW, you
may be able to do this without rebooting and changing kernels if you
really know what your doing.

To make the initrd, you'll need to know which modules to include.
You probably need a module specific to your USB controller (necessary
before flash can be read. These are common drivers (but check your
hardware if another is required):

ohci_hcd
uhci_hcd
ehci_hcd

And this module is required:
usb_storage

You may also need a filesystem module if you formatted the flash with an
advanced filesystem.


Step 2: Copy kernel and initrd to target

# mkdir /mnt/flash/boot
# cp /boot/vmlinuz-xxx /mnt/flash/boot/
# cp /boot/intitrd.gz /mnt/flash/boot

Step 1: Loader. I use the grub loader.

1.a. Install grub package at target
# installpkg -root /mnt/flash extra/grub/grub-0.97-i486-1.tgz
# mkdir /mnt/flash/boot/grub
# cp /mnt/flash/usr/lib/grub/i386-pc/* /boot/grub

1.b. Menu
Create a menu.lst file at /mnt/flash/boot/grub. Create a stanza which
references your kernel and initrd. Perhaps, something like this:

title Slackware on a stick
root (hdx,0)
kernel /boot/vmlinuz-xxx ro root=/dev/sda1
initrd /boot/initrd.gz

1.c. Install loader on target
# cd /mnt/flash
# chroot .
# grub --no-floppy
# grub> root (hdx,0)
# grub> setup (hdx)
# grub> quit
# exit

Note: hdx is system dependant.

Final notes:
1. Flash memory sometimes requires a few seconds to initialize before
Linux can start using it. I don't know if this is different when booting
from flash. Perhaps a "sleep" statement is necessary in the initrd.

2. I hope I didn't make too many mistakes ;-)

--
Douglas Mayne

linnix

unread,
Jun 22, 2006, 11:58:20 AM6/22/06
to

>
> If you want to fully encapsulate a Slackware setup to a 2G flash drive,
> then you should be able to do it- if you take account for each of the
> above requirements. It will be tight. Maybe, don't install KDE.

We have a slackware based 1G CF with KDE, 2G is more than enough.

> Final notes:
> 1. Flash memory sometimes requires a few seconds to initialize before
> Linux can start using it. I don't know if this is different when booting
> from flash. Perhaps a "sleep" statement is necessary in the initrd.

The delay is required on USB drives (flash or no flash). It is not
necessary for IDE drives (to flash or not to flash).

>
> 2. I hope I didn't make too many mistakes ;-)

Just 2. Good post otherwise.

Bill Waddington

unread,
Jun 22, 2006, 12:25:28 PM6/22/06
to

Lots of folks doing this lately.

I have done this (rather easily) using Knoppix as a base:
http://www.beezmo.com/FloobyDustDir/FDKnoppixUsbDir/FDKnoppixUsb.htm

No experience with Slackware (see other replies) but in a general-
purpose distro may not be the best choice for something like this.
USB flash has a limit to the number of writes a page can tolerate
before it fails. "behind-the-scenes" writes (logs, anything that
touches files,...) can fatigue the fob.

Use a distro that is intended to run read-only from a CD. It won't
have this (potential) problem. Something like Knoppix that uses
a compressed filesytem has the advantage of packing a lot into the
space available. In the Knoppix case, ~2G worth into 700MB.

Bill
--
William D Waddington
william.w...@beezmo.com
"Even bugs...are unexpected signposts on
the long road of creativity..." - Ken Burtch

Douglas Mayne

unread,
Jun 22, 2006, 12:30:32 PM6/22/06
to
On Thu, 22 Jun 2006 08:58:20 -0700, linnix wrote:

>
>>
>> If you want to fully encapsulate a Slackware setup to a 2G flash drive,
>> then you should be able to do it- if you take account for each of the
>> above requirements. It will be tight. Maybe, don't install KDE.
>
> We have a slackware based 1G CF with KDE, 2G is more than enough.
>
>> Final notes:
>> 1. Flash memory sometimes requires a few seconds to initialize before
>> Linux can start using it. I don't know if this is different when booting
>> from flash. Perhaps a "sleep" statement is necessary in the initrd.
>
> The delay is required on USB drives (flash or no flash). It is not
> necessary for IDE drives (to flash or not to flash).

Good to know, thanks.

>
>>
>> 2. I hope I didn't make too many mistakes ;-)
>
> Just 2. Good post otherwise.
>

I noticed an obvious error in my post (in addition to my bad grammar):

Step 1.a. fixed


1.a. Install grub package at target
# installpkg -root /mnt/flash extra/grub/grub-0.97-i486-1.tgz
# mkdir /mnt/flash/boot/grub

# cp /mnt/flash/usr/lib/grub/i386-pc/* /mnt/flash/boot/grub
---------------------------------------^^^^^^^^^^^

Next generation flash (4G) and beyond will be exiting. I have a
basic setup which has Gnome, the basic part of KDE (plus k3b), and Open
Office. This uses over 2G (but less than 4G). This setup can be written
as a loopback file to a DVD, and be combined with a USB flash device, as I
wrote here: http://www.xmission.com/~ddmayne2/10.2-live/index.html

OT: Unionfs seems to be working hard at finding bugs and moving forward.

--
Douglas Mayne

notbob

unread,
Jun 22, 2006, 12:42:50 PM6/22/06
to
On 2006-06-22, m...@privacy.net> <m...@privacy.net> wrote:
>
> I have a 2GB USB stick and would like to boot and run Slackware
> Linux 10.2 on it. Is this possible? How would I go about doing
> the install?

Just when you thought you were the only one:

http://www.pendrivelinux.com/

nb

alisonken1

unread,
Jun 22, 2006, 4:46:39 PM6/22/06
to
m...@privacy.net wrote:
> I have a 2GB USB stick and would like to boot and run Slackware
> Linux 10.2 on it. Is this possible? How would I go about doing
> the install?
<snip>

Try starting with Slax (http://www.slax.org) and go from there.

I've been working with the Mutagenix (http://mutagenix.org) Linux
LiveCD guys (Slax base, Freerock Gnome), and by starting with something
designed to run off a CD, it converts over to installing on a USB drive
relatively easy.

Douglas Mayne

unread,
Jun 22, 2006, 10:30:58 PM6/22/06
to
On Thu, 22 Jun 2006 09:33:14 -0600, Douglas Mayne wrote:

> On Thu, 22 Jun 2006 13:39:02 +0000, me2 wrote:
>

<snip>


>>
> Caveat: I haven't done this using flash, but I plan to do so in the near
> future. If these instructions don't help you, then maybe they'll help me.
>

I have now verified this method works. I have added a couple of extra
notes (in the name of not causing someone to beat their head against the
wall while trying to get this working using my instructions.)

> Going back to fundamentals, four things are necessary to boot the Linux
> kernel and a GNU/Linux distribution, such as Slackware:
>
> 1. Hardware compatibility to start bootloader.
> 2. A bootloader which can load the kernel and the initial ramdisk.
> 3. An initial ramdisk which includes modules necessary to mount root
> filesystem.
> 4. A root filesystem.
>
> If you want to fully encapsulate a Slackware setup to a 2G flash drive,
> then you should be able to do it- if you take account for each of the
> above requirements. It will be tight. Maybe, don't install KDE. You have
> verified step 1 works. My discussion works backwards through these steps.
>
> Step 4: root filesystem on target
> Building a root filesystem on the USB stick is probably the easiest
> step. That is, it is easiest if you start from a fully setup Slackware
> system which includes the flash memory mounted in its filesystem. From
> this environment, you can either clone an existing setup, or you can
> install individual packages using syntax similar to this:
>
> # P=a
> # TARGET=/mnt/flash
> # for i in $(find $P/. -type f | grep tgz$);do \
> installpkg -root $TARGET $i \
> done

If using this method to setup, remember to manually create a
/mnt/flash/etc/fstab which will be appropriate for the running kernel.

>
> The above installs just the "a" series, for example. It also assumes
> your flash is freshly formatted and is ready to accept you setup.
>

Also, if using this manual setup technique, remember to initialize the
library dependancies at the target when you have finished installing
your packages. Use a command like this:

# ldconfig -r /mnt/flash

You can also set the root password (if you want):


# cd /mnt/flash
# chroot .

# passwd
# exit



> Step 3: initrd. man mkinitrd.
> You'll need an initrd. It is easiest to make an initrd for the running
> kernel. If you plan to use a kernel on the stick which is different

<snip>


>
> Step 2: Copy kernel and initrd to target
>
> # mkdir /mnt/flash/boot
> # cp /boot/vmlinuz-xxx /mnt/flash/boot/ # cp /boot/intitrd.gz
> /mnt/flash/boot
>
> Step 1: Loader. I use the grub loader.
>
> 1.a. Install grub package at target
> # installpkg -root /mnt/flash extra/grub/grub-0.97-i486-1.tgz # mkdir
> /mnt/flash/boot/grub
> # cp /mnt/flash/usr/lib/grub/i386-pc/* /boot/grub

-----------------------------------------fixed below
# cp /mnt/flash/usr/lib/grub/i386-pc/* /mnt/flash/boot/grub


>
> 1.b. Menu
> Create a menu.lst file at /mnt/flash/boot/grub. Create a stanza which
> references your kernel and initrd. Perhaps, something like this:
>
> title Slackware on a stick
> root (hdx,0)
> kernel /boot/vmlinuz-xxx ro root=/dev/sda1
> initrd /boot/initrd.gz
>

On the system I tested which allowed booting from a USB stick, the boot
drive is always assigned to be sda. Therefore, the grub stanza looks
like this:

title Slackware on a stick

root (hd0,0)
kernel /boot/vmlinuz-xxx
initrd /boot/initrd.gz

Also, when using a standard Slackware initrd, the files /initrd/ROOTDEV
/initrd/ROOTFS define the initial mount parameters. They are unnecessary
on the kernel line in the grub stanza. These files are inside the initrd.
I was using /dev/sda1 and ext2 for simplicity.

> 1.c. Install loader on target
> # cd /mnt/flash
> # chroot .
> # grub --no-floppy
> # grub> root (hdx,0)
> # grub> setup (hdx)
> # grub> quit
> # exit
>
> Note: hdx is system dependant.

This is still correct. hdx may be different value when grub is setup than
when the stick is booted. Just make sure your setup target for the loader
is the flash drive. grub's "geometry" is helpful in verifying your
assumptions.

>
> Final notes:
> 1. Flash memory sometimes requires a few seconds to initialize before
> Linux can start using it. I don't know if this is different when
> booting from flash. Perhaps a "sleep" statement is necessary in the
> initrd.

"sleep" is definitely required while waiting for USB driver to initialize.
I used sleep 10.

>
> 2. I hope I didn't make too many mistakes ;-)

Note: comments inline.

--
Johnny: I need a computer!
http://www.imdb.com/title/tt0113481/quotes

Bill Marcum

unread,
Jun 22, 2006, 11:38:02 PM6/22/06
to
["Followup-To:" header set to comp.os.linux.misc.]
Lilo can't run from DOS, but loadlin can.


--
I wish I was on a Cincinnati street corner holding a clean dog!

notbob

unread,
Jun 22, 2006, 11:46:52 PM6/22/06
to
On 2006-06-23, Bill Marcum <bma...@iglou.com> wrote:

> Lilo can't run from DOS, but loadlin can.

Well, there ya' go. Thanks for the clarification, Bill. :)

nb

Alan Clifford

unread,
Jun 23, 2006, 2:21:11 PM6/23/06
to

This was on digg.com recently: http://www.pendrivelinux.com/

It seems to be aimed at using Windows (sic) to install linux on a pendrive
but you might get some ideas.


--
Alan

( If replying by mail, please note that all "sardines" are canned.
There is also a password autoresponder but, unless this a very
old message, a "tuna" will swim right through. )

Blaza

unread,
Jun 28, 2006, 4:30:55 AM6/28/06
to
Użytkownik <m...@privacy.net>> napisał w wiadomości
news:EKudnTEG15b...@giganews.com...

>
>
>
> I have a 2GB USB stick and would like to boot and run Slackware
> Linux 10.2 on it. Is this possible? How would I go about doing
> the install?
>
> If Slackware Linux 10.2 is not suitable, is there another distro
> that is -- hopefully one with a slacklike philosophy?

You should check out:
http://myslax.bonsonno.org/
I have tried slax on 1gb kingston dt2 and it runs smooth.

Blaza


0 new messages