1、查看本机IP地址:
[root@test_srv ~]# ifconfig
ens192: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 11.200.1.108 netmask 255.255.255.0 broadcast 11.200.1.255
inet6 fe80::250:56ff:fea1:a92e prefixlen 64 scopeid 0x20<link>
ether 00:50:56:a1:a9:2e txqueuelen 1000 (Ethernet)
RX packets 504134113 bytes 1203618368919 (1.0 TiB)
RX errors 0 dropped 56022 overruns 0 frame 0
TX packets 338192853 bytes 53139131889 (49.4 GiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
2、编辑虚拟机-->增加硬盘容量【200GB->400GB】-->给虚拟机打快照
3、操作系统扫盘
[root@test_srv ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 600M 0 part /boot/efi
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 198.4G 0 part
├─rl-root 253:0 0 60.8G 0 lvm /
├─rl-swap 253:1 0 7.9G 0 lvm [SWAP]
└─rl-home 253:2 0 129.7G 0 lvm /home
sr0 11:0 1 1024M 0 rom
[root@test_srv ~]# cd /sys/class/block/sda/device/
[root@test_srv device]# echo '- - -' > rescan
[root@test_srv device]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 400G 0 disk
├─sda1 8:1 0 600M 0 part /boot/efi
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 198.4G 0 part
├─rl-root 253:0 0 60.8G 0 lvm /
├─rl-swap 253:1 0 7.9G 0 lvm [SWAP]
└─rl-home 253:2 0 129.7G 0 lvm /home
sr0 11:0 1 1024M 0 rom
4、使用 parted 命令,为/dev/sda的第三个分区扩容【/home所在的分区】
[root@test_srv device]# parted /dev/sda
GNU Parted 3.5
使用 /dev/sda
欢迎使用 GNU Parted!输入 'help' 来查看命令列表。
(parted) resizepart 3 100%
警告: 并非所有可用于 /dev/sda 的空间都被用到了,您可以修正 GPT 以使用所有的空间 (额外的 419430400
个区块),还是说要继续使用目前的设置?
修正/Fix/忽略/Ignore? Fix
分区编号? 3
结束点? [215GB]?
(parted) print
型号:VMware Virtual disk (scsi)
磁盘 /dev/sda:429GB
扇区大小 (逻辑/物理):512B/512B
分区表:gpt
磁盘标志:
编号 起始点 结束点 大小 文件系统 名称 标志
1 1049kB 630MB 629MB fat32 EFI System Partition 启动, esp
2 630MB 1704MB 1074MB xfs
3 1704MB 215GB 213GB lvm
(parted) quit
信息: 你可能需要 /etc/fstab。
[root@test_srv device]# parted /dev/sda
GNU Parted 3.5
使用 /dev/sda
欢迎使用 GNU Parted!输入 'help' 来查看命令列表。
(parted) print
型号:VMware Virtual disk (scsi)
磁盘 /dev/sda:429GB
扇区大小 (逻辑/物理):512B/512B
分区表:gpt
磁盘标志:
编号 起始点 结束点 大小 文件系统 名称 标志
1 1049kB 630MB 629MB fat32 EFI System Partition 启动, esp
2 630MB 1704MB 1074MB xfs
3 1704MB 215GB 213GB lvm
(parted) resizepart 3 100%
(parted) print
型号:VMware Virtual disk (scsi)
磁盘 /dev/sda:429GB
扇区大小 (逻辑/物理):512B/512B
分区表:gpt
磁盘标志:
编号 起始点 结束点 大小 文件系统 名称 标志
1 1049kB 630MB 629MB fat32 EFI System Partition 启动, esp
2 630MB 1704MB 1074MB xfs
3 1704MB 429GB 428GB lvm
(parted) quit
信息: 你可能需要 /etc/fstab。
5、LVM逻辑卷管理命令,进行卷的在线扩容
[root@test_srv device]# pvresize /dev/sda3
Physical volume "/dev/sda3" changed
1 physical volume(s) resized or updated / 0 physical volume(s) not resized
[root@test_srv device]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda3 rl lvm2 a-- 398.41g 200.00g
[root@test_srv device]# lvresize -l +100%FREE /dev/rl/home
Size of logical volume rl/home changed from 129.70 GiB (33204 extents) to 329.70 GiB (84404 extents).
Logical volume rl/home successfully resized.
[root@test_srv device]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
home rl -wi-ao---- 329.70g
root rl -wi-ao---- 60.83g
swap rl -wi-ao---- <7.88g
[root@test_srv device]# lvdisplay /dev/rl/home
--- Logical volume ---
LV Path /dev/rl/home
LV Name home
VG Name rl
LV UUID TDkpFC-jjVx-kWmt-q5Oa-cuZO-jEyQ-eezY0g
LV Write Access read/write
LV Creation host, time test_srv, 2023-10-26 21:40:14 +0800
LV Status available
# open 1
LV Size 329.70 GiB
Current LE 84404
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2
[root@test_srv device]# df -hT
文件系统 类型 容量 已用 可用 已用% 挂载点
devtmpfs devtmpfs 4.0M 0 4.0M 0% /dev
tmpfs tmpfs 12G 0 12G 0% /dev/shm
tmpfs tmpfs 4.7G 21M 4.7G 1% /run
/dev/mapper/rl-root xfs 61G 5.8G 56G 10% /
/dev/sda2 xfs 1014M 284M 731M 28% /boot
/dev/sda1 vfat 599M 7.0M 592M 2% /boot/efi
/dev/mapper/rl-home xfs 130G 129G 989M 100% /home
tmpfs tmpfs 2.4G 36K 2.4G 1% /run/user/1001
tmpfs tmpfs 2.4G 96K 2.4G 1% /run/user/0
tmpfs tmpfs 2.4G 36K 2.4G 1% /run/user/1000
[root@test_srv device]# xfs_growfs /dev/rl/home
meta-data=/dev/mapper/rl-home isize=512 agcount=18, agsize=1946624 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1 bigtime=1 inobtcount=1
data = bsize=4096 blocks=34000896, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=3802, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 34000896 to 86429696
[root@test_srv device]# df -hT
文件系统 类型 容量 已用 可用 已用% 挂载点
devtmpfs devtmpfs 4.0M 0 4.0M 0% /dev
tmpfs tmpfs 12G 0 12G 0% /dev/shm
tmpfs tmpfs 4.7G 21M 4.7G 1% /run
/dev/mapper/rl-root xfs 61G 5.8G 56G 10% /
/dev/sda2 xfs 1014M 284M 731M 28% /boot
/dev/sda1 vfat 599M 7.0M 592M 2% /boot/efi
/dev/mapper/rl-home xfs 330G 131G 200G 40% /home
tmpfs tmpfs 2.4G 36K 2.4G 1% /run/user/1001
tmpfs tmpfs 2.4G 96K 2.4G 1% /run/user/0
tmpfs tmpfs 2.4G 36K 2.4G 1% /run/user/1000
[root@test_srv device]#
6、删除虚拟机的快照
文章评论