如何在ubuntu服务器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) 

谢谢!

当插入USB设备时,它会被探测。 如果你有一个现代的Linux distributen,那么会触发udev规则。 (参见/lib/udev/rules.d )。

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

但是:我自己没试过。 我所拥有的只是对如何做到这一点以及一些方便的链接感兴趣。 (在我的情况下,目标是将mdadm镜像重新同步到特定的USB驱动器)。

无论如何,这些链接可能会让您走上正确的道路,也许有人会发布一个现成的答案。

您应该只能将它们添加到/ 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