Auto-mount partitions with fstab

Sometimes we need a partition se mount automatically when the system is being raised. The correct way to solve this problem is to use the file fstab located in / etc / fstab.

Luis López is one of the winners of our weekly competition: «Share what you know about Linux«. Congratulations Luis!

It is necessary to have a small definition of some concepts before starting:

FileSystem: All physical media that can store files must have a filesystem to be able to fulfill this function (example: a partition of a hard disk). A filesystem is a system used to organize files on said storage medium, but we could see it as the storage medium itself (at the user level). It is necessary to clarify that this is not a formal definition, but it will bring us closer to the concept ...

Filesystem type: As we have seen, a filesystem is an organization system and it is reasonable that there are several different systems to organize files, each one with its pros and cons. For example: FAT, NTFS, EXT2, EXT3, EXT4, etc.

Mounting point: The mount point is a folder or directory. After mounting the filesystem in said directory we will be able to access the files through it (directory).

Mounting options: They allow you to specify certain parameters so that when the filesystem is mounted it is done in a special way, for example: ro (read-only) this means that files cannot be created, modified or deleted in that filesystem. Another example: errors = remount-ro (remount as read-only) in case of some serious error, the filesystem is mounted in read-only mode.

dump: Dump is a backup tool and I'm just going to mention it because I still don't understand it completely, and I also don't want you to spend all day thinking what this will be. When the number in this column is 0 (zero), dump will ignore that filesystem.

passport: We will start by explaining what fschk is. fschk is a tool to check filesystems for errors, etc. This is another column that I just want to name for the same reason as the one above. When the number in this column is 0 (zero), fschk will ignore that filesystem.

In case you want to continue deepening your knowledge of fstab, you may be interested in reading these old items from the blog.

Working with the fstab file

First we will see the structure of this file:

In this file, each line refers to a file system (filesystem) and each line respects the following structure:

Let's look at an example:

UUID = d4f1ec7e-f3d3-4bd4-becf-4f6da208237f / ext3 errors = remount-ro 0 1 / dev / sda5 / home ext3 defaults 0 2
You already noticed that in the first line the UUID (Unique Universal Identifier, for its acronym in English) of the filesystem and in the second the path of the same (I do not mean the mount point). If we use the UUID, our method will be much more robust.

How to get the correct UUID for each partition?

For this they must execute as root (or using sudo as in the example) the following line:

sudo blkid

And we will see something like this:

/dev/sda1: UUID="B6F0C97EF0C94579" TYPE="ntfs"
/dev/sda5: UUID="d4f1ec7e-f3d3-4bd4-becf-4f6da208237f" TYPE="ext3"
/dev/sda6: UUID="b8146e8f-77aa-44b8-9b37-5a2a90706eea" TYPE="ext3"
/dev/sda7: UUID="57cfda85-b5ce-4288-b42e-c19dc57a65d9" TYPE="swap"/dev/sdb1: LABEL="Backup" UUID="5D9A907246C7446B" TYPE="ntfs"
Thank you Luis López!
Do you want to participate in our monthly competition and make a contribution to the community?
You just have to send us a mail including the trick or mini-tutorial of your own.

The content of the article adheres to our principles of editorial ethics. To report an error click here!.

6 comments, leave yours

Leave a Comment

Your email address will not be published. Required fields are marked with *



  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Anonymous said

    People talk themselves out of exercising so easily, and the opposite can be so easy.
    'The picture is just as worrying for youngsters - by 2010, it's predicted 22 per cent of girls
    and 19 per cent of boys between the ages of two and 15 will
    be obese, with girls under 11 at particular risk.
    'Being physically active can promote good mental health and help you to manage stress, anxiety and depression.

    Visit my web-site: just click the following web site

  2.   PacheKo Morrison said

    good information thanks, at first it was difficult for me to understand certain procedures, now it is easy, but it is well explained here .. excellent

  3.   anymex said

    for more detailed information consult:

  4.   Leonskb4 said

    Thanks, I didn't remember how it was done 😛

    and I need it for my phone ... not to use applications

  5.   hiccup said

    The article is incomplete ... it only goes as far as obtaining the UUID 🙁

  6.   xapayito said

    And ... how do you mount the partitions?