Tip & How-To about Computers & Internet

How to Mount storage devices automatically on linux

Hi..
This will be nice that all your local Hard drives are mounted automatically during the boot. This can be achieved by modifying "fstab" (File System TABle) file. This file is located on /etc/ which would need superuser permissions(root user password) to modify.

How we can alter fstab and set system to mount partitions by itself is explained below..

  1. First Open a terminal and type blkid and press
    this will show your local Hard disks with their UUIDs( Universal Unique IDentification). This may look like this


    here 1st column with /dev entries are the links of partitions(in the format /device/
    2nd column : LABEL describes the Name or Label of partitions. Not all partitions necessarily needs a Label.
    3rd column starting with UUID is the entry shows the UUIDs of the Partition
    4th column shows the File system used in the partitions

  2. So Now we know some important informations about our partitions like their File system type and UUIDs. In linux to use a filesystem, we need to mount it in somewhere in the root directory. This is because of the Hierarchy nature of Linux .

    Usual location of mounted file systems are on /mount/ or /mnt/. I take /mount/ as my default Mount location. Create a new folder with a name(Without any space between words, ex: New_Partition) simillar to Partiton Label or No

    To create folders in /mount/ , we need root permissions.
    Open a terminal and type su and press . It will ask for root password. type in root password and press enter.

    Then type mkdir -v /media/
    ex.: If you want to create New_Drive in /media/ then type mkdir -v /media/New_Drive
    You can also create multiple folders in one step
    ex. You want to create Drive1, Drive2 , Drive3 then you need to type as
    mkdir -v /media/Drive1 /media/Drive2 /media/Drive3

    You may get as this


    Now we created mount points needed to mount the filesystems

  3. Now we need to modify fstab file .
    Default location of fstab is /etc/fstab



    On terminal ( where we typed commands to create folders in /media)
    Before we start editing fstab file, lets make a backup copy of it

    Type on terminal cp -v /etc/fstab /etc/fstab.backup and press . You should see as below.



    type sudo gedit & and press

    This will open text editor. Click on Open and point it to /etc/fstab



    It will Open fstab file. This may look like this



    Any entry starting with #, will not taken into account. So you can use # for commenting

    Basic structure of fstab file is





    File System Address --> Its is the Identifier for the file system. You can use either Links (ex.: /dev/sda2) or Labels (ex.: LABEL="DRIVE1") or UUIDs (ex.: UUID="74c9c3d9-a374-406d-ba41-e030c7d35f5d")


    Mount Point --> This is folder on which the file system mounts. (Refer Step 2) (ex.: /media/Drive2)


    File System Type --> specify the file system (ex ext3, ntfs, fat)


    Options --> Contains more complicated options
    For normal user, its good to set Defaults as Options


    Dump --> set whether to Backup or not. (ex. 0, 1)


    Pass --> set whether to check filesystem before mounting


    example of a edited fstab file is





    After finishing with fstab save it. You may get errors if you don't have permissions to alter fstab. In that case, Open a terminal and type su and press and provide Password for root account. and
    Then type gedit &.

  4. After saving the file , restart the system, if everything go just good as expected the computer boots up with local partitions mounted on specified locations


If you got any doubts , please contact me

Posted by on

Computers & Internet Logo

Related Topics:

Related Questions:

2 Answers

how repair redhat operating system the ask ctrl -d


whoops! You'll have to boot off of an installation disc, maybe Knoppix or Ubuntu if the RedHat install disc doesn't work. Once you do that you should find the old version of your fstab (often with a tilde ~ after it), restore the old version, and go from there!

Oct 15, 2009 | Computers & Internet

2 Answers

Missing floppy disk in 64bit ubuntu 8.10


I solved the problem now, so I hope it works for you. In the /etc/modules file, I added "floppy" top the list. I think the developers just removed the module loading for floppies because so few people need them now. This change should get the floppy module to load at boot. Note that you can also use the modprobe command to accomplish the same thing, but if you want it to load automatically upon booting, modify the /etc/modules file.

Nov 10, 2008 | Canonical Ltd. Ubuntu

1 Answer

Files are permanently read only.


What operating system are you using? If your using a Microsoft Windows operating system, you can go to Start->My Computer , open my computer, and right click on the drive in My Computer, and change the access of the drive there.

If your using a NIX(Linux, Unix, OSX) operating sytem, you need to mount the drive with rwx permissions, and to do that you'll have to edit the fstab file in /etc.

Nov 13, 2007 | SanDisk 2GB Cruzer Micro SDCZ62048A10 Hard...

Not finding what you are looking for?

213 people viewed this tip

Ask a Question

Usually answered in minutes!

Top Computers & Internet Experts

Doctor PC
Doctor PC

Level 3 Expert

7733 Answers

kakima

Level 3 Expert

102366 Answers

David Payne
David Payne

Level 3 Expert

14161 Answers

Are you a Computer and Internet Expert? Answer questions, earn points and help others

Answer questions

Loading...