1

I have taken a backup of a large directory onto a mounted external disk, using rsync -av. The command terminated after sometime, but after that I am unable to unmount the disk, when I try to unmount I get the error disk is busy, try after some time.

Is the data been cached up and the copying is still in progress? How can I know when the copying is finally done and I can unmount?

Or, is there a better way to take a backup of a large directory?

(This is on ubuntu 20.04)

R71
  • 131

1 Answers1

0

Maybe you can't unmount the device because rsync does not use direct I/O (O_DIRECT) while writing. So it's not:

rsync > device

Instead it is:

rsync > RAM > device

And after rsync has finished its work, the Linux Kernels (sometimes) needs time to copy the page cache to the device and as long this isn't finished, you probably can not unmount it.

You have some options to solve this:

  1. Mount your device with direct i/o, but this will probably cause a bad performance
  2. Use sync before umount
  3. Use umount -l which removes the mount path from the filesystem, but it is still present for the Kernel to finish its work and after this is done, the mount is finally removed, so why this is called a lazy unmount. But this is considered as bad practice.
mgutt
  • 150