How To Set Write Permission On ext4 Partition In Ubuntu Linux

ext4 permission UbuntuWhen I last installed Ubuntu 13.04, 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 we’ll see how to set write permission on ext4 partition in Ubuntu, in the correct way. Lets find out how to do it.

How to set write permission on ext4 partition in Ubuntu:

The tutorial is performed in Ubuntu 13.04 and uses extensively command line. A little knowledge about file ownership in Unix 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 we have the name, we 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, we can easily identify the UUID.

Step 2:

Once we 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 display the mounted partitions in the following manner:

ll /media/<user_name>

Replace the <user_name> with your user name. 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. We 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 we’ll 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. :)

  • Michel

    Hi, got my self a htpc with 4x 3tb wd greens (and 250gb sdd for OS)

    I’ve used ‘gpt’ with gparted to create 3 tb partitions in ext4, however using fdisk is suggesting to use gpn instead and won’t show me the UUID.

    With ever growing HDD this might be a problem.

    For now I thinking to just use NTFS instead, although I suspect that it might bring problems with automatic mounting i use 3 tb partitions, since I also need UUID for that.

    Anyway, It’s still a good and easy to follow guide. THX!

    • http://www.computerandyou.net/ Abhishek Prakash

      I am not sure why fdisk does not work for you and I am also not familiar with gpn command :(
      Thanks for liking the post though :)

  • D Flynn

    Your chmod for permissions do not work.

    • http://www.computerandyou.net/ Abhishek Prakash

      Some details would be good to have.

  • Rodolfo

    Step 1, on user account execute, sudo nautilus, modify permision on parittion , exit.

  • Ravenuy

    Excellent I last I did it helped by your excellent guide!

  • Joe

    FYI: I’m in Debian 7.3 and apparently it is in just plain “/media” instead of “/media//”

    • http://www.computerandyou.net/ Abhishek Prakash

      Thanks for the info.

  • Prabhath MP

    Awesome :) Thanks so much for the tutorial. It was very helpful.

    • http://www.computerandyou.net/ Abhishek Prakash

      Welcome

  • ashoke

    Dear Abhishek, I am a Ubuntu lover, but novice. Your tutorial worked like a charm. Out of a dozen recipes I have gone through to solve this problem, yours is the BEST. You deserve a perfect 10/10. I appreciate your knowledge and the will to share it with others. Wish you all the best. Hug and love.

    • http://itsfoss.com/ Abhishek Prakash

      Welcome Ashok :)

  • James W

    Abhishek, this guide was fantastic as I needed it to help me move from XP to Ubuntu. I hope others that are moving away from M$ will find this great tutorial. Forever grateful

    • http://itsfoss.com/ Abhishek Prakash

      Welcome James :)