spacer.png, 0 kB
Home arrow Articles
Creative Commons License
Categories
Recent Articles
Latest Comments
Archives
FREE Newsletter!

Want to hear more about the Black Art of Linux and Mac? Subscribe to our FREE Newsletter to make sure you don't miss a beat!







Awesome Reading

Anaedor Book

Click here to read the first two chapters!
Get Ubuntu Linux!

Get Ubuntu
Get Firefox!

Get Firefox
We are green!

Green Web Hosting! This site hosted by DreamHost.
spacer.png, 0 kB
spacer.png, 0 kB

Linux On A Stick

linux I was in a wild and crazy mood the other day and thought it would be really cool to install Linux on my 4GB USB Flash Stick.  How comforting, I thought, to always be able to carry Linux around with me in my pocket.  If I went to a friend’s house who had a Windows machine (shudder), I wouldn’t have to suffer.  I could just put in my USB Flash Stick and boot the machine from the USB device to run Linux.  How cool is that?  Beyond words cool. 

Here’s how I did it…

First of all, I will assume that you have an external USB Flash Stick.  If you don’t, you can get one at most computer stores.  I recommend you buy one with at least 1GB of RAM (the more RAM, the better - especially if you’re a ram).  In fact, the one I used is listed at the end of this article.  It worked without a hitch and was a great price!

Also, this article is not directed toward the beginner.  To make it truly beginner friendly, I should have put these steps in a shell script.  That may be an exercise I undertake down the road (if you’re willing to pay me).

Also, since you may be running either Linux, Windows or Mac OSX (Intel Based), I need you to download the Ubuntu Live CD and boot into that first.  That way, we are all on the same page and have access to the same tools and commands.  All right, go burn, baby, burn!  When you are done with the burning, follow the instructions below.

1. Insert both the Ubuntu Live CD and the USB Flash Stick into your computer and reboot the machine.

2. Once you are booted into Ubuntu, open up a Terminal. shell

3. Type sudo su to become root.

4. Next, type fdisk -l to help you locate what the system believes is the name of your USB Flash Stick.  Mine was named /dev/sdc1.  Yours may be named something different (like /dev/sdb1, for example).  For the rest of the article, I will pretend that yours was also named /dev/sdc1.  Please insert your device name into the places where I have my device name.  ¿Comprende?

5. Type umount /dev/sdc1 (Remember, yours may not be named /dev/sdc1).  Now type fdisk /dev/sdc (Yes, you’re reading that right - there should not be a 1 after the sdc)

6. Next we are going to perform a bunch of mini-tasks on your stick, though be forewarned that it might not be as fun as it sounds.  Please, follow the small list below, and in order:

  • type p to show the existing partition(s)
  • press d to delete it (type 1 when asked what partition)
  • type p again to show any remaining partitions (if partitions exist, repeat the previous step - that is d to delete)
  • type n to make a new partition
  • type p for primary partition
  • type 1 to make this the first partition
  • hit enter to use the default 1st cylinder
  • hit enter again to accept the default last cylinder size
  • type a to make this partition active
  • type 1 to select partition 1
  • type t to change the partition filesystem
  • type 6 to select the fat16 file system (Just for fun, you can type L to see all the supported partition types)
  • type w to write the new partition table

7. Now, type fdisk -l to see the new partition you just created.  You should see a /dev/sdc1 partition listed for your USB Flash Stick.

8. Type umount /dev/sdc1 to unmount your USB Flash Stick.

9. Type mkfs.vfat -F 16 -n ubuntu /dev/sdc1 to format the first partition as a Fat16 partition.

10. At the terminal again, get the latest software updates by typing apt-get update

11. Type apt-get install syslinux mtools lilo (Say "Y" if asked any questions)

12. Type cd /cdrom

13. Type cp -rf casper disctree dists install pics pool preseed .disk isolinux/* md5sum.txt README.diskdefines ubuntu.ico casper/vmlinuz casper/initrd.gz /media/ubuntu/  (Note: Ignore all "cannot create symbolic link" errors. Also, this will take some time.)

14. Type cd /media/ubuntu

15. Type rm isolinux.cfg to delete this file from the USB Flash Stick.

16. Download the custom syslinux.cfg file by typing this:
wget http://www.gorkee.com/downloads/articles/syslinux.cfg

17. Make the USB Flash Stick bootable by typing, syslinux -f /dev/sdc1

18. Finally, to be on the safe side and to fix any MBR issues, type lilo -M /dev/sdc

19. Reboot your machine (I had to press the F12 key on reboot, yours may be different) and boot from your USB Flash Stick, which is now running Ubuntu!

Ahhh…  Wasn’t that fun, boys and girls!  You now have Linux on a Stick.  It may not have happened in a ‘flash’, but who cares?  You’re now able to carry Linux with you everywhere you go.  Like Linus with his blankie.  Like you and your iPod.  Like me and my pot belly pig.  You are set to go.  You are ready to rumble any time, anywhere.  Now go!  Go forth, my friends, and spread Linux everywhere! My Flash 4GB RB1 USB 2.0 Water-Proof Secured Flash Drive w/ Anti-Shock

 

 

 

 

 

  

2 Responses to “Linux On A Stick”

  1. JonRob responded on Saturday, April 19, 2008 at 5:26 pm:

    Do you know how much easier it is to do in Fedora, and to make that Live USB persistent too?

    If you’re running a Fedora 8 system, all you have to do is install the “livecd-iso-to-disk” package, and run a single command:

    # ./livecd-iso-to-disk –overlay-size-mb 1200 /path/to/iso /path/to/stick

    where –overlay-size-mb is how big a persistent partition you want. Wow, wasn’t that easy :)

    Actually, –overlay-size-mb may only be available in F9…

  2. Gorkee responded on Saturday, April 19, 2008 at 8:55 pm:

    Thanks JonRob for that awesome Fedora hint! And you are right, to make it persistent would require making a second partition on the USB device.

Add your own comment...

spacer.png, 0 kB
spacer.png, 0 kB
Copyright © 2008 Gorkee, LLC - General Policies | Privacy Policy | Disclaimer | Site Map spacer.png, 0 kB