0

I am in folder /datadrive/ which is the mount point of /dev/sdc1 (in /etc/fstab I have /dev/sdc1 /datadrive ext4 defaults,nofail 1 2) and whenever I try to make any operation in this folder (e.g. mv, cp, touch...) the root privilege is required (sudo). I guess this is because the file system is "read-only" (sorry for my ignorance, but I am not sure about that).

Since that I am going to execute many scripts, I would like to convert the file system here in what I guess is called "read/write", so that sudo is not anymore required (correct me if I'm wrong).

I already tried with sudo mount -o remount,rw '/datadrive/' without any effects. Do you have any idea so on how to remove the sudo requirement?

EDIT

With ls -l I get:

total 52
drwxr-xr-x 10 1002 1002  4096 Feb 22 15:53 ./
drwxr-xr-x 24 root root  4096 Feb 22 16:13 ../
drwxrwxr-x  5 1002 1002  4096 Feb 22 16:04 NGS-SparkGATK/
drwxr-xr-x  3 root root  4096 Feb 22 15:36 delete/
drwx--x--x 14 root root  4096 Feb 22 16:13 docker_var/
drwxrwxr-x  9 1002 1002  4096 Jan 22 15:18 fastq/
drwxr-xr-x  6 root root  4096 Feb 22 15:54 libraries/
drwx------  2 root root 16384 Sep 25 13:23 lost+found/
drwxrwxr-x  4 1002 1002  4096 Nov 14 11:37 reference/
drwxrwxrwt 16 root root  4096 Feb 21 12:53 tmp/
5
  • 1
    Can you edit and add the output to the following command ? ls -l /datadrive It seems to be a permission issue.
    – Félicien
    Feb 22, 2018 at 16:48
  • The requirement of sudo is not related to whether the device is mounted read/write or not. However, /dev/sdc is the primary device (not the partition, which would be /dev/sdc1 for example), and it's the partition which gets mounted at another location. Given your mount command example with /datadrive/ I presume that is the actual mount path? Please edit your question and explain which file system the partition is. Likely you mounted as root without setting appropriate permissions options when mounting.
    – dobey
    Feb 22, 2018 at 16:49
  • Updated, if I didn't answer correctly to your questions, ask me please!
    – Vzzarr
    Feb 22, 2018 at 17:09
  • Ask the system how /datadrive is mounted: grep /datadrive /proc/mounts
    – waltinator
    Feb 22, 2018 at 17:44
  • @waltinator /dev/sdc /datadrive ext4 rw,relatime,stripe=32748,data=ordered 0 0 seems to be Read/Write, so the problem is not in file system type, it must be something else...
    – Vzzarr
    Feb 22, 2018 at 17:49

2 Answers 2

4

As you can see from your ls -l output, the files are owned by user root and group root, or the unknown uid/gid 1002, and are not world writable.

You can change the owner to your current user, using the chown command, for all the files and directories on the partition. Use man chown for documentation on how to use the command.

1
  • thanks man! It was necessary to use chown -R user /datadrive/, where "user" is the name of the user who logged to the VM. Feel free to report the command in your answer, to help next users :)
    – Vzzarr
    Feb 22, 2018 at 18:57
0

From man mount:

  defaults
          Use the default options: rw, suid, dev, exec, auto, nouser, and async.

And

   The non-superuser mounts.
          Normally, only the superuser can mount filesystems.  However, when fstab contains the user option on a line, anybody can mount the corresponding filesystem.

          Thus, given a line

                 /dev/cdrom  /cd  iso9660  ro,user,noauto,unhide

          any user can mount the iso9660 filesystem found on an inserted CDROM using the command

                 mount /dev/cdrom

          or

                 mount /cd

          For more details, see fstab(5). 

Replace the defaults keyword in the /datadrive /etc/fstab entry with rw,suid,dev,exec,auto,user,async. Read man mount again and consider changing to ...nosuid,nodev,noexec...

1
  • thanks for your answer, anyway now the line is /etc/fstab is /dev/sdc /datadrive ext4 rw,suid,dev,exec,auto,user,async,nofail 1 2, but even after rebooting I still have to use sudo for example, for create a file (sudo touch example.txt). Moreover in another VM I have the same parameters used in the /etc/fstab's line, so I guess the problem is not here
    – Vzzarr
    Feb 22, 2018 at 18:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .