6

I want to increase root LVM volume space. Is it possible to merge LogVol01 to LogVol00? My LVM setup looks like this:

   [root@server~]# lvs
     LV       VG         Attr   LSize  Origin Snap%  Move Log Copy%  Convert
     LogVol00 VolGroup00 -wi-ao 34.84G
     LogVol01 VolGroup00 -wi-ao 33.38G
   [root@server~]# pvs
     PV                VG         Fmt  Attr PSize  PFree
     /dev/cciss/c0d0p2 VolGroup00 lvm2 a-   68.22G    0
   [root@server~]# vgs
     VG         #PV #LV #SN Attr   VSize  VFree
     VolGroup00   1   2   0 wz--n- 68.22G    0
   [root@server~]# df -h
   Filesystem            Size  Used Avail Use% Mounted on
   /dev/mapper/VolGroup00-LogVol00
                          34G  1.3G   31G   4% /
   /dev/cciss/c0d0p1      99M   13M   81M  14% /boot
   tmpfs                  16G     0   16G   0% /dev/shm
   [root@server~]#fdisk -l

   Disk /dev/cciss/c0d0: 73.3 GB, 73372631040 bytes
   255 heads, 63 sectors/track, 8920 cylinders
   Units = cylinders of 16065 * 512 = 8225280 bytes

              Device Boot      Start         End      Blocks   Id  System
   /dev/cciss/c0d0p1   *           1          13      104391   83  Linux
   /dev/cciss/c0d0p2              14        8920    71545477+  8e  Linux LVM

   [root@server~]#lvremove -f /dev/VolGroup00/LogVol01
     Can't remove open logical volume "LogVol01"

   [root@server~]#lvchange -a n /dev/VolGroup00/LogVol01
       /dev/hdc: open failed: No medium found
       LV VolGroup00/LogVol01 in use: not deactivating

Fixed:

   swapoff -a
   lvchange -a n /dev/VolGroup00/LogVol01 
   lvextend -l +100%FREE /dev/VolGroup00/LogVol00

That should do it. Thanks Jonathan

Ondra Sniper Flidr
  • 2,623
  • 11
  • 18
guest210391
  • 63
  • 1
  • 4

1 Answers1

9

Logical volumes would have their own filesystems so it would not be possible to directly merge the two.

You would need to first remove the second volume and then grow the first.

By continuing, you will irrevocably destroy any data on your second volume.

As always, ensure you have all important data (on either volume) backed up before continuing.

You must first umount and deactivate the second volume:

lvchange -a n /dev/VolGroup00/LogVol01

Then remove it:

lvremove /dev/VolGroup00/LogVol01

Then extend your first volume:

lvextend -l +100%FREE /dev/VolGroup00/LogVol00

After that, you would need to grow your filesystem. Assuming ext4, you can grow online with:

resize2fs /dev/VolGroup00/LogVol00
  • getting LV VolGroup00/LogVol01 in use: not deactivating error – guest210391 Nov 18 '15 at 22:02
  • Something must be using it. Check to make sure it isn't mounted: `mount | grep LogVol01` – Jonathan Rouleau Nov 18 '15 at 22:20
  • swapoff -a and then lvremove worked. – guest210391 Nov 18 '15 at 22:28
  • 2
    I just followed these steps in a similar scenario and have just one addition. I had 3 lvs on one vg (swap + 2 file systems) and wanted to merge the two file systems into one. I created a file system on the swap lv and copied the data from the lv/file system to be removed. Then I followed the steps above with one addition: remember to update `/etc/fstab` and remove the file system there as well. (finished by copying back data from swap file system and reformat as swap) – hlovdal Feb 20 '16 at 19:32