ToB企服应用市场:ToB评测及商务社交产业平台
标题:
Centos7 将home空间分配给根目录(/dev/centos/root)
[打印本页]
作者:
南七星之家
时间:
2024-7-26 09:13
标题:
Centos7 将home空间分配给根目录(/dev/centos/root)
1、查看目录布局
[root@localhost opt]# df -hl
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 7.7G 0 7.7G 0% /dev
tmpfs 7.7G 0 7.7G 0% /dev/shm
tmpfs 7.7G 18M 7.7G 1% /run
tmpfs 7.7G 0 7.7G 0% /sys/fs/cgroup
/dev/mapper/centos-root 50G 39G 12G 78% /
/dev/sda2 1014M 176M 839M 18% /boot
/dev/sda1 200M 12M 189M 6% /boot/efi
/dev/mapper/centos-home 180G 33M 180G 1% /home
tmpfs 1.6G 0 1.6G 0% /run/user/0
overlay 50G 39G 12G 78% /var/lib/docker/overlay2/b13ed87897fe1cabe547341e9a855c43bf04fcf7f3ef44e41138b08e62fb6191/merged
overlay 50G 39G 12G 78% /var/lib/docker/overlay2/502140d31ceae249f65f90e2fc096af6d8cece5f086ab9ce7e01ff80ec82576d/merged
overlay 50G 39G 12G 78% /var/lib/docker/overlay2/b8bfb2a4f4360f9b3915452fb4303d5ebf02299bee754de9d7245b5efc0d8149/merged
overlay 50G 39G 12G 78% /var/lib/docker/overlay2/59d0f795fa7c6d89467ada62d8e9e1cd8b9ad5628ca251bb5c9011fbed513af1/merged
overlay 50G 39G 12G 78% /var/lib/docker/overlay2/b7ed9b03a812579f993ac7dbe086afb15401ec5109af9467a5efbbc524f74b79/merged
复制代码
2、备份/home数据
[root@localhost opt]# mkdir /home-backup
[root@localhost opt]#
[root@localhost opt]# mv /home/* /home-backup
复制代码
3、删除/home逻辑卷
[root@localhost /]# umount /home
[root@localhost /]#
[root@localhost /]# lvremove /dev/centos/home
Do you really want to remove active logical volume centos/home? [y/n]: y
Logical volume "home" successfully removed
复制代码
4、查看可用空间大小
[root@localhost /]# vgdisplay
--- Volume group ---
VG Name centos
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size <237.28 GiB
PE Size 4.00 MiB
Total PE 60743
Alloc PE / Size 14784 / 57.75 GiB
Free PE / Size 45959 / <179.53 GiB
VG UUID 6zqmne-yIRi-DzR0-pOc7-pwHI-O1hM-Vh7T5c
复制代码
根据:Free PE / Size 45959 / <179.53 GiB判断
可用空间为:179.53 GiB
5、新建/home卷
[root@localhost /]# lvcreate -L 50G -n home centos
WARNING: xfs signature detected on /dev/centos/home at offset 0. Wipe it? [y/n]: y
Wiping xfs signature on /dev/centos/home.
Logical volume "home" created.
复制代码
6、查看/home卷
[root@localhost /]# lvdisplay
--- Logical volume ---
LV Path /dev/centos/swap
LV Name swap
VG Name centos
LV UUID PkUzOD-edvq-AYZH-RZte-nOOF-h27l-UDywl5
LV Write Access read/write
LV Creation host, time localhost, 2024-05-07 16:07:38 +0800
LV Status available
# open 2
LV Size 7.75 GiB
Current LE 1984
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
--- Logical volume ---
LV Path /dev/centos/root
LV Name root
VG Name centos
LV UUID jpAxQq-GFzU-AfaT-Hotn-k6bG-FwII-a6EzIq
LV Write Access read/write
LV Creation host, time localhost, 2024-05-07 16:07:43 +0800
LV Status available
# open 1
LV Size 50.00 GiB
Current LE 12800
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Path /dev/centos/home
LV Name home
VG Name centos
LV UUID jMNrQ0-VpnG-FBry-wmrb-9oue-ALSZ-fuXYrd
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2024-05-08 09:38:46 +0800
LV Status available
# open 0
LV Size 50.00 GiB
Current LE 12800
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2
复制代码
分配50G空间成功
7、查看可用空间大小
[root@localhost /]# vgdisplay
--- Volume group ---
VG Name centos
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 6
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 <237.28 GiB
PE Size 4.00 MiB
Total PE 60743
Alloc PE / Size 27584 / 107.75 GiB
Free PE / Size 33159 / <129.53 GiB
VG UUID 6zqmne-yIRi-DzR0-pOc7-pwHI-O1hM-Vh7T5c
复制代码
根据:Free PE / Size 33159 / <129.53 GiB判断
可用空间为129.53 GiB
8、/home上创建xfs文件体系
[root@localhost /]# mkfs -t xfs /dev/centos/home
Discarding blocks...Done.
meta-data=/dev/centos/home isize=512 agcount=4, agsize=3276800 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=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 log bsize=4096 blocks=6400, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
复制代码
9、挂载/home
[root@localhost /]# mount /dev/centos/home /home
[root@localhost /]#
[root@localhost /]#
[root@localhost /]# df -h
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 7.7G 0 7.7G 0% /dev
tmpfs 7.7G 0 7.7G 0% /dev/shm
tmpfs 7.7G 18M 7.7G 1% /run
tmpfs 7.7G 0 7.7G 0% /sys/fs/cgroup
/dev/mapper/centos-root 50G 39G 12G 78% /
/dev/sda2 1014M 176M 839M 18% /boot
/dev/sda1 200M 12M 189M 6% /boot/efi
tmpfs 1.6G 0 1.6G 0% /run/user/0
overlay 50G 39G 12G 78% /var/lib/docker/overlay2/b13ed87897fe1cabe547341e9a855c43bf04fcf7f3ef44e41138b08e62fb6191/merged
overlay 50G 39G 12G 78% /var/lib/docker/overlay2/502140d31ceae249f65f90e2fc096af6d8cece5f086ab9ce7e01ff80ec82576d/merged
overlay 50G 39G 12G 78% /var/lib/docker/overlay2/b8bfb2a4f4360f9b3915452fb4303d5ebf02299bee754de9d7245b5efc0d8149/merged
overlay 50G 39G 12G 78% /var/lib/docker/overlay2/59d0f795fa7c6d89467ada62d8e9e1cd8b9ad5628ca251bb5c9011fbed513af1/merged
overlay 50G 39G 12G 78% /var/lib/docker/overlay2/b7ed9b03a812579f993ac7dbe086afb15401ec5109af9467a5efbbc524f74b79/merged
/dev/mapper/centos-home 50G 33M 50G 1% /home
复制代码
10、迁移home目录的备份数据
[root@localhost /]# mv /home-backup/* /home
[root@localhost /]#
[root@localhost /]#
[root@localhost /]# rm -rf /home-backup
复制代码
11、将剩余的空间129.53 GiB分配给根目录(/dev/centos/root)
[root@localhost /]# lvextend -L +129G /dev/centos/root
Size of logical volume centos/root changed from 50.00 GiB (12800 extents) to 179.00 GiB (45824 extents).
Logical volume centos/root successfully resized.
[root@localhost /]#
[root@localhost /]#
[root@localhost /]#
[root@localhost /]#
[root@localhost /]# lvdisplay
--- Logical volume ---
LV Path /dev/centos/swap
LV Name swap
VG Name centos
LV UUID PkUzOD-edvq-AYZH-RZte-nOOF-h27l-UDywl5
LV Write Access read/write
LV Creation host, time localhost, 2024-05-07 16:07:38 +0800
LV Status available
# open 2
LV Size 7.75 GiB
Current LE 1984
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
--- Logical volume ---
LV Path /dev/centos/root
LV Name root
VG Name centos
LV UUID jpAxQq-GFzU-AfaT-Hotn-k6bG-FwII-a6EzIq
LV Write Access read/write
LV Creation host, time localhost, 2024-05-07 16:07:43 +0800
LV Status available
# open 1
LV Size 179.00 GiB
Current LE 45824
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Path /dev/centos/home
LV Name home
VG Name centos
LV UUID jMNrQ0-VpnG-FBry-wmrb-9oue-ALSZ-fuXYrd
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2024-05-08 09:38:46 +0800
LV Status available
# open 1
LV Size 50.00 GiB
Current LE 12800
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2
复制代码
12、扩展根目录(/dev/centos/root)
[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 46923776
[root@localhost /]#
[root@localhost /]#
[root@localhost /]#
[root@localhost /]# df -h
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 7.7G 0 7.7G 0% /dev
tmpfs 7.7G 0 7.7G 0% /dev/shm
tmpfs 7.7G 18M 7.7G 1% /run
tmpfs 7.7G 0 7.7G 0% /sys/fs/cgroup
/dev/mapper/centos-root 179G 39G 141G 22% /
/dev/sda2 1014M 176M 839M 18% /boot
/dev/sda1 200M 12M 189M 6% /boot/efi
tmpfs 1.6G 0 1.6G 0% /run/user/0
overlay 179G 39G 141G 22% /var/lib/docker/overlay2/b13ed87897fe1cabe547341e9a855c43bf04fcf7f3ef44e41138b08e62fb6191/merged
overlay 179G 39G 141G 22% /var/lib/docker/overlay2/502140d31ceae249f65f90e2fc096af6d8cece5f086ab9ce7e01ff80ec82576d/merged
overlay 179G 39G 141G 22% /var/lib/docker/overlay2/b8bfb2a4f4360f9b3915452fb4303d5ebf02299bee754de9d7245b5efc0d8149/merged
overlay 179G 39G 141G 22% /var/lib/docker/overlay2/59d0f795fa7c6d89467ada62d8e9e1cd8b9ad5628ca251bb5c9011fbed513af1/merged
overlay 179G 39G 141G 22% /var/lib/docker/overlay2/b7ed9b03a812579f993ac7dbe086afb15401ec5109af9467a5efbbc524f74b79/merged
/dev/mapper/centos-home 50G 33M 50G 1% /home
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/)
Powered by Discuz! X3.4