只有root可以在/ media / sdb1上挂载/ dev / sdb1 - 对外部USB驱动器有贡献

Modified on: Thu, 14 Jun 2018 05:53:23 +0800

我无法理解为什么当我在Ubuntu 12.04中尝试使用插件外置USB驱动程序时,我会看到下一条消息:

Error mounting: mount exited with exit code 1: helper failed with:
mount: only root can mount /dev/sdb1 on /media/sdb1

以下是/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>
proc                                       /proc           proc  nodev,noexec,nosuid       0  0  
# / was on /dev/sda1 during installation
UUID=5f5d330f-d5f2-4157-9496-94f1dce2f181  /               ext4  errors=remount-ro         0  1  
# swap was on /dev/sda5 during installation
UUID=84747ef4-6f50-49bc-9df1-fcba364ba299  none            swap  sw                        0  0  

/dev/fd0                                   /media/floppy0  auto  rw,user,noauto,exec,utf8  0  0  
/dev/sdc1                                  /media/sdc1     vfat  uid=1000,noauto           0  0  
/dev/sdd1                                  /media/sdd1     vfat  uid=1000,noauto           0  0  
/dev/sdb1                                  /media/sdb1     vfat  uid=1000,noauto           0  0

这是我当前的sudo fdisk -l

Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders, total 312581808 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: 0x000e28b8

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048   310484991   155241472   83  Linux
/dev/sda2       310487038   312580095     1046529    5  Extended
/dev/sda5       310487040   312580095     1046528   82  Linux swap / Solaris

Disk /dev/sdb: 993 MB, 993001472 bytes
2 heads, 1 sectors/track, 969728 cylinders, total 1939456 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

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1             133     1939455      969661+   6  FAT16

Disk /dev/sdc: 4009 MB, 4009754624 bytes
16 heads, 32 sectors/track, 15296 cylinders, total 7831552 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: 0xd8e1f237

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *          32     7831551     3915760    b  W95 FAT32

sdcsdb - 有外部USB驱动程序。

我可以自动解决此问题并安装所有外置USB驱动器吗?

最佳答案

您需要将user选项添加到fstab

/dev/sdc1    /media/sdc1     vfat  uid=1000,noauto,user           0  0  
/dev/sdd1    /media/sdd1     vfat  uid=1000,noauto,user           0  0  
/dev/sdb1    /media/sdb1     vfat  uid=1000,noauto,user           0  0

user选项允许任何用户安装设备,如男人所说:

  

通常,只有超级用户才能挂载文件系统。但是,当fstab在一行中包含user选项时,任何人都可以挂载相应的系统。

或者,如果您希望任何用户安装/卸载驱动器,请使用users

/dev/sdc1    /media/sdc1     vfat  uid=1000,noauto,users           0  0  
/dev/sdd1    /media/sdd1     vfat  uid=1000,noauto,users           0  0  
/dev/sdb1    /media/sdb1     vfat  uid=1000,noauto,users           0  0

手册页:

  

只有安装了文件系统的用户才能再次卸载它。如果任何用户应该能够卸载,那么在fstab行中使用用户而不是用户。

注意: user选项还隐含noexecnosuidnodev,所以如果你需要这些选项,你需要添加他们的对应物。例如,如果您需要从驱动器执行二进制文件,则应添加选项exec,因此您的选项将是uid=1000,noauto,user,exec

进一步阅读:Fstab - Ubuntu文档


相关问答

添加新评论