使用parted命令,对2T大小以上的硬盘进行分区操作
参考资料:
https://blog.csdn.net/qq_35590198/article/details/81356637
环境需求:当前已有硬盘24TB大小,需要划分为6个分区,每个4TB,当我使用fdisk命令时,最大仅可操作2TB的大小进行分区,经过查询得知,2T以上大小不能使用fdisk命令进行磁盘分区操作。这需要使用parted命令。
经过查询相关资料总结命令使用如下:
#先查看磁盘情况 [root@xz-ddd-hadoop1 ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 931G 0 disk ├─sda1 8:1 0 476M 0 part /boot └─sda2 8:2 0 930.5G 0 part ├─centos-root 253:0 0 531.9G 0 lvm / ├─centos-swap 253:1 0 119.2G 0 lvm [SWAP] └─centos-var 253:2 0 279.4G 0 lvm /var sdb 8:16 0 21.8T 0 disk #使用命令准备开始分区操作 [root@xz-ddd-hadoop1 ~]# parted /dev/sdb GNU Parted 3.1 Using /dev/sdb Welcome to GNU Parted! Type 'help' to view a list of commands. #输入p查看当前已有分区。 (parted) p Model: LSI RAID 5/6 SAS 6G (scsi) Disk /dev/sdb: 24.0TB Sector size (logical/physical): 512B/4096B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags #输入mkpart新建分区。 (parted) mkpart #定义磁盘名称。 Partition name? []? sdb1 #定义文件格式。 File system type? [ext2]? ext4 #磁盘开始位置以及结束位置(注意,下一个分区的开始位置必须使用这里的结束位置为开始。) Start? 1 End? 4TB #查看分区效果。 (parted) P Model: LSI RAID 5/6 SAS 6G (scsi) Disk /dev/sdb: 24.0TB Sector size (logical/physical): 512B/4096B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1049kB 4000GB 4000GB ext3 sdb1 。。。。 #注意,这里略过一个错误的操作! 。。。。 (parted) mkpart Partition name? []? sdb2 File system type? [ext2]? ext4 Start? 4TB End? 8TB #查询分区发现出现相同名称的分区,所以我们需要把它删除掉。 (parted) P Model: LSI RAID 5/6 SAS 6G (scsi) Disk /dev/sdb: 24.0TB Sector size (logical/physical): 512B/4096B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 2 1048kB 1049kB 512B sdb2 1 1049kB 4000GB 4000GB ext3 sdb1 3 4000GB 8000GB 4000GB ext3 sdb2 #使用RM命令删除,输入Number。 (parted) RM 2 #查看删除效果,成果。 (parted) P Model: LSI RAID 5/6 SAS 6G (scsi) Disk /dev/sdb: 24.0TB Sector size (logical/physical): 512B/4096B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1049kB 4000GB 4000GB ext3 sdb1 3 4000GB 8000GB 4000GB ext3 sdb2 #继续新建分区。 (parted) mkpart Partition name? []? sdb3 File system type? [ext2]? ext4 Start? 8TB End? 12TB (parted) p Model: LSI RAID 5/6 SAS 6G (scsi) Disk /dev/sdb: 24.0TB Sector size (logical/physical): 512B/4096B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1049kB 4000GB 4000GB ext3 sdb1 3 4000GB 8000GB 4000GB ext3 sdb2 2 8000GB 12.0TB 4000GB ext3 sdb3 (parted) mkpart Partition name? []? sdb4 File system type? [ext2]? ext4 Start? 12TB End? 16TB (parted) P Model: LSI RAID 5/6 SAS 6G (scsi) Disk /dev/sdb: 24.0TB Sector size (logical/physical): 512B/4096B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1049kB 4000GB 4000GB ext3 sdb1 3 4000GB 8000GB 4000GB ext3 sdb2 2 8000GB 12.0TB 4000GB ext3 sdb3 4 12.0TB 16.0TB 4000GB ext3 sdb4 (parted) mkpaRT Partition name? []? sdb5 File system type? [ext2]? ext4 Start? 16TB End? 20TB (parted) P Model: LSI RAID 5/6 SAS 6G (scsi) Disk /dev/sdb: 24.0TB Sector size (logical/physical): 512B/4096B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1049kB 4000GB 4000GB ext3 sdb1 3 4000GB 8000GB 4000GB ext3 sdb2 2 8000GB 12.0TB 4000GB ext3 sdb3 4 12.0TB 16.0TB 4000GB ext3 sdb4 5 16.0TB 20.0TB 4000GB ext3 sdb5 (parted) mkpart Partition name? []? sdb6 File system type? [ext2]? ext4 Start? 20TB End? 24TB (parted) p Model: LSI RAID 5/6 SAS 6G (scsi) Disk /dev/sdb: 24.0TB Sector size (logical/physical): 512B/4096B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1049kB 4000GB 4000GB ext3 sdb1 3 4000GB 8000GB 4000GB ext3 sdb2 2 8000GB 12.0TB 4000GB ext3 sdb3 4 12.0TB 16.0TB 4000GB ext3 sdb4 5 16.0TB 20.0TB 4000GB ext3 sdb5 6 20.0TB 24.0TB 4001GB ext3 sdb6 #保存分区修改。 (parted) q Information: You may need to update /etc/fstab. #分区全部新建完成后查看当前磁盘分区状况。 [root@xz-ddd-hadoop1 ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 931G 0 disk ├─sda1 8:1 0 476M 0 part /boot └─sda2 8:2 0 930.5G 0 part ├─centos-root 253:0 0 531.9G 0 lvm / ├─centos-swap 253:1 0 119.2G 0 lvm [SWAP] └─centos-var 253:2 0 279.4G 0 lvm /var sdb 8:16 0 21.8T 0 disk ├─sdb1 8:17 0 3.7T 0 part ├─sdb2 8:18 0 3.7T 0 part ├─sdb3 8:19 0 3.7T 0 part ├─sdb4 8:20 0 3.7T 0 part ├─sdb5 8:21 0 3.7T 0 part └─sdb6 8:22 0 3.7T 0 part #使用mkfs重新格式化分区。 [root@xz-ddd-hadoop1 ~]# mkfs.ext4 /dev/sdb1 [root@xz-ddd-hadoop1 ~]# mkfs.ext4 /dev/sdb2 [root@xz-ddd-hadoop1 ~]# mkfs.ext4 /dev/sdb3 [root@xz-ddd-hadoop1 ~]# mkfs.ext4 /dev/sdb4 [root@xz-ddd-hadoop1 ~]# mkfs.ext4 /dev/sdb5 [root@xz-ddd-hadoop1 ~]# mkfs.ext4 /dev/sdb6 #编写文件,添加开机自动挂载。 mkdir /data{1..6} vim /etc/fstab /dev/sdb1 /data1 ext4 defaults 0 0 /dev/sdb2 /data2 ext4 defaults 0 0 /dev/sdb3 /data3 ext4 defaults 0 0 /dev/sdb4 /data4 ext4 defaults 0 0 /dev/sdb5 /data5 ext4 defaults 0 0 /dev/sdb6 /data6 ext4 defaults 0 0 mount -a
发表评论