I was recently tinkering with a Linux VM, where I was looking to increase the size of the /home file-system, as I was running out of disk space :-(
Long story short, I was hoping that I could simply unmount the /home file-system, increase the size of the underlying Logical Volume ( /dev/mapper/vg_db2cloud-lv_home ) and then remount /home.
However, when I tried to unmount /home : -
umount /home/
I saw this: -
umount: /home: device is busy.
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1))
even though I was running as root.
I knew that DB2 was the only thing running, so stopped my instances: -
su - db2inst1
db2stop
09/20/2016 14:29:10 0 0 SQL1064N DB2STOP processing was successful.
SQL1064N DB2STOP processing was successful.
logout
su - db2inst3
db2stop
09/20/2016 14:29:15 0 0 SQL1064N DB2STOP processing was successful.
SQL1064N DB2STOP processing was successful.
logout
and then retried: -
umount /home/
umount: /home: device is busy.
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1))
This time I actually read the message, and checked the currently open files: -
lsof /home
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
db2dasrrm 49948 dasusr1 cwd DIR 253,2 4096 49 /home/dasusr1/das/tmp
db2dasrrm 49948 dasusr1 txt REG 253,2 297481 42 /home/dasusr1/das/adm/db2dasrrm
db2dasrrm 49948 dasusr1 mem REG 253,2 62088 71 /home/dasusr1/das/tmp/dasMemMappedFile1
db2dasrrm 49948 dasusr1 5uW REG 253,2 0 70 /home/dasusr1/das/tmp/dasrrmpid
db2dasrrm 49948 dasusr1 6u REG 253,2 62088 71 /home/dasusr1/das/tmp/dasMemMappedFile1
which led me to the DB2 Administration Service (DAS), which I then stopped: -
su - dasusr1
db2admin stop
SQL4407W The DB2 Administration Server was stopped successfully.
logout
and then re-checked: -
lsof /home
which now returned NOTHING :-)
I was then able to unmount /home.
For the record, in the end, it was easier to simply rebuild the VM from scratch, with a larger /home directory, rather than "mess" about with fdisk and Volume Groups, but that's not the point of this article :-)