parted命令可以划分单个分区大于2T的GPT格式的分区,也可以划分普通的MBR分区,fdisk命令对于大于2T的分区无法划分,所以用fdisk无法看到parted划分的GPT格式的分区。
Parted 命令分为两种模式:命令行模式和交互模式。
1、命令行模式: parted [option] device [command] ,该模式可以直接在命令行下对磁盘进行分区操作,比较适合编程应用。
2、交互模式:parted [option] device 类似于使用fdisk /dev/xxx
MBR:MBR分区表(即主引导记录)大家都很熟悉。所支持的最大卷:2T,而且对分区有限制:最多4个主分区或3个主分区加一个扩展分区
GPT: GPT(即GUID分区表)。是源自EFI标准的一种较新的磁盘分区表结构的标准,是未来磁盘分区的主要形式。与MBR分区方式相比,具有如下优点。突破 MBR 4个主分区限制,每个磁盘最多支持128个分区。支持大于2T的分区,最大卷可达18EB。
[[email protected] /]# parted /dev/sdb GNU Parted 1.8.1 Using /dev/sdb Welcome to GNU Parted! Type ‘help‘ to view a list of commands. (parted) p Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 21.5GB Sector size (logical/physical): 512B/512B Partition Table: msdos #由于磁盘小于2TB,table 模式是msdos,如果大于2TB,就是gpt模式,也可以用mklabel gpt 改成gpt模式 Number Start End Size Type File system Flags
创建2个分区
(parted) print Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 21.5GB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags #创建2个主分区 (parted) mkpart primary 0 10.0G (parted) mkpart primary 10.0G -1 #剩下的容量直接创建一个分区 (parted) print Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 21.5GB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 32.3kB 10.0GB 10.0GB primary 2 10.0GB 21.5GB 11.5GB primary (parted) quit #直接退出,会保存分区 Information: Don‘t forget to update /etc/fstab, if necessary.
3,准备格式化新分区
[[email protected] /]# parted /dev/sdb print #查看分区 Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 21.5GB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 32.3kB 10.0GB 10.0GB primary 2 10.0GB 21.5GB 11.5GB primary Information: Don‘t forget to update /etc/fstab, if necessary.
[[email protected] /]# mkfs.ext3 /dev/sdb1 [[email protected] /]# mkfs.ext3 /dev/sdb2 [[email protected] /]# blkid #查看已经格式化的分区 /dev/sda3: LABEL="SWAP-sda3" TYPE="swap" /dev/sda2: LABEL="/" UUID="1c07b7ee-bca0-4bad-8272-2d0c03f19081" TYPE="ext3" /dev/sda1: LABEL="/boot" UUID="463ce1ce-3a47-438d-b4cf-bf1fdf866fdb" TYPE="ext3" /dev/sdb1: UUID="d516e2c4-c4bf-468f-ba1c-d138c0b40745" SEC_TYPE="ext2" TYPE="ext3" /dev/sdb2: UUID="b2ab2810-ffc9-468b-b6dc-66b7de0d9f10" SEC_TYPE="ext2" TYPE="ext3"
4,挂载分区
[[email protected] /]# mkdir /date01 [[email protected] /]# mkdir /date02 [[email protected] /]# [[email protected] /]# [[email protected] /]# mount /dev/sdb1 /date01 [[email protected] /]# mount /dev/sdb2 /date02 [[email protected] /]# df -lh Filesystem Size Used Avail Use% Mounted on /dev/sda2 48G 2.3G 43G 5% / /dev/sda1 289M 16M 258M 6% /boot tmpfs 252M 0 252M 0% /dev/shm /dev/sdb1 9.2G 150M 8.6G 2% /date01 /dev/sdb2 11G 155M 9.9G 2% /date02 [[email protected] /]#
5,开机自动挂载分区
[[email protected] /]# vi /etc/fstab /dev/sdb1 /date01 ext3 defaults,noatime 1 2 /dev/sdb2 /date02 ext3 defaults,noatime 1 2
时间: 2024-11-05 23:32:29