WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Howto: Create Bootable USB Stick  (Read 56000 times)

Offline dmoerner

  • Newbie
  • *
  • Posts: 14
Howto: Create Bootable USB Stick
« on: December 02, 2008, 06:29:39 PM »
This is a shameless modification of the old DSL instructions (written by SaidinUnleashed, to give full credit).  This was performed from a Debian Sid x86 system.  The USB stick is /dev/sdc1.

1) Install necessary tools.  On Debian this is syslinux, mtools, and dosfstools:

Code: [Select]
aptitude install syslinux mtools dosfstools
2) Partition the thumb drive.  I used fdisk to partition the thumb drive into one large FAT32 partition.  The following directions are from memory but should be correct.

Code: [Select]
umount /dev/sdc1 # Never use fdisk on a mounted partition
fdisk /dev/sdc1
d
1
d
2
d
3
d  # These commands delete all partitions currently on the device
n
p
1 # This makes a new primary partition
a
1 # This makes it bootable
t
1
b # This makes it FAT 32
w

Now, I always overwrite the drive's mbr in case it was used for booting from grub sometime in the past.  This is not normally necessary.

Code: [Select]
dd if=/usr/lib/syslinux/mbr.bin of=/dev/sdc
Now, make a FAT 32 partition:

Code: [Select]
mkfs.vfat -F 32 /dev/sdc1
3) Copy over the files

You will need to mount the iso image using loopback and then copy over the files.

