CentOS7.6新增一块100G磁盘扩容给根分区及home分区,新增/data分区
**
需求:现有CentOS根分区及/home分区空间不够,需要新增一块100G的磁盘将20G空间扩容给根分区,60G空间扩容给/home分区,剩下的20G空间划给新建/data分区
[root@localhost ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs tmpfs 1.9G 16K 1.9G 1% /dev/shm
tmpfs tmpfs 1.9G 185M 1.7G 10% /run
tmpfs tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/mapper/centos-root xfs 50G 3.6G 47G 8% /
/dev/vda1 xfs 1014M 189M 826M 19% /boot
/dev/mapper/centos-home xfs 26G 377M 25G 2% /home
tmpfs tmpfs 379M 0 379M 0% /run/user/0
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
fd0 2:0 1 4K 0 disk
sr0 11:0 1 4.3G 0 rom
vda 252:0 0 80G 0 disk
├─vda1 252:1 0 1G 0 part /boot
└─vda2 252:2 0 79G 0 part
├─centos-root 253:0 0 50G 0 lvm /
├─centos-swap 253:1 0 3.9G 0 lvm [SWAP]
└─centos-home 253:2 0 25.1G 0 lvm /home
vdb 252:16 0 100G 0 disk
[root@localhost ~]# fdisk -l
Disk /dev/vda: 85.9 GB, 85899345920 bytes, 167772160 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 label type: dos
Disk identifier: 0x000bd0ad
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 2099199 1048576 83 Linux
/dev/vda2 2099200 167772159 82836480 8e Linux LVM
Disk /dev/mapper/centos-root: 53.7 GB, 53687091200 bytes, 104857600 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/centos-swap: 4160 MB, 4160749568 bytes, 8126464 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/centos-home: 27.0 GB, 26969374720 bytes, 52674560 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/vdb: 107.4 GB, 107374182400 bytes, 209715200 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@localhost ~]# mkdir /data
[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name centos
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 178.99 GiB
PE Size 4.00 MiB
Total PE 45822
Alloc PE / Size 20222 / 78.99 GiB
Free PE / Size 25600 / 100.00 GiB
VG UUID uBTksn-aQAX-Qj8E-Ezw9-7EH6-nCQm-d48dha
[root@localhost ~]# lvdisplay
--- Logical volume ---
LV Path /dev/centos/swap
LV Name swap
VG Name centos
LV UUID wYvp54-IM0a-Ur8O-6glF-PksC-gRFi-MFhpcI
LV Write Access read/write
LV Creation host, time localhost, 2021-06-30 23:24:34 -0400
LV Status available
# open 2
LV Size <3.88 GiB
Current LE 992
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:1
--- Logical volume ---
LV Path /dev/centos/home
LV Name home
VG Name centos
LV UUID aIpK61-I41C-6oKX-5Gcz-LRnj-LNCV-7Q8IAT
LV Write Access read/write
LV Creation host, time localhost, 2021-06-30 23:24:34 -0400
LV Status available
# open 1
LV Size <85.12 GiB
Current LE 21790
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:2
--- Logical volume ---
LV Path /dev/centos/root
LV Name root
VG Name centos
LV UUID LSxMUH-zNHQ-JKp3-DSbU-GunX-8cJ3-I7lj3v
LV Write Access read/write
LV Creation host, time localhost, 2021-06-30 23:24:34 -0400
LV Status available
# open 1
LV Size 70.00 GiB
Current LE 17920
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0
[root@localhost ~]# vgextend centos /dev/vdb
WARNING: xfs signature detected on /dev/vdb at offset 0. Wipe it? [y/n]: y
Wiping xfs signature on /dev/vdb.
Physical volume "/dev/vdb" successfully created.
Volume group "centos" successfully extended
[root@localhost ~]# lvcreate -L 20G -n data centos
Logical volume "data" created.
#-L:指定大小 -n:定义LVM卷名(lv0) centos(指定vg)
root@localhost ~]# mkfs.xfs /dev/mapper/centos-data
meta-data=/dev/mapper/centos-data isize=512 agcount=4, agsize=1310720 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=5242880, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
1.7 挂载该lv到/data分区上
[root@localhost ~]# mount /dev/mapper/centos-data /data/
[root@localhost ~]# blkid /dev/mapper/centos-data
/dev/mapper/centos-data: UUID="4a88369f-3749-49e5-9f1b-15389b8482e5" TYPE="xfs"
vim /etc/fstab
2.1 给/分区扩容20G
[root@localhost ~]# lvextend -L +20G /dev/mapper/centos-root
Size of logical volume centos/root changed from 50.00 GiB (12800 extents) to 70.00 GiB (17920 extents).
Logical volume centos/root successfully resized.
2.2 给/home分区扩容60G
[root@localhost ~]# lvextend -L +60G /dev/mapper/centos-home
Size of logical volume centos/home changed from <25.12 GiB (6430 extents) to <85.12 GiB (21790 extents).
Logical volume centos/home successfully resized.
附:lvextend是可以动态调整分区的,-l是按百分比分配,+表示增加;-L是安装指定容量分配,+表示增加,-表示减少,不带符号表示将分区调整至指定大小;
lvextend –L +20G /dev/mapper/centos-root #root分区增加20G
lvreduce -L -20G /dev/mapper/centos-home #root分区减少2G
lvextend –L 20G /dev/mapper/centos-root #root分区设置为20G
lvextend -l +10%FREE /dev/mapper/vg_master-lv_root #root分区增加空闲空间的10%
[root@localhost ~]# xfs_growfs /dev/centos/root
meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=3276800 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=13107200, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=6400, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 13107200 to 18350080
[root@localhost ~]# xfs_growfs /dev/centos/home
meta-data=/dev/mapper/centos-home isize=512 agcount=4, agsize=1646080 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=6584320, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=3215, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 6584320 to 22312960
[root@localhost ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs tmpfs 1.9G 16K 1.9G 1% /dev/shm
tmpfs tmpfs 1.9G 185M 1.7G 10% /run
tmpfs tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/mapper/centos-root xfs 70G 3.6G 67G 6% /
/dev/vda1 xfs 1014M 189M 826M 19% /boot
/dev/mapper/centos-home xfs 86G 378M 85G 1% /home
tmpfs tmpfs 379M 0 379M 0% /run/user/0
原文地址:https://blog.csdn.net/qq_41965208/article/details/130662193
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.7code.cn/show_40816.html
如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。