0

I have a hard disk partition with no mount point and freshly formatted at ext4 file system. I want to store my own files there. But trying to create anything there tells me that permission is denied. I deleted that partition and recreated it only to experience the exact same thing. How can I make that partition usable without any limitations? I have no idea why this is even happening in the first place... The chown command didn't work, without "sudo" it returns permission denied which is hilarious (that is why I am using that command in the first place) and with "sudo" literally nothing happens.

14
  • 3
    If it has no mount point, how are you attempting to store files there? – steeldriver Feb 14 at 2:37
  • Well, I wanted to give it a mount point but apparently, it doesn't seem to be possible with KDE partition manager? What mount point should I assign it if it is just for storing files by the way? I have recently switched from windows and I want that partition to be used for storing anything else with no hassle, but apparently linux is making me jump a few extra hoops for this. – EvilRaceHorse Feb 14 at 2:39
  • Even Ubuntu wiki says that one can have a partition with no mount point for system-independent media files, another OS or anything else. Should that mean "permission denied" if I try to use/modify it? But if I have to set a mount point to it, no problem. But please let me know what mount point I need to set for system-independent miscellaneous files. – EvilRaceHorse Feb 14 at 2:58
  • In that case, what mount point should I assign to a partition that would be used just for storing files? Also, does that mean that if there is no mount point I should not be allowed to use it? Because I do recall very clearly that I used Ubuntu to access files belonging to a windows partition. So, there has to be something else here. – EvilRaceHorse Feb 14 at 3:01
  • I mean, I JUST want to use that partition like I would if it was a random USB drive, or an external HDD, essentially store whatever I want there with no strings attached, what is this insanity with "Permission denied"? It is a freshly formatted partition, whom else am I supposed to get a "permission" from?assign a partition I want to store anything there, be it pictures, music, books or anything else, should I assign a partition depending on the type of the files I will be storing there? Please excuse my ignorance as I am new to linux, in short, this partition has no relation to the system. – EvilRaceHorse Feb 14 at 3:06
2

Addressing your questions:

The way I understand it, the lubuntu file manager doesn't let one use any partition that doesn't have a mount point unless one has root access.

and

I never would have had to change permission to a brand new-formatted hard disk as if it is owned by someone else.

  1. It's not about Lubuntu. This works like this in Ubuntu and at least several other Linux distributions.
  2. This is not about the file manager. Command line access also works like this.
  3. It's not about the disk or the partitions. It's about the folders. (And later on, the contents of those folders too, like files and subdirectories in them. But that comes later.)

Do an experiment:

sudo mkdir /mnt/test_dir_1

or, to demonstrate that it's not related to /mnt at all, another one directly in /:

sudo mkdir /test_dir_2
  1. As you have seen, sudo was needed to create these directories.
    • Nothing is mounted, nothing is about disks; these are just normal directories.
  2. Now go ahead and try to copy anything into these directories.
    • Errrr. Permission denied. You need sudo to change the contents of these directories at all.

Why is that? Because you have created them with sudo. And you had to use sudo because they are outside your /home/<YOURUSERNAME> directory. You get to freely move things around and change files only in your user's own directory. Elsewhere you get restricted very soon.

/mnt/, /mnt/test_dir_1, and /test_dir_2 are outside of your home directory, and therefore restricted areas for your user. You need sudo to put or modify anything in there. In most of the places you get at least a read permission without sudo: listing contents and opening files are allowed. But changing anything requires sudo. This is standard Linux stuff. Later on we will get to why it works like that.

The funny thing is, without root access I couldn't even modify the fstab file.

Now you see why. the /etc/fstab file is in /etc, a highly restricted system folder.


Now comes a different experiment. Follow along:

# This creates an empty text file:
sudo touch /mnt/test_dir_1/test.txt

# This lists the contents and shows you the new file in there:
ls -l /mnt/test_dir_1

Now when you mount a partition, then things can get a bit (more) confusing.

Mounting a partition to /mnt/test_dir_1 somehow replaces that directory with another one, one that represents the partition.