Code: [Select]
mkdir /mnt/iso
mount -o loop tinycore_1.0rc1.iso /mnt/iso
mkdir /mnt/usb
mount /dev/sdc1 /mnt/usb
cp /mnt/iso/* /mnt/usb

4) Set up syslinux

Since the ISO uses isolinux, we will need to make some changes

Code: [Select]
mv /mnt/iso/boot/isolinux /mnt/iso/boot/syslinux
mv /mnt/iso/boot/syslinux/isolinux.cfg /mnt/iso/boot/syslinux/syslinux.cfg
rm -f /mnt/iso/boot/syslinux/isolinux.bin # This didn't stop it from working for me, but I'm not sure if this file is necessary.
syslinux /dev/sdc1

5) Cross your finger, unmount the flash drive, and reboot.  If you get an error like "image linux not found" when booting, you forgot to correctly rename the isolinux files to syslinux.

APPENDIX A: Using Grub

You can also use grub to manage booting the pendrive, as described at http://tinycorelinux.com/files/extensions/grub-0.97-splash.tce.info.  However, the process is a bit more involved than that.  After installing grub, you need to do the following:

Code: [Select]
mkdir -p /mnt/usb/boot/grub
rm -rf /mnt/usb/boot/isolinux
cp /usr/lib/grub/i386-pc/*stage* /mnt/usb/boot/grub
grub # now follow the instructions in the .info document
cat > /mnt/usb/boot/grub/menu.lst << EOF
default 0
timeout 5
title tinycorelinux
root (hdX,Y)
kernel /boot/bzImage quiet
initrd /boot/tinycore.gz
EOF

APPENDIX B: Persistent /home

I have not tested this yet, but if you want a persistent, encrypted /home on the thumb drive, the easy method would probably be to use fdisk to make one tiny FAT32 partition on the thumb drive and one larger ext2 partition.  Then specify the ext2 partition using the directions in the "help" file to use an encrypted home.

EDIT 12/2/08: Added grub appendix, corrently cited SaidinUnleashed after discussion on IRC :)
« Last Edit: December 03, 2008, 12:27:52 AM by dmoerner »

Offline roberts

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 7361
  • Founder Emeritus
Re: Howto: Create Bootable USB Stick
« Reply #1 on: December 03, 2008, 12:20:51 AM »
Bootable pendrive are always a challenge.

If the target is a bootable pendrive, then might try unetbootin from other OS (Windows or Linux).
It worked very for me:

1. format pendrive fat32 from other OS
2. download tc iso
3. run unetbootin

unetbootin is a single exe that does not need to be installed on the other OS.

Just choose iso image and specify full path
then specify the pendrive

After successful installation you can edit syslinux.cfg file to add/change boot options.

You can get unetbootin from:
http://unetbootin.sourceforge.net
10+ Years Contributing to Linux Open Source Projects.

Offline SaidinUnleashed

  • Newbie
  • *
  • Posts: 4
Re: Howto: Create Bootable USB Stick
« Reply #2 on: December 03, 2008, 03:54:27 PM »
Wow, that's useful, and much simpler than my hacked up w32 version of syslinux.

Editus: Except that I can't get it to boot...
« Last Edit: December 03, 2008, 04:15:56 PM by SaidinUnleashed »

Offline paulc

  • Newbie
  • *
  • Posts: 3
Re: Howto: Create Bootable USB Stick
« Reply #3 on: December 05, 2008, 12:04:25 PM »

Couldn't get the above going but did manage an "old style"  copy all files into the top directory of the pendrive and point the syslinux.cfg to the new location (i.e. delete /boot/ and directory structure). Then it flies...........

.......boots a variety of eBox's (including the 200MHz one) and an eee 701 beautifully.

Nice work.




Offline cjgau

  • Newbie
  • *
  • Posts: 27
Re: Howto: Create Bootable USB Stick
« Reply #4 on: December 09, 2008, 02:14:11 PM »
Unetbooting is really easy; I run it on my office M$ machine; and then boot my Asus901 right away under my desk. =o)

Thanks, Robert.

Offline T_Hobbit

  • Newbie
  • *
  • Posts: 12
Re: Howto: Create Bootable USB Stick
« Reply #5 on: December 14, 2008, 10:16:10 AM »
It works for me. Now, how can I make my USB stick boot with permanent definitions and programs and personal stuff?
« Last Edit: December 14, 2008, 01:26:21 PM by T_Hobbit »
T_Hobbit @ This little country by the sea!
Save the Lynx!

Offline jls

  • Hero Member
  • *****
  • Posts: 2135
Re: Howto: Create Bootable USB Stick
« Reply #6 on: December 15, 2008, 09:14:03 AM »
I installed unetbootin on the pendrive, it boots, but then nothing, it stops on the boot screen.
dCore user

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14790
Re: Howto: Create Bootable USB Stick
« Reply #7 on: December 15, 2008, 09:46:20 AM »
I'm using extlinux.tce to create a bootable usb stick starting from a blank stick formatted ext2 - it works fine with freeware ext2 drivers in windows too.

/mnt/sda1/boot/tinycore.gz
/mnt/sda1/boot/bzImage
/mnt/sda1/boot/extlinux/extlinux.sys
/mnt/sda1/boot/extlinux/extlinux.conf

Quote
$ cat /mnt/sda1/boot/extlinux/extlinux.conf 

        kernel /boot/bzImage
        append initrd=/boot/tinycore.gz quiet vga=773 noswap laptop tce=sda1 waitusb=5 noscan text
« Last Edit: December 17, 2008, 11:13:09 AM by Juanito »

Offline T_Hobbit

  • Newbie
  • *
  • Posts: 12
Re: Howto: Create Bootable USB Stick
« Reply #8 on: December 17, 2008, 04:58:19 AM »
If I create mydata.gz/tclocal/tce directory on my laptop HD and boot from CD I'm able to load my data and my programs.

If I boot from an USB stick made with unetbootin and create mydata.gz/tclocal/tce directory on the stick, after boot the definitions are lost.

How can this be solve so I can boot my USB stick and work directly with my files and programs?
T_Hobbit @ This little country by the sea!
Save the Lynx!

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11041
Re: Howto: Create Bootable USB Stick
« Reply #9 on: December 17, 2008, 09:38:22 AM »
Your usb stick might need an additional wait: add "waitusb=5" to your boot arguments, where 5 is the number of seconds to wait for slow usb devices.
The only barriers that can stop you are the ones you create yourself.

Offline T_Hobbit

  • Newbie
  • *
  • Posts: 12
Re: Howto: Create Bootable USB Stick
« Reply #10 on: December 17, 2008, 06:25:23 PM »
Your usb stick might need an additional wait: add "waitusb=5" to your boot arguments, where 5 is the number of seconds to wait for slow usb devices.

I'm not sure if it was that or the tce=sda1 (or both) that solve the problem (will try each one separately), but it works now. Thanks a lot!

Next step: USB stick dual boot with Puppy!
T_Hobbit @ This little country by the sea!
Save the Lynx!

Offline jaygeetiny

  • Newbie
  • *
  • Posts: 20
Re: Howto: Create Bootable USB Stick
« Reply #11 on: February 04, 2009, 12:52:07 PM »
Hi All

I'm a former DSL newbie and judged by my inability to achieve persistence with TC on a bootable USB stick I'm now a TC newbie as well :-(

Briefly; I've created a bootable 4GB USB stick using Unetbootin in WinXP - in fact I'm posting this via Opera 9.62 in Cloud/Internet mode - but I can't seem to get persistence in any of the available  modes.

Ideally I'd like to set up persitence in Mode 4 (PPI/TCE) and any help to achieve this along the lines of a dummies guide would be much appreciated.
Using TC 1.1 in PPR/TC mode on a bootable USB stick with boot options "quiet noswap tce=sda1 waitusb=7 pause"

Offline cjgau

  • Newbie
  • *
  • Posts: 27
Re: Howto: Create Bootable USB Stick
« Reply #12 on: February 04, 2009, 02:01:59 PM »
Did you try waitusb=7

Please refer to Robert's advice --- http://forum.tinycorelinux.net/index.php?topic=474.msg2969#msg2969

Offline jaygeetiny

  • Newbie
  • *
  • Posts: 20
Re: Howto: Create Bootable USB Stick
« Reply #13 on: February 04, 2009, 06:55:00 PM »
Did you try waitusb=7

Please refer to Robert's advice --- http://forum.tinycorelinux.net/index.php?topic=474.msg2969#msg2969

I've already set my PC's BIOS to a slow USB boot which copes with all the other distros I've tried. However if the TC waitusb=7 boot option has another function then I'll give it a try.

BTW I'm confused by the first post on the quoted link as the only place I can find any sort of similar reference is within the syslinux.cfg file on my USB stick which contains the following:

default vesamenu.c32

prompt 0
menu title UNetbootin
timeout 100

label unetbootindefault
menu label Default
kernel /ubnkern
append initrd=/ubninit quiet

label ubnentry0
menu label tinycore
kernel /boot/bzImage
append initrd=/boot/tinycore.gz quiet
Using TC 1.1 in PPR/TC mode on a bootable USB stick with boot options "quiet noswap tce=sda1 waitusb=7 pause"

Offline jaygeetiny

  • Newbie
  • *
  • Posts: 20
Re: Howto: Create Bootable USB Stick
« Reply #14 on: February 04, 2009, 07:49:39 PM »
I tried the waitusb=7 boot option together with tclocal=sda1, downloaded a couple of TCE extensions, backed up to sda1 and rebooted to find no sign of the downloaded extensions on the menu bar or within the right click menu.

Until I can find a simple way of setting up persistence on a USB stick I'll content myself by playing with TC in Virtualbox within Hardy Heron.
Using TC 1.1 in PPR/TC mode on a bootable USB stick with boot options "quiet noswap tce=sda1 waitusb=7 pause"