Previous Post: Disable load URL from clipboard with middle click in firefox
Next Post: How to mount and unmount a drive in linux
Posted By Scott Klarr on Feb 27, 2008 at 4:05 am
As with most aspects of linux, simply adding an extra drive can become a chore and headache for those with no previous experience. Here is a simple way to setup a hard drive so that it will automatically mount on boot with friendly permissions so all users can read/write. If you need added security on a computer that others use, then you'll need to do some more searching on setting up permissions, but a shared drive will be suffice for most desktop linux users who are new to this.
This post only covers setting up the mounting of your disc. It assumes that your drive already has a compatible filesystem in place. If its a brand new drive, it will need to be partitioned and formated. Google this or you can contact me and I will write up some instructions on how to do this in linux.
First off, you will need to find out which device name has been assigned to the drive you want to setup. Your hard drives are given incremental names like hda, hdb, hdc and sda, sdb, sdc, etc. PATA (IDE) drives typically will show up with the hd prefix, and SATA/SCSI drives will have a sd prefix. The partitions of each drive are then accessed through the device id with a postfixed number to identify the partition (starting at 1). If you had 3 partitions on the hda drive, there will be hda1, hda2, and hda3. Also, all devices are located symbolically in the /dev/ folder of your filesystem. So for example, the second partition of the 3rd IDE drive would be /dev/hdc2.
Figuring out which device and partition you need to setup can be tricky if for example you have several identical drives, but I will try to walk you through it here.
Open up the command line and change to super user (root) using the su command.
fdisk -l | more
Disk /dev/sda: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/sda1 * 1 6376 51215188+ 83 Linux
/dev/sda2 6377 30401 192980812+ 5 Extended
/dev/sda5 6377 6885 4088511 82 Linux swap / Solaris
/dev/sda6 6886 30401 188892238+ 83 Linux
Disk /dev/sdb: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/sdb1 * 1 30401 244196001 83 Linux
Disk /dev/sdc: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/sdc1 * 1 30401 244196001 83 Linux
Disk /dev/sdd: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/sdd1 * 1 30401 244196001 83 Linux
Disk /dev/sde: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xc95487db
Device Boot Start End Blocks Id System
/dev/sde1 * 1 14594 117226273+ 7 HPFS/NTFS
By looking at this ouput you should be able to figure out which drive you have just added. The first thing to consider is the size of the drives in your system. If for example you have one 120gb, and the drive your adding is 250gb, its pretty straight forward to see which drive is which. If the drive has an equal size of another drive, you can then take into consideration the file system listed. If that does not help you determine which drive is which, you can map out the device names to the actual ports of the drives.
Here is how PATA (IDE) drives are mapped to the device names:
Similiarly, SATA drives are also mapped in an orderly fashion. Sata port 1 = /dev/sda, port 2 = /dev/sdb, port 3 = /dev/sdc, and so on.
If your drive is USB or firewire, I do not know the naming scheme used so I cant be of much help there, but that shouldn't be hard to find on google.
Using the example output above, Since the first 4 drives are all the same size, and the latter three have equal partitions and file systems - I would ultimately have to figure out which drive I need to target by the sata port its plugged into.
If at this point you are still unsure of the drive device name, then you might want to post in a forum to get more specific help for your system and hardware. Moving on.
Assuming you know without a doubt the device name of the drive/partition you want to mount, we can now modify the filesystem table with the drive information.
Before we can do this though, we need to create the directory where this drive will be mounted. An example could be /mnt/myDrive/ or /home/yourUsername/myDrive/. For this example we will go ahead and use /home/yourUsername/media/
mkdir /home/yourUsername/media
chmod 777 /home/yourUsername/media
Now open up /etc/fstab in the editor of your choice. I use vi.
vi /etc/fstab
You will now want to add this line:
/dev/sda1 /home/yourUsername/media auto rw,auto,user 0 0
You will of course need to change /dev/sda1 to the device name of the partition you want to mount.
Save. Exit. Then run:
mount -a
Thats it! You should now be able to access the drive through /home/yourUsername/media or whatever mounting point you chose.
If you have any questions, comments, suggestions for revision, or simply found this helpful, please leave a comment!

Nazar - Jul 21, 2008
Error! it must be "* Secondary Slave: /dev/hdd"
Here is how PATA (IDE) drives are mapped to the device names:
* Primary Master: /dev/hda
* Primary Slave: /dev/hdb
* Secondary Mater: /dev/hdc
* Secondary Slave: /dev/hda
hanafi harron - May 21, 2008
thanks. works great!
steve richardson - Mar 28, 2008
very helpful many thanks just getting to grips with linux and was having trouble after installing 2 extra scsi drives sorted now