Centos 7 Reallocate logical volume space to another

Do you hate how Centos 7 defaults to allocating most of your valuable space to /home even though it is a production server?

Here is a quick guide on how to take back that space live, while online (of course make sure you have backups just in case something goes wrong!):

First we will reduce our home dir by 100G:

lvreduce -L -100G /dev/mapper/centos-home
  WARNING: Reducing active and open logical volume to <5.12 GiB.
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce centos/home? [y/n]: y
  Size of logical volume centos/home changed from <105.12 GiB (26910 extents) to <5.12 GiB (1310 extents).
  Logical volume centos/home successfully resized.

 

Now let's give it back to /root:


lvextend -l 100%FREE /dev/centos/root
  Size of logical volume centos/root changed from 50.00 GiB (12800 extents) to 100.00 GiB (25601 extents).
  Logical volume centos/root successfully resized.

OK but now what does our filesystem magically know what we did with the LV/logical volume?  No


[root@disc livefilesystem]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   50G   35G   16G  70% /

devtmpfs                 1.9G     0  1.9G   0% /dev
tmpfs                    1.9G     0  1.9G   0% /dev/shm
tmpfs                    1.9G  8.7M  1.9G   1% /run
tmpfs                    1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/mapper/centos-home  106G   33M  106G   1% /home
/dev/sda1               1014M  176M  839M  18% /boot
tmpfs                    379M     0  379M   0% /run/user/0

Maybe we could just remount it? No



[root@disc livefilesystem]# mount -o remount /
[root@disc livefilesystem]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   50G   35G   16G  70% /

How do we resize the filesystem?  xfs_growfs of course!


xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=512    agcount=4, agsize=3276800 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=13107200, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=6400, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 13107200 to 26215424

Now it's all good!


[root@disc livefilesystem]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root  100G   35G   66G  35% /
devtmpfs                 1.9G     0  1.9G   0% /dev
tmpfs                    1.9G     0  1.9G   0% /dev/shm
tmpfs                    1.9G  8.7M  1.9G   1% /run
tmpfs                    1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/mapper/centos-home  106G   33M  106G   1% /home
/dev/sda1               1014M  176M  839M  18% /boot
tmpfs                    379M     0  379M   0% /run/user/0


Tags:

centos, reallocate, volume, anotherdo, defaults, allocating, server, online, backups, reduce, dir, lvreduce, dev, mapper, reducing, active, gib, filesystem, etc, extents, successfully, resized, lvextend, ok, magically, lv, disc, livefilesystem, df, avail, mounted, devtmpfs, tmpfs, shm, sys, fs, cgroup, sda, user, remount, mount, resize, xfs_growfs, meta, isize, agcount, agsize, blks, sectsz, attr, projid, crc, finobt, spinodes, bsize, imaxpct, sunit, swidth, naming, ascii, ci, ftype, lazy, realtime, extsz, rtextents,

Latest Articles

  • How To Add Windows 7 8 10 11 to GRUB Boot List Dual Booting
  • How to configure OpenDKIM on Linux with Postfix and setup bind zonefile
  • Debian Ubuntu 10/11/12 Linux how to get tftpd-hpa server setup tutorial
  • efibootmgr: option requires an argument -- 'd' efibootmgr version 15 grub-install.real: error: efibootmgr failed to register the boot entry: Operation not permitted.
  • Apache Error Won't start SSL Cert Issue Solution Unable to configure verify locations for client authentication SSL Library Error: 151441510 error:0906D066:PEM routines:PEM_read_bio:bad end line SSL Library Error: 185090057 error:0B084009:x509 certif
  • Linux Debian Mint Ubuntu Bridge br0 gets random IP
  • redis requirements
  • How to kill a docker swarm
  • docker swarm silly issues
  • isc-dhcp-server dhcpd how to get longer lease
  • nvidia cannot resume from sleep Comm: nvidia-sleep.sh Tainted: Linux Ubuntu Mint Debian
  • zfs and LUKS how to recover in Linux
  • [error] (28)No space left on device: Cannot create SSLMutex Apache Solution Linux CentOS Ubuntu Debian Mint
  • Save money on bandwidth by disabling reflective rpc queries in Linux CentOS RHEL Ubuntu Debian
  • How to access a disk with bad superblock Linux Ubuntu Debian Redhat CentOS ext3 ext4
  • ImageMagick error convert solution - convert-im6.q16: cache resources exhausted
  • PTY allocation request failed on channel 0 solution
  • docker error not supported as upperdir failed to start daemon: error initializing graphdriver: driver not supported
  • Migrated Linux Ubuntu Mint not starting services due to broken /var/run and dbus - Failed to connect to bus: No such file or directory solution
  • qemu-system-x86_64: Initialization of device ide-hd failed: Failed to get