深入Linux:学会设置分区(linux设置分区)

With the development of Linux operating system,how to set up partition in Linux is becoming more and more important for those who desire to deeply conquer the former. Based on my long experience of the field, this article will illustrate my own way of setting up Linux partition.

Firstly, use fdisk to set up partition sizes. Fdisk is a program making it possible to help us create, delete, modify and check the partitions. When using it, we need to enter the following code line: fdisk –l, which helps show the information about the existing partitions. For example, the following statements shows the size, start and end sectors of the partition:

Command:fdisk –l

Disk /dev/sda: 500GB

Sector size (logical/physical): 512B/512B

Partition Table:msdos

Number Start End Size Type File system Flags

1 32.3kB 500GB 500GB primary ext4 lba

2 500GB 500GB 32.3kB Free space

Secondly, employ parted to create partition. To set up partition on different file system, parted is a must tool. With it we can easily create partitions on popular file systems like ext2, ext3, FAT16, FAT32 and others.Again, the following statement can be used when creating partition:

Command: parted /dev/sda

(parted) mkpart primary ext4 20GB 40GB

(parted) print

Number Start End Size File system Name Flags

1 32.3kB 20GB 20GB primary ext4 lba

2 20GB 40GB 20GB primary ext4

3 40GB 500GB 500GB primary ext4

Finally, resize the created partition. When the partition is being set up, the size is fixed. But with the help of gparted, the size of partition can be accelerated. The code line should be typed in terminal:

Command: gparted /dev/sda

(gparted) resize

The size of partition can be adjusted through the pop-up window.

All in all, it’s not difficult to set up partitions in Linux. With fdisk, parted and gparted, it is a breeze to create, modify, resize and check partitions. However, please pay attention to the warning message caused by wrong operations and make sure you understand what the code lines mean before operating.


数据运维技术 » 深入Linux:学会设置分区(linux设置分区)