如何自動掛載NTFS磁區 [論壇 - Ubuntu基本設定]


正在瀏覽:   1 名遊客


 到底部   前一個主題   下一個主題  [無發表權] 請登錄或者註冊



如何自動掛載NTFS磁區
會員二級
註冊日期:
2009/3/29 10:12
所屬群組:
已註冊使用者
等級: 5
HP : 0 / 112
MP : 15 / 4682
EXP: 51
離線
請問如何在/etc/fstab加入開機自動掛載NTFS磁區的參數?

我加入此參數

UUID=12D6427BD6425EDB /media/roger/Data ntfs defaults 0 0

不能將檔案移到垃圾桶,如下圖附件

記得以前有一個指令,可以在檔案視窗管理員手動掛載後,查詢掛載的參數,並將此參數加入到fstab中

但我早已忘了什麼指令了,或者我應加入正確的參數是什麼

附件:



jpg  2019-04-16 12-31-03 的螢幕擷圖.jpg (267.04 KB)
15048_5cb55b2ccc2a5.jpg 1920X1080 px

2019/4/16 12:35
應用擴展 工具箱
回覆: 如何自動掛載NTFS磁區
會員五級
註冊日期:
2009/10/29 4:50
所屬群組:
已註冊使用者
等級: 41
HP : 204 / 1021
MP : 928 / 40617
EXP: 87
離線
twroger 寫到:
請問如何在/etc/fstab加入開機自動掛載NTFS磁區的參數?

我加入此參數

UUID=12D6427BD6425EDB /media/roger/Data ntfs defaults 0 0

不能將檔案移到垃圾桶,如下圖附件

記得以前有一個指令,可以在檔案視窗管理員手動掛載後,查詢掛載的參數,並將此參數加入到fstab中

但我早已忘了什麼指令了,或者我應加入正確的參數是什麼


UUID=12D6427BD6425EDB /media/roger/Data ntfs defaults,umask=007,gid=46,uid=1000 0 0

要讓檔案能移到垃圾桶必須加入「uid=1000」,但…這也只對第一位使用者生效,
我對這個問題也感到困擾很久了,如果有人知道如何令「每一位」使用者都能把檔案移入垃圾桶,也請告訴我。

2019/4/16 14:58
應用擴展 工具箱
回覆: 如何自動掛載NTFS磁區
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 37
HP : 0 / 901
MP : 671 / 29303
EXP: 6
離線
twroger 寫到:
請問如何在/etc/fstab加入開機自動掛載NTFS磁區的參數?

我加入此參數

UUID=12D6427BD6425EDB /media/roger/Data ntfs defaults 0 0

不能將檔案移到垃圾桶,如下圖附件

記得以前有一個指令,可以在檔案視窗管理員手動掛載後,查詢掛載的參數,並將此參數加入到fstab中

但我早已忘了什麼指令了,或者我應加入正確的參數是什麼


您指的指令,也許是「mount」,您可以測看看,

就只要在「Terminal」輸入「mount」然後按下「Enter」,就會顯示一些訊息。

後記 2019-10-25: 在「#2 回覆: ubuntu1804 (server版)硬碟掛載-就是無法掛載」,發現還有另一個指令「findmnt」可以使用。

================================================================================

$ man fstab
$ man mount
$ man findmnt

================================================================================

我對「如何在/etc/fstab加入開機自動掛載NTFS磁區的參數?」這個議題其實不了解
剛找了一下資料,因為我目前手上沒有對應的硬體可以去實測,
所以就把找到的連結貼上來,供您參考

使用關鍵字「ubuntu ntfs」查詢

可以找到下面連結

* https://wiki.ubuntu-tw.org/index.php?title=HowtoReadWriteNTFS

裡面有提到操作的方式,您可以自行測試看看

================================================================================

上面的連結提到關鍵字「ntfs-3g」,

所以我用「ntfs-3g」當關鍵字查詢

查到下面的連結

* https://wiki.archlinux.org/index.php/NTFS-3G_(%E6%AD%A3%E9%AB%94%E4%B8%AD%E6%96%87)
* https://wiki.archlinux.org/index.php/NTFS-3G

================================================================================

接著我測試我的系統「Ubuntu 18.04」。


dpkg -l ntfs-3g



顯示


Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                            Version              Architecture         Description
+++-===============================-====================-====================-=======
ii  ntfs-3g                         1:2017.3.23-2ubuntu0 amd64                read/write NTFS driver for FUSE




表示我的系統,已經有安裝「ntfs-3g」這個「Package」了。

================================================================================

接著在擴大查詢,執行下面指令


dpkg -l '*ntfs-3g*'



