Wood Chen

Partition Issues After Installing RED HAT LINUX9

0 comments179 views134 words

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

  1. Back up your data: Make sure you have backed up all data in the /home directory. You can use rsync or another backup tool.

  2. Unmount the /home partition: Unmount the /home partition in single-user mode or after ensuring that no users are using the /home directory.

    umount /home
    
  3. Remove the /home partition: Use a tool such as lvremove to remove the /home logical volume.

    lvremove /dev/mapper/rhel-home
    
  4. Extend the / partition: Use lvextend to extend the / logical volume into the space previously used by /home.

    lvextend -l +100%FREE /dev/mapper/rhel-root
    
  5. Grow the filesystem: Use the appropriate filesystem tool (such as resize2fs for ext4) to grow the filesystem to the new logical volume size.

    resize2fs /dev/mapper/rhel-root
    
  6. Remove the default mount configuration

    vi /etc/fstab
    #Delete the line containing /home, then save with ESC+
    :wq
    
  7. 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

Related posts

Comments 0