contador web Skip to content

How to configure disks and partitions on Linux using FSTAB

When I was learning Linux, I remember reading somewhere that said, "In Linux all are files"And whether or not, in fact, the entire system configuration is usually done through" simple "text files, configured to do everything you see on your screen works as it should. files the File Systems Table (FSTAB).

Even if you never even thought about it, your Linux distribution does, every time you turn on your computer and boot into the operating system, mounting your disk partitions, your SWAP and where each thing is. This is an automatic process that takes place based on the information contained in a file in the directory. / etc / fstab.

Configuring FSTAB

What makes many people afraid of FSTAB is that it is a really unclear file, especially compared to others out there that have several commentary lines telling how to work with the information contained within themselves.

My most basic advice : Face FSTAB as what it: a table. The name TAB (of Table) is not there at all. When opening it, for ease, try to visualize the columns and rows, this will help a lot.

You can open it with any text editor you want, such as gedit, xed, plume, among others, but how about play at the terminal a little?

You can take a quick read of what is contained in your FSTAB with this command:

cat / etc / fstab

This should bring you information similar to this:

FSTAB Linux FSTAB is responsible for setting up your own system, so it is a very "sensitive" file, if you are just studying, I recommend do it on a virtual machine.

Another possibility to back up the file before you start editing it, for example:

sudo cp / etc / fstab / etc / fstab-bkp

If you need to use this backup file, put it back in place like this:

sudo cp / etc / fstab-bkp / etc / fstab

Let's use a simple text editor available for all Linux distros to edit FSTAB, Nano. To open the file with properties suitable for modification, use:

sudo nano / etc / fstab

Or run the command as Root if your distro does not have its user inside sudoers.

Understanding FSTAB

