LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Blogs > Whaling the FOSS
User Name
Password

Notices

The experiences of an Australian student who uses Linux.

Cover all topics from shell scripts to monopolies and reviews to political comments.
Rate this Entry

(UNFINISHED)How to install Debian onto a USB stick

Posted 08-08-2011 at 04:05 AM by William (Dthdealer)
Updated 08-08-2011 at 04:07 AM by William (Dthdealer)

This guide is in direct response to http://kpweb.homelinux.org/blog/index.php?id=17 - a guide that uses a rather roundabout and un-hacker like way to install Linux onto a USB stick using a virtual machine.

How to Install Debian onto a USB stick

Requirements

You will need the following:
  • A USB stick ( preferably larger than 1 GB )
  • A working Debian system
  • Root privileges on such a system
  • Time
  • An internet connection

I will quote the package name of everything used in this guide, so if you do not already have it installed a quick apt-get install will fix the problem.

Assumed skills:
  • No fear of the command line
  • Ability to find information relating to my instructions using tools such as man

Theory

Partitions

Every modern storage device is divided up into sections called partitions. Each of these partitions is identifiable and usable as if it were another device or harddrive. Internal storage medium such as harddrives as well as external medium such as USB sticks are both partitionable devices, but both are commonly sold with only one partition setup on them.

It is entirely possible to install and use Linux on a USB stick without repartitioning it, but I highly recommend you repartition first.. By partitioning a device you separate components into their own partitions, giving them separate places to live and therefore better security and fault-resistance.

Please note that Windows hates partitions with a passion. While all other operating systems correctly identify multiple partitions on removable devices, Windows will only ever 'see' the first one. On top of this, Windows only 'sees' FAT and NTFS filesystems ( natively, without modification ).

If Windows cannot see a FAT or NTFS partition on the USB device, it thinks it is unformatted and brings up the obligatory "Do you wish to format... " dialogue box. Most people will hit 'yes' on impulse, even if the USB stick is not theirs, and if you lose your USB stick and someone finds it they will probably believe it has no value.

To address Windows compatibility I highly advise you place a small partition ( 16 MB will be more than enough ) formatted as FAT16 at the beginning of your device. In this partition your should also leave a text file naming you as the owner of the device and listing your contact information in case you do lose the device. Make sure the text file has CRLF line endings, or it will look screwed up in Windows!

USB drawbacks and how they can be avoided

USB flash driver have several major draw backs in comparison to internal harddrives for running Linux:
  1. Considerably lower read/write speed
  2. Considerably lower life ( number of writes before the device fails )
  3. Security considerations ( because USB sticks are portable )

There are two ways to bypass the first two problems in the list. One is to use the Puppy Linux method of loading the whole USB device to RAM and then only writing back to the USB drive when done, which is a really clever solution to both problems. Unfortunately this also requires the target system to have ample RAM or you will be limited to only a small amount of space.

I have discovered that most of the pain of installing Debian onto a USB stick comes from the amount of writes done during the installation process. On a USB stick installing Debian directly to it is both slow and detrimental to the life of your device, so in this guide I will show you how to install Debian in a 'fake' chroot environment and then copy it over to your USB stick when you are done.

The third and final point is more difficult to work with. If a Linux savvy person has your USB stick in their possession, the only way to protect your information from them is to encrypt it. Processes of encryption are beyond the scope of this guide, but I would like to point out that even encrypting the whole partition Debian will inhabit has a major possible hole. If someone does obtain your device, even temporarily, they could modify your bootloader to log the passphrase you use to decrypt your partition and then steal the device off you again.

Creating your system

You need to log in as root for this to work. I have not come across an implementation of 'chroot' that allows non-root users to use the command without something like 'sudo', so you are better off just using root anyway.

First you need to create a folder that will temporarily house Debian before we copy it over to your USB stick. Read the theory section above on why we do this. You should know how to create a folder - in this guide I will call it 'stickfolder'.

To setup a base Debian system, we could either manually copy components of ours over but this is a complex procedure. A useful program called 'debootstrap' is available in Debian to do this for us. The syntax for how we will want it will look like the following:

Code:
 # debootstrap --arch=ARCH DIST DESTINATION
Where ARCH is the desired architecture ( to work on most computers choose i386 ), DIST is the your preferred distribution/version of Debian ( in my case I am choosing 'wheezy' ) and DESTINATION is the folder in which you want to create the new installation temporarily ( for me: stickfolder ).

Debootstrap should now download and install the base Debian packages ( providing your internet connection is working and no other problems are hit ). While this process is happening, you should partition your device.

Partitioning your USB stick

Rather than give you a guide here, I will simply show you the layout I recommend. There are many guides for using programs such as parted, gparted ( for newbies ) and fdisk ( recommend ) on the web.'

I would also recommend you use either ext4 or XFS as your filesystem. GRUB support for BTRFS is shady at the moment, so you would have to waste space creating another partition just for GRUB to sit on. Ext4 is supposedly faster than XFS, but XFS is more flexible and is the filesystem I have used and tested.

(UNFINISHED)

I have had this sitting around for a week, slowly getting bigger. I will finish it

Regards, William
Views 1008 Comments 0
« Prev     Main     Next »
Total Comments 0

Comments

 

  



All times are GMT -5. The time now is 07:44 PM.

Main Menu
Advertisement

My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration