Sunday, November 20, 2011

Device left behind after umount in Nautilus

Whenever I mount an iso via the loop device an entry representing the virtual drive shows up in Nautilus in Ubuntu. It has been like this for ages and it is correct. However in the Lucid cycle (10.04) I noticed that the drive icon is not always removed after unmounting the iso file.

This turned out to be a kernel issue: the loopback driver failes to emit the change uevent when auto releasing the device. Finally a patch made its way into the -mm branch but the behavior under the current Ubuntu release (11.10) is the same.

I am using a workaround which is emitting a change event manually after umount:

udevadm trigger --action=change --subsystem-match=block --sysname-match="$DEVICE_NAME"

I created a script which sets the $DEVICE_NAME based on the mount point. For my own convenience I packaged it into a deb file that can be installed under Ubuntu. Basically it's just two scripts: mount.loop and umount.loop

The deb can be downloaded from my ppa for Lucid.

Update: The fix made it into Oneiric as an update. Starting from kernel version 3.0.0-16.28 the workaround is not needed.

No comments:

Post a Comment