[root@he~]#df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 877M 0 877M 0% /dev tmpfs 896M 0 896M 0% /dev/shm tmpfs 896M 8.7M 887M 1% /run tmpfs 896M 0 896M 0% /sys/fs/cgroup /dev/mapper/rl-root 70G 2.2G 68G 4% / #现在逻辑卷是70G-------------------------------- /dev/sr0 10G 10G 0 100% /mnt/cdrom /dev/sda1 1014M 212M 803M 21% /boot /dev/mapper/rl-home 127G 939M 126G 1% /home tmpfs 180M 0 180M 0% /run/user/ [root@he~]#fdisk -l Disk /dev/sda: 200 GiB, 214748364800 bytes, 419430400 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: 0x884fdf57 Device Boot Start End Sectors Size Id Type /dev/sda1 * 2048 2099199 2097152 1G 83 Linux /dev/sda2 2099200 419430399 417331200 199G 8e Linux LVM Disk /dev/mapper/rl-root: 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 Disk /dev/mapper/rl-swap: 2 GiB, 2181038080 bytes, 4259840 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 Disk /dev/mapper/rl-home: 127 GiB, 136327462912 bytes, 266264576 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 Disk /dev/sdb: 20 GiB, 21474836480 bytes, 41943040 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 [root@he~]#lsblk #这个命令也可以看见------------------------------------------------ NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 200G 0 disk ├─sda1 8:1 0 1G 0 part /boot └─sda2 8:2 0 199G 0 part ├─rl-root 253:0 0 70G 0 lvm / ├─rl-swap 253:1 0 2G 0 lvm [SWAP] └─rl-home 253:2 0 127G 0 lvm /home sdb 8:16 0 20G 0 disk #新添加的硬盘------------------------------- sr0 11:0 1 10G 0 rom /mnt/cdrom [root@he~]#vgdisplay --- Volume group --- VG Name rl System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 4 VG Access read/write VG Status resizable MAX LV 0 Cur LV 3 Open LV 3 Max PV 0 Cur PV 1 Act PV 1 VG Size <199.00 GiB PE Size 4.00 MiB #扩容之前先查看逻辑卷所在的卷组还有没有容量可以扩展了,如果没有需要先扩展卷组--------------------- Total PE 50943 Alloc PE / Size 50943 / <199.00 GiB Free PE / Size 0 / 0 VG UUID sBkdQ0-QvEj-G8nS-iD67-dUdZ-I1pg-989anR [root@he~]# pvcreate /dev/sdb #将sdb格式化魏物理卷----------------------------------------------------- Physical volume "/dev/sdb" successfully created. [root@he~]#pvdisplay #查看到格式化出来的物理卷sdb---------------------------------------------------- --- Physical volume --- PV Name /dev/sda2 VG Name rl PV Size <199.00 GiB / not usable 3.00 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 50943 Free PE 0 Allocated PE 50943 PV UUID sVJqiA-KB0e-LQMj-sgx3-WnmA-FyPn-uYcY3C "/dev/sdb" is a new physical volume of "20.00 GiB" --- NEW Physical volume --- PV Name /dev/sdb VG Name PV Size 20.00 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID gtiWj5-uvuI-ifne-uBYi-D3wz-uE0X-ITxOoK #将新的分区加入到卷组rl中 ---------------------------------------------------------------------- [root@he~]#vgextend rl /dev/sdb Volume group "rl" successfully extended [root@he~]# vgdisplay --- Volume group --- VG Name rl System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 5 VG Access read/write VG Status resizable MAX LV 0 Cur LV 3 Open LV 3 Max PV 0 Cur PV 2 Act PV 2 VG Size 218.99 GiB PE Size 4.00 MiB Total PE 56062 Alloc PE / Size 50943 / <199.00 GiB Free PE / Size 5119 / <20.00 GiB #现在可以看到rl卷组空闲空间大小多了20G--------------------------------------- VG UUID sBkdQ0-QvEj-G8nS-iD67-dUdZ-I1pg-989anR #给逻辑卷/dev/mapper/rl-root扩容----------------------------------------------------- [root@he~]# lvextend -L +19G /dev/mapper/rl-root Size of logical volume rl/root changed from 70.00 GiB (17920 extents) to 89.00 GiB (22784 extents). Logical volume rl/root successfully resized. #注意此时df -h是看不见逻辑卷空间变大,但是lvdisplay可以看见------------------------------------------------ [root@he~]# lvdisplay --- Logical volume --- LV Path /dev/rl/swap LV Name swap VG Name rl LV UUID fKi3aU-AP0Z-CpW7-LQ2Q-R4KY-j1ei-rJ9Jan LV Write Access read/write LV Creation host, time 10.0.0.137, 2022-09-06 08:31:58 +0800 LV Status available # open 2 LV Size 2.03 GiB Current LE 520 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:1 --- Logical volume --- LV Path /dev/rl/home LV Name home VG Name rl LV UUID KYEUgN-LSCo-Xyl1-AHsR-Gngf-rUkT-5Y5Fgq LV Write Access read/write LV Creation host, time 10.0.0.137, 2022-09-06 08:31:58 +0800 LV Status available # open 1 LV Size 126.96 GiB Current LE 32503 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:2 --- Logical volume --- LV Path /dev/rl/root LV Name root VG Name rl LV UUID Ou1bac-L5M0-o340-XssC-kVYM-yWiD-eiJSJG LV Write Access read/write LV Creation host, time 10.0.0.137, 2022-09-06 08:31:59 +0800 LV Status available # open 1 LV Size 89.00 GiB #现在这里可以看见逻辑卷扩容了-------------------------------------------------------- Current LE 22784 Segments 2 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:0 #当给逻辑卷扩容之后并不是立马生效的,还要有一步,让扩容的空间生效----------------------------------------------- [root@he~]#xfs_growfs /dev/mapper/rl-root # 等同于resiozee2fs---------------------------------------------- meta-data=/dev/mapper/rl-root isize=512 agcount=4, agsize=4587520 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=1, sparse=1, rmapbt=0 = reflink=1 data = bsize=4096 blocks=18350080, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0, ftype=1 log =internal log bsize=4096 blocks=8960, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 18350080 to 23330816 [root@he~]#df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 877M 0 877M 0% /dev tmpfs 896M 0 896M 0% /dev/shm tmpfs 896M 8.7M 887M 1% /run tmpfs 896M 0 896M 0% /sys/fs/cgroup /dev/mapper/rl-root 89G 2.4G 87G 3% / #可以看见容量扩大了------------------------------------------------------- /dev/sr0 10G 10G 0 100% /mnt/cdrom /dev/sda1 1014M 212M 803M 21% /boot /dev/mapper/rl-home 127G 939M 126G 1% /home tmpfs 180M 0 180M 0% /run/user/0
Linux磁盘扩容
最新推荐文章于 2024-08-31 14:59:09 发布