Mount partition at startup and get write privileges on GNU/Linux

Normally, when you install any type of operating system, your hard disk is partitioned with one or more OS partitions or data partitions.

If you want to read and write data partitions from GNU/Linux OS, you have to follow these simple steps. Suppose that you want to mount /dev/sda2 partion.

  1.  You need the informations about all available block devices of your hard disk to identify the properties of the sda2 partition.
    The lsblk (LiSt BLocK) command reads the sysfs file system and return the needed informations. Thus open a console and type:
    lsblk -f

    where -f option returns info about filesystems, in my case

    NAME   FSTYPE LABEL UUID                                 MOUNTPOINT
    ├─sda1 ext4         ba7acccb-67ce-482d-97c3-40baae3e4a8d /
    ├─sda2 ext4         63ab33e8-43e3-4931-9cda-16cd3be75232
    ├─sda3 ext4         1c95c6fd-fa28-4291-b990-4508bbf696ce /mnt/ubuntu
    └─sda4 swap         a03c9590-74ef-42d2-8c91-2a2ff3aaee5f [SWAP]

    You need the follow info (in this case we will observe the sda2 option):

    • FSTYPE : ext4
    • UUID : 63ab33e8-43e3-4931-9cda-16cd3be75232

  3. You have to decide the folder where to mount the partition, if necessary create it.
    You can create the folder with the simple bash command mkdir (MaKe DIRectory), using root privileges if you want to create the folder into file system directory, like my choice:
    sudo mkdir /mnt/data

  5. Now open your fstab like root via console, with your preferred text editor:
    sudo emacs -nw /etc/fstab

    and add these commands separated by tab at the end of the file:

    • universally unique identifier (device name) :
    • mount point : /mnt/data
    • file system type : ext4
    • options : defaults,errors=remount-ro
    • dump-freq : 0
    • pass-num : 2

    (for more info about fstab, visit the Wikipedia – fstab page), this is my fstab as example:

    # /etc/fstab: static file system information
    # /dev/sda1
    UUID=ba7acccb-67ce-482d-97c3-40baae3e4a8d       /               ext4            rw,relatime,data=ordered        0       1
    # /dev/sda2
    UUID=63ab33e8-43e3-4931-9cda-16cd3be75232       /mnt/data       ext4            defaults,errors=remount-ro      0        2
    # /dev/sda3
    UUID=1c95c6fd-fa28-4291-b990-4508bbf696ce       /mnt/ubuntu     ext4            defaults,errors=remount-ro      0        2
    # /dev/sda4
    UUID=a03c9590-74ef-42d2-8c91-2a2ff3aaee5f       none            swap            defaults                        0        0

    Then Save and Close your fstab.


    Now the data partition will be mounted automatically at startup of your OS. You can read within the partition, but you can’t already write because you haven’t got privileges to do this. So via console type:

    sudo chmod 770 /mnt/data

    where the option 77 represents the read, write and execute (full) permission for user and groups, while the option 0 represents the null permission for other. For more info read the Wikipedia – Chmod page.

    That’s all. After reboot, you can type lsblk and you will see:

    sda      8:0    0 465.8G  0 disk
    ├─sda1   8:1    0  68.4G  0 part /
    ├─sda2   8:2    0 322.3G  0 part /mnt/data
    ├─sda3   8:3    0  68.4G  0 part /mnt/ubuntu
    └─sda4   8:4    0   6.8G  0 part [SWAP]

About Francesco Serafin

I am a PhD student at the Department of Civil, Environmental and Mechanical Engineering at the University of Trento. My two greatest loves: Computer Science and Water (take three with my Lenovo!:D). As a result, the aim of my life is to make both passions coexist. My gpg public key available at

One thought on “Mount partition at startup and get write privileges on GNU/Linux

Leave a Reply

Your email address will not be published.