2T硬盘装完系统后分区

lvm扩容:

[root@localhost ~]# yum install parted -y
[root@localhost ~]# parted /dev/sda
(parted) mkpart
Partition name? []?
File system type? [ext2]?
Start? 43.2GB
End? -1
Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy). As a result, it may not reflect all of your
changes until after reboot.
(parted) P
Model: LSI MR9240-8i (scsi)
Disk /dev/sda: 4000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number Start End Size File system Name Flags
1 1049kB 211MB 210MB ext4 boot
2 211MB 43.2GB 42.9GB lvm
3 43.2GB 4000GB 3957GB

(parted) toggle 3 lvm
Warning: WARNING: the kernel failed to re-read the partition table on /dev/sda (Device or resource busy). As a result, it may not reflect all of your
changes until after reboot.
(parted) p
Model: LSI MR9240-8i (scsi)
Disk /dev/sda: 4000GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number Start End Size File system Name Flags
1 1049kB 211MB 210MB ext4 boot
2 211MB 43.2GB 42.9GB lvm
3 43.2GB 4000GB 3957GB lvm

(parted) q
[root@localhost ~]# partx -a /dev/sda
BLKPG: Device or resource busy
error adding partition 1
BLKPG: Device or resource busy
error adding partition 2
[root@localhost ~]# ll /dev/sd*
sda sda1 sda2 sda3 sdb sdc sdd sde sdf sdg sdh sdi sdj sdk sdl
[root@localhost ~]# pvcreate /dev/sda3
Physical volume “/dev/sda3” successfully created
[root@localhost ~]# vgextend vg0 /dev/sda3
Volume group “vg0” successfully extended
[root@localhost ~]# lvextend -L +1.6T /dev/vg0/lvroot
Rounding size to boundary between physical extents: 1.60 TiB
Extending logical volume lvroot to 1.62 TiB
Logical volume lvroot successfully resized
[root@localhost ~]# resize2fs /dev/vg0/lvroot
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg0/lvroot is mounted on /; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 104
Performing an on-line resize of /dev/vg0/lvroot to 434740224 (4k) blocks.
The filesystem on /dev/vg0/lvroot is now 434740224 blocks long.

2T及以上硬盘格式化脚本:

[root@master185 ~]# cat fdisk.sh
#!/bin/bash
for sd in $(cat /mnt/sd.txt)
do
parted $sd << ESXU
mklabel gpt
mkpart primary 0% 100%
ignore
print
quit
ESXU

partx -a ${sd}1
mkfs.ext4 ${sd}1
done

[root@master185 ~]# cat /mnt/sd.txt
/dev/sdb
/dev/sdc
/dev/sdd
/dev/sde
/dev/sdf
/dev/sdg
/dev/sdh
/dev/sdi
/dev/sdj
/dev/sdk
/dev/sdl
/dev/sdm

Print Friendly

发表评论

电子邮件地址不会被公开。 必填项已用*标注