LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 10-29-2022, 01:31 AM   #1
Johng
Member
 
Registered: Feb 2002
Location: NZ
Distribution: Kubuntu, Mint
Posts: 408

Rep: Reputation: 31
Auto mount usb drive


I am using Kubuntu 22.04 and found that all partitions on three drives were being auto mounted. I found a site that said I could stop this by issuing the command:
Code:
systemctl mask udisks2
I did this, and it worked, and no drives were mounted on rebooting except those in fstab

However, when I plug in a usb drive, nothing happens. So I tried reversing the command with
Code:
systemctl unmask udisks2
I get an error
Quote:
Unit udisk2.service does not exist, proceeding anyway.
Failed to unmask unit: Connection timed out
Rebooting, no drives are mounted, and inserting a usb drive draws a blank.

How do I get usb auto mounting working again??
 
Old 10-29-2022, 09:04 AM   #2
kilgoretrout
Senior Member
 
Registered: Oct 2003
Posts: 2,990

Rep: Reputation: 388Reputation: 388Reputation: 388Reputation: 388
Quote:
I am using Kubuntu 22.04 and found that all partitions on three drives were being auto mounted.
That's not my experience with kubuntu 22.04. Items not listed in fstab are not auto mounted on both a fresh install of 22.04 and an upgrade install from 20.04. It's probably a kde configuration issue. Check in System Settings > Removable Devices > Attached Devices. You may be able to get your desired behavior re auto mounting by setting things up in there. Note, for me, something odd is going on in System Settings > Removable Devices > Attached Devices. Partitions which are not on removable media(i.e. are on drives installed in the box) are listed under Attached Devices.
 
Old 10-29-2022, 10:06 PM   #3
Johng
Member
 
Registered: Feb 2002
Location: NZ
Distribution: Kubuntu, Mint
Posts: 408

Original Poster
Rep: Reputation: 31
Thank you kilgoretrout
It's all very confusing. Comparing initial installs: Kubuntu 20.04 does not auto mount partitions. However a Neon 5.6/Ubuntu 22.04 does auto mount available partitions. The Neon Settings/Hardware/Removable Storage/Attached Devices is not editable. I don't know why or when my Kubuntu 22.04 suddenly decided to mount other partitions. I suspect I have seen this happen on other Mint install also. Kubuntu 22.04 Settings has a menu item Storage Devices, which enables editing mount at log on. I have seen it stated on web sites:
Quote:
The Auto-mounting of disks in Debian-based Linux distros (and perhaps others) comes from a service called udisks2.
However, I created my problem making a typo, as indicated by the error message referred to in my first post. I omitted an 's' in udisks2, and restored usb mounting with:
Code:
systemctl unmask udisks2
 
Old 10-30-2022, 10:17 PM   #4
Johng
Member
 
Registered: Feb 2002
Location: NZ
Distribution: Kubuntu, Mint
Posts: 408

Original Poster
Rep: Reputation: 31
I am still vexed by Kubuntu 22.04 insisting on mounting all partitions at boot.

System Settings, Removable Devices, lists all attached devices (partitions), with two columns of boxes on the right labelled 'On Login' and 'On Attach'. None of these is checked, which suggests none will be mounted. BUT on booting they are all mounted. Does this matter? Yes if you want to keep data on those partitions safe.

The only way I have found to stop auto mounting all partitions is to issue the command
Code:
systemctl mask udisks2
The problem then is that when plugging in a usb device it cannot be mounted!
 
Old 10-31-2022, 08:52 AM   #5
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,161
Blog Entries: 6

Rep: Reputation: 1836Reputation: 1836Reputation: 1836Reputation: 1836Reputation: 1836Reputation: 1836Reputation: 1836Reputation: 1836Reputation: 1836Reputation: 1836Reputation: 1836
Quote:
The problem then is that when plugging in a usb device it cannot be mounted!
Why? How are you trying to mount it manually?

Issue:
Code:
dmesg -w
Plug the usb device in, see what device node it is, mount it.

Example:
Code:
mount /dev/sdb1 /mount/point
Of if it's a ntfs volume, and you are still using ntfs-3g:
Code:
ntfs-3g /dev/sdb1 /mount/point
You need to give more info about what you are doing.
 
Old 10-31-2022, 08:57 AM   #6
kilgoretrout
Senior Member
 
Registered: Oct 2003
Posts: 2,990

Rep: Reputation: 388Reputation: 388Reputation: 388Reputation: 388
This is puzzling. My 22.04 installations do not auto mount unless set to auto mount in fstab. And attached is a screenshot of System Settings>Removable Devices>Attached Devices. Even entries that have the "On Attached" box ticked do not auto mount without an entry in fstab.The only thing I would suggest as a workaround is to create entries in fstab for all partitions you don't want auto mounted and explicitly have them set noauto.
Attached Thumbnails
Click image for larger version

Name:	Screenshot_20221031_084604.png
Views:	24
Size:	105.1 KB
ID:	39794  
 
Old 11-01-2022, 05:31 PM   #7
Johng
Member
 
Registered: Feb 2002
Location: NZ
Distribution: Kubuntu, Mint
Posts: 408

