Linux-Mint

無法掛載卷,操作已掛起(有多個使用者)

  • October 17, 2020

我正在執行 Linux Mint 14——幾乎不管預設安裝設置是什麼。當我有多個使用者登錄並插入快閃記憶體驅動器、數位相機或任何其他 USB 儲存設備時,而不是彈出自動掛載,它什麼也不做。

因此,如果我使用 Caja(我猜是 Nautilus 等價物)嘗試安裝它,它會告訴我:

                               無法掛載 4.0 GB 卷 - 操作已掛起

如果我登錄到其他使用者帳戶,我會看到一個視窗,詢問我想採取什麼行動。

如何關閉自動掛載,並且只有在我從文件瀏覽器中點擊它時才嘗試掛載?

如何關閉自動掛載,並且只有在我從文件瀏覽器中點擊它時才嘗試掛載?

通過使用dconf-editor來禁用自動掛載,如下所述:如何在 nautilus 的首選項中禁用自動掛載

或者,執行以下命令:

gsettings set org.gnome.desktop.media-handling automount false

這是未經測試的,但我確實遇到了這個頁面:automounting usb flash drive on linux with udev and pmount

一般的想法是您創建一個 UDEV 操作,該操作將使用 pmount 自動掛載。如果您查看評論,則punmount -l會有一個懶惰的解除安裝,它應該更安全。

摘抄

這是僅使用 udev 和 pmount 在 linux 上自動掛載 USB 快閃記憶體驅動器/記憶棒的解決方案。

  1. 中添加一個文件automount.rules/etc/udev/rules.d
  2. 將以下幾行放入其中
# automounting usb flash drives
# umask is used to allow every user to write on the stick
# we use --sync in order to enable physical removing of mounted memory 
# sticks -- this is OK for fat-based sticks
# I don't automount sda since in my system this is the internal hard 
# drive depending on your hardware config, usb sticks might be other 
# devices than sdb*

ACTION=="add",KERNEL=="sdb*", RUN+="/usr/bin/pmount --sync --umask 000 %k"
ACTION=="remove", KERNEL=="sdb*", RUN+="/usr/bin/pumount %k"
ACTION=="add",KERNEL=="sdc*", RUN+="/usr/bin/pmount --sync --umask 000 %k"
ACTION=="remove", KERNEL=="sdc*", RUN+="/usr/bin/pumount %k"
  1. 重新載入 udev 規則:udevadm control --reload-rules

**注意:**如果你想讓這個設置更能容忍解除安裝,那麼你需要將-lfor lazy unmounting 包含到punmount.

ACTION=="remove", KERNEL=="sda*", RUN+="/usr/bin/pumount -l %k"

pumount的手冊頁:

  -l, --lazy
         Lazy unmount. Detach the filesystem from the filesystem hierarchy 
         now, and cleanup all references to the filesystem as soon as it is
         not  busy  anymore.   (Requires kernel 2.4.11 or later.) 
         IMPORTANT NOTES This option should not be used unless you really 
         know what you are doing, as chances are high that it will result 
         in data loss on the removable drive. Please run  pumount  manually  
         and  wait until it finishes. In addition, pumount will not 
         luksClose a device which was unmounted lazily.

引用自:https://unix.stackexchange.com/questions/117721