Partition Issues After Installing RED HAT LINUX9
This post was translated from Chinese by AI. If anything reads oddly, the Chinese original is authoritative. 中文原文
The default partition layout includes home
[root@node1-bt ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 1T 0 disk
├─sda1 8:1 0 600M 0 part /boot/efi
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 1022.4G 0 part
├─rhel-root 253:0 0 70G 0 lvm /
├─rhel-swap 253:1 0 7.9G 0 lvm [SWAP]
└─rhel-home 253:2 0 944.5G 0 lvm /home
sr0 11:0 1 1024M 0 rom
Merge home into the root partition
-
Back up your data: Make sure you have backed up all data in the
/homedirectory. You can usersyncor another backup tool. -
Unmount the /home partition: Unmount the
/homepartition in single-user mode or after ensuring that no users are using the/homedirectory.umount /home -
Remove the /home partition: Use a tool such as
lvremoveto remove the/homelogical volume.lvremove /dev/mapper/rhel-home -
Extend the / partition: Use
lvextendto extend the/logical volume into the space previously used by/home.lvextend -l +100%FREE /dev/mapper/rhel-root -
Grow the filesystem: Use the appropriate filesystem tool (such as
resize2fsfor ext4) to grow the filesystem to the new logical volume size.resize2fs /dev/mapper/rhel-root -
Remove the default mount configuration
vi /etc/fstab #Delete the line containing /home, then save with ESC+ :wq -
Remount the / partition: Remount the
/partition.mount -a
Expand the system disk
[root@node1-bt ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 4.0M 0 4.0M 0% /dev
tmpfs 7.7G 16K 7.7G 1% /dev/shm
tmpfs 3.1G 11M 3.1G 1% /run
/dev/mapper/rhel-root 70G 3.4G 67G 5% /
/dev/sda2 960M 249M 712M 26% /boot
/dev/sda1 599M 7.0M 592M 2% /boot/efi
tmpfs 1.6G 0 1.6G 0% /run/user/0
[root@node1-bt ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 1T 0 disk
├─sda1 8:1 0 600M 0 part /boot/efi
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 1022.4G 0 part
├─rhel-root 253:0 0 1014.5G 0 lvm /
└─rhel-swap 253:1 0 7.9G 0 lvm [SWAP]
sr0 11:0 1 1024M 0 rom
Grow the filesystem
[root@node1-bt ~]# xfs_growfs /dev/mapper/rhel-root
meta-data=/dev/mapper/rhel-root isize=512 agcount=4, agsize=4587520 blks
= sectsz=512 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=16384, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 18350080 to 265956352
Done
[root@node1-bt ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 4.0M 0 4.0M 0% /dev
tmpfs 7.7G 16K 7.7G 1% /dev/shm
tmpfs 3.1G 11M 3.1G 1% /run
/dev/mapper/rhel-root 1015G 10G 1005G 1% /
/dev/sda2 960M 249M 712M 26% /boot
/dev/sda1 599M 7.0M 592M 2% /boot/efi
tmpfs 1.6G 0 1.6G 0% /run/user/0
Last updated 2024-01-14
Comments 0