test.txt will disappear from /mnt/test_dir_1, while the partition is mounted there.

When you unmount the partition with the umount command, the original contents "return", and you get to see test.txt in there again.


On to:

when I did use the chown command with sudo, nothing happened, neither did it fix the problem. It just accepted the command but didn't react to it in any way.

When chown manages to run without any issues, it does not return any message.

The reason you might have not perceived any change afterwards, could be that all the contents in there were already impacted by the fact that you have previously used the file manager as administrator, to create and modify them. Now all that content belongs to root, not you. Permission is still denied to your user, you still need sudo to modify them.

Theoretically,

sudo chown -R YOURUSERNAME:YOURUSERNAME /mnt/my_stuff

(note the -R part, for recursive) should fix that.

By now, you may notice that it makes an important difference whether the partition is mounted on this directory or not, when you issue this command.

For a good measure, in this specific case, you can run it in both cases. Once when the partition is not mounted, and once when it is. That should do it.

How can you form an idea about ownership and permissions?

Use the ls -l command to list stuff in a directory. That shows you.

Let's use our previous example where we used sudo touch to create a text file.

ls -l /mnt/test_dir_1
-rw-r--r-- 1 root root 0 Feb 14 16:26 test.txt

This line shows you that the test.txt file is owned by the root user belonging in the root group.

# This will change the ownership of all contents, giving them to you.
sudo chown -R YOURUSERNAME:YOURUSERNAME /mnt/test_dir_1

ls -l /mnt/test_dir_1
-rw-r--r-- 1 YOURUSERNAME YOURUSERNAME 0 Feb 14 16:26 test.txt

But why does it all have to work that way?

I believe it's for system security. When you log in, you end up as your regular non-sudo user.

Any command that is issued, and any script that is being run, is being done so as your user. If you want to do anything that would impact the system itself, you have to authenticate first, with your password, triggered by sudo before commands.

Thing is, scripts can sometimes run without your knowledge. Potentially malicious scripts might find their way onto the computer, might run in the background, and try to change the system. But thanks to this system of restrictions nearly everywhere, an evil script will not get far compromising the system. Because everything is protected by this system of ownership and permissions.


A theoretical demonstration for this kind of defense could be a case called "arbitrary code execution" vulnerability. It can happen to various programs that process data that is originating from outside of your computer; like content originating from the internet.

Video codecs can sometimes suffer from this kind of vulnerablity. When you watch a maliciously prepared video, the video stream may contain a "booby-trap" for the video-parser codec that the video-player app uses. That can trick the codec/player into a so-called "arbitrary code execution" state, where a "script" is being spawned and being run on your system.

Then it's important that the video player app is being run by your user. That way the spawned and executed malicious code will also be run on behalf of your user: Without having the sudo password, the script will end up failing to meet its goal.

A long-term defense of course is to keep updating packages on the system. As soon as such vulnerabilities are identified in software, an update is being released for them, and the new, improved version replaces the old vulnerable one.

But the system of controlled ownership and permissions nicely held your system together even before installing the security update.

But it seems inconvenient

You could say, like tens of thousands of novice Linux users before you: "Now I will be smart, and run everything as root / administrator, so I will never have to worry about passwords."

  1. It will compromise the security of the system, from day one (I have added an example, just above).
  2. Directory and file ownerships may end up in a sorry mess that will need extra work to sort out.

Don't get tempted; instead, recognize that this system is in place for your long-term enjoyment of your operating system. Get used to it.

What you can do to make your life easier is choosing a password that is easy and quick to type. When it becomes muscle memory, you will even draw reassurance from it.

2
  • I must say I seem to have a lot better understanding compared to yesterday. I don't mind small "inconveniences" like these if I understand the principle behind them. I was first concerned if it would let me manipulate the data of a USB drive or an external hard disk and it fortunately works without root access, as I can create/delete folders and files there. But how would always having root access compromise the system? I understand that in principle but if one is only downloading programs from the official repositories, where would the danger come from? – EvilRaceHorse Feb 14 at 16:30
  • "if one is only downloading programs from the official repositories, where would the danger come from?" — with time, as you use and build and customize your system, you may be tempted to install stuff not only from the official repositories. There are PPAs, (private package archives), there are extensions on github.com; Hardware vendors may supply drivers that you want to install; software may arrive from a lot of places. – Levente Feb 14 at 16:35
