A disk can have a maximum of four primary partitions,
Managing disk partitions:
Fdisk parameter [path] P: displays partitions of the current hardware, including unsaved changes n: creates a new partition e: extends partition P: primary partition D: deletes a partition W: saves and exits q: does not save and exits t: changes the partition type L: L: Display all supported types to see which partitions are recognized by the current kernel: Cat /proc/partitions partprobe dd if=/dev/zero of=/dev/sd* bs=512 count=1 This command is used to quickly format partitions sync synchronize disk MKFS -t ext4 path Format the device as an ext4 file system mkswap Device name Format the device as a swap file system swapon Device name Enable the file system capacity corresponding to the device swapoff Device name Disable the file system capacity corresponding to the deviceCopy the code
Fstab file format
Device to be mounted Mount point File System Type Mount Option Dump frequency File system detection order proc /proc Proc Defaults 0 0 Device to be mounted: device directory or device UUID Mounting option: Dump frequency: How many days is a full backup performed? 0 indicates that no backup is performed. In general, 0 indicates that no check is performedCopy the code
For example, divide the new SDB disk into two partitions sdb1 and SDB2. Sdb1 is 1 GB in size, and add it to the swap partition. The remaining space is allocated to SDB2, the SDB2 partition is ext4, and SBD2 is mounted to/Media /test
Fdisk /dev/sdb :n New partition P type primary partition 1 Partition number 1 1 Start from the first sector +1 GB Partition capacity G :n New partition P type primary partition 2 Partition number 2 Change the file system type of the partition 1. Change partition 1. 82 to 82, that is, the swap type. W Save and exit mkswap /dev/sdb1 Format /dev/sdb1 into swap format MKFS -t ext4 /dev/sdb2 Format /dev/sdb2 into ext4 format swapon /dev/sdb1 Enable the swap partition for /dev/sdb1. Mount /dev/sdb2/media /test To mount /dev/sdb2 to /media/testCopy the code