How to increase the filesystem in Linux without adding more disk

oo_tatang used Ask the Experts™
How can I increase the filesystem from the following full filesystems. Please itemize every step like lvreduce from some fs and lvextend etc...

1. /dev/mapper/vg_maxmmcpd-lv_maxmmcpd_data
                       46G   43G  444M  99% /DEV/DB1maxmmcpd/data

2. /dev/mapper/vg_maxproto-lv_proto_data
                       50G   47G  8.0M 100% /DEV/DB2maxproto/data

                      210G   31G  169G  16% /DEV/DB2db1mmcpd/data
                      9.9G  3.2G  6.3G  34% /DEV/DB0maxmmcpd/redoctl
                       46G   43G  444M  99% /DEV/DB1maxmmcpd/data
                       50G   47G  8.0M 100% /DEV/DB2maxproto/data
                      9.9G  151M  9.2G   2% /DEV/DB1maxproto/archive
                      5.0G  3.1G  1.6G  67% /DEV/DB0maxproto/redoctl
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Distinguished Expert 2017

You can use lvresize -L -20G from the 169GB partition

You can the allocate the space
lvresize -L +8G to the large partitions
Add some MB to the others.

If you do not resolve what the data is and how it grows, you will have to rebalance it in the bear future.

Make sure you have good backups just in case.
It would be a lot easier to add some more disk, i know thats an easy statement to make, not knowing your config or circumstances.

You could afford to move 120GB from your 210GB partition and add 30GB to your 4 big partitions and alleviate your space shortage.

But make sure you have a full backup before you do anything!!!
Distinguished Expert 2017

You actually will have to shift data all the way up to the volume groups.

Lv shifting is within the same volume group.
Volume group space shifting can only be done within the same PV.
Should you be charging more for IT Services?

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Top Expert 2013
Please correct my assumptions:

You have two volume groups, vg_maxmmcpd and vg_maxproto.

You want to extent these LV's:

To make any other statements we need to know the number (if any) of free pysical extents in both volume groups. Please provide the output of vgdisplay, here an example. Look for 'Free PE / Size':
$ su -c 'vgdisplay'
  --- Volume group ---
  VG Name               vg_server
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  11
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               95,64 GiB
  PE Size               4,00 MiB
  Total PE              24485
  Alloc PE / Size       23205 / 90,64 GiB
  Free  PE / Size       1280 / 5,00 GiB
  VG UUID               6Pf6wX-WXzt-qyeV-WpKH-XmaZ-dzis-bjXPx0

Open in new window

If there are enough free PE's then you can extend your LV's on a running system with basically one command:

$ su -c 'lvextend --size +20GB --resizefs /dev/mapper/vg_maxmmcpd-lv_maxmmcpd_data'
$ su -c 'lvextend --size +20GB --resizefs /dev/mapper/vg_maxproto-lv_proto_data'

Open in new window

Note I: This is an example. It will only work if you have more then 20GB in free PE's on each volume group.

Note II: The '-r' / '--resizefs' option is very handy as it resizes the file system along with the LV. Depending on your lvm2 version, this option might not be available. The --resize does work both ways (extending / shrinking) but in case of shrinking the whole process cannot be done on a mounted filesystem; you need to unmount it first.

If you have none or not enough free physical extents in one or both volume groups, you need to shrink existing volumes. The following example will shift 5GB from vg_maxproto-lv_proto_archive to vg_maxproto-lv_proto_data, assuming there are no open file hanldes on /DEV/DB1maxproto/archive:
$ su -
# umount /DEV/DB1maxproto/archive
# lvextend --size -5GB --resizefs /dev/mapper/vg_maxproto-lv_proto_archive
# mount /DEV/DB1maxproto/archive
# lvextend --size +5GB --resizefs /dev/mapper/vg_maxproto-lv_proto_data

Open in new window

If this does not work, for instance you have not enough room in both your VG's, will be much more complicated. It means moving physical volumes (PV's) from one VG to another. This means a downtime, backup and so on.
It is much easier to add more disk space.
Distinguished Expert 2017

Did not notice (looked too closely) it, but there are three Volume groups.
 The one Daniel listed and vg_db1mmcpd which has the 169GB  of currently Free space.
And this is the only LV on this VG.
The other LVs that are running out of space are on different groups.  Some on the same VG where there is an LV with 6.3GB of free space.  
vg_maxmmcpd-lv_maxmmcpd_data can be resized with free space from vg_maxmmcpd-lv_maxmmcpd_mgmt

The others, have to take space from vg_maxproto-lv_proto_archive that has 9.2GB

One option depending on where the 169GB is and its purpose, shuffling the partitions might be simpler.
Shrink the 210GB To the space you need it to be.80GB
add additional volumes larger than the large ones on the. i.e. a 50GB and 49GB create two  65gb partitions.

Make sure nothing is running as to not overwrite.
Then use find . | cpio to copy the data from the existing to the newly created.  Then remount the newly created in place where the old ones were.

The issue is that the original two 49/50GB are on two separate VG suggesting their on different "disks" with this change, you will concentrate all these presumably DATA partitions on the same "disks".  IF this system is high Input/Output (read/write to disks), the performance of the system could be impacted and not in a positive direction.
Top Expert 2013

The one Daniel listed and vg_db1mmcpd which has the 169GB  of currently Free space.
And this is the only LV on this VG.

Not necessarily without any more info, and my first statement was wrong - it should read three VG's. 'vg_db1mmcpd' might have some currently unmounted volumes (like snapshots).

However, if you do need to change the underlying PV's then you should move them to one volume group.
Different VG's on one physical system cause only trouble if you want to extend volumes and should IMHO only be used to separate different types of disks (like slow and fast) - though even there you can create LV's on any PV you like with lvcreate; lets assume /dev/sdd is a fast RAID LUN with 500GB and you want that as a special fast volume in your vg_database:
# pvcreate /dev/sdd
# vgextend vg_database /dev/sdd
# lvcreate -n lv_fastdisk -L 500GB vg_database /dev/sdd

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial