There are two types of commands for primary partitions: Fdisk and parted
Both commands require root access,
The fdisk command is introduced first:
Fdisk can see how the current file system is being used
-l
Because I'm a system with an SD card. So the partition starts with/dev/mmcblk0, and you can see that there are currently 3 actual partitions (the/dev/mmcblk1,2,5.linux partition has the primary partition, the extension partition and the logical partition, Only primary and logical partitions are really storing data, so MMCBLK3 is not the actual partition.
by directive
fdisk /dev/[这里填的是磁盘驱动名,如果是IDE的硬盘则为hd(a-p),SATA硬盘为sd(a-p),我使用的SD卡驱动名为mmcblk0]
Specific help using M code:
Use code p to view current disk partition status
And then add the partition by the N code.
In such cases, the disk can only have a maximum of four non-logical partitions (which is determined by the partition table partition tables in the boot sector), where the extended partition is 0-1, and the logical partition is created under an extended partition
1. There are four non-logical partitions, you cannot create a new partition
2. The non-logical partition is under 4, you can choose to create a primary or extend partition (note that extend can only have at most one), there is a extend in the case of a logical partition (the IDE interface can create up to 59 partition designators from 5~ 63,sata can create up to 11 logical partitions from 5~15, note that logical partitions start with the 5 codename, since the first four are given non-logical partitions)
I have a extend partition, so just let me create a primary partition or logical partition.
Select the start sector of the new partition, where you will refer to the previous partition:
This gives the recommended values for the start sector and the end sector (typically the start sector directly with the suggested value, the end sector needs to use the start sector + partition size)
You will be prompted to create a success, and then use the P code to view the partition.
Finally if you want to save partition results using W code exit, do not save select Q Code exit
parted command
To view the status of a partition using print
parted print
这里写代码片
New Partition
parted /dev/mmcblk0 mkpart logical ext4 10.1GB 11.1GB```![这里写图片描述](http://img.blog.csdn.net/20160414223050641)mkpart是创建分区参数logical 分区类型(primary extend logical)ext4 文件系统类型 10.1GB 分区开始位置(根据最后一个分区的End来确定,之前代号为5的分区End值为10.1GB,所以这里我们从10.1GB开始)11.1GB 分区截止位置建好分区后,还要通过partprobe命令,强制将分区信息写到磁盘<div class="se-preview-section-delimiter"></div>
Write code here
"'
The last two methods require file system creation after the partition is created and mounted on the boot
partprobe
The last two methods require file system creation after the partition is created and mounted on the boot
mkfs -t [文件系统类型,ext4]/dev/[分区号,mmcblk0p6]
To create a mount directory:
mkdir /MyPartition
Set the boot mount, modify the/etc/fstab file, add a new line
nano /etc/fstab
/DEV/MMCBLK0P6 is the new partition
/mypartition mount point
EXT4 File System
Defaults File system parameters
0 fifth, dump, whether backup, 0 not backup, 1 per day, 2 irregular
2 last item, fsck,0 does not check check, 1 check, 2 check (1 priority is higher than 2 first check is usually root set to 1)
Through MOUNT-A, check whether success, success will not prompt, error will prompt, I did not create a mount point before, so hint mount point does not exist
-a
Finally, through the DF view Mount situation, you can see that the partition is mounted successfully
-h
To delete a partition, you need to uninstall it before deleting it.
Umount unload parameter is a partition name or mount point
parted disk name RM [partition number] to delete a partition
umount /dev/mmcblk0p6parted /dev/mmcblk0 rm 6
linux--Raspberry Pi System partition