1

I have set up 16.04 manually and have now two partitions (ext4). My second (and bigger) partition can be written at only by root. Now when I hit sudo su in the terminal and my password, I'm still forbidden access to the folder. I actually think I messed up the partition process... My goal was to have two partitions, one for ubuntu and one for my data. But now everything is on the same (small) partition.

After sudo parted -l I get

Festplatte /dev/sda: 500GB
Sektorgröße (logisch/physisch): 512B/512B
Partitionstabelle: msdos
Disk-Flags:

Nummer  Anfang Ende    Größe   Typ       Dateisystem     Flags
1      1049kB  15,7GB  15,7GB  primary   ext4            boot
3      15,7GB  496GB   480GB   primary   ext4
2      496GB   500GB   4223MB  extended
5      496GB   500GB   4223MB  logical   linux-swap(v1)

3 is the one with the problem.

From
mount | grep 'media/johanna/home'
I get /dev/sda3 on /media/johanna/home type ext4 (rw,nosuid,nodev,relatime,data=ordered,uhelper=udisks2)

  • How are you mounting this partition? – Ravexina May 2 '17 at 18:48
  • When you say "I actually think I messed up the partition process", what happened to make you sat that? What is the result of "sudo parted -l" – user680858 May 2 '17 at 19:07
  • @Ravexina I think I did that with GParted, it's already a while ago and I tried various kinds of doing it. – user293817 May 2 '17 at 19:37
  • @user293817 I mean are you using fstab or something to mount your device? – Ravexina May 2 '17 at 19:39
  • Add the output of this command to your question: grep '^[^#]' /etc/fstab, also specify which device is your hard drive which got the problem. – Ravexina May 2 '17 at 19:43
1

First create a mount-point:

sudo mkdir /media/data

Change the ownership of the mount-point:

sudo chown johanna: /media/data

Set the permissions:

sudo chmod 755 /media/data

Now open the fstab-file:

sudo nano /etc/fstab

Add the following line at the end of the file:

/dev/sda3  /media/data  ext4 defaults  0  2

Press Ctrl+o and then hit Enter

Press Ctrl+x

Close the terminal and reboot. You will be able to write to your mounted partition now without root-privileges.

Note

On german keyboards the Ctrl-key should be the left Strg-key.

Explanation

It looks like you mounted the partition via the desktop-icon or opening the partition in the file-manager. Doing so will automatically create the directory /media/<username>/<partition-name>, the partition-name might be the label of the partition (if one exists) or the UUID of the partition.

This automatically created folder should be owned by and you should have read- and write-permissions, but mysteriously this doesn't seems to be the case. Also, this folder will be removed as soon as the partition is unmounted, if you don't unmount the partition yourself, the partition will be unmounted whenever the system shuts down. This explains that any changes (ownership, permissions) will not survive a reboot.

To ship around this we create a directory which we use as mount-point, adjust ownership and permissions of the directory and at last we add an entry to the fstab-file, so the partition will be auto-mounted at start-up. This directory is not going to be removed when the partition is unmounted.

Addition

I also have the impression that you wanted to set up your installation with a separate /home-partition. It seems you created the partition, but you didn't specify the mount-point (which would be /home) during installation. As the result you got a system with your system-partition and a big, but empty partition. Don't worry, you still can achieve this by copying the contents of the /home-folder to the partition and after doing so changing the mount-point of the partition to /home, here is a nice "How to do that":

https://help.ubuntu.com/community/Partitioning/Home/Moving

  • Thanks, this really solved my problem. I have already copied my home-folder which seems to work fine. If I have any problems with that, I'll have a look at that link. Thanks for the additional info. – user293817 May 4 '17 at 20:23
  • You're welcome, would have answered in German, but we have to keep it in English here. – mook765 May 4 '17 at 21:21
0

That a normal user can't write to a newly created partition is perfectly normal. That root can't access it, though, isn't.

First off: Mount the partition. You will learn why below.

Your mount point should have these permissions, owner, and group:

drwxr-xr-x  25 root root

Navigate to the folder where your mount point is. So if your mount point is /media/john/data, navigate to /media/john in the terminal. Then execute ll. You can get it to have the properties mentioned above by executing these commands:

sudo chown root data
sudo chgrp root data
sudo chmod 751 data

You, however, want access for yourself. So swap root in the first 2 lines out for your own user name:

sudo chown john data
sudo chgrp john data
sudo chmod 751 data

You have to execute these commands when the partition is mounted. When the partition is mounted, these commands modify the properties of the root of the file system of the mounted partition. If nothing is mounted in that folder, the commands modify the properties of the folder on the FS mounted in /media/john (probably the same one as in / on your system). You don't want this.

  • this only helps for the time being. when i unmount the partition and mount it again, I've got the same problem as before. – user293817 May 2 '17 at 22:20
  • This seems weird. To make sure it's not a bug in Nautilus, please check whether the permissions change back after unmounting and remounting. You can mount via sudo mount /dev/sda3 /media/john/data and unmount via sudo umount /dev/sda3. Note that it's umount, not unmount. Please also test whether you can write to the FS from the command line. This command should create a new file whose name is the current date and time. I can't post it here directly because markdown formatting won't work with it. That's why I use a pastebin link. – UTF-8 May 3 '17 at 12:15
0

I think I have a much, much easier way to achieve this (for GUI users), and re-mounting it does work with same permissions. I do everything with Nautilus. Normally the new partition will appear in the left side of Nautilus, and one can click it to mount it, right? For this procedure you start Nautilus as root user, I do this with "gksudo nautilus" (Tip; assign a key combination in system settings, keyboard, custom). Type root password in the dialog. Then mount the drive, click properties, and go to the rights tab (don't know the exact term because my system is in dutch), and change to your preferences. That's it.

If this is not working for you I would remove the partition in GParted and re-create it, and try again, since you have applied several operation on it that maybe could interfere.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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