Trashcan support on NTFS volumes: Difference between revisions

From WickyWiki
No edit summary
mNo edit summary
 
(14 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[Category:Ubuntu]]
[[Category:Ubuntu]]
[[Category:Ubuntu System]]
[[Category:Ubuntu Storage]]
[[Category:201201]]
[[Category:201201]]


To enable Trash can support on a NTFS partition you will have to make an entry in your /etc/fstab file. You must specify the drive by UUID and assign a userid.
To enable ''Trashcan'' support on an NTFS partition you need to associate a user-id with the partition.


To find the correct UUID:
== Modify fstab ==
 
Associating a user-id with a partition can be done with an entry in the /etc/fstab file. You also need the drive's UUID, system's main user-id usually is 1000. The trash will be stored in a per-user folder on the drive ''/.Trash-<USER-ID>/''
 
Show your user-id:
 
<syntaxhighlight lang=bash>
id -u
</syntaxhighlight>
 
Show your group-id:
 
<syntaxhighlight lang=bash>
id -g
</syntaxhighlight>
 
To find the correct drive-UUID:


<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>
Line 21: Line 39:
</blockquote>
</blockquote>


Now edit fstab:
Edit fstab:


<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>
Line 27: Line 45:
</syntaxhighlight>
</syntaxhighlight>


Add the following lines:
Add or edit the following line to include ''uid=1000'':


<blockquote>
<blockquote>
<pre>
<syntaxhighlight lang=bash>
...
...
# NTFS Partitions
UUID=45645645645645645 /media/DATA ntfs-3g defaults,umask=077,fmask=177,uid=1000,gid=1000,noatime,nofail  0 0
UUID=45645645645645645 /media/DATA ntfs-3g defaults,uid=1000,locale=en_US.UTF-8 0 0
...
...
</pre>
</syntaxhighlight>
</blockquote>
</blockquote>


Note: to prevent automatic mounting add 'noauto':
The partition will be mounted after you start your machine. If you don't want automatic mount you should add 'noauto':


<blockquote>
<blockquote>
<pre>
<syntaxhighlight lang=bash>
...
...
# NTFS Partitions
UUID=45645645645645645 /media/DATA ntfs-3g defaults,umask=077,fmask=177,uid=1000,gid=1000,noauto,noatime,nofail  0 0
UUID=45645645645645645 /media/DATA ntfs-3g noauto,defaults,uid=1000,locale=en_US.UTF-8 0 0
...
...
</pre>
</syntaxhighlight>
</blockquote>
</blockquote>


Now remount the partitions.
Now remount the partitions:


<syntaxhighlight lang=bash>
<syntaxhighlight lang=bash>
Line 55: Line 71:
sudo mount -a
sudo mount -a
</syntaxhighlight>
</syntaxhighlight>
In this example the ''Trash can'' will be located in /media/DATA/.Trash-1000/.
== Mount manually ==
You can also use the same options when manually mounting:
<syntaxhighlight lang=bash>
sudo mkdir /media/DATA
sudo mount /dev/sda3 /media/DATA -o defaults,umask=077,fmask=177,uid=1000,gid=1000,noatime,nofail
</syntaxhighlight>
== Other settings explained ==
{| class="wikitable"
|-
! Header text !! Header text
|-
| /media/DATA  || mount point
|-
| ntfs-3g || volume type
|-
| uid=1000 || user-id 1000, check yours with 'id -u'
|-
| gid=1000 || group-id 1000, check yours with 'id -g'
|-
| umask=077 || causes files to be accessible only to you, not other users
|-
| fmask=177 || makes files non-executable
|-
| noatime || do not store accesstimes, advisable on SSD drives
|-
| user,noauto || if you want user-mounting, not automatic
|-
| exec || user implies noexec, add this if you still want to execute things
|-
| nofail || if you want the boot proces to continue after mounting fails
|}

Latest revision as of 11:30, 4 September 2025


To enable Trashcan support on an NTFS partition you need to associate a user-id with the partition.

Modify fstab

Associating a user-id with a partition can be done with an entry in the /etc/fstab file. You also need the drive's UUID, system's main user-id usually is 1000. The trash will be stored in a per-user folder on the drive /.Trash-<USER-ID>/

Show your user-id:

id -u

Show your group-id:

id -g

To find the correct drive-UUID:

sudo blkid

Returns:

...
/dev/sda2: LABEL="Ubuntu" UUID="12312312312312312" TYPE="ext4" 
/dev/sda3: LABEL="Data" UUID="45645645645645645" TYPE="ntfs" 
...

Edit fstab:

sudo gedit /etc/fstab

Add or edit the following line to include uid=1000:

...
UUID=45645645645645645  /media/DATA  ntfs-3g  defaults,umask=077,fmask=177,uid=1000,gid=1000,noatime,nofail  0  0
...

The partition will be mounted after you start your machine. If you don't want automatic mount you should add 'noauto':

...
UUID=45645645645645645  /media/DATA  ntfs-3g  defaults,umask=077,fmask=177,uid=1000,gid=1000,noauto,noatime,nofail  0  0
...

Now remount the partitions:

sudo umount -a
sudo mount -a

In this example the Trash can will be located in /media/DATA/.Trash-1000/.

Mount manually

You can also use the same options when manually mounting:

sudo mkdir /media/DATA
sudo mount /dev/sda3 /media/DATA -o defaults,umask=077,fmask=177,uid=1000,gid=1000,noatime,nofail

Other settings explained

Header text Header text
/media/DATA mount point
ntfs-3g volume type
uid=1000 user-id 1000, check yours with 'id -u'
gid=1000 group-id 1000, check yours with 'id -g'
umask=077 causes files to be accessible only to you, not other users
fmask=177 makes files non-executable
noatime do not store accesstimes, advisable on SSD drives
user,noauto if you want user-mounting, not automatic
exec user implies noexec, add this if you still want to execute things
nofail if you want the boot proces to continue after mounting fails