How to change the permissions for a disk partition?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
How to change the permissions for a disk partition?
I have created and formatted a disk partition with GParted. The problem is that this new partition is marked as read-only by default, so I am not able to write on it. To be more precise, it appears to be read-only for all except the root user. I have found a drop-down menu in the file manager to change permissions, but when I try to apply the change it does go through, probably because I am not running the file manager as root. And yet, when I ran it as root, that partition is not even listed in the file manager. What is going on? I am sure that the partition is there, no doubt about it.
In short, how can I change the partition's permission to make it accessible and writable by anyone?
Please suggest some easy solution, possibly one that does not involve the command line.
Formatting the partition has created a filesystem. You need to mount the filesystem for it to show up in Nautilus and to be able to read and write files. If you have the Gnome Disk Utility you can used it to mount the filesystem.
In short, how can I change the partition's permission to make it accessible and writable by anyone?
Please suggest some easy solution, possibly one that does not involve the command line.
In short, how can I change the partition's permission to make it accessible and writable by anyone?
Please suggest some easy solution, possibly one that does not involve the command line.
Thanks
That's gonna be difficult as I've had to use the command line to get permissions on my newly created partition.
But the thing is, all you need to do is cut and paste the correct command on the command line.
Hopefully, you've assigned a label (name) to the partition.
Open the terminal as root and use this command:
Code:
lsblk -o name,mountpoint,label,size,uuid
This should list all your partitions including your newly created partition. As an example, let's say it's sda9.
Now mount the new partition to your 'user' directory (as opposed to the root directory).
Code:
mount /dev/sda9 /home/user/Public
Of course, you would use your own username instead of 'user'.
Also, 'Public' is an empty folder on my file manager. You may want to create a new empty file so your new partition appears under that file.
Now give user ownership to the newly mounted partition. Where it says 'user', you'll be putting in your user name.
Code:
chown user -R /home/user/Public
This should now give you read/write permission for the new partition.
This is a quick and easy method and you'll have to do it every time you boot up.
There is a more permanent method by adding the partition to your fstab file.
If you want to unmount the new partition, then it's simply:
Code:
umount /home/user/Public
Again, 'Public' is an example directory I'm using.
Last edited by trumpforprez; 04-01-2017 at 11:45 AM.
Distribution: Currently: OpenMandriva. Previously: openSUSE, PCLinuxOS, CentOS, among others over the years.
Posts: 3,881
Rep:
Quote:
Originally Posted by Grabby
I have created and formatted a disk partition with GParted. The problem is that this new partition is marked as read-only by default, so I am not able to write on it. To be more precise, it appears to be read-only for all except the root user. I have found a drop-down menu in the file manager to change permissions, but when I try to apply the change it does go through, probably because I am not running the file manager as root. And yet, when I ran it as root, that partition is not even listed in the file manager. What is going on? I am sure that the partition is there, no doubt about it.
In short, how can I change the partition's permission to make it accessible and writable by anyone?
Please suggest some easy solution, possibly one that does not involve the command line.
Thanks
If it's a fixed disk, it sounds like root owns it, and therefore that would explain why it's read-only. So you would (as others have said), need to assign the appropriate permissions to it. In that case you would assign them to the mount point it is mounted to, but in that case I would also recommend you create a folder somewhere (and mount your new partition to that folder) and assign the appropriate permissions to that. And then add it to /etc/fstab
It is how it's mounted that determines it's permissions. And basic unix permissions apply beyond that, for unix based filesystems. You can use umask when you mount it as root to give permissions to others. You can put it as an entry in /etc/fstab and when a user mounts it, that user has access to it. I find it simpler to just make directories on the / of the partition and assign them owners:groups that are usable by the users.
umask is kind of an odd one, it's the permissions you don't want available. So, umask=0222 means that it cannot be written to. Where 4=read, 2=write, and 1=execute, so rwx = 111 in binary or 7 in decimal. But for umask it would be the xor / binary opposite so rwx=0.
you too can if it is just for your use instead of 766 if root created it then only root can still read write and execute within it.
you need to chown and give it a user and a group that if you want more than one to be able to read,write, and execute out of it too.
Then the others are added to that group that is attached to that partition giving them all of the permissions attached to that group within it, or you can set it up for directories within that partition too. All depending on how you want to slice and it a dice it.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.