Linux mount LVM format disk (make full use of disk)

Don't talk nonsense, just give the order and just follow along


  • Check the space usage of the partitioned area: fdisk -l
  • View the space usage of the partitioned area: df -hal

Remember the third line below: /dev/mapper/VolGroup-lv_root (maybe yours is different from mine), it will be useful later

 
 
[root@XS10351145199 ~]# df -hal
Filesystem            Size  Used Avail Use% Mounted on
/ dev / folders / VolGroup-lv_root
                      8.3G 665M 7.2G 9% /
proc 0 0 0 - /proc
sysfs                    0     0     0    - /sys
devpts                   0     0     0    - /dev/pts
tmpfs                 936M     0  936M   0% /dev/shm
/dev/xvda1            477M   28M  424M   7% /boot
none                     0     0     0    - /proc/sys/fs/binfmt_misc
none                     0     0     0    - /proc/xen

  • Hard disk partition: fdisk /dev/xvdb

Enter in sequence: n, p, 1, two carriage returns, t, 8e, w

  • Restart the server: reboot
  • Please see the partition to see how much space is left to allocate: fdisk -l
  • Create a physical volume: pvcreate /dev/xvdb1
  • Add the physical volume to the group in the purple section above: vgextend VolGroup (see what your own) /dev/xvdb1. I am here: vgextend VolGroup /dev/xvdb1
Check the physical volume group status: vgdisplay. The numbers after Free PE/Size below are unallocated capacity
 
 
[root@XS10351145199 ~]# vgdisplay
  --- Volume group ---
  VG Name               VolGroup
  System ID             
  Format lvm2
  Metadata Areas        2
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  With LV 2
  Open LV               2
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               29.50 GiB
  PE Size               4.00 MiB
  Total PE 7552
  Alloc PE / Size       2434 / 9.51 GiB
  Free  PE / Size       5118 / 19.99 GiB
  VG UUID               FX3ulC-bbxl-9fHs-Bg4V-HuNz-U54E-dAqd8G


  • Expansion , you can allocate as much as there is unallocated capacity: lvresize -L + unallocated capacity G /dev/ fill in the purple part above / fill in the blue part above
  • Here I am: lvresize -L +19G /dev/VolGroup/lv_root, lvresize -L +1016M /dev/VolGroup/lv_root
  • Dynamically expandable partition size: resize2fs /dev/ purple part above / blue part above
  • Here I am: resize2fs /dev/VolGroup/lv_root

  • Finally, check whether the expansion is completed, and check whether the green bold part above is 0. If the expansion is not continued, repeat the above expansion .

The next step is to automatically mount the disk command. This command will cause the Linux system to automatically mount the disk when it is powered on.

Execute the command : sh /root/AutoTools.sh, enter: 1 The system will automatically restart.

After restarting, execute the command: df -lh. Check if the mount is complete

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325492080&siteId=291194637