The Smorgasbord:  Gadget reviews, geek blog

How to install second hard drive in Ubuntu Linux

Posted in ubuntu linux on Jun 29, 2007

So you’ve been using linux for awhile now, and it’s time to install another hard drive for some more storage? Maybe it’s finally time to wipe out a Window’s or NTFS partition.

In any event, I wrote this post so you would have a little help through this step. I’m going to assume that you already know how to install a hard drive. I’m also going to assume that you knew how to make it a master or slave, you’ve checked to make sure that it shows up in bios, and that it was intalled properly. It also assumes you’ve already formatted your drive in linux ext3 format, using a tool like gParted, or something similar.

If you’ve done all of these things, then boot up your system – and let’s get going. I’m using Ubuntu linux – formerly Breezy 5.10, but I’ve recently upgraded to Dapper 6.06.

Open up a terminal window and run the following command:
$ sudo fdisk -l

You should get a listing of the hard drives installed on your computer. There will be a little paragraph for each one that will look like this:


Disk /dev/hda: 40.0 GB, 40020664320 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hda1 * 1 4678 37576003+ 83 Linux
/dev/hda2 4679 4865 1502077+ 5 Extended
/dev/hda5 4679 4865 1502046 82 Linux swap / Solaris

In windows disk drives are assigned an alphabet letter, and traditionally – floppy disk drives were a: and / or b:, and the main hard drive was c:/. Then the first cdrom or dvdrom was d:/, and any additional drives would be e:, f:, and so on. In linux it’s kind of the same, but in a different format. All hard drives installed are listed in the ‘device’ or /dev directory. All drives start with the appendage “hd” (I think for ‘hard drive’).

So, if you have 2 hard drives and one cdrom – then you have 3 devices. You have a hda, hdb, and hdc. The number of partitions comes next. If your main hard drive is linux – and you have 3 partitions, then you’ll have a hda1, hda2, and hda5. The partition numbers aren’t in a logical order – hda5 is always the swap partition.

So know, if you see your hard drive listed in the sudo fdisk -l, then you know you can mount it. Your computer has a startup file that tells it what to mount when it boots. We need to edit this file and add the new drive.

But first we have to create a directory. We have to create what’s called a “mount point”. A mount point is a virtual directory. It’s like saying – mount that hard drive from this directory.

The most logical place to create the mount point for the new hard drive is either the /mnt or /media folder. Many would say that /mnt is the only place it should be – the mount folder. However, Ubuntu always mounts all dvd, cd, and removable media in /media. I chose to make my mount point here for just that very reason.

Think of what you want to call the new mount point name. Just make sure you don’t use any special characters or spaces in the name. I called mine linuxstore. Now, in terminal run the following command substituting my mount point name for yours:
$ sudo mkdir /media/linuxstore

Next, here’s one of the most important things….and somethng that I didn’t find in any of the articles on the web when I was trying to figure out how to do this. You have to make the mount point directory ‘writable’. In other words, you have to give it writable permissions. They have to be world-writable permissions since you aren’t a member of the ‘root’ group in which all mount points are owned.

So, now you want to run the following command (again substituting my mount point name for yours):
$ chmod 777 /media/linuxstore

If you want to mount your drive right away, and you don’t care if it’s mounted automatically every time you boot – then in terminal run the following command:
$ mount /dev/hdd1 /media/linuxstore

There! Now you are temporarily mounted. But…if you want it to be permanent, you need to edit your filesystem tab file. Run the following command in terminal:
$ gedit /etc/fstab

The text editor window will appear with the fstab file loaded up. You will see something that looks kind of like this:

# /etc/fstab: static file system information.
#
# proc /proc proc defaults 0 0
/dev/hda1 / ext3 defaults,errors=remount-ro 0 1
/dev/hda5 none swap sw 0 0
/dev/hdb1 /media/hdb1 ext3 defaults 0 0
/dev/hdc /media/cdrom0 udf,iso9660 user,noauto 0 0
/dev/fd0 /media/floppy0 auto rw,user,noauto 0 0

All you have to do is add a new line for the new drive…
I will add the following line to my fstab for my new drive:

