7

I'm trying to use zerofree, which seems to be the answer for this: How to reduce VM size?

I have successfully umounted /dev/sda1, and zerofree worked fine, releasing ~37gb.

But I can't seem to umount or remount as read only /dev/mapper/mypc-root, it says:

umount: / is busy

or

mount: / is busy

The commands used were:

$ umount /dev/mapper/mypc-root
$ mount -no remount,ro -t ext2 /dev/mapper/mypc-root /

I'm in single user mode, entered it with 'init 1'.

The guest SO is Ubuntu 12, with encrypted LVM and home.

Any ideas?

3 Answers 3

7

/ can't be unmounted from the system, as / is in use (thus the message you see) by the system itself.

You will need to do this procedure from a Live-CD.

1
  • 7
    It cannot be unmounted, but it can be remounted read-only if there are no open files in write mode open.
    – Michael
    Mar 27, 2013 at 10:56
4

This typically happens when you have deleted, but still open files on your root filesystem. Some process is keeping a reference to the file and it can't be freed on disk until it is closed. Updating system libraries is one way to create such a situation.

Since there is no way how a filesystem in a clean state can contain a deleted but unfreed file, the kernel will refuse to remount the filesystem read only.

Restarting those processes helps. It lets the kernel free the files and the filesystem can be cleanly unmounted.

Another option is to force a readonly remount using the SysRq key:

echo u > /proc/sysrq-trigger

This is safe, but will cause kernel/fsck to complain on the next mount/run.

1
  • This worked in Ubuntu 20.04, thanks!!
    – xCovelus
    Dec 16, 2021 at 17:29
0

You could follow this post: https://unix.stackexchange.com/questions/42015/mount-is-busy-when-trying-to-mount-as-read-only-so-that-i-can-run-zerofree

In my case I did not want to worry with killing processes. Since I had two virtual machines in my VirtualBoX I mounted the disk of the VM i needed to compress on my other VM and zerofree it from that machine.

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.