如何在 ubuntu server 12.04 中自动挂载 USB 外部硬盘?

如何在 ubuntu server 12.04 中自动挂载 USB 外部硬盘?

如何自动安装 USB HD?我安装了 usbmount 但似乎不起作用。下面是一些详细信息:

sudo fdisk-lu:

Disk /dev/sda: 20.4 GB, 20416757760 bytes
255 heads, 63 sectors/track, 2482 cylinders, total 39876480 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: 0x000859fe

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048    38238207    19118080   83  Linux
/dev/sda2        38240254    39874559      817153    5  Extended
/dev/sda5        38240256    39874559      817152   82  Linux swap / Solaris

Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 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: 0x0000d617

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *        2048   972597247   486297600   83  Linux
/dev/sdb2       972599294   976771071     2085889    5  Extended
/dev/sdb5       972599296   976771071     2085888   82  Linux swap / Solaris

Disk /dev/sdc: 40.0 GB, 40020664320 bytes
255 heads, 63 sectors/track, 4865 cylinders, total 78165360 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: 0x43ba43ba

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *          63    78140159    39070048+   7  HPFS/NTFS/exFAT

Disk /dev/sdd: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 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: 0x000c85ff

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1              63  1953520064   976760001    7  HPFS/NTFS/exFAT

Disk /dev/sde: 1500.3 GB, 1500301910016 bytes
255 heads, 63 sectors/track, 182401 cylinders, total 2930277168 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: 0x48686a76

   Device Boot      Start         End      Blocks   Id  System
/dev/sde1              63  2930272064  1465136001    7  HPFS/NTFS/exFAT

sudo blkid:

/dev/sda1: UUID="70d2b83a-1b0a-4c5d-b6ff-89d187b4c96a" TYPE="ext4" 
/dev/sda5: UUID="444db037-76b9-4a53-b357-ab5ae1764044" TYPE="swap" 
/dev/sdb1: LABEL="500GB" UUID="7c0f92c4-3428-4e0a-b724-abe13229224c" TYPE="ext4" 
/dev/sdb5: UUID="370e0ecf-3190-4fe8-92d3-13cb1fedecb1" TYPE="swap" 
/dev/sdc1: LABEL="admin_only" UUID="528b53ef-15ac-4a2d-ad97-425af3a61995" TYPE="ext4" 
/dev/sdd1: LABEL="Hitachi" UUID="e7f30f9f-2d42-4222-bce3-4b58d65c26e3" SEC_TYPE="ext2" TYPE="ext3" 
/dev/sde1: LABEL="Toshiba" UUID="5c61d0bd-eb41-4a8e-aa4e-b6db05d1b43e" SEC_TYPE="ext2" TYPE="ext3" 

山:

/dev/sda1 on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
udev on /dev type devtmpfs (rw,mode=0755)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)
none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)
none on /run/shm type tmpfs (rw,nosuid,nodev)

谢谢你!

答案1

当 USB 设备插入时,它会被探测。如果您有现代 Linux 发行版,则 udev 规则会被触发。(请参阅/etc/udev/rules.d& /lib/udev/rules.d)。

您可以使用这些规则来运行脚本。然后,该脚本可以读取驱动器标签并根据该标签采取特定操作(例如,如果标签是“backup_drive_1”,则将 /data rsync 到该驱动器)。

但是:我自己还没有尝试过。我现在只对如何做到这一点感兴趣,并且有几个方便的链接。(我的目标是将 mdadm 镜像重新同步到特定的 USB 驱动器)。

无论如何,这些链接可能会为您指明正确的道路,也许有人会发布现成的答案。

答案2

您只需将它们添加到 /etc/fstab 即可

UUID=your-uuid-goes-here /where-to-mount-goes-here      ext4    defaults        0       2

NTFS示例:

UUID=your-uuid-goes-here /where-to-mount-goes-here  ntfs-3g defaults,auto,umask=000,users,rw 0 

相关内容