顯示


Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                            Version              Architecture         Description
+++-===============================-====================-====================-======
ii  libntfs-3g88                    1:2017.3.23-2ubuntu0 amd64                read/write NTFS driver for FUSE (runtime library)
ii  ntfs-3g                         1:2017.3.23-2ubuntu0 amd64                read/write NTFS driver for FUSE



執行


apt-cache pkgnames ntfs



顯示


ntfs-3g
ntfs-3g-dbg
ntfs-3g-dev
ntfs-config



執行


apt-cache showsrc ntfs-3g | grep '^Binary:' -B 2



顯示


Package: ntfs-3g
Format: 3.0 (quilt)
Binary: ntfs-3g, ntfs-3g-dbg, ntfs-3g-dev, libntfs-3g88, ntfs-3g-udeb
--
...略...



================================================================================

接著查詢「ntfs-3g」這個「Package」,安裝那些檔案在系統上

可以執行下面指令


dpkg -L ntfs-3g



或是加上排序,可以執行下面指令


dpkg -L ntfs-3g | sort



顯示


/.
/bin
/bin/lowntfs-3g
/bin/ntfs-3g
/bin/ntfs-3g.probe
/bin/ntfscat
/bin/ntfscluster
/bin/ntfscmp
/bin/ntfsfallocate
/bin/ntfsfix
/bin/ntfsinfo
/bin/ntfsls
/bin/ntfsmove
/bin/ntfsrecover
/bin/ntfssecaudit
/bin/ntfstruncate
/bin/ntfsusermap
/bin/ntfswipe
/sbin
/sbin/mkfs.ntfs
/sbin/mkntfs
/sbin/mount.lowntfs-3g
/sbin/mount.ntfs
/sbin/mount.ntfs-3g
/sbin/ntfsclone
/sbin/ntfscp
/sbin/ntfslabel
/sbin/ntfsresize
/sbin/ntfsundelete
/usr
/usr/bin
/usr/bin/ntfsdecrypt
/usr/share
/usr/share/doc
/usr/share/doc/ntfs-3g
/usr/share/doc/ntfs-3g/changelog.Debian.gz
/usr/share/doc/ntfs-3g/copyright
/usr/share/doc/ntfs-3g/README.Debian
/usr/share/doc/ntfs-3g/README.gz
/usr/share/doc/ntfs-3g/TODO.Debian
/usr/share/hal
/usr/share/hal/fdi
/usr/share/hal/fdi/policy
/usr/share/hal/fdi/policy/10osvendor
/usr/share/hal/fdi/policy/10osvendor/25-ntfs-3g-policy.fdi
/usr/share/initramfs-tools
/usr/share/initramfs-tools/hooks
/usr/share/initramfs-tools/hooks/ntfs_3g
/usr/share/initramfs-tools/scripts
/usr/share/initramfs-tools/scripts/local-bottom
/usr/share/initramfs-tools/scripts/local-bottom/ntfs_3g
/usr/share/initramfs-tools/scripts/local-premount
/usr/share/initramfs-tools/scripts/local-premount/ntfs_3g
/usr/share/man
/usr/share/man/man8
/usr/share/man/man8/lowntfs-3g.8.gz
/usr/share/man/man8/mkfs.ntfs.8.gz
/usr/share/man/man8/mkntfs.8.gz
/usr/share/man/man8/mount.lowntfs-3g.8.gz
/usr/share/man/man8/mount.ntfs-3g.8.gz
/usr/share/man/man8/mount.ntfs.8.gz
/usr/share/man/man8/ntfs-3g.8.gz
/usr/share/man/man8/ntfs-3g.probe.8.gz
/usr/share/man/man8/ntfscat.8.gz
/usr/share/man/man8/ntfsclone.8.gz
/usr/share/man/man8/ntfscluster.8.gz
/usr/share/man/man8/ntfscmp.8.gz
/usr/share/man/man8/ntfscp.8.gz
/usr/share/man/man8/ntfsdecrypt.8.gz
/usr/share/man/man8/ntfsfallocate.8.gz
/usr/share/man/man8/ntfsfix.8.gz
/usr/share/man/man8/ntfsinfo.8.gz
/usr/share/man/man8/ntfslabel.8.gz
/usr/share/man/man8/ntfsls.8.gz
/usr/share/man/man8/ntfsprogs.8.gz
/usr/share/man/man8/ntfsrecover.8.gz
/usr/share/man/man8/ntfsresize.8.gz
/usr/share/man/man8/ntfssecaudit.8.gz
/usr/share/man/man8/ntfstruncate.8.gz
/usr/share/man/man8/ntfsundelete.8.gz
/usr/share/man/man8/ntfsusermap.8.gz
/usr/share/man/man8/ntfswipe.8.gz



================================================================================

接下來過濾,找出「manpage」相關的檔案列表


dpkg -L ntfs-3g | grep '/man/man.*/'



顯示


