Linux 下挂载U盘

首先通过fdisk –l检 查USB设备是否已经被系统识别:

[root@bjtest ~]# fdisk -l

Disk /dev/sda: 1197.7 GB, 1197759004672 bytes
255 heads, 63 sectors/track, 145619 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 5235 41945715 83 Linux
/dev/sda3 5236 10457 41945715 83 Linux
/dev/sda4 10458 145619 1085688765 5 Extended
/dev/sda5 10458 13068 20972826 83 Linux
/dev/sda6 13069 14112 8385898+ 82 Linux swap / Solaris
/dev/sda7 14113 145619 1056329946 83 Linux

Disk /dev/sdb: 60.0 GB, 60022480896 bytes
255 heads, 63 sectors/track, 7297 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 2 3825 30716280 f W95 Ext'd (LBA)
/dev/sdb2 * 3826 7297 27888840 c W95 FAT32 (LBA)
/dev/sdb5 2 3825 30716248+ b W95 FAT32

可以看到/dev/sdb就 是USB盘,而且这个U盘花费了多个区,尝 试通过MOUNT命令挂载U盘,对于fat16、fat32和ntfs在Linux系统中可以统一使用vfat来指定:

[root@bjtest ~]# mkdir /mnt/usb1 /mnt/usb2
[root@bjtest ~]# mount -t vfat /dev/sdb1 /mnt/usb1
mount: wrong fs type, bad option, bad superblock on /dev/sdb1,
missing codepage or other error
(aren’t you trying to mount an extended partition,
instead of some logical partition inside?)
In some cases useful info is found in syslog – try
dmesg | tail or so

[root@bjtest ~]# mount -t vfat /dev/sdb2 /mnt/usb1
[root@bjtest ~]# mount -t vfat /dev/sdb5 /mnt/usb2
[root@bjtest ~]# df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 40631988 17589084 20945620 46% /
/dev/sda1 101086 15958 79909 17% /boot
/dev/sda7 1023246840 783797928 186632416 81% /data
tmpfs 8209472 3989672 4219800 49% /dev/shm
/dev/sda3 40631988 13570856 24963848 36% /home
/dev/sda5 20315812 176352 19090820 1% /tmp
/dev/sdb2 27875200 19757344 8117856 71% /mnt/usb1
/dev/sdb5 30701232 176 30701056 1% /mnt/usb2

其中/dev/sdb1无 法挂载,不过可以看到,/dev/sdb2和/dev/sdb5挂 载后,两个文件系统总和就是60G,说明USB盘已 经挂载成功。

卸载USB设 备就更容易了,只需要执行umount /mnt/usb1和umount /mnt/usb2就可以了:

[root@bjtest /]# umount /mnt/usb1
[root@bjtest /]# umount /mnt/usb2

你可能感兴趣的:(linux)