对centos的home目录进行扩容
- 1 首先要了解PV\VG\LV的含义
- 1.1 基本概念
- 1.2 基本命令行
- 2 实际操作
- 2.1 盘符当前现状
- 2.1实操
1 首先要了解PV\VG\LV的含义
1.1 基本概念
- 物理卷(Physical Volume,PV)
指磁盘分区或从逻辑上与磁盘分区具有同样功能的设备(如RAID),是LVM的基本存储逻辑块,但和基本的物理存储介质(如分区、磁盘等)比较,却包含有与LVM相关的管理参数。 - 卷组(Volume Group,VG)
类似于非LVM系统中的物理磁盘,其由一个或多个物理卷PV组成。可以在卷组上创建一个或多个LV(逻辑卷)。 - 逻辑卷(Logical Volume,LV)
类似于非LVM系统中的磁盘分区,逻辑卷建立在卷组VG之上。在逻辑卷LV之上可以建立文件系统(比如/home或者/usr等)。
ps: 1.1节引用来源为简书,作者为运维少年,原为链接
1.2 基本命令行
- 常用命令行
- 查看命令行
ps: 1.2节引用来源为CSDN,作者为胖胖不胖、,原为链接
2 实际操作
2.1 盘符当前现状
因为我装的是双系统,所以需要先在windows下划分出20G空闲空间,至于怎么划出20G,网上有大量教程。在linux下查看为
2.1实操
- 实操参考百度教程link
Last login: Thu Jun 22 23:35:22 2023 from 192.168.3.13
[root@study ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 931.5G 0 disk
├─sda1 8:1 0 150G 0 part
├─sda2 8:2 0 1K 0 part
├─sda3 8:3 0 1G 0 part /boot
├─sda4 8:4 0 30G 0 part
│ ├─centos-root 253:0 0 10G 0 lvm /
│ ├─centos-swap 253:1 0 1G 0 lvm
│ └─centos-home 253:2 0 5G 0 lvm /home
├─sda5 8:5 0 261G 0 part
├─sda6 8:6 0 261G 0 part
├─sda7 8:7 0 189.5G 0 part
└─sda8 8:8 0 20G 0 part
[root@study ~]# echo "- - -" > /sys/class/scsi_host/host0/scan
[root@study ~]# fdisk -l
Disk /dev/sda: 1000.2 GB, 1000204886016 bytes, 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: dos
Disk identifier: 0x7989ea63
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 314576895 157287424 7 HPFS/NTFS/exFAT
/dev/sda2 314576896 1848666111 767044608 f W95 Ext'd (LBA)
/dev/sda3 1848666112 1850763263 1048576 83 Linux
/dev/sda4 1850763264 1913686015 31461376 8e Linux LVM
/dev/sda5 314578944 861935615 273678336 7 HPFS/NTFS/exFAT
/dev/sda6 861939712 1409298431 273679360 7 HPFS/NTFS/exFAT
/dev/sda7 1409300480 1806723071 198711296 7 HPFS/NTFS/exFAT
/dev/sda8 1806725120 1848666111 20970496 7 HPFS/NTFS/exFAT
Disk /dev/mapper/centos-root: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/mapper/centos-swap: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/mapper/centos-home: 5368 MB, 5368709120 bytes, 10485760 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
[root@study ~]# pvcreate /dev/sda8
WARNING: ntfs signature detected on /dev/sda8 at offset 3. Wipe it? [y/n]: y Wiping ntfs signature on /dev/sda8.
Physical volume "/dev/sda8" successfully created.
[root@study ~]# vgdisplay
--- Volume group ---
VG Name centos
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 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 30.00 GiB
PE Size 4.00 MiB
Total PE 7680
Alloc PE / Size 4096 / 16.00 GiB
Free PE / Size 3584 / 14.00 GiB
VG UUID 13qShD-1DCk-9LqQ-P8mU-JA5A-EqS6-2lwBpm
[root@study ~]# vgextend centos /dev/sda8
Volume group "centos" successfully extended
[root@study ~]# lvdisplay
--- Logical volume ---
LV Path /dev/centos/root
LV Name root
VG Name centos
LV UUID Yl0TIJ-GBld-sfcZ-lSs5-aC8g-h19l-5bfhOk
LV Write Access read/write
LV Creation host, time study.centos.vbird, 2019-03-23 04:23:04 +0800
LV Status available
# open 1
LV Size 10.00 GiB
Current LE 2560
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Path /dev/centos/swap
LV Name swap
VG Name centos
LV UUID KHhhNP-82Dx-0sUA-eAYU-tcHL-djnL-xhLZCn
LV Write Access read/write
LV Creation host, time study.centos.vbird, 2019-03-23 04:23:05 +0800
LV Status available
# open 0
LV Size 1.00 GiB
Current LE 256
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
--- Logical volume ---
LV Path /dev/centos/home
LV Name home
VG Name centos
LV UUID UvhEfA-0aku-UTsQ-DhjJ-J49N-8PCp-6EZ7wC
LV Write Access read/write
LV Creation host, time study.centos.vbird, 2019-03-23 04:23:05 +0800
LV Status available
# open 1
LV Size 5.00 GiB
Current LE 1280
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2
[root@study ~]# lvextend -l +20G /dev/centos/home
Invalid argument for --extents: +20G
Error during parsing of command line.
[root@study ~]# lvextend -L +20G /dev/centos/home
Size of logical volume centos/home changed from 5.00 GiB (1280 extents) to 25.00 GiB (6400 extents).
Logical volume centos/home successfully resized.
[root@study ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 10G 8.0G 2.0G 81% /
devtmpfs 7.7G 0 7.7G 0% /dev
tmpfs 7.7G 4.0K 7.7G 1% /dev/shm
tmpfs 7.7G 9.9M 7.7G 1% /run
tmpfs 7.7G 0 7.7G 0% /sys/fs/cgroup
/dev/sda3 1014M 236M 779M 24% /boot
/dev/mapper/centos-home 5.0G 5.0G 41M 100% /home
tmpfs 1.6G 12K 1.6G 1% /run/user/42
tmpfs 1.6G 0 1.6G 0% /run/user/0
[root@study ~]# xfs_growfs /dev/centos/home
meta-data=/dev/mapper/centos-home isize=512 agcount=4, agsize=327680 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=1310720, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=2560, version=2
= sectsz=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 1310720 to 6553600
[root@study ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 10G 8.0G 2.0G 81% /
devtmpfs 7.7G 0 7.7G 0% /dev
tmpfs 7.7G 4.0K 7.7G 1% /dev/shm
tmpfs 7.7G 9.9M 7.7G 1% /run
tmpfs 7.7G 0 7.7G 0% /sys/fs/cgroup
/dev/sda3 1014M 236M 779M 24% /boot
/dev/mapper/centos-home 25G 5.0G 21G 20% /home
tmpfs 1.6G 12K 1.6G 1% /run/user/42
tmpfs 1.6G 0 1.6G 0% /run/user/0
[root@study ~]#