Ubuntu Gets a Second Friend (or More)

You have your Ubuntu system up and running.  Now you’d like to add a second harddrive to store all of your porn music.  You may know the ropes for this in Windows, but the world of Linux is, as usual, a little different.

Here is my take on adding a second (or third…) drive to your Linux box.  You may want to read through the entire post and then only select out the bits that actually apply to your specific situation.

First we need to install the drive into your machine.  I am only going to look at SATA and IDE drives here.  As regards IDE drives we have to worry about jumper settings.  This is not an issue with SATA drives.

Drives in IDE are attached to a channel.  You can have up to two drives attached to a given IDE channel.  One of those drives is the master and the other the slave.  Most commonly you will set your jumper settings to Cable Select and merely position the drives accordingly (Master closest to the board and Slave at the end of the cable).  There are cases where this arrangement won’t work or isn’t possible, but try that first and see if your drive is recognized.

One important thing to note here is that your OS drive (the drive from which you boot your operating system) must be the Master on its IDE channel.  Also of interest is that when you have a CD drive and a harddrive attached to the same channel you will want to ensure the harddrive is in the Master position (or it may not show up once you log in).

So, arrange your new drive according to these basic rules, and adjust your IDE jumper settings as indicated by the manufacturer.  (Usually the jumper settings are indicated somewhere on the drive but I have in the past had to seek out the jumper settings on-line.  Google is your friend.)

If you are installing a drive that is already partitioned and contains data you can skip this next bit.  If you are installing a new drive (or one which you intend to re-format) you will want to get a new partition created and formatted.

Assuming you have surmounted this little jumper problem you should see your newly installed drive in your system when you run GParted (System —> Administration —> Partition Editor).  This is the dangerous part so be cautious—you can ruin a perfectly good partition, like your OS partition, by choosing the wrong drive here.

At the right of the GParted window you will see a drop down of drives.  It is probably defaulted to your main drive and will perhaps read something like /dev/sda (74.53 GiB).  As you can see from this, my main drive is about 75 GB.  If I click on the drop down I get a list of the other drives installed on this machine (I have two): /dev/sdb (149.05 GiB) & /dev/sdc (465.76 GiB).

Your new drive will likely be sdb, but as I have said you must be cautious.

From the dropdown choose the drive you wish to partition.  We may create more than one partition on the drive but we are going to create a single large partition in this example.

(If a partition already exists and you wish to destroy that partition and all its containing data, you merely select the partition and click the Delete button from the toolbar in GParted.)

Once you have selected the drive you wish to partition from the dropdown, you must then click on the unpartitioned space in the visual display immediately below the toolbar.  This selects the partition/free-space so you can work on it.  Next, click the New button in the toolbar to begin partition creation.

You will have to select a file system.  I typically choose the ext3 file system.  It’s standard to Linux and uses indexing.  Quite fast, really.  There may be concerns about attaching Mac or Windows machines to this drive (should you choose to share the drive to other machines later).  However, since utilities can be had for both of those operating systems which will allow them to connect to ext3 it still stands as a good choice—and in my opinion the best choice.  (If you are certain you don’t need indexing, ext2 will be sufficient.)

(Certain sharing is possible across platforms even using ext3; for instance you can create a Samba share (like a Windows File and Print share) and other computers will be able to read from and potentially write to the file system; the reason for this is that Samba performs a translation and the other system doesn’t actually have to mount, read, or write using ext3.)

(Mac has a hard time writing to NTFS.  For the problems with FAT32 see my ink.  You can read much more about the ext3 file system here.)

Let GParted create the partition (just using the defaults should be sufficient).  In order to write these changes to the disc you will have to click the Apply button.  This is the final safeguard.  Until you click Apply nothing gets written.  Once you’ve gone that far, there is no turning back.

So at this point your drive exists and has a file system on it.  Your system sees it.  Now you will want to tell your system to give you access to the drive by mounting that new drive.

I have been mounting my drives in /media but will listen to altering opinions on the matter.  Open a terminal and change into the /media directory: cd /media .  Once in /media, take a look around: ls -al .  This will display a list of all folders/files in /media which roughly corresponds to all the drives to which you are mounted.  You should at least see your OS drive and your CD drive in there already.  Create a folder for your new drive: mkdir Musica (I called mine Musica because there is music on it, clever eh?).  Name yours anything you’d like but don’t use spaces.

Ok, so now you have a place to mount the new drive.  Let’s actually mount it.

If you installed a drive from another system, you may run into a permissions issue at this point.  If you do, you will want to take ownership of the entire drive: sudo chown [username]:[usergroup] /media/[harddrive] (use your actual username—your usergroup is presumably also your username).

Mount the drive: sudo mount /dev/sdb1 /media/Musica (make necessary changes to match your actual drive information).  Note the sdb1 in this command.  That is because sdb is the drive while sdb1 is the first partition on that drive.

Again, if you run into permissions troubles try opening the permissions for the drive: chmod 777 /media/Musica (again making appropriate alterations to the code—777 means anybody on your machine has general access to the drive mount but you can still limit permissions on containing folders later).

Perhaps you don’t want to run this mount command each time you login?  Well then, why not set up an auto-mount?

Open your fstab file in GEdit: gksudo gedit /etc/fstab (password required).  You will see a list of drives and you will want to add a couple of lines below that list of drives:

  • # Here is my auto-mount for my Musica drive
  • /dev/sdb1 /media/Musica ext3 defaults 0 0

I have taken to using UUID’s instead of /dev/[drive] because the UUID of a drive will never change (where the drive designation can, the same way that drive letters can change under Windows).  You can get a drive’s UUID easily enough ( sudo blkid ) then substitute UUID=blahblahblah in your fstab entry.

By the way, what comes after the # is merely a notation and may be altered to your whim.  Alter yours as per usual, including the file system type if you didn’t use ext3.  You may add as many drives as is necessary.

Log out and back in and you should be all set to go.

Please let me know if my instructions need work.  I rather cobbled them together from at least this post and this post and this post (many thanks to them).

Happy hunting.

Share

3 thoughts on “Ubuntu Gets a Second Friend (or More)

Leave a Reply

Your email address will not be published. Required fields are marked *