Linux – why can’t I umount /home

filesystemsgpartedlinuxumountvirtualbox

I'm trying to create a new partition on my Linux system, my intent is to take a small amount of my /home filesystem and change the type for experimentation. I'm using OpenSuse 12.1 in a virtual box.

gparted shows I have the following partitions:

Partition   File System MountPoint   Size          Used
********************************************************
/dev/sda1   linux-swap               744.00MiB       ---
/dev/sda2   ext4        /             10.35GiB    5.16GiB
unallocated                            1.00MiB       ---
/dev/sda3   ext4        /home         28.92GiB   11.51GiB
unallocated                            1.00MiB       ---

I'm logged in a root and my cwd is /, when I try umount /home I get:

umount: /home: device is busy.
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1))

When I run fuser -m /dev/sda3 I get a good sized list:
1 303 311 594 649 672 692 696 700 738 754 786...

running ps -e I can find these processes:

PID    TTY      TIME  CMD
1      ?    00:00:00  systemd
303    ?    00:00:00  systemd-stdout-
311    ?    00:00:00  udevd
594    ?    00:00:00  systemd-logind
649    ?    00:00:00  systemd-logind
672    ?    00:00:00  avahi-daemon
692    ?    00:00:00  acpid
700    ?    00:00:00  haveged
...

What I'm trying to figure out is how to proceed. I guess I can "force" the umount, but that seems like a bad idea. I can kill all of these processes, then do the umount, but I'm not sure that will work.

What other options do I have? How should I unmount the /home drive?

Best Answer

You should boot into a rescue session using a Linux CD, or you can drop to a lower runlevel using init. It is not a good idea to unmount your $HOME while logged in.

You might also be able to do this if you log in as root (actually log in, not su or sudo). That way the /home partition is not needed and you will be able to unmount it. You will still have to make sure no one is accessing it (see next paragraph) and unmount it manually.

Finally, a useful tool is lsof /dev/sda3 which will list the processes currently accessing that partition. To kill all processes listed by lsof (careful, this may crash your system, depending on the process, but if this happens you should be OK after a reboot), do this:

kill `lsof /dev/sda3 | awk '{print $2}'`
Related Question