Linux-Raspberry Pi system partition
There are two main partition commands: fdisk and parted.
Both commands require the root permission,
First, we will introduce the fdisk command:
Fdisk allows you to view the usage of the current file system.
fdisk -l
Because I installed the system on the SD card, the partition starts with/dev/mmcblk0. We can see that there are currently three actual partitions (/dev/mmcblk1, 2, 5. linux partitions are divided into primary partitions and logical partitions. Only primary partitions and logical partitions actually store data. Therefore, mmcblk3 is not a real partition)
Instructions <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KCgoKPHByZSBjbGFzcz0 = "brush: SQL;"> Fdisk/dev/[the disk driver name is entered here. If it is an IDE hard disk, It is hd (a-p), and SATA hard disk is sd (a-p ), my SD card driver named mmcblk0]
The specific help uses the m code:
Use the code p to view the current disk partition status
Then add a partition using the n code
In these cases, a disk can have up to four non-logical partitions (determined by the partition table in the boot sector). The extended partitions are 0-1 and the logical partitions are created under the extended partitions.
1. If there are four non-logical partitions, you cannot create a new partition.
2. if there are no more than four non-logical partitions, you can choose to create a primary or extend partition (Note that there can be only one extend partition ), with extend, you can create logical partitions (the IDE interface can create up to 59 partition codes from 5 ~ 63. SATA can create up to 11 logical partitions from 5 ~ 15. Note that all logical partitions start with code 5, because the first four are given non-logical partitions)
I have extend partitions, so I only need to create primary partitions or logical partitions.
Select the start sector of the new partition. refer to the previous partition information here:
Here we provide the recommended values for the start sector and the end sector (generally, the recommended value is directly used for the start sector, and the end sector must use the start sector + partition size)
A prompt is displayed when the partition is successfully created. Then, use the p code to view the partition information.
If you want to save the partition result and exit with w code, do not save and select q code to exit
Parted command
Use print to view the partition status
parted /dev/mmcblk0 print
Write code snippets here
Create Partition
Parted/dev/mmcblk0 mkpart logical ext4 10.1 GB 11.1GB '''! [Write image description here] (http://img.blog.csdn.net/20160414223050641) mkpart is the logical partition type that creates the partition parameter (primary extend logical) ext4 file system type 10.1 GB partition start position (determined based on the End of the last partition, the End value of the previously Code 5 partition is 10.1 GB, so here we start from 10.1GB) after creating a partition at the end of the 11.1 GB partition, you must use the partprobe command to forcibly write the partition information to the disk <div class = "se-preview-section-delimiter"> </div>
Write code snippets here
''
After creating a partition, you need to create a file system and mount it on the boot device.
partprobe
After creating a partition, you need to create a file system and mount it on the boot device.
Mkfs-t [file system type, ext4]/dev/[Partition Number, mmcblk0p6]
Create a mount directory:
mkdir /MyPartition
Set boot mounting, modify the/etc/fstab file, and add a new row
nano /etc/fstab
/Dev/mmcblk0p6 is the new partition
/MyPartition mount point
Ext4 File System
Defaults File System Parameters
0 item 5, dump, whether to back up, 0 no backup, 1 daily, 2 irregular
2 last item, fsck, 0 do not check, 1 check, 2 check (1 priority is high, than 2 first check is generally set to 1 as root)
Run mount-a to check whether the mount point is successful. If it is successful, no prompt is displayed. If the mount point is not created before, the system prompts that the mount point does not exist.
mount -a
Finally, check the mounting status through df. You can see that the partition has been mounted successfully.
df -h
To delete a partition, unmount it before deleting it.
The unmount parameter of umount is the partition name or mount point.
Parted disk name rm [Partition Number] is used to delete a partition
umount /dev/mmcblk0p6parted /dev/mmcblk0 rm 6