文章目录
-
-
- 一.实验环境
- 二.实验步骤
-
-
- 0.接入SD卡
- 1.fdisk命令。
- 2.准备进入fdisk
- 3.完成实验步骤
- 4.实验结果
-
-
一.实验环境
虚拟机软件:vmware16 workstation Ubuntu 14.04 SD卡 16GB
二.实验步骤
0.接入SD卡
打开虚拟机软件 登录linux系统 将sd卡通过读卡器插入电脑usb接口 并且选择SD卡接入虚拟机
1.fdisk命令。
指令:fdisk 用途:观察硬盘实体的使用情况,分割硬盘。
- 输入 m 显示所有命令列示。
- 输入 p 显示硬盘分割。
- 输入 a 设置硬盘启动区。
- 输入 n 设置新的硬盘分区。 4.1. 输入 e 硬盘[延伸]分区(extend)。 4.2. 输入 p 硬盘[主要]分区(primary)。
- 输入 t 改变硬盘分区属性。
- 输入 d 删除硬盘分割区属性。
- 输入 q 硬盘分不存储硬盘分割区属性。
- 输入 w 结束并写入硬盘分区属性。
2.准备进入fdisk
以下两个命令将进入fdisk 更改sd卡分区模式 umount /dev/sdb* sudo fdisk /dev/sdb
PS: 若无法显示sd卡,可以用下面的命令查看linux虚拟机下的所有硬盘和sd卡。 改变以上两个命令dev/sdb 的sdb为sda或者sdd 对应sd卡设备 sudo fdisk -l
3.完成实验步骤
#运行fdisk sd卡分区程序 tronlong@tronlong-virtual-machine:~/AM57x/mksdboot_22_23_22$ umount /dev/sdb* tronlong@tronlong-virtual-machine:~/AM57x/mksdboot_22_23_22$ sudo fdisk /dev/sdb #p:显示sd卡的分区 Command (m for help): p Disk /dev/sdb: 15.7 GB, 15732310016 bytes 64 heads, 32 sectors/track, 15003 cylinders, total 30727168 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: 0x500a0dff This doesn't look like a partition table Probably you selected the wrong device. Device Boot Start End Blocks Id System /dev/sdb1 ? 1948285285 3650263507 850989111 6e Unknown /dev/sdb2 ? 0 0 0 74 Unknown /dev/sdb4 28049408 28049848 220 0 Empty Partition table entries are not in disk order #m:显示帮助信息 Command (m for help): m Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) #d:删除分区 现在删除三个分区 1 2 4是分区号 Command (m for help): d Partition number (1-4): 1 Command (m for help)/span>: d Partition number (1-4): 2 Command (m for help): d Selected partition 4 #再次查看已经没有了之前的3个分区 Command (m for help): p Disk /dev/sdb: 15.7 GB, 15732310016 bytes 64 heads, 32 sectors/track, 15003 cylinders, total 30727168 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: 0x500a0dff Device Boot Start End Blocks Id System #n:新增分区 Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): Using default response p Partition number (1-4, default 1): 1 First sector (2048-30727167, default 2048): Using default value 2048 #+3G:设置分区大小3G Last sector, +sectors or +size{
K,M,G} (2048-30727167, default 30727167): +3G Command (m for help): n Partition type: p primary (1 primary, 0 extended, 3 free) e extended Select (default p): Using default response p Partition number (1-4, default 2): Using default value 2 First sector (6293504-30727167, default 6293504): Using default value 6293504 Last sector, +sectors or +size{
K,M,G} (6293504-30727167, default 30727167): +6G Command (m for help): n Partition type: p primary (2 primary, 0 extended, 2 free) e extended Select (default p): Using default response p Partition number (1-4, default 3): Using default value 3 First sector (18876416-30727167, default 18876416): Using default value 18876416 Last sector, +sectors or +size{
K,M,G} (18876416-30727167, default 30727167): Using default value 30727167 Command (m for help): p Disk /dev/sdb: 15.7 GB, 15732310016 bytes 64 heads, 32 sectors/track, 15003 cylinders, total 30727168 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: 0x500a0dff Device Boot Start End Blocks Id System /dev/sdb1 2048 6293503 3145728 83 Linux /dev/sdb2 6293504 18876415 6291456 83 Linux /dev/sdb3 18876416 30727167 5925376 83 Linux #t:改变文件分区类型 Command (m for help): t Partition number (1-4): 1 #l:显示可设置的分区类型 Hex code (type L to list codes): l 0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris 1 FAT12 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT- 2 XENIX root 39 Plan 9 83 Linux c4 DRDOS/sec (FAT- 3 XENIX usr 3c PartitionMagic 84 OS/2 hidden C: c6 DRDOS/sec (FAT- 4 FAT16 <32M 40 Venix 80286 85 Linux extended c7 Syrinx 5 Extended 41 PPC PReP Boot 86 NTFS volume set da Non-FS data 6 FAT16 42 SFS 87 NTFS volume set db CP/M / CTOS / . 7 HPFS/NTFS/exFAT 4d QNX4.x 88 Linux plaintext de Dell Utility 8 AIX 4e QNX4.x 2nd part 8e Linux LVM df BootIt 9 AIX bootable 4f QNX4.x 3rd part 93 Amoeba e1 DOS access a OS/2 Boot Manag 50 OnTrack DM 94 Amoeba BBT e3 DOS R/O b W95 FAT32 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor c W95 FAT32 (LBA) 52 CP/M a0 IBM Thinkpad hi eb BeOS fs e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD ee GPT f W95 Ext'd (LBA) 54 OnTrackDM6 a6 OpenBSD ef EFI (FAT-12/16/ 10 OPUS 55 EZ-Drive a7 NeXTSTEP f0 Linux/PA-RISC b 11 Hidden FAT12 56 Golden Bow a8 Darwin UFS f1 SpeedStor 12 Compaq diagnost 5c Priam Edisk a9 NetBSD f4 SpeedStor 14 Hidden FAT16 <3 61 SpeedStor ab Darwin boot f2 DOS secondary 16 Hidden FAT16 63 GNU HURD or Sys af HFS / HFS+ fb VMware VMFS 17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fc VMware VMKCORE 18 AST SmartSleep 65 Novell Netware b8 BSDI swap fd Linux raid auto 1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fe LANstep 1c Hidden W95 FAT3 75 PC/IX be Solaris boot ff BBT 1e Hidden W95 FAT1 80 Old Minix #c:设置为W95 FAT32类型 Hex code (type L to list codes): c Changed system type of partition 1 to c (W95 FAT32 (LBA)) Command (m for help): p Disk /dev/sdb: 15.7 GB, 15732310016 bytes 64 heads, 32 sectors/track, 15003 cylinders, total 30727168 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: 0x500a0dff Device Boot Start End Blocks Id System /dev/sdb1 2048 6293503 3145728 c W95 FAT32 (LBA) /dev/sdb2 6293504 18876415 6291456 83 Linux /dev/sdb3 18876416 30727167 5925376 83 Linux #最后别忘记保存,输入w Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: If you have created or modified any DOS 6.x partitions, please see the fdisk manual page for additional information. Syncing disks.
4.实验结果
sudo fdisk -l查看sd卡分区结果 那个15.7GB的是我们的sd卡
tronlong@tronlong-virtual-machine:~/AM57x/mksdboot_22_23_22$ sudo fdisk -l
Disk /dev/sda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders, total 209715200 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: 0x0003e565
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 205522943 102760448 83 Linux
/dev/sda2 205524990 209713151 2094081 5 Extended
/dev/sda5 205524992 209713151 2094080 82 Linux swap / Solaris
Disk /dev/sdb: 15.7 GB, 15732310016 bytes
64 heads, 32 sectors/track, 15003 cylinders, total 30727168 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: 0x500a0dff
Device Boot Start End Blocks Id System
/dev/sdb1 2048 6293503 3145728 c W95 FAT32 (LBA)
/dev/sdb2 6293504 18876415 6291456 83 Linux
/dev/sdb3 18876416 30727167 5925376 83 Linux