2
umount /dev/mapper/nvmeVg-home
umount: /home: target is busy

I looked at this answer and found this useful page I was unable to solve my problem before posting here.

My /var directory is full. /var is on a lvm. Last night, I went to increase the size of /var and accidentally executed lvextend -L+50G /dev/mapper/nvmeVg-home when I should have lvextend -L +50G dev/mapper/nvmeVg-var oops.

So no big deal right? lvextend -L-50G /dev/mapper/nvmeVg-home results in

Size may not be negative.  Invalid argument for --size: -50G.  Error during parsing of command line:

So then I see to shrink a non root volume I must umount the device first. Sure no problem: /umount /dev/mapper/nvmeVg-home results in

umount: /home: target is busy 

So I lsof /dev/mapper/nvmeVg-home and get lots of output. So if I am unable to umount because /home has files in use, then I tried lsof | grep /dev/mapper/nvme returned nothing. I was expecting to see the total number of files open. Then I tried /lsof +f -- /dev/mapper/nvmeVg-home which returned alot of files currently in use. Fine. I then notice /home is mounted to multiple volume groups?(still uncertain on terminology). That's odd. Doesn't look right. Could this be a second issue with in my issue?

nvme0n1         259:0    0 953.9G  0 disk 
├─nvme0n1p1     259:1    0   953M  0 part 
├─nvme0n1p2     259:2    0  46.6G  0 part 
│ └─nvmeVg-var  253:2    0    50G  0 lvm  /var
├─nvme0n1p3     259:3    0  46.6G  0 part 
│ ├─nvmeVg-var  253:2    0    50G  0 lvm  /var
│ ├─nvmeVg-home 253:3    0   150G  0 lvm  /home
│ └─nvmeVg-root 253:4    0   100G  0 lvm  
├─nvme0n1p4     259:4    0  46.6G  0 part 
│ └─nvmeVg-home 253:3    0   150G  0 lvm  /home
├─nvme0n1p5     259:5    0  46.6G  0 part 
│ └─nvmeVg-home 253:3    0   150G  0 lvm  /home
├─nvme0n1p6     259:6    0  46.6G  0 part 
│ └─nvmeVg-root 253:4    0   100G  0 lvm  
├─nvme0n1p7     259:7    0  46.6G  0 part 
│ └─nvmeVg-root 253:4    0   100G  0 lvm  
├─nvme0n1p8     259:8    0  46.6G  0 part 
│ └─nvmeVg-home 253:3    0   150G  0 lvm  /home
├─nvme0n1p9     259:9    0  46.6G  0 part 
├─nvme0n1p10    259:10   0  46.6G  0 part 
├─nvme0n1p11    259:11   0  46.6G  0 part 
└─nvme0n1p12    259:12   0     1G  0 part 

I feel like it is wise to pause and reach out for help at this point.

berndbausch
  • 3,477
  • 2
  • 15
  • 21
powerhousemethod
  • 435
  • 9
  • 25
  • 2
    `lvextend` can only increase the size. This has nothing to do with being mounted. Try `lvreduce` or `lvresize` instead, but be **very** careful not to reduce too much. The `lsof` command, without options, doesn't print the device on which a file is located, therefore your grepping for *nvme* returns nothing. /home is not mounted multiple times, but is spread over multiple physical volumes. In short, you have no issue, just a slight misunderstanding how things work. – berndbausch Feb 15 '21 at 19:03
  • 1
    One way of avoiding damage by reducing the volume too much is by adding the `-r` option. It also resizes the filesystem. If /home is XFS, however, the command might refuse working, since XFS can't be reduced. – berndbausch Feb 15 '21 at 19:12

1 Answers1

4

Most probably you are logged in to the system as a regular user. When a regular user logs on, they occupy the /home as part of the path to their home directory.

You must login as root in order to unmount /home. The root user account has a home directory of /root therefore is not affected by /home. Also make sure that no other regular user is logged before you attempt to unmount /home

Then use lvresize command:

lvresize -r -L -50G /dev/mapper/nvmeVg-home

Explanation:

lvresize command will do four things:

  1. Unmount the partition /dev/mapper/nvmeVg-home
  2. Deduct 50GB of disk space from LV which will be credited back into VG (-L -50G)
  3. Check the file system by calling resizefs (-r)
  4. Then remounts the partition /dev/mapper/nvmeVg-home
Bruce Malaudzi
  • 1,522
  • 1
  • 4
  • 11