将SD卡经过读卡器插入虚拟机内,执行如下命令检测挂在位置。
mount | grep /media
卸载SD卡
sudo umount /dev/sdxx
用“dd”命令清除MRB和分区信息:
sudo dd if=/dev/zero of=/dev/sdx bs=10M count=1
用“fdisk”命令修改分区表
sudo fdisk /dev/sdx
按“P”键显示当前分区信息:
Command (m for help): p Disk /dev/mmcblk0: 2002 MB, 2002780160 bytes 11 heads, 10 sectors/track, 35560 cylinders Units = cylinders of 110 * 512 = 56320 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Device Boot Start End Blocks Id System
按“n”键增加一个primary分区,并确定分区尺寸
Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-35560, default 1): Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-35560, default 35560): +64M
按“t”键,再输入数字 6, 使新分区为FAT16文件系统:
Command (m for help): t Selected partition 1 Hex code (type L to list codes): 6 Changed system type of partition 1 to 6 (FAT16)
按“n”键创建第二个分区:
Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 2 First cylinder (1194-35560, default 1194): Using default value 1194 Last cylinder, +cylinders or +size{K,M,G} (1194-35560, default 35560): +1500M
按“P”键显示当前分区信息:
Command (m for help): p Device Boot Start End Blocks Id System /dev/mmcblk0p1 1 1193 65610 6 FAT16 /dev/mmcblk0p2 1194 29121 1536040 83 Linux
按“W”键写入分区信息。
Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table.
格式化并挂载分区:
sudo mkfs.msdos /dev/mmcblk0p1 # format as FAT32 you need add parameters "-F 32". if using SD card reader you need change the device name to "/dev/sdx1"
sudo mkfs.ext2 /dev/mmcblk0p2 # if using SD card reader you need change the device name to "/dev/sdx2"
sudo mount -t vfat /dev/sdx1/mnt/fat
sudo mount -t ext2 /dev/sdx2 /mnt/ext