0

I need to reduce my /tmp LV so I type this command :

$ sudo lvreduce -r -L -2G /dev/myVG/tmp
Do you want to unmount "/tmp" ? [Y|n] y
umount: /tmp: target is busy.
fsadm: Cannot proceed with mounted filesystem "/tmp".
  /sbin/fsadm failed: 1
  Filesystem resize failed.

So I investigated with fuser and lsof but they show nothing :

$ sudo fuser -vm /tmp
                     USER        PID ACCESS COMMAND
/tmp:                root     kernel mount /tmp
$ sudo lsof /tmp
lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1001/gvfs
      Output information may be incomplete.
lsof: WARNING: can't stat() fuse file system /run/user/1001/doc
      Output information may be incomplete.
$ sudo lsof +f -- /tmp
lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1001/gvfs
      Output information may be incomplete.
lsof: WARNING: can't stat() fuse file system /run/user/1001/doc
      Output information may be incomplete.
$ 

EDIT0 : I created /tmp manually (and other partitions as well) before installing Ubuntu 20.04 :

$ mount | grep -w /tmp
/dev/mapper/myVG-tmp on /tmp type ext4 (rw,relatime)

EDIT1 : I also tried the same commands in Ubuntu recovery mode but neither fuser nor lsof were able to show me what process was locking the /tmp filesystem.

The lsof manual is hard to comprehend. Does anyone know if there is another lsof option that can show me more processes that would eventually lock that filesystem ?

6
  • What does mount | grep tmp show? Does it show tmp as a tmpfs? THat's not able to be resized with lvreduce because tmp is usually in memory, NOT on disk. Output on my 24.04 system for /tmp: tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime,size=10485760k) – Thomas Ward Mar 20 at 18:50
  • @ThomasWard See my EDIT0 – SebMa Mar 20 at 18:55
  • 1
    OK so you have a unique /tmp setup. You won't be able to resize /tmp while the system is online, the system will have a ton of lockfiles and storage data there. You'll need to power off the system, boot into an installer or recovery disk, and resize the LV from the other system. (This is why we usually leave /tmp/ in tmpfs/`memory) – Thomas Ward Mar 20 at 18:58
  • @ThomasWard OK I see. I also tried the same commands in Ubuntu recovery mode but neither fuser nor lsof were able to show me what process was locking the /tmp filesystem. The lsof manual is hard for me to comprehend. Do you know if there is another lsof option that can show me more processes that would eventually lock that filesystem ? – SebMa Mar 20 at 19:03
  • 1
    Recovery mode still mounts /tmp/. I don't know an fuser or lsof that'll list, because there's a lot of things that use /tmp/ including running SystemD services (core components of SystemD) among other things. The only way to approach this is to shut down, boot to an installer disk, and then adjust the LVs (so that the tmp LV isn't actually being used, since it's not mounted at /tmp, and the Kernel and such aren't writing there). – Thomas Ward Mar 20 at 19:09
2

Your only option here is to power down your system and boot to an alternative environment or LiveUSB. There's no lsof or fuser command that'll list that the SystemD system is using /tmp for storage of things.

SystemD among other things (critical system processes and such) all write to /tmp - this is USUALLY why you don't create LVs or anything for /tmp and let it live in volatile memory which is much much faster than writing to the disks for temporary files.

The recovery environment also uses /tmp because of the kernel and such and critical systemd resources writing there. This is where you will need to go into your system from the other boot disk, activate the LVM environment, and then resize your LVs from there when there's no data being written or used in your special /tmp LV.

I would also recommend that unless your RAM is at a premium, you remove the /tmp LV and replace it with a tmpfs that lives in RAM and is erased on reboot. This is why /tmp is usually not on-disk but a tmpfs in most installs.

3
  • Hi, can you please add your /tmp entry from your /etc/fstab so I can do something similar ? – SebMa Mar 26 at 10:59
  • 1
    @SebMa sure. My /tmp line also designates the size in memory of the /tmp space - on my system I have the RAM to spare so that's up to 10G. Just set that to the size you want or omit the size= part in the options. This is what's in my /etc/fstab for my /tmp folder/partition: tmpfs /tmp tmpfs defaults,noatime,nosuid,nodev,mode=1777,size=10G 0 0 – Thomas Ward Mar 26 at 15:36
  • Thanks bro. :+1: – SebMa Mar 26 at 18:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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