Problem Scenario:
I have a NTFS drive which is automounted every-time I start Ubuntu 11.04. I created this automount using fstab (Click Here to know how to automount windows partition in Ubuntu?). The problem is when I try to delete a file/directory (using delete button) it gives the following error:
Cannot move file to trash, do you want to delete immediately?
And if I select Yes, it permanently deletes the file/directory without moving it to trash (Permanently deleting i.e. Shift+Delete is not a good idea as you can accidentaly delete a wrong file).
Reason:
You might have noticed a folder .trash-1000 into your NTFS partition, External Drives etc when you are in . This folder is responsible for keeping the deleted files in trash so that you can recover them from trash. In other words, this .trash folder lets you move the files into trash. (The Windows counterpart of .trash is $RECYCLE.BIN which you can see in your Windows partitions/USB drives when you are in Linux). The 1000 in the folder name tells the owner of the trash folder which in this case is user with uid=1000 (This user, with uid=1000, is the first user you create while installing Linux and it has admin privileges i.e. super user rights).
Now. when I check my auto-mounted NTFS partition (/dev/sda5) I found no .trash folder in their. Why? Probably because there is something wrong with the ownership of the partition. This is the content of my fstab file:
sudo less /etc/fstab
#adding ntfs partition for auto mouNt /dev/sda5
UUID=01CB76F7C2628FB0 /home/takshak/mount/WindowsDrive ntfs defaults 0 0
Solution:
What I did is I edited the fstab file in /etc folder and added the uid=1000 with the NTFS partition in somewhat following manner:
sudo gedit /etc/fstab
#adding ntfs partition for auto mouNt /dev/sda5
UUID=01CB76F7C2628FB0 /home/takshak/mount/WindowsDrive ntfs defaults,uid=1000 0 0
And then I unmounted and mounted it back by using this command:
sudo umount /dev/sda5 && sudo mount -a
Possible Error:
The unmount and mount command may result in the following error:
uumount: /home/takshak/mount/WindowsDrive: device is busy.
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1))
To solve it, check if the drive is in use (In my case it was being used by Torrent client). Close all the programs which are using the drive.
Further Solution:
It might happen that just adding uid=1000 will not work. What next then? Well you can try adding the group id ‘gid‘ along with uid. Generally gid=1000 works in most of the cases but even if that doesn’t work then find out your gid:
cat /etc/group | grep plugdev Output:plugdev:x:46:takshak
So here my gid is 46 (takshak is my username). Add it to the fstab file in similar fashion:
UUID=01CB76F7C2628FB0 /home/takshak/mount/WindowsDrive ntfs defaults,uid=1000,gid=46 0 0
Hope it has solved your problem. Question, suggestion and feedback are welcomed. Don’t forget to like/vote the post as a token of appreciation. Enjoy
Related articles
- How to mount a windows partition on Linux automatically on each start up (computerandu.wordpress.com)