/usr/share/man/man8/mkntfs.8.gz
/usr/share/man/man8/ntfs-3g.8.gz
/usr/share/man/man8/ntfs-3g.probe.8.gz
/usr/share/man/man8/ntfscat.8.gz
/usr/share/man/man8/ntfsclone.8.gz
/usr/share/man/man8/ntfscluster.8.gz
/usr/share/man/man8/ntfscmp.8.gz
/usr/share/man/man8/ntfscp.8.gz
/usr/share/man/man8/ntfsdecrypt.8.gz
/usr/share/man/man8/ntfsfallocate.8.gz
/usr/share/man/man8/ntfsfix.8.gz
/usr/share/man/man8/ntfsinfo.8.gz
/usr/share/man/man8/ntfslabel.8.gz
/usr/share/man/man8/ntfsls.8.gz
/usr/share/man/man8/ntfsprogs.8.gz
/usr/share/man/man8/ntfsrecover.8.gz
/usr/share/man/man8/ntfsresize.8.gz
/usr/share/man/man8/ntfssecaudit.8.gz
/usr/share/man/man8/ntfstruncate.8.gz
/usr/share/man/man8/ntfsundelete.8.gz
/usr/share/man/man8/ntfsusermap.8.gz
/usr/share/man/man8/ntfswipe.8.gz
/usr/share/man/man8/lowntfs-3g.8.gz
/usr/share/man/man8/mkfs.ntfs.8.gz
/usr/share/man/man8/mount.lowntfs-3g.8.gz
/usr/share/man/man8/mount.ntfs-3g.8.gz
/usr/share/man/man8/mount.ntfs.8.gz



================================================================================

接下來再多一層過濾,找出「manpage」並且和「mount」相關的檔案列表


dpkg -L ntfs-3g | grep '/man/man.*/' | grep 'mount'




顯示


/usr/share/man/man8/mount.lowntfs-3g.8.gz
/usr/share/man/man8/mount.ntfs-3g.8.gz
/usr/share/man/man8/mount.ntfs.8.gz



所以可以執行下面指令,來閱讀相關參考文件

$ man mount.ntfs-3g
$ man mount.ntfs
$ man mount.lowntfs-3g

================================================================================

接下來執行下面指令,了解「ntfs-3g」這個「Package」的相關資訊。


apt-cache show ntfs-3g



顯示


Package: ntfs-3g
Architecture: amd64
Version: 1:2017.3.23-2ubuntu0.18.04.1
Priority: standard
Section: otherosfs
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Laszlo Boszormenyi (GCS) <gcs@debian.org>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 1367
Pre-Depends: fuse
Depends: libc6 (>= 2.17), libgcrypt20 (>= 1.8.0), libgnutls30 (>= 3.5.0), libntfs-3g88 (= 1:2017.3.23-2ubuntu0.18.04.1)
Filename: pool/main/n/ntfs-3g/ntfs-3g_2017.3.23-2ubuntu0.18.04.1_amd64.deb
Size: 384580
MD5sum: 51843251bc7c454f44616ca1c0aff88b
SHA1: 5c66a815b7530c29a8e86238e5938e4e24806a04
SHA256: 6e7673aabb6fa884746b532c93912563b70db402b51bb0fd8851a6818f7d9460
Homepage: http://www.tuxera.com/community/ntfs-3g-advanced/
Description-en: read/write NTFS driver for FUSE
 NTFS-3G uses FUSE (Filesystem in Userspace) to provide support for the NTFS
 filesystem used by Microsoft Windows.
Description-md5: d38b96403238266210560bdd2ee0d28c
Task: standard
Supported: 5y

...略...




================================================================================

接下來可以搭配「grep」過濾,例如


apt-cache show ntfs-3g | grep '^Homepage:'



顯示


Homepage: http://www.tuxera.com/community/ntfs-3g-advanced/
Homepage: http://www.tuxera.com/community/ntfs-3g-advanced/



可以連到上面找到的連結「http://www.tuxera.com/community/ntfs-3g-advanced/」。

找到下面的連結

* https://www.tuxera.com/community/open-source-ntfs-3g/#installation
* https://www.tuxera.com/community/open-source-ntfs-3g/#usage
* https://www.tuxera.com/community/ntfs-3g-manual/

尤其「https://www.tuxera.com/community/open-source-ntfs-3g/#usage」這個連結要注意

一開始提到有找到兩個網頁,可以對照裡面提到的方式。


Usage

If there was no error during installation then the NTFS volume can be mounted in read-write mode for everybody as follows. Unmount the volume if it had already been mounted, replace /dev/sda1 and /mnt/windows, if needed.

mount -t ntfs-3g /dev/sda1 /mnt/windows

Please see the NTFS-3G Manual for more options and examples.