0

I am surprised that no one suggested this yet. It turns out that PCManFM-Qt File Manager does not open by default with root access. Going to "Tools" => "Open as Root" fixed this issue. No partitioning necessary as I expected.

5
  • That does not seem to be a good solution. Instead, you need to use the sudo chown command. If you have mounted it outside your user's home directory (which is not a bad idea), then you need to run sudo chown YOURUSERNAME:YOURUSERNAME /whereever/you/mounted. This is needed only once. – Levente Feb 14 at 8:00
  • The links oldfred offered in the comments above are useful and important. You might need to learn a bit about how directory and file permissions work on Linux. – Levente Feb 14 at 8:06
  • (You probably have not been the owner of the directory you were trying to access. The chown command means to "change owner".) (It's not about the partition; that's unrelated. It's just about the directory that you have mounted that partition to.) – Levente Feb 14 at 8:13
  • Well, when I did use the chown command with sudo, nothing happened, neither did it fix the problem. It just accepted the command but didn't react to it in any way. The way I understand it, the lubuntu file manager doesn't let one use any partition that doesn't have a mount point unless one has root access. I'd appreciate if there is a user friendly resource on how permissions and directories work on Linux as this is totally new to me. I never would have had to change permission to a brand new-formatted hard disk as if it is owned by someone else. – EvilRaceHorse Feb 14 at 14:08
  • On the other hand, when I went to the properties of that folder, it said "root" for the owner, that should have been my clue that root access is warranted if I am to access/modify those contents. But I have connected that partition to /home eliminating the need for root access in the first place. – EvilRaceHorse Feb 14 at 14:10
0

There seem to be confusion about mounting.

After your installation is complete, you don't need to keep going back to a disk / or partition manager program any more.

You should be able to mount partitions at any time using just the terminal. For example something like this:

sudo mkdir /mnt/my_stuff
sudo chown YOURUSERNAME:YOURUSERNAME /mnt/my_stuff

then

sudo mount /dev/sdaX /mnt/my_stuff

Here you mount the example partition /dev/sdaX to the /mnt/my_stuff directory. (But you have to create this target directory first, and change its ownership to yourself (with chmod)).

To determine the exact partition identifier, you can use the command:

sudo lsblk -e 7

After you have done this, you cannot say it has no mount point. Now it's mounted. Now it has a "mount point".

What you probably meant was that there was no assigned mount point at installation time, but that's not very important. That just means, that if you want this to survive a reboot, you will have to add an entry to /etc/fstab manually. That makes the mounting automatic on each boot. Look here for a well-contained small example. Then search the net for the term "etc/fstab examples explained" or something. Also read about the mount options.

Consider all this just an introductory step to the links that @oldfred offered in his comment:

Storing data on second HDD, mounting and Installing all applications on a SSD disk and putting all files on HDD disk

Now you are well-prepared and patient enough to deal with the info in them.

3
  • Inbefore new question about the ownership of the content that you have already copied to your partition while running the file manager as administrator: you will have to fix the ownership of all those stuff, because they are owned by root now. The recursive option of chown will probably help. – Levente Feb 14 at 8:58
  • I have an idea. If you have sudo chown'ed the directory before mounting, but after mounting it still says no permission, go again with a sudo chown -R YOURUSERNAME:YOURUSERNAME /mnt/my_stuff. The part -R makes it recursive and applies at everything within. – Levente Feb 14 at 10:00
  • The funny thing is, without root access I couldn't even modify the fstab file. Normally, if I launch something "important" it will ask for a password and afterwards grant me root access. The file manager doesn't do this by default. It starts without root access and one needs to give that command manually. I think it is better to ask for a password and then give root access to save oneself the hassle. – EvilRaceHorse Feb 14 at 14:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.