Linux平台命令挂载U盘——实现数据共享
废话少说,一一道来,Linux中按照步骤来做就可以啦。(嵌入式平台)
1、先看看本地的mount信息
# mount
rootfs on / type rootfs (rw)
/dev/root on / type yaffs2 (rw,relatime)
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
tmpfs on /dev type tmpfs (rw,relatime)
devpts on /dev/pts type devpts (rw,relatime,mode=600)
/dev/mtdblock6 on /root/HI3716C type yaffs2 (rw,relatime)
/dev/mtdblock7 on /FlashData type yaffs2 (rw,relatime)
2、插入优盘,系统出现相关打印
# usb 1-1.1: new high speed USB device using hiusb-ehci and address 4
scsi2 : usb-storage 1-1.1:1.0
scsi 2:0:0:0: Direct-Access Generic Flash Disk 8.07 PQ: 0 ANSI: 4
sd 2:0:0:0: [sdb] 15601664 512-byte logical blocks: (7.98 GB/7.43 GiB)
sd 2:0:0:0: [sdb] Write Protect is off
sd 2:0:0:0: [sdb] Assuming drive cache: write through
sd 2:0:0:0: [sdb] Assuming drive cache: write through
sdb: sdb1
sd 2:0:0:0: [sdb] Assuming drive cache: write through
sd 2:0:0:0: [sdb] Attached SCSI removable disk
3、通过fdisk查看u盘的信息
# fdisk -l
Disk /dev/sdb: 7988 MB, 7988051968 bytes
41 heads, 29 sectors/track, 13121 cylinders
Units = cylinders of 1189 * 512 = 608768 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 3 13122 7799544 b Win95 FAT32
上面显示的就是U盘在系统设备中的挂载点,还需要mount到具体的目录中
4、mount,关于mount的详细参数,请自行google
可以看到u盘的分区,然后将该分区mount到指定目录,注意mount的参数
# mount -t yaffs2 /dev/sdb1 /root/Upan ---错误
mount: mounting /dev/sdb1 on /root/Upan failed: No such file or directory
# mkdir /root/Upan
# mount -t yaffs2 /dev/sdb1 /root/Upan ---错误
yaffs: dev is 8388625 name is "sdb1" rw
yaffs: passed flags ""
mount: mounting /dev/sdb1 on /root/Upan failed: Invalid argument
# mount /dev/sdb1 /root/Upan ---这里才是挂载成功的命令,为什么?请自行google mount命令的详细说明
5、查看U盘中的文件信息
进入到mount的目录中,就可以查看文件,实现数据拷贝和保存了。
# cd /root/Upan/
# ls
Fedora 8 i386 DV.iso UpgradeFile
VMware-8.0.4??? ???? RECYCLER tcjt
挂载成功,可以看到u盘中的数据了。