You can also make NTFS to be mounted during boot by adding the following line to the end of the /etc/fstab file:

/dev/sda1 /mnt/windows ntfs-3g defaults 0 0



================================================================================

$ man fstab
$ man mount
$ man mount.ntfs
$ man mount.ntfs-3g
$ man mount.lowntfs-3g

================================================================================

以上提供參考

報告完畢


2019/4/16 15:23
應用擴展 工具箱
回覆: 如何自動掛載NTFS磁區
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 37
HP : 0 / 901
MP : 671 / 29303
EXP: 6
離線
另外上面找尋的過程中,看到「fuse」這個關鍵字,好奇之下,簡單做一點探索,
以下是簡易的探索紀錄。

================================================================================

執行


dpkg -l fuse



顯示


Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-===============================-====================-====================-======
ii fuse 2.9.7-1ubuntu1 amd64 Filesystem in Userspace



表示「fuse」這個「Package」,之前已經有安裝在我的系統裡了。

================================================================================

執行


dpkg -l '*fuse*'



顯示


Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                            Version              Architecture         Description
+++-===============================-====================-====================-=======
ii  fuse                            2.9.7-1ubuntu1       amd64                Filesystem in Userspace
un  fuse-module                     <none>               <none>               (no description available)
un  fuse2fs                         <none>               <none>               (no description available)
ii  gvfs-fuse                       1.36.1-0ubuntu1.3    amd64                userspace virtual filesystem - fuse server
ii  libconfuse-common               3.2.1+dfsg-4ubuntu0. all                  Common files for libConfuse
ii  libconfuse2:amd64               3.2.1+dfsg-4ubuntu0. amd64                Library for parsing configuration files
ii  libfuse2:amd64                  2.9.7-1ubuntu1       amd64                Filesystem in Userspace (library)




================================================================================

執行


apt-cache pkgnames fuse



顯示


fuse
fuseext2
fuse2fs
fusedav
fusefat
fuse-zip
fuseiso
fuse-emulator-utils
fuse-emulator-gtk
fuse-emulator-common
fusesmb
fusecram
fuse-emulator-sdl
fuseiso9660
fuse-posixovl
fuse-dbg
fuse-convmvfs



================================================================================

執行


apt-cache showsrc fuse | grep '^Binary:' -B 2



顯示


Package: fuse
Format: 3.0 (quilt)
Binary: fuse, fuse-dbg, libfuse2, libfuse-dev, fuse-udeb, libfuse2-udeb



================================================================================


apt-cache show fuse



顯示


Package: fuse
Architecture: amd64
Version: 2.9.7-1ubuntu1
Priority: standard
Section: utils
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Laszlo Boszormenyi (GCS) <gcs@debian.org>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 104
Depends: libc6 (>= 2.14), libfuse2 (= 2.9.7-1ubuntu1), adduser, mount (>= 2.19.1), sed (>= 4)
Filename: pool/main/f/fuse/fuse_2.9.7-1ubuntu1_amd64.deb
Size: 24544
MD5sum: 59c7fc4041e5dba888527f60cc4124a6
SHA1: ca67fce684384b619fe4507d297c55ec7db03d91
SHA256: a7b3de22b2944948a4a3c64af62b42af76806bdc3eeaf3e02a7c33bc11e2d160
Homepage: https://github.com/libfuse/libfuse/wiki
Description-en: Filesystem in Userspace
Filesystem in Userspace (FUSE) is a simple interface for userspace programs to
export a virtual filesystem to the Linux kernel. It also aims to provide a
secure method for non privileged users to create and mount their own filesystem
implementations.
Description-md5: 7c02c670c9296dcdf481f6c060b0083d
Task: standard
Supported: 5y



執行


apt-cache show fuse | grep '^Homepage:'



顯示


Homepage: https://github.com/libfuse/libfuse/wiki



================================================================================

執行


dpkg -L fuse



或是加上排序,執行


dpkg -L fuse | sort



顯示


/.
/bin
/bin/fusermount
/bin/ulockmgr_server
/etc
/etc/fuse.conf
/sbin
/sbin/mount.fuse
/usr
/usr/share
/usr/share/doc
/usr/share/doc/fuse
/usr/share/doc/fuse/changelog.Debian.gz
/usr/share/doc/fuse/copyright
/usr/share/initramfs-tools
/usr/share/initramfs-tools/hooks
/usr/share/initramfs-tools/hooks/fuse
/usr/share/lintian
/usr/share/lintian/overrides
/usr/share/lintian/overrides/fuse
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/fusermount.1.gz
/usr/share/man/man1/ulockmgr_server.1.gz
/usr/share/man/man8
/usr/share/man/man8/mount.fuse.8.gz



================================================================================

執行


dpkg -L fuse | grep '/man/man.*/'



