
我在 Xubuntu 21.10(核心 5.11.0-41-generic)下遇到此問題。
當我插入 USB 外部驅動器後,請點擊 Thunar 側欄中的標籤(因此它會顯示,但仍然未安裝),驅動器會以不同的方式安裝“標籤”每一次。它始終安裝在同一個父資料夾中,但它安裝到的資料夾是/media/$USER/DRIVE_NAME$NUMBER
,其中$NUMBER是每次安裝驅動器時都會遞增的數字。
每次插入時如何將驅動器安裝到同一安裝點?
答案1
您可以在 中告訴掛載點/etc/fstab
。因此,您可以設定名稱,並且您的分割區將始終以相同的名稱掛載。文件頭有合理的解釋
$ cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
看1:
sudo fdisk -l
運行和的組合sudo blkid
來識別分區的 UUID。- 編輯
sudo nano /etc/fstab
(或使用您選擇的編輯器)。 - 新增一行,如
UUID="xxxx-xxxx" /media/<mount point of your choice> ext4 defaults,user,auto 0 1
. - 重啟。
應該對要使用的確切標誌進行微調。您必須建立目錄/media/<mount point of your choice>
才能進行安裝。
答案2
以下是我自動安裝 USB 隨身碟的步驟:
1.建立掛載點
$ sudo mkdir /mount/<usb-drive-name>
<usb-drive-name>
按照你喜歡的方式命名,但請記住
掛載點名稱中不應包含空格。
2. 找出您的磁碟機的號UUID
和號TYPE
$ sudo blkid
將為您提供已安裝驅動器的列表,找到您的 USB 驅動器:
...
/dev/sda1: LABEL="my-usb-drive" UUID="e6a1db23-be63-4b39-b263-e68101bb179d" TYPE="ext4"
...
3. 編輯fstab
(我使用vim
,但任何編輯器都可以)
$ sudo vim /etc/fstab
通常它看起來像這樣:
# /etc/fstab: static file system information.
#
# These are the filesystems that are always mounted on boot, you can
# override any of these by copying the appropriate line from this file into
# /etc/fstab and tweaking it as you see fit. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
/dev/root / ext4 defaults 0 1
/swfile none swap sw 0 0
TYPE
如果是ext4
(linux 分割區),請新增此行:
# <file system> <mount point> <type> <options> <dump> <pass>
/dev/root / ext4 defaults 0 1
/swfile none swap sw 0 0
UUID="e6a1db23-be63-4b39-b263-e68101bb179d" /media/<usb-drive-name> ext4 defaults 0 2
TYPE
如果是ntfs
(Windows 分割區),請新增此行:
# <file system> <mount point> <type> <options> <dump> <pass>
/dev/root / ext4 defaults 0 1
/swfile none swap sw 0 0
UUID="e6a1db23-be63-4b39-b263-e68101bb179d" /media/<usb-drive-name> ntfs defaults 0 0
如果TYPE
是fat
(所有作業系統分割):
# <file system> <mount point> <type> <options> <dump> <pass>
/dev/root / ext4 defaults 0 1
/swfile none swap sw 0 0
UUID="e6a1db23-be63-4b39-b263-e68101bb179d" /media/<usb-drive-name> fat defaults 0 0
PASS(fsck 指令參數)解釋:
實際上,使用“1”表示根分區/,使用 2 表示其餘分區。所有標示為「2」的分割區都會依序檢查,您無需指定順序。
對於
pass
參數,使用「0」停用啟動時檢查檔案系統或網路共用。
這裡有fstab 選項解釋道。
4.(選購)將 USB 隨身碟新增至您的主目錄
如果您希望安裝的 USB 隨身碟也自動出現在您的HOME
目錄中,請將此行新增至fstab
:
# <file system> <mount point> <type> <options> <dump> <pass>
/dev/root / ext4 defaults 0 1
/swfile none swap sw 0 0
UUID="e6a1db23-be63-4b39-b263-e68101bb179d" /media/<usb-drive-name> ext4 defaults 0 2
/media/<usb-drive-name> /home/<USERNAME>/<usb-drive-name> none bind 0 0