en línea jainbasil
Posts tagged mount
Mounting your Partitions in GNU/Linux
Sep 23rd
As you open ‘My Computer’ in your Microsoft Windows, you will see all your hard drives/ partitions as C drive, D drive and so on.But this is not the case as far as GNU/Linux and other Unix like operating systems are considered.So if you are migrating from Windows to the world of Gnu/Linux, you may get confused; i.e. you may not be able to access your partitions of windows in GNU/Linux.(Don’t worry, your data is not lost….!!!).
Unix systems provide two commands : mount and umount , to mount and unmount your partitions.Mounting is the process of attaching a device( any storage device like HDD,FDD,CD..) to an existing directory in your filesystem inorder to make it accessible.
But the process of mounting using the above said commands are temporary.They get unmounted as you poweroff your machine.Now to make it permanently mounted, you may need to edit a special configuration file in your /etc directory.This file is called fstab.The Operating System automatically mounts all the devices mentioned in this file at the time of boot up depending on the option you specify under the tab <mount options>( explained below).
Now, let me introduce you another useful tool : fdisk. This is a Partition table manipulator for Linux (check out man fdisk for more information).There are different usages for this, but we now need only the usage : fdisk -l.This list the partition tables for the specified devices and then exit. If no devices are given, those mentioned in /proc/partitions (if that exists) are used.
So we are on the move……..!!!
Open your terminal. Get into the Super User mode; sudo su. Now you get the prompt as
root@<machine-name>#
Type in the command fdisk -l. You will get an overview of the partition table of your HDD.This is mine……
Now, see that the next prompt is waiting for your commands.Here sd(a-h) stands for SCSI disks (mine is SCSI) and hd(a-p) for IDE disks.You can easily identify your windows drives from the output of the above command.Here, I have 5 windows partitions; one ntfs and 4 fat32 partitions.sda1 is my C drive,D drive is sda5, and so on. Note that sda2 is the Extended Partition.So you don’t try to mount that partition.Open up the file named fstab in the directory /etc (I prefer opening this file in vi editor by using the same terminal; but in a new tab i.e. using shift+ctrl+T)
root@<machine-name># vim /etc/fstab
You will get the file opened.(Remember to check that you are the super user since only the super user has the permission to edit a file in your file system)Now I will try to give a rough idea of the structure of the file fstab.
fstab file contains six columns namely, <filesystem>,<mount point>,<type>,<options>,<dump>,<pass>
- filesystem: This tells the mount command the same thing as its name indicates; the device or partition you want to mount. You can get the name from the stuff which we got earlier i.e. from our fdisk -lcommand.for eg. /dev/sda1
- mount point: This tells mount command where to mount the device.This can be any directory,but I recommend creating one new directory inside your /media.For eg, I created a new directory named win_c inside my /media using the command mkdir /media win_c
- type: This tab specifies the type of the filesystem.Since I am writing this article for mounting the windows partitions,I am explaining only about the filesystem types related to it. Your Windows partitions are probably either Vfat or NTFS. The 9x series (95, 98, ME) all use Vfat (more widely known as FAT32), and the NT series (NT, 2000, XP) use NTFS. In 2000 and XP you can choose the filesystem type, so 2000 and XP partitions may be formatted as Vfat, too. So you may specify vfat under this tab for Fat32 and ntfs for your NTFS Partitions.
- mount options:The fourth column in fstab lists all the mount options for the device or partition. This is also the most confusing column in the fstab file, but knowing what some of the most common options mean, saves you from a big headache. Yes, there are many options available, but I’ll take a look at the most widely used ones only. For more information, check out the man page of mount.
auto and noauto: With the auto option, the device will be mounted automatically (at bootup).auto is the default option. If you don’t want the device to be mounted automatically, use the noauto option in /etc/fstab. With noauto, the device can be mounted only explicitly.
user and nouser: These are very useful options. The user option allows normal users to mount the device, whereas nouser lets only the root to mount the device. nouser is the default, which is a major cause of headache for new Linux users. If you’re not able to mount your cdrom, floppy, Windows partition, or something else as a normal user, add the user option into /etc/fstab.
exec and noexec:exec lets you execute binaries that are on that partition, whereas noexec doesn’t let you do that. noexec might be useful for a partition that contains binaries you don’t want to execute on your system, or that can’t even be executed on your system. This might be the case of a Windows partition.exec is the default option.
ro: Mount the filesystem read-only.
rw:Mount the filesystem read-write. Again, using this option might cure the headache of many new Linux users who are tearing their hair off because they can’t write to their floppies, Windows partitions, or something else.
sync and async: This option deals with how the input and output to the filesystem should be done. sync means it’s done synchronously.Commonly,this is the option used with the floppy. In plain English, this means that when you, for example, copy a file to the floppy, the changes are physically written to the floppy at the same time you issue the copy command.
However, if you have the async option in /etc/fstab, input and output is done asynchronously. Now when you copy a file to the floppy, the changes may be physically written to it long time after issuing the command. This isn’t bad, and may sometimes be favorable, but can cause some nasty accidents: if you just remove the floppy withoutunmounting it first, the copied file may not physically exist on the floppy yet!
async is the default. However, it may be wise to use sync with the floppy, especially if you’re used to the way it’s done in Windows and have a tendency to remove floppies before unmounting them first.
defaults :Uses the default options that are rw, suid, dev, exec, auto, nouser, and async
- dump:The 5th column in /etc/fstab is the dump option. Dump checks the file and uses the number to decide if a filesystem should be backed up. If it’s zero, dump will ignore that filesystem.In most of the cases, this option is set to zero.
- fsck: fsck looks at the number in the 6th column to determine in which order the filesystems should be checked. If it’s zero, fsck won’t check the filesystem.
Now create new directories inside the directory /media and append to the fstab file, devices you want to mount using proper options below each tab.Make sure that you don’t mount your partition shown as Extended in the fdisk -l output.Also, prefer using defaults below the tab named <mount options> and use dump and fsck as 0.Save and exit from the editor and return to your prompt.
In your prompt, type in the following command to mount the devices you added to fstab :
mount -a
Thus your devices/Partitions get mounted.
Further Reading : http://www.tuxfiles.org/linuxhelp/mounting.html


Recent Comments