顯示


/usr/share/man/man1/fusermount.1.gz
/usr/share/man/man1/ulockmgr_server.1.gz
/usr/share/man/man8/mount.fuse.8.gz



執行


dpkg -L fuse | grep '/man/man.*/'



$ man mount.fuse
$ man fusermount
$ man ulockmgr_server

================================================================================

目前探索到這,

報告完畢。


2019/4/16 16:03
應用擴展 工具箱
回覆: 如何自動掛載NTFS磁區
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 37
HP : 0 / 901
MP : 671 / 29303
EXP: 6
離線
================================================================================

Xenomorph0525 寫到:
twroger 寫到:
請問如何在/etc/fstab加入開機自動掛載NTFS磁區的參數?

我加入此參數

UUID=12D6427BD6425EDB /media/roger/Data ntfs defaults 0 0

不能將檔案移到垃圾桶,如下圖附件

記得以前有一個指令,可以在檔案視窗管理員手動掛載後,查詢掛載的參數,並將此參數加入到fstab中

但我早已忘了什麼指令了,或者我應加入正確的參數是什麼


UUID=12D6427BD6425EDB /media/roger/Data ntfs defaults,umask=007,gid=46,uid=1000 0 0

要讓檔案能移到垃圾桶必須加入「uid=1000」,但…這也只對第一位使用者生效,
我對這個問題也感到困擾很久了,如果有人知道如何令「每一位」使用者都能把檔案移入垃圾桶,也請告訴我。


================================================================================

有些還沒有弄清楚,以下先紀錄一下目前找到的線索。

================================================================================

在我的系統,即使不是使用「ntfs」,
我使用「pcmanfm-qt」掛載某個「partition」,
也不能正常使用「Trash Can」,但可以正常刪除。
以前我也沒特別去管它,通常我是直接打指令,或是直接刪除。

所以我剛剛一開始,是先找「pcmanfm-qt」程式碼來看。

主要看的套件有下面三個

* pcmanfm-qt (Soruce: pcmanfm-qt)
* libfm-qt-dev (Soruce: libfm-qt)
* libfm-dev (Soruce: libfm)

也可以從「pcmanfm」追起

* pcmanfm (Soruce: pcmanfm)
* libfm-dev (Soruce: libfm)

下載「Source Package」的指令是,舉例


apt-get source pcmanfm-qt



但要注意有個前置作業,請參考「#24 回覆: Ubuntu 17.10 推出」。

不過程式碼這部份我還沒有很熟悉,所以目前還看不出個所以然。

只有一個線索,不能正常「Move to Trash」時,
會出現一個「Error」的「對話視窗」,
裡面的訊息是「Unable to find or create trash directory for ...」 「...」是我要刪除那個檔案的路徑。

================================================================================

接著我使用關鍵字「ubuntu trash can path」找了一下網路上的參考資料

找到

* https://askubuntu.com/questions/102099/where-is-the-trash-folder

從裡面找到下面兩個連結

* https://specifications.freedesktop.org/trash-spec/trashspec-1.0.html
* https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html

從一開始找到的連結,可以知道「Trash」放置的位置是「~/.local/share/Trash/」

執行


ls ~/.local/share/Trash/ -1



顯示


expunged
files
info



這三個都是資料夾,

假設我將「~/test.txt」這個檔案,透過「pcmanfm-lxqt」去「Move to Trash」

則會看到「~/.local/share/Trash/files/test.txt」這個檔案

也會看到「~/.local/share/Trash/info/test.txt.trashinfo」這個檔案

執行


cat ~/.local/share/Trash/info/test.txt.trashinfo



顯示


[Trash Info]
Path=/home/user/test.txt
DeletionDate=2019-04-17T00:43:15



================================================================================

接著我又找到另外一篇參考文章

* http://karuppuswamy.com/wordpress/2010/06/08/how-to-manage-trash-from-command-line-in-gnome-delete-list-restore-and-empty/

裡面除了有提到上面的概念,

還有提到一個工具「trash-cli」。

執行下面指令安裝


sudo apt-get install trash-cli



安裝好後,接著執行下面指令


dpkg -L trash-cli



顯示


