Password for mounting USB sticks and other devices

Hi.
Could you please tell me how to make the system ask for a Root password or the one I set for this purpose when connecting to USB drives or other devices…?

2 Likes

Found the answer on the internet.

  1. Create a rule in /etc/polkit-1/rules.d/99-udisk2_mount.rules with the following contents:
polkit.addRule(function(action, subject) 
 { 
 polkit.log("action "+ action); 
 polkit.log("subject "+ subject); 
 if (action.id == "org.freedesktop.udisks2.filesystem-mount-system") 
 { 
 return polkit.Result.AUTH_ADMIN
 }; 
 if (action.id == "org.freedesktop.udisks2.filesystem-mount") 
 { 
 return polkit.Result.AUTH_ADMIN; 
 }; 
 if (action.id == "org.freedesktop.udisks2.filesystem-mount-other-seats") 
 { 
 return polkit.Result.AUTH_ADMIN; 
 }; 
 });
  1. Restart the Polkit policies:
systemctl restart polkit
4 Likes