gparted 创建分区 / mkfs 格式化分区为某filesystem

gparted 命令:

(parted) mkpart part-type fs-type start end
part-type is one of primary, extended or logical, and is meaningful only for MBR partition tables.
fs-type is an identifier chosen among those listed by entering help mkpart as the closest match to the file system that you will use.
The mkpart command does not actually create the file system: the fs-type parameter will simply be used by parted to set a 1-byte code that is used by boot loaders to “preview” what kind of data is found in the partition, and act accordingly if necessary. See also Wikipedia:Disk partitioning#PC partition types.
Tip: Most Linux native file systems map to the same MBR partition type code (0x83), so it is perfectly safe to e.g. use ext2 for an ext4-formatted partition.
start is the beginning of the partition from the start of the device. It consists of a number followed by a unit, for example 1MiB means start at 1 MiB.
end is the end of the partition from the start of the device (not from the start value). It has the same syntax as start, for example 100% means end at the end of the device (use all the remaining space).

gparted 实践:

背景:我是vmware上安装好的debian,后面打算分出一部分来实验linux from scratch

步骤1:

首先用fdisk -l 查询以下现在磁盘的使用情况,我的情况是:

root@peng:/home/peng# fdisk -l
Disk /dev/sda: 70 GiB, 75161927680 bytes, 146800640 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x4f34802b

Device     Boot     Start       End   Sectors  Size Id Type
/dev/sda1  *         2048 103811071 103809024 49.5G 83 Linux
/dev/sda2       103811072 104857599   1046528  511M  5 Extended
/dev/sda5       103813120 104857599   1044480  510M 82 Linux swap / Solaris

步骤2:

参数1: 你想在哪个设备上操作,我是/dev/sda
参数2:使用生成分区mkpart
参数3:选择主分区primary
参数4:文件系统选择ext4
参数5:磁盘起点选择50G以后,系统会自动帮你分配合适的位置
参数6:该分区的终点懒得指明了,我要用剩下的所有,所以这里填100%

parted /dev/sda mkpart primary ext4 50G 100%
步骤3 格式化分区为ext4格式:

mkfs /dev/sda3 -t ext4

发布了43 篇原创文章 · 获赞 2 · 访问量 3376

猜你喜欢

转载自blog.csdn.net/songpeng26/article/details/105180694