1. 查看存储设备的信息
fdisk -l
显示如下:
Device Boot Start End Sectors Size Id Type
/dev/mmcblk1p1 2048 43007 40960 20M 83 Linux
/dev/mmcblk1p2 43008 452607 409600 200M 83 Linux
/dev/mmcblk1p3 452608 14876671 14424064 6.9G 83 Linux
Disk /dev/mmcblk0: 3.7 GiB, 3965190144 bytes, 7744512 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
Disklabel type: dos
Disk identifier: 0x3bcb1b2b
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 8192 7744511 7736320 3.7G c W95 FAT32 (LBA)
/dev/mmcblk0p3 24897 24897 0 0B 0 Empty
2. 进入操作存储设备的操作界面,下面这个是个sd卡,这样可以直接操作整个卡,如果后面有p1,p2,p3则是代表的分区
fdisk /dev/mmcblk0
输出内容如下:
Welcome to fdisk (util-linux 2.31.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help):
3. 查看帮助m,输入m则为查看帮助
Command (m for help): m
Help:
DOS (MBR)
a toggle a bootable flag
b edit nested BSD disklabel
c toggle the dos compatibility flag
Generic
d delete a partition
F list free unpartitioned space
l list known partition types
n add a new partition
p print the partition table
t change a partition type
v verify the partition table
i print information about a partition
Misc
m print this menu
u change display/entry units
x extra functionality (experts only)
Script
I load disk layout from sfdisk script file
O dump disk layout to sfdisk script file
Save & Exit
w write table to disk and exit
q quit without saving changes
Create a new label
g create a new empty GPT partition table
G create a new empty SGI (IRIX) partition table
o create a new empty DOS partition table
s create a new empty Sun partition table
4. 删除分区d,需要删除那个分区就选择数字几
Command (m for help): d
Partition number (1,3, default 3): 1
Partition 1 has been deleted.
5. 新建分区n,一般直接建立主分区就行,就是利用p,扩展分区的话采用e
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-7744511, default 2048): 2048
Last sector, +sectors or +size{K,M,G,T,P} (2048-7744511, default 7744511): 43007
6.保存分区w
Command (m for help): w
The partition table has been altered.
Syncing disks.
7. 查看分区参数p
Command (m for help): p
Disk /dev/mmcblk0: 3.7 GiB, 3965190144 bytes, 7744512 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
Disklabel type: dos
Disk identifier: 0x3bcb1b2b
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 2048 43007 40960 20M 83 Linux
/dev/mmcblk0p2 43008 452607 409600 200M 83 Linux
/dev/mmcblk0p3 452608 7744511 7291904 3.5G 83 Linux
Command (m for help):
版权声明:本文为cao849861802原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。