![在 ubuntu 14.04 啟動時為所有使用者安裝外部硬碟](https://rvso.com/image/1048338/%E5%9C%A8%20ubuntu%2014.04%20%E5%95%9F%E5%8B%95%E6%99%82%E7%82%BA%E6%89%80%E6%9C%89%E4%BD%BF%E7%94%A8%E8%80%85%E5%AE%89%E8%A3%9D%E5%A4%96%E9%83%A8%E7%A1%AC%E7%A2%9F.png)
您好,我是 Ubuntu 新手,最近安裝了 14.04 LTS。我在啟動時為所有用戶安裝外部硬碟時遇到問題。例如,啟動後如果我以使用者A登錄,則只有使用者A可以存取外部媒體,其他人無法存取這些外部媒體。有人可以幫我解決這個問題嗎?
輸出到以下命令
須藤塊
/dev/sda1: UUID="98715d8d-bf13-48f5-882e-36270c539c94" TYPE="ext4"
/dev/sda2: UUID="qOUDEc-qHDq-y9NL-OWCF-fO04-vnPI-8UNrtV" TYPE="LVM2_member"
/dev/sdb1: UUID="6ulNAl-1Hky-orpE-ntL2-Brgu-Qen1-BYqCIh" TYPE="LVM2_member"
/dev/mapper/VolGroup-lv_root: UUID="a7e84558-d5d3-43f3-8788-a483dde96fd8" TYPE="ext4"
/dev/mapper/VolGroup-lv_home: UUID="fb65cc75-ab1a-44a4-8f98-b1767d03f15a" TYPE="ext4"
/dev/mapper/VolGroup-lv_swap: UUID="69e3381b-a2b5-4866-81b6-bd368c9157d5" TYPE="swap"
/dev/sdc1: LABEL="ExtHDD04" UUID="0DFFA1CB15212E12" TYPE="ntfs"
/dev/sdd1: LABEL="ExtHDD03" UUID="485AA7713243CEFB" TYPE="ntfs"
/dev/sde1: UUID="485ef4bd-0093-42c5-a3e5-0090e68e93c1" TYPE="ext4"
/dev/sr1: LABEL="WD SmartWare" TYPE="udf"
/dev/sdg1: LABEL="ExtHDD01" UUID="00148BDE148BD4D6" TYPE="ntfs"
須藤 fdisk -l
Disk /dev/sda: 250.0 GB, 250000000000 bytes
255 heads, 63 sectors/track, 30394 cylinders, total 488281250 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xc648a420
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 488280063 243627008 8e Linux LVM
Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders, total 3907029168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000617c8
Device Boot Start End Blocks Id System
/dev/sdb1 2048 3907028991 1953513472 8e Linux LVM
Disk /dev/mapper/VolGroup-lv_root: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders, total 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/VolGroup-lv_root doesn't contain a valid partition table
Disk /dev/mapper/VolGroup-lv_home: 2168.7 GB, 2168656494592 bytes
255 heads, 63 sectors/track, 263657 cylinders, total 4235657216 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/VolGroup-lv_home doesn't contain a valid partition table
Disk /dev/mapper/VolGroup-lv_swap: 27.5 GB, 27481079808 bytes
255 heads, 63 sectors/track, 3341 cylinders, total 53673984 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/VolGroup-lv_swap doesn't contain a valid partition table
WARNING: GPT (GUID Partition Table) detected on '/dev/sdc'! The util fdisk doesn't support GPT. Use GNU Parted.
Disk /dev/sdc: 3000.6 GB, 3000558944256 bytes
255 heads, 63 sectors/track, 364797 cylinders, total 5860466688 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/sdc1 1 4294967295 2147483647+ ee GPT
Partition 1 does not start on physical sector boundary.
WARNING: GPT (GUID Partition Table) detected on '/dev/sdd'! The util fdisk doesn't support GPT. Use GNU Parted.
Disk /dev/sdd: 3000.6 GB, 3000558944256 bytes
255 heads, 63 sectors/track, 364797 cylinders, total 5860466688 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/sdd1 1 4294967295 2147483647+ ee GPT
Partition 1 does not start on physical sector boundary.
WARNING: GPT (GUID Partition Table) detected on '/dev/sde'! The util fdisk doesn't support GPT. Use GNU Parted.
Disk /dev/sde: 3000.6 GB, 3000558944256 bytes
255 heads, 63 sectors/track, 364797 cylinders, total 5860466688 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000
Device Boot Start End Blocks Id System
/dev/sde1 1 4294967295 2147483647+ ee GPT
Partition 1 does not start on physical sector boundary.
Disk /dev/sdg: 1999.7 GB, 1999696297984 bytes
228 heads, 56 sectors/track, 305894 cylinders, total 3905656832 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xe534f55f
Device Boot Start End Blocks Id System
/dev/sdg1 2048 3905656831 1952827392 7 HPFS/NTFS/exFAT
貓 /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>
/dev/mapper/VolGroup-lv_root / ext4 errors=remount-ro 0 1
/dev/mapper/VolGroup-lv_home /home ext4 defaults 0 2
/dev/mapper/VolGroup-lv_swap none swap sw 0 0
答案1
要在啟動時為所有使用者安裝分割區,我們需要在fstab
文件中新增一個條目。目前發生的情況是,正在為登入的使用者安裝 HDD,僅向該使用者授予存取權限。透過在 fstab 中新增條目,該分割區將由 root 掛載,並有權存取所有使用者。此讀/寫存取可以稍後控制。
sudo blkid
列出系統上所有可用的分割區。記下要UUID
在啟動時掛載的 NTFS 分割區的分割區號碼。在你的情況下,似乎00148BDE148BD4D6
現在建立一個資料夾,例如sudo mkdir /media/ExtHDD01
.這是將安裝外部 HDD 分割區的資料夾。該資料夾將歸 root 所有。要授予其他使用者讀取和寫入此資料夾的權限,我們需要授予適當的權限。這樣chmod -R 777 /media/ExtHDD01
就足夠了。現在您需要編輯 fstab 檔案。為此,請鍵入以下命令。
sudo nano /etc/fstab
轉到文件底部並添加以下行。
UUID=00148BDE148BD4D6 /media/ExtHDD01/ ntfs-3g auto,user,rw 0 0
重新啟動系統,你應該就可以開始了。您可以對任意數量的 HDD 執行相同的程序。
答案2
圖形使用者介面方法
插入驅動器。
轉到
Disks
桌面查找器(或sudo gnome-disks
在終端機上)在左欄中選擇正確的磁碟。
點擊齒輪圖標
選擇
edit mount options
轉動
off
檢查
mount at startup
和show user interface
就是這樣!
答案3
我最近遇到了同樣的情況,我找到了解決方案。
我有 2 個用戶,管理員和桌面用戶,我想在他們各自的登入時安裝標記為「儲存」的相同驅動器,因此:
在文件中/etc/fstab
我必須新增以下條目:
LABEL=STORAGE /media/$USER/STORAGE auto nosuid,nodev,nofail,x-gvfs-show 0 0
值得注意的是環境變數的使用$USER
。
這是針對 Ubuntu 16.04,其中新磁碟機安裝在/media/<username>/<drive-label>
您也可以使用 UUID 來代替<drive-label>
.