7

I have a VM with 1 280GB disk. For some reason my layout is:

$ df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   50G   21G   30G  41% /
devtmpfs                 5.8G     0  5.8G   0% /dev
tmpfs                    5.8G     0  5.8G   0% /dev/shm
tmpfs                    5.8G  8.5M  5.8G   1% /run
tmpfs                    5.8G     0  5.8G   0% /sys/fs/cgroup
/dev/mapper/centos-home  224G   13G  212G   6% /home
/dev/sda1                497M  145M  352M  30% /boot
tmpfs                    1.2G     0  1.2G   0% /run/user/1000

Running fdisk -l:

$ sudo fdisk -l
[sudo] password for admin:

Disk /dev/sda: 300.6 GB, 300647710720 bytes, 587202560 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0006c283

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048   587202559   293088256   8e  Linux LVM

Disk /dev/mapper/centos-swap: 6316 MB, 6316621824 bytes, 12337152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/centos-root: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/centos-home: 240.1 GB, 240115515392 bytes, 468975616 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

And:

$ sudo lsblk -io NAME,TYPE,SIZE,MOUNTPOINT,FSTYPE,MODEL
NAME            TYPE   SIZE MOUNTPOINT FSTYPE      MODEL
fd0             disk     4K
sda             disk   280G                        Virtual disk
|-sda1          part   500M /boot      xfs
`-sda2          part 279.5G            LVM2_member
  |-centos-swap lvm    5.9G [SWAP]     swap
  |-centos-root lvm     50G /          xfs
  `-centos-home lvm  223.6G /home      xfs
sr0             rom   1024M                        VMware IDE CDR10

How do I move the disk space used for /dev/mapper/centos-home to /dev/mapper/centos-root? Do I have to shrink centos-home and reallocate to centos-root?

7

You can reduce your home LV as long as it's unmounted. (please keep in mind that shrinking has some risks )

Go like this:

umount /dev/mapper/centos-home
lvreduce -L 200G /dev/mapper/centos-home

Mount back your home partition as you're done with it.

Then just extend your root volume.

lvextend -t -r -l+100%FREE /dev/mapper/centos-root

-t is test, if it's ok just run the command a second time without -t

  • I am getting a "umount: /home device is busy". After logging in as root in the vSphere console and running "fuser -mv /home" I get: – GodAtum Mar 22 '16 at 14:46
  • USER PID ACCESS COMMAND /home: root kernel mount /home jenkins 2101 f...m java – GodAtum Mar 22 '16 at 14:47
  • 2
    The accepted answer is incomplete: while you can reduce the underlying logical volume, you can not shrink an XFS filesystem. Reducing /dev/mapper/centos-home will cause data loss for the home partition. If you follow this route, please backup anything important you have on this volume before reducing it. – shodanshok Mar 26 '17 at 22:11
1

I forced the unmount by using the command sudo umount -fl /home

then carried on with those instructions.

1

The answer gave by runyoufreak helped me a lot.

I would like to add a tip because when I finished the process of resize partitions, my Cent OS after of a reboot turned on emergency mode. At my case I am not using /home so I commented the partition at /etc/fstab. After that I could to boot my system.

1

Here is a better approach. It shows you how to recreate the mount that you blow away (as this is the easiest way) but is only viable if you don't have too much under that directory tree.

How to shrink /home and add more space on CentOS7

Not the answer you're looking for? Browse other questions tagged or ask your own question.