Ubuntu: How to make Ubuntu ask for password when mounting partitions?


I have been through this kind of feature in older versions of Ubuntu. When I'd like to mount a partition it will ask me a password. Now I want to enable that kind of feature in Ubuntu 12.04.

How can I achieve this?


According to the Ubuntu ManPage Repository, pklocalauthority - PolicyKit Local Authority makes a distinction between user authentication (to make the user in front of the system prove he really is the user) and administrator authentication (to make the user in front of the system prove he really is an administrator)

Therefore you can use this policykit to provide administration authentication for mounting all (internal and external) devices.

To do so, follow these steps:

  1. Open a terminal(CTRL+ALT+T) and type:

    gksu gedit /var/lib/polkit-1/localauthority/10-vendor.d/com.ubuntu.desktop.pkla  
  2. In line 4, look for ResultActive=yes and change it to:

  3. Save and Close the file.

Ubuntu will now require a password when mounting all drives (internal and external drives).

For specific partitions:

In 10.04 and newer versions, mounting all devices (internal and external) are allowed without asking for password unless it was defined in the filesystem table (fstab) file.

Therefore, to make Ubuntu prompt users for sudo password when mounting specific partitions, you need to edit your fstab file.

To do so, follow these steps:

  1. Open a terminal and type:

    gksu gedit /etc/fstab  
  2. At the last line, add the UUID of your partition with the defaults option.

    You can find out the UUIDs of partitions by running blkid in the terminal.

    For example:

    $ sudo blkid  /dev/sda1: UUID="5474ce02-5c07-4002-a0e7-10c8bc5dba2c" TYPE="ext4"   /dev/sda2: LABEL="windows" UUID="7355DDFB0563F31F" TYPE="ntfs"   /dev/sda5: LABEL="data" UUID="7e3fbc57-03fe-4742-bb72-756f31852059" TYPE="ext4"   /dev/sda6: LABEL="films" UUID="a319fb28-3061-404f-abbc-6519cf81c6c9" TYPE="ext4"   /dev/sda7: LABEL="tv" UUID="5D10E5D66886BCCF" TYPE="ntfs"   /dev/sda8: UUID="12d16683-5530-454e-809b-1a30ed47a8c9" TYPE="swap"   

    Now that you know the UUID, you can add it to the fstab file. But first, you need to create a mountpoint where the partition will be mounted.

    You can do that by running:

    sudo mkdir /path/to/dir/name-dir  

    In my example, I want to mount the partition under /media/data:

    sudo mkdir /media/data  

    Now, I can simply add the line below to make sure that Ubuntu prompts for a password when the "data" partition is mounted:

    UUID=7e3fbc57-03fe-4742-bb72-756f31852059 /media/data   ext4 defaults 0 0  
  3. Save and Close the file.


The defaults option uses the default options that are rw, suid, dev, exec, auto, nouser, and async.

The user allows normal users to mount the device, whereas nouser lets only the root to mount the device.

For detailed information, visit How to edit and understand /etc/fstab.


The easy answer is to edit the policy file with one of the commands below:

gksu gedit /var/lib/polkit-1/localauthority/10-vendor.d/com.ubuntu.desktop.pkla  


sudo -H gedit /var/lib/polkit-1/localauthority/10-vendor.d/com.ubuntu.desktop.pkla  

And add # at the start of line 2


changing it to


Since the system will no longer identify mount requests as admin or sudo requests it will require the password for mount requests not listed as user mountable in /etc/fstab.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »