Welcome to the part 2 of “Installing Linux on USB“ series.
Purpose: In this part we will learn how to install Debian Linux (Lenny) on a USB hard drive. In part 1 of this series I had explained the difference between a USB hard drive and USB flash drive. I suggest you refer to it before you go ahead any further with this part. This is the simplest type of install that you can do on a USB hard drive. Later on we will cover more complex ones like using FAT/ext2 combo, JFFS and squashfs filesystem. For now we will just use the our good old ext3 file system which is recommended for hard drive.
Also this tutorial will mostly be image-oriented and I will add my comments wherever necessary.
Requirements for this part:.
1. A USB or an IDE CD-ROM
2. Debian Lenny Install CD
3. A computer which can boot from USB devices – Hard drives and CD-ROMs (optional, but you need to have an IDE CD-ROM)
Quick conclusion: Installing Debian on USB hard drive is not at all different than installing on a regular IDE (or PATA) and SATA hard disk. The only main difference is that the USB hard drive is detected as “/dev/sdX” instead of the traditional “/dev/hdX” which is for IDE/PATA hard drives. If you are interested in detailed installation step then please read on…
Tip: In order to avoid any confusion and prevent data loss please disconnect any IDE/SATA drive that you may have attached to your system if possible. If you cannot physically disconnect them then try to disable them in your BIOS so that Linux installer does not detect it.
Note: If at any time you want to enlarge the screenshots just click on them and they will open in a new browser window.
Step 0: Boot from the CD-ROM with Debian Lenny Install CD
Step 1: Select either Graphic or simple install (I selected Graphic install)
Note: I just had a USB hard drive attached so the only disk I had was /dev/sda. In case if you also have fixed IDE hard drive attached to your system (which you are likely to have) then you will also see an entry with /dev/hda or even /dev/sdb if your have a SATA drive. Make sure you know the name, size and model number of your USB hard drive so that you select it instead of selecting your IDE/SATA drive and erasing them. Linux detects USB and SATA devices as /dev/sdX
Note: Make sure that you install GRUB bootloader to the MBR of your USB hard drive.
Congratulations! If you have reached so far chances are that you will be able to boot into your Debian system on your USB hard drive. Simply restart your machine and boot from USB hard drive. You should be able to see the GRUB menu.
Upon successfully booting to a console (prompt) you can use this installation just like any other IDE hard drive installation.
What after installation?
Now let’s review how our disk structure and filesystem looks like.
# cat /etc/fstab
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
/dev/sda1 / ext3 errors=remount-ro 0 1
/dev/sda5 none swap sw 0 0
/dev/scd0 /media/cdrom0 udf,iso9660 user,noauto 0 0
/dev/sda1 – Is our primary partition with ext3 filesystem
/dev/sda5 – Is our swap file system
/dev/scd0 – Is our USB CD-ROM
Please note that there are lots of different filesystem like ext2, XFS, ReiserFS, JFFS, etc that you can install Debian too. Each one of them has their own advantage and disadvantage. We will try to cover each one of them separately in this series. So please stay tuned.
There is lot of debate regarding throughput/performance when it comes to installing Debian on USB devices which in turn is partly dependent on the filesystem that we use. So we will keep track of data throughput for each install type throughout our series. We will use the tool ‘hdparm’ for this purpose.
# apt-get update
# apt-get install hdparm
Note: You might need to change your sources.list file to point to proper repositories in case if you are no longer using the installation CD.
Now give the following command:
debian:~# hdparm -tT /dev/sda
Timing cached reads: 428 MB in 2.01 seconds = 213.26 MB/sec
Timing buffered disk reads: 60 MB in 3.05 seconds = 19.65 MB/sec
And following is the throughput when installing Debian on a regular hard drive.
debian:~# hdparm -tT /dev/hda
Timing cached reads: 462 MB in 2.01 seconds = 230.33 MB/sec
Timing buffered disk reads: 74 MB in 3.07 seconds = 24.13 MB/sec
As you may have guessed by now that there is nothing special required to install Debian Lenny on a USB hard drive. However there are various things that you can do to optimize the throughput by tweaking the files system setting which we will cover in our new few parts.
As usual, please leave a comment/feedback if you have any. Comments encourages bloggers to post more and keep their spirits high.
Also don’t forget to rate this post below.