How To Set Write Permission On ext4 Partition In Ubuntu Linux

ext4 permission Ubuntu

When I last installed Ubuntu, I made an ext4 partition of around 80 Gb in notebook’s HDD.

The problem arouse when I tried to copy something on this partition. I was simply not able to copy anything in it or create a new file.

Apparently, I did not have ‘write permission’ on the said partition.

In this tutorial I’ll show you how to set write permission on ext4 partition in Ubuntu, in the correct way. Let’ssee how to do it.

How to set write permission on ext4 partition in Ubuntu:

The tutorial is performed in Ubuntu and uses extensively command line. A little knowledge about file ownership in Linux system would be a plus. Even if you do not know, no worries. You can still follow the tutorial with ease. Just follow the steps below:

Step 1:

First this, you need to know the UUID of the ext4 partition. But before that it will be better to know the name of partition.

The name, in Ubuntu, would be like sdaX or something. To find that, use the following command in terminal (Ctrl+Alt+T):

sudo fdisk -l

Output of the command will look like this:

Check the disk partition in Ubuntu

You can find the name of the partition from its size, given under the Blocks field (in bytes). So in the picture above 78123008 roughly amounts to 78 Gb and thus it tells me that the partition name is sda7.

Now when you have the name, you can find the UUID by using the following command:

sudo blkid

Output of the command looks like this:

Check the disk partition in Ubuntu

As you can see, with the partition name, you can easily identify the UUID.

Step 2:

Once you have the UUID, the next step is to find out where is the partition mounted.

Usually the location of the ext4 mount is /media/<user_name>. Where user_name is your own username.

You can also use $USER variable. It automatically takes your username.

You can display the mounted partitions in the following manner:

ll /media/$USER

The output of the command for me was this:

Check the mounted drive

Now you see why I took the trouble of finding the UUID. If you have several partition mounted, you need to distinguish between them.

You can also see that only root has write on the mounted ext4 partition. You need to change the write permission for this partition here.

Step 3:

Now the easiest option is to give the write access to everyone using the infamous chmod 777.

But again, you won’t want to do that as it will give write access to anyone. Avoid using chmod 777 as far as it is possible.

Now, if not chmod 777, then what else? The file has root as owner and root as the group. Even ‘admin’ comes under ‘other’ group here.

What you can do do here is to change the group ownership of the mounted drive to admin. The admin group is generally named adm. You can use the following command to change the group owner:

sudo chgrp adm /media/itsfoss/56d0c0ab-60a0-48bf-955d-bc2f283009b6

Once you have changed the group, change the write permission for the group in the following manner:

sudo chmod g+w /media/itsfoss/56d0c0ab-60a0-48bf-955d-bc2f283009b6

Voila! Now you can copy-paste and create new files in the ext4 partition without any hindrance. And with added security, non-admin users will not be able to do so.

This tutorial is similar to what you need to do in order to auto mount Windows partition in Ubuntu. Any questions or suggestions are always welcomed. :)

Similar Posts

  • I have unsuccessfully attempted to apply your insrtruction in linux mint (latest LT version). My effort is as follows:

    [email protected]:~$ sudo fdisk -l

    Disk /dev/sda: 1.84 TiB, 2000398934016 bytes, 3907029168 sectors
    Disk model: ST2000DM008-2FR1
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 4096 bytes
    I/O size (minimum/optimal): 4096 bytes / 4096 bytes
    Disklabel type: gpt
    Disk identifier: FC177D94-DBD5-472F-9A2C-EF790ECE16DE

    Device Start End Sectors Size Type
    /dev/sda1 2048 1050623 1048576 512M EFI System
    /dev/sda2 1050624 3907028991 3905978368 1.8T Linux filesystem

    Disk /dev/sdb: 3.65 TiB, 4000787030016 bytes, 7814037168 sectors
    Disk model: ST4000DM004-2CV1
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 4096 bytes
    I/O size (minimum/optimal): 4096 bytes / 4096 bytes
    Disklabel type: gpt
    Disk identifier: 3D59D690-C94D-4F6C-B965-574D92E942FB

    Device Start End Sectors Size Type
    /dev/sdb1 2048 6152148991 6152146944 2.9T Linux filesystem
    /dev/sdb2 6152148992 7814035455 1661886464 792.5G Linux filesystem

    [email protected]:~$ sudo blkid

    /dev/sda1: UUID=”224B-59DD” TYPE=”vfat” PARTLABEL=”EFI System Partition” PARTUUID=”82b147d1-11f1-462d-bd19-0cf6e495c8a9″
    /dev/sda2: UUID=”5f8c4ca5-7afc-4137-804f-2af761eaa2e5″ TYPE=”ext4″ PARTUUID=”c6ddc79c-ba80-48f0-93c0-9d253fed0f6b”
    /dev/sdb1: LABEL=”BACKUP” UUID=”3ccd7087-dde9-4c8a-9935-3e93e14e201c” TYPE=”ext4″ PARTUUID=”c278381d-0fed-4de5-ac3d-e192eb07d5c3″
    /dev/sdb2: LABEL=”SNAPSHOTS” UUID=”144afc05-0a55-4f9d-9816-aa804b649353″ TYPE=”ext4″ PARTUUID=”8275a151-38c8-4a8c-ac4d-98885214acdb”
    [email protected]:~$ ll /media/mack
    total 12
    drwxr-x—+ 3 root root 4096 Nov 18 23:59 ./
    drwxr-xr-x 3 root root 4096 Nov 15 22:48 ../
    drwxr-xr-x 3 root root 4096 Nov 18 01:59 BACKUP/

    [email protected]:~$ sudo chgrp adm /media/mack/3ccd7087-dde9-4c8a-9935-3e93e14e201c

    chgrp: cannot access ‘/media/mack/3ccd7087-dde9-4c8a-9935-3e93e14e201c’: No such file or directory
    [email protected]:~$

  • I am not able to change permissioon :(
    please help me ot sir
    this message is shown

    sudo chgrp adm /media/$USER/222a22ee-7f5b-46b1-a668-5d80ef7c92a8
    chgrp: cannot access '/media/kamran/222a22ee-7f5b-46b1-a668-5d80ef7c92a8': No such file or directory