Original Poster
Rep: Reputation: 31
Thank you teckk
Normally, when a usb device is plugged in, it is detected and a window pops up at the bottom right with options. After issuing the command systemctl mask udisks2 that was not happening, and there was no option to mount the usb inspecting the usb widget. That is what I meant when I said the usb device could not be mounted. In other words, the usb removable device was masked.

and thank you kilgoretrout
Referring to your screenshot, on my system it does not matter whether all boxes are checked or unchecked (empty), on fresh boot 16 partitions are listed in Dolphin under Devices. Clicking any one opens the partition in /media/john/ without need of a password. This is what I referred to as auto mounting. Is this to be expected?? I have believed that generally mounting needs to be commanded by administrator directly or indirectly.

If I issue the command
Code:
systemctl mask udisks2
no partitions are listed in Dolphin under Devices. However plugging in a usb device does not initiate the pop up window at bottom right as explained to teckk
 
Old 11-01-2022, 08:15 PM   #8
colorpurple21859
LQ Veteran
 
Registered: Jan 2008
Location: florida panhandle
Distribution: Slackware Debian, Fedora, others
Posts: 7,416

Rep: Reputation: 1601Reputation: 1601Reputation: 1601Reputation: 1601Reputation: 1601Reputation: 1601Reputation: 1601Reputation: 1601Reputation: 1601Reputation: 1601Reputation: 1601
Found this:https://askubuntu.com/questions/2116...ing-partitions
 
Old 11-02-2022, 09:12 AM   #9
kilgoretrout
Senior Member
 
Registered: Oct 2003
Posts: 2,990

Rep: Reputation: 388Reputation: 388Reputation: 388Reputation: 388
Quote:
Clicking any one opens the partition in /media/john/ without need of a password. This is what I referred to as auto mounting. Is this to be expected?? I have believed that generally mounting needs to be commanded by administrator directly or indirectly.
OK. Now I get it. That's not what I would call auto mounting but rather user mountable without password in dolphin. Same behavior here. Also, I tried creating an entry in fstab for a partition with noauto and that didn't change that behavior; I could still mount the partition in dolphin without a password, although the mount point changed to the one designated in fstab. You can right click any item in dolphin > Devices and hide it as a workaround.

You're using systemctl udisks2 to modify this behavior. The udisks man page provides:

https://manpages.ubuntu.com/manpages.../udisks.8.html

The "Access Control" section of the above provides in relevant part:
Quote:
Note that the x-udisks-auth option can be used in the /etc/fstab and /etc/crypttab files to specify
that additional authorization is required to mount resp. unlock the device (typically
requiring the user to authenticate as an administrator).
I'm not familiar with that option, but it may provide a way to do what you want. Also, polkit configuration may do it as well as indicated in the link posted by colorpurple.

Edit: Additional information. This appears to be a ubuntu configuration issue with respect to udisks and polkit. I checked this behavior in my installations of Mageia, Arch, OpenSuse and Debian. In every case, when I clicked on a partition in dolphin that was not mounted in fstab, I was prompted for a password before the partition would mount.

Last edited by kilgoretrout; 11-02-2022 at 12:20 PM.
 
Old 11-02-2022, 05:46 PM   #10
Johng
Member
 
Registered: Feb 2002
Location: NZ
Distribution: Kubuntu, Mint
Posts: 408

Original Poster
Rep: Reputation: 31
Thank you colorpurple. I will experiment with you reference.

and kilgoretrout
Quote:
Edit: Additional information. This appears to be a ubuntu configuration issue with respect to udisks and polkit. I checked this behavior in my installations of Mageia, Arch, OpenSuse and Debian. In every case, when I clicked on a partition in dolphin that was not mounted in fstab, I was prompted for a password before the partition would mount.
Bingo! The Mageia, Suse, etc response is just the security behavior I was expecting and aiming at.
 
Old 11-02-2022, 06:37 PM   #11
Johng
Member
 
Registered: Feb 2002
Location: NZ
Distribution: Kubuntu, Mint
Posts: 408

Original Poster
Rep: Reputation: 31
Following colorpurple reference, I did:
Quote:
sudo -H gedit /var/lib/polkit-1/localauthority/10-vendor.d/com.ubuntu.desktop.pkla

And add # at the start of line 2

Identity=unix-group:admin;unix-group:sudo

changing it to

#Identity=unix-group:admin;unix-group:sudo
On rebooting, internal drives were listed in Dolphin. They were not open in /media/john.
Clicking a partition asked for password, and mounted in /media/john
Plugging in a usb device was recognised, and could be opened without a password.

Just what I was looking for.
Thank you all for baring with me.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
can't auto mount ext3 drive, "mount terminated with status 32" rey Linux - Hardware 9 05-12-2012 08:21 PM
can't auto mount ext3 drive, "mount terminated with status 32" rey Linux - Security 1 05-12-2012 09:57 AM
Auto mount USB drive to specified mount point after reboot smallbook Linux - Server 7 07-21-2010 04:40 AM
got my ntfs sata drive to mount but cat get to auto mount Jack Daniels Linux - Hardware 3 04-15-2007 10:42 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 08:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration