如何自動掛載 USB HD?我安裝了 usbmount 但似乎不起作用。以下是一些細節:
須藤 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
須藤塊:
/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”,則 rsync /data 到該磁碟機)。
但是:我自己還沒有嘗試過。我所擁有的只是對如何做到這一點的興趣以及一些方便的連結。 (在我的例子中,目標是將 mdadm 鏡像重新同步到特定的 USB 隨身碟)。
無論如何,這些連結可能會讓您走上正確的道路,也許有人會發布現成的答案。
- http://reactivated.net/writing_udev_rules.html#external-run
- https://unix.stackexchange.com/questions/5623/what-happens-when-a-usb-drive-is-plugged-in
- http://ubuntuforums.org/showthread.php?t=168221
- https://stackoverflow.com/questions/469243/how-can-i-listen-for-usb-device-inserted-events-in-linux-in-python
答案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