![在 ubuntu 14.04 启动时为所有用户安装外部硬盘](https://linux22.com/image/1048338/%E5%9C%A8%20ubuntu%2014.04%20%E5%90%AF%E5%8A%A8%E6%97%B6%E4%B8%BA%E6%89%80%E6%9C%89%E7%94%A8%E6%88%B7%E5%AE%89%E8%A3%85%E5%A4%96%E9%83%A8%E7%A1%AC%E7%9B%98.png)
嗨,我是 Ubuntu 新手,最近安装了 14.04 LTS。我在启动时为所有用户安装外部硬盘时遇到问题。例如,启动后,如果我以用户 A 登录,则只有用户 A 可以访问外部媒体,其他人无法访问这些外部媒体。有人能帮我解决这个问题吗?
输出到以下命令
命令 blkid
/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"
sudo 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
。这是将安装外部硬盘分区的文件夹。此文件夹将归 root 所有。要授予其他用户读写此文件夹的权限,我们需要授予适当的权限。这样chmod -R 777 /media/ExtHDD01
就足够了。现在您需要编辑 fstab 文件。为此,请键入以下命令。
sudo nano /etc/fstab
转到文件底部并在那里添加以下行。
UUID=00148BDE148BD4D6 /media/ExtHDD01/ ntfs-3g auto,user,rw 0 0
重启系统,一切就绪。您可以对任意数量的硬盘执行相同的步骤。
答案2
GUI 方法
插入驱动器。
进入
Disks
桌面查找器(或sudo gnome-disks
终端)在左栏中选择正确的磁盘。
点击齿轮图标
选择
edit mount options
转动
off
检查
mount at startup
show user interface
就是这样!
答案3
我最近遇到了同样的情况并且找到了解决方案。
我有 2 个用户,ADMIN 和 DESKTOP USER,我想在他们各自的登录名上安装同一个标有 STORAGE 的驱动器,因此:
/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>
。