This is the primordial point. As you have already reported, FSTAB is nothing more than a table (even though it doesn't have much of that camera initially), each column supports some different information. Just them: FSTAB Configuration I actually put this example in a table to be a little clearer, but it's worth noting, often in place of "/ dev / sda1"example, there may be the device UUID, similar to this: UUID = 04b60adc-ccc2-406e-9cbb-fb80f9c4e5fb. In the end, that's a bit of a mess, but you can mount your disks and parties just by knowing their names, using the command:


Notice the names below the "NAME" column and next to it you can see the size and type if "read only" (RO) and if it is already mounted somewhere in "MOUNTPOINT".

Before we process it, it is important that you know some of the options involving the FSTAB columns:

File System: It may contain the device's UUID or its address. Devices such as parties and records are always on / dev in the Linux world, so a partition (like this 1.4T in the image above) could be found in / dev / sdc1.

To verify the UUID of a partition to use in place of the address, use the command:


Mount Point: It is simply the place where the partition or disk is mounted. It can point anywhere on the system from the root (/). Usually devices automatically mounted by the system, such as flash drives, external hard drives, etc. are mounted on /averagebut when this is done manually it is common to use the directory / mntBut really, you can ride anywhere you want.

Type: In that column you should enter the file system type of each disk, you can see which file system your partition uses with the command:

sudo file -s /dev / sdc1

Note that the underlined part must be changed by the path of the unit you want to observe, to know what unit names you can use the command we showed earlier, the lsblk. This command "file -s"may still be useful for you to figure out the disk UUID, as well as let you see which file system your disk is formatted in.

Some common ones would be:– ext4- swap– ntfs-3g– vfat-btrfs– ntfs– self

If for some reason you don't know or couldn't figure out which one filesystem from the disk, you can try using the "self", which tries to guess the format at the time of mounting.

Options: In this column of FSTAB you will add the mounting options that exist. There are several different options, I'll list some of the most common here. Several options can be used on the same line by simply adding a comma just between each one, without the need for space.

– auto / noauto: This option allows the device to be mounted automatically during system boot, with "self"The default option, if you don't want the disk to be mounted during boot, you need to explicitly say that you don't want this by setting the option"noauto"

– dev / nodev: Indicates whether or not the disk or partition should be considered a device that contains a "special" file system. Usually the "nodev"Used on systems that have public access and such an option prevents any user from making certain changes, such as creating a"device file"

– exec / noexec: As you can see, the options until they are simple to understand, one allows something, the other denies. In this case you can allow or deny that binaries on that partition or disk are executed.

– rw / ro: If you associate with their meanings it's easy to understand, rw (read and write) and ro (read only).

– user / users / nouser: In this session we can have three options. To dust "user " allows any user to mount this file system, which automatically activates other functions such as noexec, nosuid and nodevUnless you advise otherwise. If the option "nouser"is specified, only the root can mount this file system, if the option "users"is selected, any user within the group users be able to mount the device.

– defaults: As the name suggests, this option uses the distro's Linux / defaults. The default setting is set according to the file system. This usually means that the options will be equivalent to rw, suid, dev, exec, auto, nouser, async. – owner: Allows only the device owner to mount it, ie who created the file system.

There are many other options available, and a nice read to do about this can be on the pages:

Ubuntu Community HelpArchWikiDebian Wiki

Dump: In this column you can indicate by one (1) or zero (0) whether the drive being mounted should receive a backup of the dump program. Setting Zero indicates that this file system will never be automatically "backed up" in this way, in some cases, I need to see if the dump is installed in the distro.

Pass: The number added on this line indicates the order in which the number fsck will check the disk for errors at boot time.

1 – Check this partition first. 2 – Check after checking the first.

This concludes the explanation of each of the most popular options for mounting a partition. For you to understand a little better, let's go to a practical case.

Mounting a disk and adding to FSTAB

Let's go back to the part where I showed the command "lsblk"Let's say I want to mount my 1.4TB" sdc1 "partition via FSTAB at boot time.

First let's create the ideal environment for mounting. I will do my assembly inside / mnt, So I will create a folder within this directory to mount my disk, so everything is organized. This 1.4TB disk is a backup HD, so I'll call the folder "Dice"

sudo mkdir / mnt / data

The above command creates a folder, or directory, inside my folder. / mnt with the name "Dice", so now let's indicate this mount point in the fstab, let's edit it using the nano editor.

sudo nano / etc / fstab

FSTAB configured
Can you see the idea of ​​the table in action now? πŸ™‚

At the nano You must navigate using the arrow keys on your keyboard to the last line and enter the data of the partition you want to mount, in my case:

Indicating, in order, the disk I want to mount (/ dev / sdc1), where I want it to be mounted (/ mnt / data), which disk file system (ext4), defaults and dump and pass set to zero (0).

You can also make comments (as I did in the image above) add a # and then write whatever you want. Everything that stays in this line will be ignored when reading the fstab By the system, these comments are only for human interaction and better understanding.

At the nano You generally use the Ctrl (Control) key combined with some other key to perform a function, but you can here to exit and save by pressing "Ctrl + X ", the editor will ask you if you want to save the file, press the "S" (YES) and overwrite your fstab giving "enter"

Tip: Be careful not to change the file name, it should keep calling itself. fstab!

Very well, in fact, now if you restart your computer your partition or disk would be mounted in the given directory, but you can do this manually to mount the device right now using this command:

sudo mount -O / dev / sdc1 / mnt / data

Remembering that "/ dev / sdc1"must be changed to the nomenclature that corresponds to your disk and"/ mnt / data"must be changed by path and folder name where you want to mount.

This gives you all the information you need to mount your server partitions, or even your desktop distro, if you are "more root".

Making assemblies for graphical interface

There are some people who get a little stuck to "old way"of doing things, and this is not always the easiest way. Of course, if a server, if you are a professional or a student of Linux another story, but if you have an interface in front of you and want to mount your disk and nothing Plus, nothing prevents you from using an interface.

There is a GNOME utility that comes with most distros called "GNOME Disks", the package name is usually "gnome-disk-utility"or"gnome-disks"and you will find it in the repository of any distro. When the system is translated to Portugus, you will usually find it in the system menu looking for"Records"


It is very cool software, it has several features to let you know about your discs. You can see party designs, sizes, formats, file systems, types, benchmarks, disk health tests, and much more. Really fantastic.

One of his features is to control the mounting of discs, so that everything we've done "on the nail" before can be done through a simple but powerful interface.

To follow the same example, let's say I want to mount my 1.4 (1.5) TB drive automatically with the system, just click on the disk on the left, then you can click on the gear icon and go to "mounting options"where you will find various configuration options, many of them related to what we learned throughout the post.


It is interesting to see the evolution of Linux in this sense, the level of customization to do what you want with the system configuring only sensational files, also curious to think that for some decades the only way to do certain things was via terminal and these configuration files. Today everything can be simpler and more beautiful, but the power of the command line remains there for those who want to take it.

See you next time!

_____________________________________________________________________________ See any errors or would you like to add any suggestions to this article? Collaborate, click here.