/.
/usr
/usr/bin
/usr/bin/restore-trash
/usr/bin/trash
/usr/bin/trash-empty
/usr/bin/trash-list
/usr/bin/trash-put
/usr/bin/trash-rm
/usr/lib
/usr/lib/python2.7
/usr/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages/trash_cli-0.12.9.14.egg-info
/usr/lib/python2.7/dist-packages/trashcli
/usr/lib/python2.7/dist-packages/trashcli/__init__.py
/usr/lib/python2.7/dist-packages/trashcli/cmds.py
/usr/lib/python2.7/dist-packages/trashcli/fs.py
/usr/lib/python2.7/dist-packages/trashcli/fstab.py
/usr/lib/python2.7/dist-packages/trashcli/list_mount_points.py
/usr/lib/python2.7/dist-packages/trashcli/rm.py
/usr/lib/python2.7/dist-packages/trashcli/trash.py
/usr/share
/usr/share/doc
/usr/share/doc/trash-cli
/usr/share/doc/trash-cli/changelog.Debian.gz
/usr/share/doc/trash-cli/copyright
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/restore-trash.1.gz
/usr/share/man/man1/trash-empty.1.gz
/usr/share/man/man1/trash-list.1.gz
/usr/share/man/man1/trash-put.1.gz
/usr/share/man/man1/trash-rm.1.gz
/usr/share/man/man1/trash.1.gz




================================================================================

然後我粗略看一下「/usr/lib/python2.7/dist-packages/trashcli/trash.py」這個檔案

有看到一段註解。

執行


grep '\.Trash' /usr/lib/python2.7/dist-packages/trashcli/trash.py -n -B 10 -A 5



顯示


266-
267-    def trash(self, file) :
268-        """
269-        Trash a file in the appropriate trash directory.
270-        If the file belong to the same volume of the trash home directory it
271-        will be trashed in the home trash directory.
272-        Otherwise it will be trashed in one of the relevant volume trash
273-        directories.
274-
275-        Each volume can have two trash directories, they are
276:            - $volume/.Trash/$uid
277:            - $volume/.Trash-$uid
278-
279-        Firstly the software attempt to trash the file in the first directory
280-        then try to trash in the second trash directory.
281-        """
282-
--
...略...



於是我做了底下的實驗,

================================================================================

我先在「pcmanfm-qt」無法正常使用「Move to Trash」那個「partition」底下去測試,

## 實驗一

產生一個檔案,執行「touch some.txt」,

接著執行「trash some.txt」,

