This is another stepping stone in my journey of getting to know Linux.
When I installed Ubuntu on my PC, it used to detect my other drives without any problems. What I mean by other drives, is my Windows partitions (C: drive, anyone?). Well, I have 4 of them, and I’ve nicknamed them as well. C: is called Cayman S, D: is called Carrera S, E: is called Carrera GT and F: is called Turbo.
You see, I’m a Porsche fanboy.
Anyway, to mount these drives, I would have to manually go to Places -> Removable Media, and select my drive. This was OK with me…till now. The thing is that, my music is all stored on D:, and having to manually mount it is, well, a little problem. In fact, I have a little applet on the panel, which allows me to mount a drive with 2 clicks, but, being the perfectionist that I am, I wanted it to be done automatically.
It didn’t take too much of digging around to find a forum thread which told me how to do this. It involved editing a file called fstab. This file can be found in the /etc folder. This is the file that Linux looks at when mounting drives while booting. It was a simple matter of adding entries for my other drives, so that they would be automounted as well.
First, you need to know what is the exact name for the drive your mounting. The thing is that in Linux, all driver are names as sda or hda, with individual partitions names as sda1 or hda6, or something like that. So, open up a terminal window, and type in
sudo fdisk -l
You’ll have to enter your password after entering the above command. This program should list all the partitions on your hard drive. Now, comes the hard part. You need to find which hda# or sda# corresponds to which partition. # represents number, by the way. Now, it’s going to be a game of hit and trial. See, generally, hda1 will represent C: rather than D:. Get it, but, if Linux resized partitions for you, this numbering might’ve got messed up.
See, the easiest way to find which sda is which partition is to mount them. But, there’s a hitch. In order to use the mount command, the partition must be in the fstab file I mentioned earlier, otherwise it won’t mount. In fact, we need to make these entries, because only then will the partitions be automounted. So, since I can’t do it that way, I mounted them using the Removable Media menu. Your hard drive partition label is automatically applied to the mounted partition, so it should help you identify the partition you mounted. Then try using the command umount. Umount is used to unmount the drives. See, if I mount C:, and then upon trying sudo umount /dev/sda1, and it gets unmounted, it means that sda1 represents C:, get it? Two things you should know, while doing all this…
- You’ll have to give the full path for the device i.e. /dev/sda# or /dev/hda#. In fact, if you have more than one hard drive, as in physical hard drive, you’ll have /dev/sdb# or /dev/hdb#, get it? a, b, c? Good boy. You’ll get to know what all to try an unmount, by going through the output of your earlier sudo fdsik -l command. I strongly recommend opening a new terminal window for your attempts at unmounting non-existent drives, because you will need to refer to the output of the fdisk command.
- Open up /etc/fstab, by typing in gedit /etc/fstab at a terminal. Keep in mind that if you don’t mention sudo before the command, you’ll only be able to view the file. That’s OK, cause I just want to know something, not edit anything. You see, the first 2 entries in the file, are your Linux partition and your swap file. Don’t try to unmount them, because it might lead to your PC crashing or something. Linux is supposed to deny any attempts to unmount them, but in any case, don’t try to. By the way, the lines in the fstab file which have a ‘#‘ before them, are comments, they’re not comments.
Now, you should’ve found out which sda# or hda# refers to which drive. Now, you need to create mountpoints for these drives. Mountpoints are nothing but the folder which points to the contents of the partition. When you try to access the folder, you’ll be able to see the contents of the partition. In Ubuntu, mountpoints are best created inside the /media folder. Other Linux distributions like to make in under /mnt, but it really doesn’t make a difference. So, now we need to make the mountpoints. Do so, by giving the command:
sudo mkdir /media/<mountpoint_name>
Here, mkdir is the command used for making directories, or as they’re better known, folders! So, make as many mountpoints as there are partitions you need to automount. Keep in mind that although while mounting through the Removable Media menu, the mountpoints can have a space in the names, it’s not advisable to put spaces when you’re manually making mountpoints. It’s not that you can’t have a space in the folder name, it’s more because I haven’t been able to figure out a way to automount a partition to a mountpoint with a space. See, to create a fodler with a space, like Cayman S, I’ll have to write:
sudo mkdir /media/Cayman S
The forward slash (I hope it’s a forward slash…I always mess up the slashes!), signifies that the upcoming character is not a part of the command being input, but is to be interpreted as is. As a character. Because while giving commands, a space can mean different things. Like, there’s a space between sudo and mkdir. But to literally mean a space, like in the folder name, you need to put a forward space.
Anyway, you can’t add an automount entry with the mountpoint having a space. At least, that’s what my experience tells me. To add the automount entry, type in:
sudo gedit /etc/fstab
gedit is the text editing program in Ubuntu. Actually, for GNOME, the desktop environment for Ubuntu. GNOME stands for GNU Object Management Environment. sudo is because we need the priveleges to edit the system file as well.
At the end of the file, after all the other system generated entries, we need to add our own. I suggest you make a copy of the file, by typing in:
sudo cp /etc/fstab /etc/fstab_bk
This copies the original fstab and names the copy as fstab_bk. In case you need to replace the edited version with the original, type in
sudo rm /etc/fstab
This removes the edited fstab. Then:
sudo mv /etc/fstab_bk
This renames the previously created fstab_bk as fstab. So back to the entries you need to add at the end of the file…
<dev_name> <mountpoint> ntfs-3g defaults 0 0
- <dev_name> – hda# or sd#
- <mountpoint> – The mountpoint i.e. /mount/<foldername>
- ntfs-3g – is the filesystem. In this case, it’s NTFS, but you’ll need to write ntfs-3g
- defaults – is for the options.
- 0 – I don’t know what this number is for
- 0 – nor this
Assuming that you didn’t try to put in some mountpoints with spaces like I did, it should work. If you’re adamant on having a space in the mountpoint, either find a website that helps you with that, or just replace the space with an underscore or ‘_’. Restart your PC, and all should be fine.





