The title pretty much explains it. I am on windows and ubuntu dual boot. When I set automatic mount options on in the app disk, the system does not auto mount the drive. I need to click the drive to mount. When I set automatic mount options off and check mount at startup. It works but is mounted as root. As a result, I cannot put any file in trash.
-
What gui are you using to mount the drives? Have you looked at this question? https://askubuntu.com/questions/46588/how-to-automount-ntfs-partitions?rq=1 – Seth Dec 13 '15 at 22:36
-
Unity. I did search on the internet. But those methods do not work – Andrew Lin Dec 14 '15 at 00:19
1 Answers
I've organized this answer going what is good to best answer in my opinion. It's not a requirement to do all of them and user discretion is advised :)
/etc/fstab approach
The way I'd personally do it use users
option. That way , a partition is available to all users - maybe I've car manual that my dad wants to read there with his account, maybe my mom also wants to open shared photo album using her account - whatever the reason may be. An example would be:
# MY WINDOWS PARTITION
UUID=4EBAAE53BAAE36FD /media/WINDOWS ntfs noatime,nodiratime,users,rw 0 0
However, yes, that's a security hole. So next better option is this to use uid=
flag. Each user on a *nix system has unique integer number attached to them (run id
command to find out your numeric id, or look into /etc/passwd
file and find your username ). So, the next entry for me would look like this:
# MY WINDOWS PARTITION
UUID=4EBAAE53BAAE36FD /media/WINDOWS ntfs noatime,nodiratime,uid=1000,rw 0 0
udisksctl approach
mount
command wants you to specify a lot of information - user, filesystem type. These pieces of info you might not know how to find. There is an easier alternative, udisksctl
. It will mount a partition as the user who runs it. Here's how I'd run it if I want to mount my Windows partition on my second HDD:
udisksctl mount -b /dev/sdb2
And that easily can be turned into a function in .bashrc
file (define at the top)
function mountWindows
{
udisksctl mount -b /dev/sdb2
}
Now you basically have a command for mounting Windows partition. If you place call to that function at the end of your .bashrc
it will be running each time you spawn terminal window. Of course it's not exactly automation , but for someone like myself who constantly has terminal window open - it's easiest automation method.
There's a small issue however - the call is made each time bash
starts, meaning each time window is open. With a bit of editing we can include a check to whether or not the partition is already mounted or not.
function mountWindows
{
grep -q '/dev/sdb2' /proc/mounts
if [ $? -eq 0 ];then
echo ">>> Windows partition already mounted";
else udisksctl mount -b /dev/sdb2
fi
}
Now, each time we spawn bash
we quietly check if /dev/sdb2
is in the /proc/mounts
file (only stuff that's already mounted is in that file). If it's there, we just say so. If it's not, we'll run udisksctl
command.

- 105,154
- 20
- 279
- 497