會出現「trash: cannot trash regular empty file `some.txt'」這樣的訊息。

================================================================================

## 實驗二

接著我就在無法正常使用「Move to Trash」那個「partition」所掛載的位置,手動建了一個「.Trash」。

執行


sudo mkdir .Trash



並且改權限


chmod 777 .Trash



接著,就重複「實驗一」的步驟,

在另外的資料夾做實驗,執行「trash some.txt」,就能正常「Move to Trash」。

不過「pcmanfm-qt」,還是無法正常「Move to Trash」。

然後觀看「.Trash」


tree .Trash



顯示


.Trash
└── 1000
├── files
│   └── some.txt
└── info
└── some.txt.trashinfo

3 directories, 2 files



================================================================================

雖然上面的方式,在「pcmanfm-qt」,還是無法正常「Move to Trash」。

但是從「pcmanfm-qt」左側欄的「Places/Trash」還是可以看得到剛剛透過「trash some.txt」的「some.txt」。

從「pcmanfm-qt」執行「Empty trash」的動作,

剛剛「.Trash」裡面的「.Trash/1000/files/some.txt」和「.Trash/1000/info/some.txt.trashinfo」,也是會被清除。

所以目前還不清楚「pcmanfm-qt」實做「Move to Trash」的規則。

但可以了解到,「Move to Trash」這個動作,不見得一定會放到「~/.local/share/Trash/」這裡,

我猜測有些位置,應該會另外再建立不同的「.Trash」的資料夾,命名規則和放置位置,我目前不確定,

可能是因為權限的原因,無法建立,所以就無法正常完成「Move to Trash」這個動作。

因此才會有提示訊息是「Unable to find or create trash directory for ...」

可以對照「#1」提供的「圖片」裡面的中文訊息。

================================================================================

目前探索到這

報告完畢


2019/4/17 1:40
應用擴展 工具箱
回覆: 如何自動掛載NTFS磁區
會員五級
註冊日期:
2009/10/29 4:50
所屬群組:
已註冊使用者
等級: 41
HP : 204 / 1021
MP : 928 / 40617
EXP: 87
離線
samwhelp 寫到:

目前探索到這

報告完畢



哈,辛苦了。

2019/4/17 1:54
應用擴展 工具箱
回覆: 如何自動掛載NTFS磁區
會員二級
註冊日期:
2009/3/29 10:12
所屬群組:
已註冊使用者
等級: 5
HP : 0 / 112
MP : 15 / 4682
EXP: 51
離線

Xenomorph0525 寫到

要讓檔案能移到垃圾桶必須加入「uid=1000」


謝謝Xenomorph0525大的回覆,可以將檔案移到垃圾桶了

至於您所提的問題,目前還不曉得

希望大家能一起來探討,謝謝


2019/4/17 13:19
應用擴展 工具箱
回覆: 如何自動掛載NTFS磁區
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 37
HP : 0 / 901
MP : 671 / 29303
EXP: 6
離線
以下暫時紀錄

================================================================================

執行


dpkg -l '*libfm*' | grep ii



顯示


ii libfm-data 1.2.5-1ubuntu1 all file management support (common data)
ii libfm-dev:amd64 1.2.5-1ubuntu1 amd64 file management support (core development files)
ii libfm-extra-dev:amd64 1.2.5-1ubuntu1 amd64 file management support (libfm-extra development files)
ii libfm-extra4:amd64 1.2.5-1ubuntu1 amd64 file management support (extra library)
ii libfm-gtk-data 1.2.5-1ubuntu1 all file management support (GTK+ library common data)
ii libfm-gtk-dev:amd64 1.2.5-1ubuntu1 amd64 file management support (GTK+ GUI development files)
ii libfm-gtk4:amd64 1.2.5-1ubuntu1 amd64 file management support (GTK+ 2.0 GUI library)
ii libfm-modules:amd64 1.2.5-1ubuntu1 amd64 file management support (loadable modules for library)
ii libfm-qt-dev 0.12.0-14build2 amd64 file management support library for pcmanfm-qt (development files)
ii libfm-qt-l10n 0.12.0-4ubuntu1 all Language package for libfm-qt
ii libfm-qt3:amd64 0.12.0-14build2 amd64 file management support for pcmanfm-qt
[color]ii libfm4:amd64 1.2.5-1ubuntu1 amd64 file management support (core library)[/color]



================================================================================

執行


apt-cache show libfm4



顯示


Package: libfm4
Architecture: amd64
Version: 1.2.5-1ubuntu1
Multi-Arch: same
Priority: optional
Section: universe/libs
Source: libfm
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: Debian LXDE Maintainers <pkg-lxde-maintainers@lists.alioth.debian.org>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 320
Depends: libc6 (>= 2.14), libdbus-glib-1-2 (>= 0.78), libexif12 (>= 0.6.21-1~), libglib2.0-0 (>= 2.37.3), libmenu-cache3 (>= 0.5.0), libfm-data (>= 1.2.0~), lxmenu-data
Recommends: libfm-modules
Filename: pool/universe/libf/libfm/libfm4_1.2.5-1ubuntu1_amd64.deb
Size: 99208
MD5sum: 5139ecc40d89fe75eee54330e3e182d4
SHA1: 795bd28a7ab71b30378b031f52ad345ba9f957a1
SHA256: 959ad452da5f3071f687a52eb1fee3e911e989479b9e46dc9affb685178ac620
Homepage: http://pcmanfm.sourceforge.net/
Description-en: file management support (core library)
LibFM provides file management functions built on top of Glib/GIO,
giving a convenient higher-level API.
.
Some features:
* Desktop-independent, following FreeDesktop standards;
* Fast, light on memory usage, and responsive - well suited to
less powerful hardware such as netbooks and thin clients;
* Uses GIO/GVFS (like Nautilus) for Trash support and access to
remote file systems (FTP, SFTP, WebDAV, Windows shares, etc.);

* Clipboard operations are compatible with GTK+/GNOME and Qt/KDE;
* Supports both Drag-and-Drop, and the X Direct Save protocol;
* Reusable design with the core functions separated out to
simplify porting to other GUIs.
.
This package contains the core library.
Description-md5: 1edf1e2cdf154e4352d46f3ed8288d75
Task: lubuntu-gtk-core, lubuntu-desktop-share, lubuntu-gtk-desktop, lubuntu-gtk-desktop, lubuntu-core, lubuntu-core, lubuntu-desktop, lubuntu-qt-core, lubuntu-qt-desktop, lubuntu-qt-desktop
Supported: 3y



================================================================================

執行


which gio



顯示


/usr/bin/gio



執行


dpkg -S $(which gio)



顯示


libglib2.0-bin: /usr/bin/gio



================================================================================

執行下面指令,觀看「libglib2.0-bin」這個「Package」,安裝在系統上的檔案


dpkg -L libglib2.0-bin | sort



顯示


/.
/usr
/usr/bin
/usr/bin/gapplication
/usr/bin/gdbus
/usr/bin/gio
/usr/bin/gio-querymodules
/usr/bin/glib-compile-schemas
/usr/bin/gresource
/usr/bin/gsettings
/usr/share
/usr/share/bash-completion
/usr/share/bash-completion/completions
/usr/share/bash-completion/completions/gapplication
/usr/share/bash-completion/completions/gdbus
/usr/share/bash-completion/completions/gresource
/usr/share/bash-completion/completions/gsettings
/usr/share/doc
/usr/share/doc/libglib2.0-bin
/usr/share/doc/libglib2.0-bin/changelog.Debian.gz
/usr/share/doc/libglib2.0-bin/copyright
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/gapplication.1.gz
/usr/share/man/man1/gdbus.1.gz
/usr/share/man/man1/gio.1.gz
/usr/share/man/man1/gio-querymodules.1.gz
/usr/share/man/man1/glib-compile-schemas.1.gz
/usr/share/man/man1/gresource.1.gz
/usr/share/man/man1/gsettings.1.gz



================================================================================

執行「man gio」觀看「manpage」


執行


gio -h



顯示


Usage:
  gio COMMAND [ARGS...]

Commands:
  help     Print help
  version  Print version
  cat      Concatenate files to standard output
  copy     Copy one or more files
  info     Show information about locations
  list     List the contents of locations
  mime     Get or set the handler for a mimetype
  mkdir    Create directories
  monitor  Monitor files and directories for changes
  mount    Mount or unmount the locations
  move     Move one or more files
  open     Open files with the default application
  rename   Rename a file
  remove   Delete one or more files
  save     Read from standard input and save
  set      Set a file attribute
  trash    Move files or directories to the trash
  tree     Lists the contents of locations in a tree

Use “gio help COMMAND” to get detailed help.



================================================================================

執行


gio help trash



顯示


Usage:
  gio trash [OPTION…] [LOCATION...]

Move files or directories to the trash.

Options:
  -f, --force     Ignore nonexistent files, never prompt
  --empty         Empty the trash



================================================================================

執行


gio trash some.txt




================================================================================

* https://developer.gnome.org/gio/stable/
* https://developer.gnome.org/gio/stable/ch33.html#id-1.5.3.3
* https://developer.gnome.org/gio/stable/GFile.html#g-file-trash

================================================================================


以上暫記


2019/4/17 15:23
應用擴展 工具箱
回覆: 如何自動掛載NTFS磁區
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 37
HP : 0 / 901
MP : 671 / 29303
EXP: 6
離線
================================================================================

執行


apt-get source libglib2.0-bin



================================================================================

執行


grep 'Trash' glib2.0-2.56.3/ -R -n



================================================================================


* https://gitlab.gnome.org/GNOME/glib/blob/glib-2-56/gio/glocalfile.c#L1862


================================================================================

執行


grep 'Unable to find or create trash directory for' glib2.0-2.56.3/ -R -n




* https://gitlab.gnome.org/GNOME/glib/blob/glib-2-56/gio/glocalfile.c#L2119
* https://gitlab.gnome.org/GNOME/glib/blob/glib-2-56/gio/glocalfile.c#L2139
* https://gitlab.gnome.org/GNOME/glib/blob/glib-2-56/gio/glocalfile.c#L2076
* https://gitlab.gnome.org/GNOME/glib/blob/glib-2-56/po/zh_TW.po#L2860

上面「#5」和「#1
有提到的提示訊息。

================================================================================

以上暫記


2019/4/17 15:54
應用擴展 工具箱
回覆: 如何自動掛載NTFS磁區
會員五級
註冊日期:
2012/4/22 10:50
所屬群組:
已註冊使用者
等級: 37
HP : 0 / 901
MP : 671 / 29303
EXP: 6
離線
從上面「#9」找到的線索,

延續上面「#5」做的「實驗一」和「實驗二」,

================================================================================

## 實驗三

使用「pcmanfm-qt」掛載某個「partition」,
然後在掛載的那個路徑,例如「/media/user/Data001」,

執行下面指令,產生一個資料夾「.Trash-1000」


sudo mkdir .Trash-1000



上面產生後,原本「.Trash-1000」的「Owner」和「Group」都是「root」。

執行下面指令,將「.Trash-1000」的「Owner」和「Group」改為目前的帳號(假設目前的帳號uid和gid都是1000,參考下面的 註:)

執行


sudo chown $(id -u):$(id -g) .Trash-1000



或是執行 (擇一即可)


sudo chown $(id -un):$(id -gn) .Trash-1000



================================================================================

然後在另外的資料夾,測試刪除檔案,

我測過「gio trash some.txt」,或是「pcmanfm-qt」或是「nautilus」的「Move to Trash」,都是OK的

都會進到剛剛建立的「.Trash-1000/filles」和「.Trash-1000/info」。

================================================================================

註: 以下可以找出相關的「id」或「name」

$ man id

可以執行


id




可以執行


id -u



可以執行


id -un




可以執行


id -u



可以執行


id -g



可以執行


id -gn



================================================================================

以上提供參考

報告完畢


2019/4/17 16:43
應用擴展 工具箱


 [無發表權] 請登錄或者註冊


可以查看帖子.
不可發帖.
不可回覆.
不可編輯自己的帖子.
不可刪除自己的帖子.
不可發起投票調查.
不可在投票調查中投票.
不可上傳附件.
不可不經審核直接發帖.