September 22, 2010

Most users use Linux on a dual boot system alongside Windows. So mounting the Windows partitions while running a Linux session is a necessity. Most of the latest Linux based operating systems lets you mount the partitions with just a click. But sometimes it is preferable to have the partitions mounted right away on start up. This post will explain to you how to mount any partition, not just the Windows partition automatically at start up. Remember that this works with only partitions on the internal hard drive, not an external one.

The first step is to decide the file-system of the partition to be mounted. For a windows partition, it is NTFS. But in general, you can determine the file system with the following command

sudo fdisk -l

This shall return a list of partitions in the internal hard drive. Note the device name ( which looks like /dev/sda1 or /dev/hda2 ) and the file-system of the partition to be mounted. Now, you need to find the universally unique identifier ( UUID ) of the disk with the following command

ls -l /dev/disk/by-uuid

Match the UUID with the device name and note it down. Now a folder is to be created onto which the partition is to be mounted.

sudo mkdir /MOUNT_POINT

Replace MOUNT_POINT with name of your choice.You may also mount it at /media/MOUNT_POINT if you would like a desktop icon while using Nautilus file manager. Before editing /etc/fstab file, you should back it up. It stores details of which partition is to be mounted where during start-up.

sudo cp /etc/fstab /etc/fstab_backup

In case something goes wrong you can reset everything by executing

sudo cp /etc/fstab_backup /etc/fstab

Now you are all set to edit the /etc/fstab file . I shall use the “nano” terminal editor to edit the file as this is a general tutorial. You may use the default text editor of the distribution you are using ( like gedit in Ubuntu ) .

sudo nano /etc/fstab

You have to add a line of  the following kind at the end of the file,

UUID=[uuid]  /MOUNT_POINT [file-system type] defaults 0 0

replace [uuid] with the UUID and [file-system type] with the file-system type and MOUNT_POINT with the folder name. For example a typical line would look like the highlighted line in the screenshot


In case of FAT file-system, the option “defaults” is to be replaced by “iocharset=utf8,umask=000″

In some cases instead of UUID the device name is the opening of the line. This can be verified by seeing the earlier entries. If earlier entries are in the format given above, well and good. Otherwise, just replace UUID=[uuid] with device name. For example,

/dev/sda3 /MOUNT_POINT ntfs default 0 0

Now save and exit and run the following command

sudo mount -a

From this point on, the partition will be mounted on to the folder created automatically on start-up.

Suggested Linux Topics:

Do you like this post?

About

Rohit is a fourth year student of IIT Kharagpur. He is an opensource enthusiast with a thing for software development.

Comments:
  1. Samir

    Awesome! The process description is very lucid. Although Windows-Linux dual boot usually causes more trouble with the Windows installation, this might be handy in case one of the drives has corrupt sectors.
    Samir recently posted..HOW TO AUTOMATICALLY CLEAR YOUR FACEBOOK WALL

  2. Bishwajeet

    @Samir Never had any problems with Windows first and then linux installation .
    Anyway great start Rohit and hope to see more of this type of superb articles from you .

  3. rrohit

    @ Samir : This becomes useful whenever any linux software like DC++, tries to access windows files ( if you are sharing those in DC++ or if you link folders to locations in the windows drive ). You need not worry about mounting it before running these softwares.

    and thank you both for the complements :)

  4. Laptop Repair Glasgow

    yeah handy to have this when mounting a windows drive.

Leave a Reply

(required)

(required)


CommentLuv badge
Copyright © 2011 Comptalks - All Rights Reserved.