Linux – How to resize LVM in Redhat

diskmanagementlinuxlvmpartitionredhat

I have a VM with Redhat 6.8 that originally started with a 60GB disk 1. In VMware I increased the size to 100GB. I would like to increase the /tmp volume from 2GB to 5GB. I assume I need to resize the sda2 partition first and then increase the LV. I tried echo 1 > /sys/class/scsi_device/2\:0\:0\:0\/device/rescan and then resize2fs /dev/sda but it said it was busy. Not sure what commands I need or what the the order is… Here's my system info –

$ fdisk -l /dev/sda

Disk /dev/sda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0000555c

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          26      204800   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              26        7833    62708736   8e  Linux LVM

$ lsblk
NAME                            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sr0                              11:0    1  3.6G  0 rom
sda                               8:0    0  100G  0 disk
├─sda1                            8:1    0  200M  0 part /boot
└─sda2                            8:2    0 59.8G  0 part
  ├─system-swap (dm-0)          253:0    0   10G  0 lvm  [SWAP]
  ├─system-root (dm-1)          253:1    0   10G  0 lvm  /
  ├─system-opt (dm-2)           253:2    0   10G  0 lvm  /opt
  ├─system-tmp (dm-3)           253:3    0    2G  0 lvm  /tmp
  ├─system-var_log (dm-4)       253:4    0    1G  0 lvm  /var/log
  ├─system-var (dm-5)           253:5    0   10G  0 lvm  /var
  ├─system-home (dm-6)          253:6    0   10G  0 lvm  /home
  └─system-var_log_audit (dm-7) 253:7    0    1G  0 lvm  /var/log/audit

$ lvdisplay /dev/system/tmp
  --- Logical volume ---
  LV Path                /dev/system/tmp
  LV Name                tmp
  VG Name                system
  LV UUID                QOy6T3-vVnK-fJ0o-hyfY-gPYf-IC61-YDLQn1
  LV Write Access        read/write
  LV Creation host, time hardlogs.localdomain, 2014-02-19 12:09:47 -0500
  LV Status              available
  # open                 1
  LV Size                2.00 GiB
  Current LE             512
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:3

Best Answer

After partition resize, you should reboot the system to be 100% sure that kernel recognizes the new size. After that:

  • you had to resize the LVM volume, issuing lvextend /dev/system/tmp -L 5G
  • you had to resize the filesystem, issuing resize2fs /dev/system/tmp

Please pay much attention to issuing the above command against the correct devices. For example, your previous resize2fs was plain and dangerously wrong, as you must not use sda as target, rather the LVM volume.

Related Topic