Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to run zerofree on Ubuntu 11.04 so that I can compact the VirtualBox vdi image using:

VBoxManage modifyhd Ubuntu.vdi --compact

In order to run zerofree the disk image has be mounted as read-only. I'm following these instructions which says to use this to remount as read-only from the recovery mode (Drop to root shell prompt):

mount -n -o remount,ro -t ext2 /dev/sda1 /

But when I do this I get the error:

mount: / is busy

Any ideas on how to do this?

Follow up: Following Jari's answer and this post by running these commands resolves the issue.

service rsyslog stop
service network-manager stop
killall dhclient
share|improve this question
The man page for zerofree suggests running telinit 1 and that solved the problem for me. – Alex Ryan Dec 25 '14 at 8:37
up vote 11 down vote accepted

Some processes are keeping files open for writing. These could be, for example, programs that write logs, like rsyslogd, networking tools, like dhclientor something else. Shutting these down one by one and trying the remount might work.

You can find processes that use certain files by using the program fuser. For example, fuser -v -m / will return a list of processes. However, I am not sure if it is one of these which keeps the file system busy.

share|improve this answer

You can only remount the filesystem read-only if there is no process that has a file open for writing. Run lsof / to see what processes have files open on the root filesystem. Files open for writing will be indicated in the FD column. You can filter these with

lsof / | awk '$4 ~ /[0-9].*w/'

To filter the process IDs automatically, parse the output of lsof -F pa:

lsof -F pa /home | awk '/^p/ {pid = substr($0, 2)} /^a.*w/ {print pid}'
share|improve this answer
Tried with this solution, still busy, might becoz some resource can't show with this way. After stop some running services, can remount the fs as read only. – Sam Liao May 20 '15 at 8:43

If you use systemd then disk writes are stopped by stopping systemd-journald.

# systemctl stop systemd-journald.socket
# systemctl stop systemd-journald.service
# mount -o ro,remount /
share|improve this answer

I assume you try to run the mount command in the VM. Anyway you probably have a different root partition than the author of the forum post.


mount -o ro,remount /

Which does not depend on the fs or mount option. If this does not work you can also try to determine your root fs with grep " / " /proc/mounts or cat /proc/cmdline. If your root filesystem is for example /dev/mapper/system-rootfs you can use:

mount -o ro,remount /dev/mapper/system-rootfs /
share|improve this answer

There are sometimes so many processes keeping the mount busy, that it might be easier to simply reboot with the mount read-only.

Change the entry for the root filesystem in /etc/fstab, for example:

/dev/sda1 / ext2 relatime,rw,errors=remount-ro 0 1


/dev/sda1 / ext2 noatime,ro 0 1

On reboot, the filesystem will be mounted read-only, so you can run zerofree on it.

When you're finished, remount the filesystem read/write again (mount -o remount,rw /) and undo your changes to /etc/fstab.

Inspired by https://wiki.debian.org/ReadonlyRoot#Enable_readonly_root

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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