Only Root can umount

Please reproduce your error on a second machine before posting, and check the error by running without saved changes or extra modules (See FAQ No. 13, "How to report a bug"). For unstable Porteus versions (alpha, beta, rc) please use the relevant thread in our "Development" section.
Post Reply
carlossp
White ninja
White ninja
Posts: 10
Joined: 15 Jun 2011, 21:49
Distribution: v3.2.2
Location: Brazil

Only Root can umount

Post#1 by carlossp » 23 May 2017, 21:13

Hi,

I have a ext4 filesystem that I can mount, read and write as guest, but I cant umount it as guest only as root.

My /etc/fstab has the line:
/home/guest/ext4_file /home/guest/ext4_dir ext4 loop,rw,user,noauto 0 0

The output of the command "mount | grep ext4" is:
/mnt/live/memory/changes/home/guest/ext4_file on /home/guest/ext4_dir type ext4 (rw,noexec,nosuid,nodev,user=guest)

My /etc/mtab has the line:
/dev/loop6 /home/guest/ext4_dir ext4 rw,noexec,nosuid,nodev,user=guest 0 0

The output of the command "ls -ld ext4_dir" is:
drwxr-xr-x 3 guest users 1024 May 23 21:24 ext4_dir/

The output of the command "umount ext4_dir" is:
umount: /home/guest/ext4_dir: umount failed: Operation not permitted

Can someone help me how can I umount as guest user?

Obs. With Slackware 14.1 and 14.2 this configuration works perfectly, I can umount as regular user without any problem.

Thanks
Carlos

fulalas
Contributor
Contributor
Posts: 579
Joined: 26 Oct 2016, 15:34
Distribution: Porteus
Location: Brazil

Re: Only Root can umount

Post#2 by fulalas » 23 May 2017, 23:39

Oi, Carlos :)

Can you unmount an USB stick with guest user?

carlossp
White ninja
White ninja
Posts: 10
Joined: 15 Jun 2011, 21:49
Distribution: v3.2.2
Location: Brazil

Re: Only Root can umount

Post#3 by carlossp » 24 May 2017, 07:10

Hi fulalas,

I booted "copy to ram" and kept the USB connected.
After the boot finished I was able to mount and umount the USB as guest user.

I am using Porteus-v3.2.2

Thank you.
Carlos

fulalas
Contributor
Contributor
Posts: 579
Joined: 26 Oct 2016, 15:34
Distribution: Porteus
Location: Brazil

Re: Only Root can umount

Post#4 by fulalas » 24 May 2017, 22:39

See if this helps:

By default, only the user that mounted a filesystem can unmount it. If you'd like to allow any user to be able to unmount a user-mount filesystem, use "users" instead of "user" in the fstab line. The "owner" option is similar to the "user" option, with the restriction that the user must be the owner of the special file. This may be useful, for example, for /dev/fd if a login script makes the console user owner of this device. The "group" option is similar, with the restriction that the user must be member of the special file's owning group.
(source: https://www.computerhope.com/unix/umount.htm)

There's also a forceful way of unmouting:

Code: Select all

fuser -km /mnt/xxxx
or

Code: Select all

umount -l /mnt/xxxx

carlossp
White ninja
White ninja
Posts: 10
Joined: 15 Jun 2011, 21:49
Distribution: v3.2.2
Location: Brazil

Re: Only Root can umount

Post#5 by carlossp » 25 May 2017, 15:07

Hi,

Still don't work.

I need to mount and umount this filesystem through a script that is run by the guest user.

If I do "losetup /dev/loop7 ext4-file" and change the fstab for /dev/loop7, I can mount and umount as guest, but as I can't "losetup /dev/loop7 ext4-file" and "losetup -d /dev/loop7" as guest, this solution is not good for me.

Note that only with Porteus I have this problem, I use it with Slackware 14.1 and 14.2 without problem.

Carlos

carlossp
White ninja
White ninja
Posts: 10
Joined: 15 Jun 2011, 21:49
Distribution: v3.2.2
Location: Brazil

Re: Only Root can umount

Post#6 by carlossp » 26 May 2017, 08:22

Hi,
I think this is a Bug since it don't work as it should and it works perfect in others Linux distributions.
So, I decided to solve my problem in other way, not so elegant but it works.
I am using "sudo umount" without password inside my script and now the user guest can umout the fs.

If someone find out the reason or solution for this problem, I would like to know.

Thank you fulalas for you help.
Carlos

Post Reply