Linux xfs格式的 /home 磁盘压缩分配给 /
本文最后更新于:2023-12-22 17:49 星期五
Linux xfs格式的 /home
磁盘压缩分配给 /
查看磁盘情况
1
2
3
4
5
6
7
8
9
10[root@bogon ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 4.0M 0 4.0M 0% /dev
tmpfs 3.7G 0 3.7G 0% /dev/shm
tmpfs 1.5G 9.8M 1.5G 1% /run
/dev/mapper/almalinux_bogon-root 70G 6.6G 64G 10% /
/dev/sda1 1014M 418M 597M 42% /boot
tmpfs 756M 92K 756M 1% /run/user/0
overlay 70G 6.6G 64G 10% /var/lib/docker/overlay2/5350a4d719574d0eb7a5fb79e75aa930b34314feb2e119380e72cc8d2fbbf315/merged
/dev/mapper/almalinux_bogon-home 853G 6.0G 847G 1% /home备份
/home
自行备份目录下文件
卸载
/home
挂载点1
2
3
4
5
6
7
8
9
10
11[root@bogon ~]# umount -v /home
umount: /home 未挂载
[root@bogon ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 4.0M 0 4.0M 0% /dev
tmpfs 3.7G 0 3.7G 0% /dev/shm
tmpfs 1.5G 9.8M 1.5G 1% /run
/dev/mapper/almalinux_bogon-root 70G 6.6G 64G 10% /
/dev/sda1 1014M 418M 597M 42% /boot
tmpfs 756M 92K 756M 1% /run/user/0
overlay 70G 6.6G 64G 10% /var/lib/docker/overlay2/5350a4d719574d0eb7a5fb79e75aa930b34314feb2e119380e72cc8d2fbbf315/merged删除 挂载
\home
的/dev/mapper/almalinux_bogon-home
1
2
3[root@bogon ~]# lvremove /dev/mapper/almalinux_bogon-home
Do you really want to remove active logical volume almalinux_bogon/home? [y/n]: y
Logical volume "home" successfully removed.1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34[root@bogon ~]# lvdisplay
--- Logical volume ---
LV Path /dev/almalinux_bogon/swap
LV Name swap
VG Name almalinux_bogon
LV UUID k3WZ81-oxNS-KJ9J-UVLx-sUX8-bqDd-0iPinl
LV Write Access read/write
LV Creation host, time bogon, 2023-12-22 14:20:48 +0800
LV Status available
# open 2
LV Size <7.77 GiB
Current LE 1989
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
--- Logical volume ---
LV Path /dev/almalinux_bogon/root
LV Name root
VG Name almalinux_bogon
LV UUID nKyL47-CJnM-Pu2Z-WQqH-ylve-QZuc-FiJnUz
LV Write Access read/write
LV Creation host, time bogon, 2023-12-22 14:20:52 +0800
LV Status available
# open 1
LV Size 70.00 GiB
Current LE 17920
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0扩展
/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16[root@bogon ~]# lvextend -L +700G /dev/mapper/almalinux_bogon-root
Size of logical volume almalinux_bogon/root changed from 70.00 GiB (17920 extents) to 770.00 GiB (197120 extents).
Logical volume almalinux_bogon/root successfully resized.
[root@bogon ~]# xfs_growfs /dev/mapper/almalinux_bogon-root
meta-data=/dev/mapper/almalinux_bogon-root isize=512 agcount=4, agsize=4587520 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1 bigtime=1 inobtcount=1 nrext64=0
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=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 18350080 to 2018508801
2
3
4
5
6
7
8
9
10[root@bogon ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 4.0M 0 4.0M 0% /dev
tmpfs 3.7G 0 3.7G 0% /dev/shm
tmpfs 1.5G 9.8M 1.5G 1% /run
/dev/mapper/almalinux_bogon-root 770G 12G 759G 2% /
/dev/sda1 1014M 418M 597M 42% /boot
tmpfs 756M 92K 756M 1% /run/user/0
overlay 770G 12G 759G 2% /var/lib/docker/overlay2/5350a4d719574d0eb7a5fb79e75aa930b34314feb2e119380e72cc8d2fbbf315/merged将剩余的空间重新分配给
/home
创建挂载点和卷宗
1
2
3[root@bogon ~]# lvcreate -l 100%FREE -n home almalinux_bogon
Logical volume "home" created.
[root@bogon ~]# mkfs.xfs /dev/mapper/almalinux_bogon-home校验挂载点
1
2
3
4
5
6
7
8
9
10
11[root@bogon ~]# mkfs.xfs /dev/mapper/almalinux_bogon-home
meta-data=/dev/mapper/almalinux_bogon-home isize=512 agcount=4, agsize=10009856 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1 bigtime=1 inobtcount=1 nrext64=0
data = bsize=4096 blocks=40039424, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=19550, version=2
= sectsz=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0挂载
/home
1
[root@bogon ~]# mount /dev/mapper/almalinux_bogon-home /home
结果
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63[root@bogon ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 4.0M 0 4.0M 0% /dev
tmpfs 3.7G 0 3.7G 0% /dev/shm
tmpfs 1.5G 9.8M 1.5G 1% /run
/dev/mapper/almalinux_bogon-root 770G 12G 759G 2% /
/dev/sda1 1014M 418M 597M 42% /boot
tmpfs 756M 92K 756M 1% /run/user/0
overlay 770G 12G 759G 2% /var/lib/docker/overlay2/5350a4d719574d0eb7a5fb79e75aa930b34314feb2e119380e72cc8d2fbbf315/merged
/dev/mapper/almalinux_bogon-home 153G 1.1G 152G 1% /home
[root@bogon ~]# lvdisplay
--- Logical volume ---
LV Path /dev/almalinux_bogon/swap
LV Name swap
VG Name almalinux_bogon
LV UUID k3WZ81-oxNS-KJ9J-UVLx-sUX8-bqDd-0iPinl
LV Write Access read/write
LV Creation host, time bogon, 2023-12-22 14:20:48 +0800
LV Status available
# open 2
LV Size <7.77 GiB
Current LE 1989
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
--- Logical volume ---
LV Path /dev/almalinux_bogon/root
LV Name root
VG Name almalinux_bogon
LV UUID nKyL47-CJnM-Pu2Z-WQqH-ylve-QZuc-FiJnUz
LV Write Access read/write
LV Creation host, time bogon, 2023-12-22 14:20:52 +0800
LV Status available
# open 1
LV Size 770.00 GiB
Current LE 197120
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Path /dev/almalinux_bogon/home
LV Name home
VG Name almalinux_bogon
LV UUID UkzIC6-6Qkc-0cr0-ULDk-swJI-AlhI-Nt0sVj
LV Write Access read/write
LV Creation host, time bogon, 2023-12-22 17:40:01 +0800
LV Status available
# open 1
LV Size <152.74 GiB
Current LE 39101
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:2
Linux xfs格式的 /home 磁盘压缩分配给 /
https://blog.dekun.wang/blog/7afb52be.html