Create Linux Disk Partitions with Fdisk & Parted
In the Linux system, you can use command line tools such as fdisk or GNU parted to partition a disk.
The steps to create disk partitions using the fdisk command are as follows:
- Execute the command “sudo fdisk /dev/sdX”
- In fdisk interactive mode, type ‘m’ to view help information and ‘n’ to create a new partition.
- 选择分区类型(主分区或逻辑分区)、起始扇区和结束扇区,按照提示操作。
- Save the partition table and exit using the ‘w’ command.
The steps to create disk partitions using the GNU parted command are as follows:
- Run the following command as a superuser: parted /dev/sdX.
- In parted interactive mode, use the mklabel command to create a disk label (such as msdos or gpt).
- Create a new partition using the mkpart command, specifying the filesystem type, starting position, and size.
- View partition information using the print command, and exit with the quit command.
After completing the above steps, you will need to use the mkfs command to format the newly created partition and mount it to the system. Please remember to back up important data before proceeding to prevent any data loss.