Automount any filesystem at startup without root & with a single command



The normal method to Automount file systems at startup in Linux always has something to do with terminal, nano, editing fstab files, finding UUIDs and all, otherwise you have to download a package for doing this for you.

Normal Mounting procedure in Ubuntu

I use Manjaro Linux XFCE and I faced the same problem I didn't want to mess up with my fstab and other files and was trying to find another way of doing this.
I seen Thunar can mount filesystems without permission or without asking any credentials, so this article should help most of the Manjaro users to mount their file systems automatically at startup.

I found out that Thunar uses udisksd to do this
We'll be using udisksctl in Manjaro to do this.

udisksctl is a command-line program used to interact with the udisksd daemon process.

If you just want to mount your desired filesystem at startup this command will help you out and you've to just launch it at startup!
udisksctl mount -b /dev/sdXN
Similarly you can unmount using this command just replace 'mount' with 'unmount', for getting more information about the command you can always run
man udisksctl
Just substitute X and N with the drive letter and the number and then run that command in the terminal, you should see that your drive is mounted.

If not, then you might not have package udisks2 or, you might not have polkit rules for udisks, in case you don't have polkit rules then execute this command

sudo nano /etc/polkit-1/rules.d/99-manjaro.rules
Then paste the following block of code
polkit.addRule(function(action, subject) {
    if (action.id == "org.freedesktop.udisks2.filesystem-mount-system" &&
        subject.isInGroup("storage")) {
        return polkit.Result.YES;
    }
});
Use Ctrl + X to save hit "y" to confirm hit ENTER

You should also be a member of group 'storage' execute following commands for adding yourself in 'storage' group
sudo groupadd -r storage
sudo gpasswd -a your_username storage
Now reboot, after that you should be able to mount drives without being asked for a password

Now we've to just add this command to session and startup.
Search "Session and Startup" in Menu

Click on "Add", then

Automount drives with udisksctl
So now click "OK" make sure the item's checkbox is "checked" and reboot the machine, your drive should automount at startup.

So thanks for reading if you found this helpful, leave a comment (you don't need to login).

Comments

Popular posts from this blog

Site wide CSRF on a popular program

Releasing Flumberbuckets: S3 Bucket Enumeration Tool for Bug Hunters

Installing XFCE & other things on Arch Linux