/dev/hdd1 /media/linuxstore ext3 defaults 0 0

Just be sure to substitute both the name of my hard drive for yours (mine is hdd1, is yours hdc1 or another name?), and my mount point hame for yours. Then save the file.

Now you will have the new hard drive mounted and writable both every time you boot. In Ubuntu, you should find your new drive listed under your ‘Places’ menu. To make the hard drive show up right now, without rebooting – just reload your fstab file with the following command:
$ sudo mount -a

Now you’re done! Enjoy your new storage drive in Linux!

originally published: 2006-06-04 13:28:53 -0400


 

16 Responses to “How to install second hard drive in Ubuntu Linux”

  1. seth myers says:

    instead of

    $ chmod 777 /mnt/point

    use perhaps…

    $ sudo chmod -R 2777 /mnt/point

  2. Gus says:

    Worked a treat! (Need to add sudo to all commands though!)

  3. Bob Jones says:

    Thank You, Thank You, Thank You.

    I have been trying to set up Ubuntu Linux for over a year and always have the same problem, I can’t write to my second hard drive. After a while I would take it back out and put Windows in. I Googled and searched the Ubuntu forum but nothing they provided helped. Now, since I HATE Vista, I have to get Ubuntu set up. After taking Ubuntu out about four times and even trying Open Suse twice I finally found Your site when I Googled. It works now. I can really write to my drive.

    Thank you very much.
    Bob Jones

  4. TK says:

    Thanks! Easy enough.

  5. jtpratt says:

    Bob:

    I’m glad it helped. I’ve been writing web pages and blogging for many years, but the best posts seem to come from personal experience. On my first Ubuntu install I wanted to install a second drive and found it hard to figure out. I googled over and hour to get the answer – so I posted it hoping it could help others. I’m glad it is… =)

  6. Douglas says:

    Sorry, but there’s a little mistake. Sometimes there isn’t hda5. hda5 means it’s a logical partition in an extended partition. But if you have only primary partition, it will be, at most, hda4. Even if it’s in an extended partition, not necessarily it will be hda5.

  7. Timothy Frye says:

    Thank you…I had been creating a new partition on a second hard drive, with GParted, and with fdisk. Each time the partition was owned by root. This was VERY helpful.

  8. Andy Brunner says:

    Any ideas how to get the mounted drive to show up under system:/media in Dolphin? or system in Konqueror?

  9. Alex says:

    Thank you it worked! I also googled and found yourpage very useful

  10. Duane says:

    Thanks, this worked extremely well!!!

  11. Ptc says:

    Worked almost well, I use Ubuntu 8.04:

    Took me over 2 hours to be able to modify…a “/” was needed at the end of chmod:

    sudo chmod 777 /media/linuxstore/

    Still, many thanks, very helpful mate ;)

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

  13. jtpratt says:

    from Stan Smith via email:

    Thank you for including this essential command (not found in the Ubuntu help)

    Next, here’s one of the most important things….and somethng that I didn’t find in any of the articles on the web when I was trying to figure out how to do this. You have to make the mount point directory ‘writable’. In other words, you have to give it writable permissions. They have to be world-writable permissions since you aren’t a member of the ‘root’ group in which all mount points are owned.

    So, now you want to run the following command (again substituting my mount point name for yours):
    $ chmod 777 /media/linuxstore

  14. Al says:

    Thank you very much for your help. It worked excellent! Great stuff

  15. John Sheridan says:

    Thanx a lot.
    I’d been trying to do this for over 2 hours to no avail.
    I have just installed Karmic Koala and didn’t remember how to do that.
    It was a piece of cake following your instructions.
    I had to add ‘sudo’ to every command, but that I know how to do. LOL
    Thanks again.
    Merry Christmas and a Happy New Year from Venezuela.
    :-)

  16. Anton says:

    I just have to say one thing:

    THANK YOU! xD

Leave a Reply

  • My name is John Pratt and I like all kinds of geeky, gadget tech stuff. I maintain web sites, write a little code, fool around with Wordpress, Ubuntu, play lead guitar in a band, and have a general fondness for computers electronic 'thingies'!

  • Get Updates via Email: