After a recent crash that caused some loss of data (not Linux), I decided to look at the possibility of an external USB back-up drive, in order to back up on a more regular basis; I lost about a weeks worth of data plus some email records. The thinking behind it was to have a drive that would back-up from both Windows® and Linux machines and therefore, the file system had to be recognised by both systems.
I already had a 250GB hard drive purchased recently for a different project that has been shelved and so it seemed the answer was to look at one of the many external cases, as a suitable build project.
You need to be aware, not all cases are equal!
There are cases that are specific to only IDE hard drives, or specific to SATA hard drives. Some will accommodate both types, but tend to be more expensive. You need to determine the hard drive size too. Is it "3.5", the standard desktop size, or "2.5", the laptop equivalent? Do you want data transfer at USB 1.0 speeds, USB 1.1 or USB 2.00? Looking at the specifications for each version will show that USB 1.0 provided data transfer rates of 1.5 Mbps (Mega bits per second), while version 1.1 offers 12 Mbps, and version 2.0, 480 Mbps. So really, it's a no brainer as version 2.0 is backwards compatible with the others.
With the above understood, my hard drive was IDE and 3.5", so I went looking for a case for a 3.5" IDE drive with a USB 2.0 port connection and came up with this:
It's a nicely finished aluminium case, complete with its own power supply, mains kettle cable, USB connector cable, screw driver, four screws and a driver disc. Purchased via ebay for £9.98p delivered! How do they manufacture these things so cheaply?
Assembling the drive
This part is only here for completeness, as depending on the case you purchase, things may vary slightly. Having said that, it seems most are fairly similar.
The main criteria is to determine (assuming it's an IDE drive) how to jumper it. You may know, a jumper(s) is used (or not) on the hard drive to set it as a Primary drive, Slave drive or Cable select. The jumper can also be used to limit the capacity of the drive for very old computers. As reports circulate around the Internet about incompatibility with various settings, I decided to tackle the problem as follows.
Using the supplied screwdriver, I removed two screws on the side of the drive adjacent to the power end of the case; in other words, where the connectors were. The end then simply slides out from the case and you will see a tiny circuit board and the main data cable and power cable all attached to the front piece you have just removed. Look at the main case and on the underside there is provision for four screws via four holes. These will line up with the fixing holes for the drive. I decided to remove the jumper from the hard drive, thereby designating it as Slave. Now the next bit I did for my convenience and no way am I making a recommendation for you to follow suit, but in order to determine if the drive would be recognised in this form, I connected the front plate data connector and power connector to the raw drive. Making ''very'' sure the components were not shorting out on anything, I fired it all up and had a look at the disk manager to see if it was recognised. As luck would have it, it was (more about that later - remember at the moment it's still a new raw drive), so I stayed with that configuration, unmounted the drive and carefully powered off.
Note: had the drive not been recognised at this point, it would have been a simple event to turn it off and try configuring it as a Master or even Cable select drive to see if that worked.
It was now just a question of noting which way up the drive mounting screw holes were and when sliding the drive in the case, aligning them with the case, so the afore mentioned case holes married up. Next I used the supplied four screws to secure the drive in the case. All that remained, was to very carefully position the data and power cables so they laid nicely in the case and resecure the front panel with its two screws.
So now I had an assembled external hard drive that I knew would be recognised in the Debian machine I was using, but of course, incapable at the moment of accepting data.Partitioning
The first thing I needed to do, was to determine how Debian designated the drive. In order to do this, I used the Desktop >> Administration >> Disks application:
When you click on Disks, this is what you'll see:
Yes, as always, it requires your root password. Once you have entered your password, you will see this:
Of course, at this point, is is essential you identify the correct hard drive, as you will be partitioning and formatting it, ''thereby destroying any previous data.'' In my case, there are three possible drives that could be my target. Each shows as 232.89 GiB, however, by choosing the Partitions tab, we can see what has been configured. In my case, remember it's a raw drive, so there are no partitions yet written. Clicking on Partitions revealed this:
Bingo! We've got it sorted! Alternatively of course, you could simply fire up Disks prior to connecting your new drive, note the drive(s) already found, then connect your new drive and see where it appears. Either way, the important information we require is on the Properties tab and if you refer back to that now, you will see the drive is designated as /dev/sde (just by the little drive icon). That's the information we need to move forward.
Shock, horror, it's now time to move to the command line, so going to Applications >> Accessories >> Root terminal, will give us what we want.
"Note to all users;" in the command boxes, #> represents the command prompt and is not part of the command. Any command typed, ''will not'' be activated until enter is selected.
"Note to the Ubuntu family users; any commands indicated here in boxes should be preceded by sudo
Once we have our root terminal open, we can start the process of preparing the drive for practical use. In order to do this, we are going to use the fdisk application, to partition the drive. The command:
will provide something similar to this:
The important part to note here, is towards the bottom of the screen-shot. Just above the bottom command prompt, there is a message that says; Disk /dev/sde doesn't contain a valid partition table. This provides further confirmation, sde is the drive we have to work on.
So the next command we need, tells Linux to use the application fdisk and what to use it on /dev/sde
You can now see some warnings, that in general, it is safe to ignore. You can also see the command prompt has changed from what would be your own, to fdisks own prompt. fdisk works on a menu based system and now you are inside the system until you opt to exit. As you can see, typing m will offer help. so let's try that and see what happens.
You can now see the various options of this powerful application that are available to you. We need to create a new partition, so appropriately, the n command, sets this in motion.
In the above screen-shot, I have combined a number of the actions required to set-up the partitions. If you start at the top of the screen-shot, it is a repeat of where we were; the menu. Next, we selected '''n''' which asks for a Command action;
p primary partition (1-4)
As I wanted a primary partition, I typed p and was then asked which number partition I wanted to create. Well, me being a logical sort of chap decided to start at 1 and so you see it typed here. Now fdisk wants to know where to position the partition on the drive (First cylinder); again I start at 1 and finally where I want it to end (Last cylinder).
This last part deserves some explanation. If I had typed in there 30401 as the last cylinder, fdisk would have used the whole of the drive as one large partition. However, it was my intention to split the drive into two equal parts, 15200 (more or less) divided it into two. Equally, I could have used the +size option, where for example, +125000M would equate to a 125GB partition.
Notice now, how we have automatically been ejected from fdisks sub-menu and are now back at its command line - Command (m for help):. Therefore, referring back to the main menu, if I now type p, it prints the partition table. That means, it ''prints to screen'' not to a printer in the conventional sense. We can now see, our first partition is specified and the next stage is to repeat exactly the same sequence of events, ''except'' I used the Partition number 2 instead of 1 to create the second partition. It should also be noted, I started the new partition at 15201 (the next available cylinder) and specified the last cylinder as 30401, thereby using all the remaining disk space. The next screen-shot shows the complete second process:
Notice, p now shows both partitions specified /dev/sde1 and /dev/sde2. You should also understand, I used the word "specified" as the partition table has not yet been written to disk. We'll get around to that soon.
Now we need to do a little tidying up. You may recall at the beginning of this page, I said this drive was to be suitable for "Windows® and Linux machines". Notice the System block, has the file system listed as Linux. This is simply a file identification and has no bearing on what the final file system will be, but in order to avoid confusion, I changed it to FAT 32. This is how it's done in fdisk. If you go back to the last but one screen-shot and take a look at the menu again, the t command allows you to change a partition's system id. So the next screen-shot shows just that.
It then asks you for the partition number you want to change; I selected 1. It then tells you (type L to list codes): Doing this provides a list of all the available options. The codes are in the left hand column and the description in the right. As I wanted any machine to be able to access this drive, W95 FAT 32 LBA was an obvious choice. In order to select this, I needed to use the code c. Once I pressed enter, I got a message telling me; Changed system type of partition 1 to c (W95 FAT32 (LBA)). Now selecting p (print to screen) shows the first partition altered. Repeat for partition 2, shown in the next screen-shot:
Selecting the command '''p''', confirms both partitions have had their '''id's''' altered.
Finally, I needed to write all these changes to the drive. Referring back to the menu screen-shot will show the command w will write table to disk and exit. Once you hit w >> Enter the changes are committed. ''There's no going back!''
You will now see; The partition table has been altered! and another couple of messages telling you what fdisk is doing. Now fdisk dumps you back at your own command line prompt. If you've finished with the terminal, type exit to close it.
The easiest way to format the drive is via Disks manager (DM).
You will remember we used that originally when assembling the drive to help identify which designation Linux had assigned. So go back into DM and take a look at your drives again. This time, we'll see something rather different.
We can see there are now two partitions available, although as yet, they are not formatted. You can also see, the Format button has come alive. Clicking on that produces this:
Clicking on the Extended 2 drop-down list gives us four options: Extended 2; Extended 3; Windows Virtual FAT (vfat); Memory Swap.
Clearly I needed Windows Virtual FAT (vfat) so that's what I selected and then clicked on Format.
As formatting destroys any data on the drive, you are given a final warning.
Providing you are happy to commit, click on Yes.
Formatting takes seconds in Linux, so almost immediately, you are taken back to the DM screen which has changed yet again.
You can now see, to the left of the Format button, the Filesystem has changed from Unformatted to Windows Virtual FAT (vfat). I now repeated the procedure on Partition 2, and then shut DM.
That's it; job done! and to prove it, plugging in the eternal drive automatically produces this:
I have now tested this drive in Debian etch; Ubuntu 7.04; Linux Mint 4.0 Daryna; gOS; Windows ME; Windows 2000 Pro and Windows XP Home and it works flawlessly in each system. Sadly, PCLinuxOS 2007 has issues as does SuSE 10.2. You would think that with the Novel SuSE tie-up with Microsoft, FAT 32 recognition would not be a problem. But I suspect that is where the problem lays, as one of the systems reported it could not read the file system.
Never-the-less, if you have an old working drive hanging around, this is an inexpensive way to utilise it.