Saturday, October 26, 2013

Workaround for USB Drive is Mounted Again After "Safely Remove" on Debian Wheezy

Some of you might experience this issue whereby after performing "Safely Remove" on a USB disk, it gets mounted again after a few seconds and you have to perform "Safely Remove" once again. Some people found that only nvidia chipsets are affected by this issue.

The details of this issue can be found here:


My laptop which is affected by this issue is an Acer Aspire 4530.

Acer Aspire 4530

00:00.0 RAM memory: NVIDIA Corporation MCP78S [GeForce 8200] Memory Controller (rev a2)
00:01.0 ISA bridge: NVIDIA Corporation Device 075e (rev a2)
00:01.1 SMBus: NVIDIA Corporation MCP78S [GeForce 8200] SMBus (rev a1)
00:01.3 Co-processor: NVIDIA Corporation MCP78S [GeForce 8200] Co-Processor (rev a2)
00:01.4 RAM memory: NVIDIA Corporation MCP78S [GeForce 8200] Memory Controller (rev a1)
00:02.0 USB controller: NVIDIA Corporation MCP78S [GeForce 8200] OHCI USB 1.1 Controller (rev a1)
00:02.1 USB controller: NVIDIA Corporation MCP78S [GeForce 8200] EHCI USB 2.0 Controller (rev a1)
00:04.0 USB controller: NVIDIA Corporation MCP78S [GeForce 8200] OHCI USB 1.1 Controller (rev a1)
00:04.1 USB controller: NVIDIA Corporation MCP78S [GeForce 8200] EHCI USB 2.0 Controller (rev a1)
00:07.0 Audio device: NVIDIA Corporation MCP72XE/MCP72P/MCP78U/MCP78S High Definition Audio (rev a1)
00:08.0 PCI bridge: NVIDIA Corporation MCP78S [GeForce 8200] PCI Bridge (rev a1)
00:09.0 SATA controller: NVIDIA Corporation Device 0ad5 (rev a2)
00:0b.0 PCI bridge: NVIDIA Corporation MCP78S [GeForce 8200] PCI Express Bridge (rev a1)
00:13.0 PCI bridge: NVIDIA Corporation MCP78S [GeForce 8200] PCI Bridge (rev a1)
00:14.0 PCI bridge: NVIDIA Corporation MCP78S [GeForce 8200] PCI Bridge (rev a1)
00:15.0 PCI bridge: NVIDIA Corporation MCP78S [GeForce 8200] PCI Bridge (rev a1)
00:18.0 Host bridge: Advanced Micro Devices [AMD] Family 11h Processor HyperTransport Configuration (rev 40)
00:18.1 Host bridge: Advanced Micro Devices [AMD] Family 11h Processor Address Map
00:18.2 Host bridge: Advanced Micro Devices [AMD] Family 11h Processor DRAM Controller
00:18.3 Host bridge: Advanced Micro Devices [AMD] Family 11h Processor Miscellaneous Control
00:18.4 Host bridge: Advanced Micro Devices [AMD] Family 11h Processor Link Control
02:00.0 VGA compatible controller: NVIDIA Corporation C77 [GeForce 9100M G] (rev a2)
08:00.0 Ethernet controller: Broadcom Corporation NetXtreme BCM5764M Gigabit Ethernet PCIe (rev 10)
0b:00.0 Network controller: Atheros Communications Inc. AR928X Wireless Network Adapter (PCI-Express) (rev 01)

If my memory serves my right, this issue did not exist on the original Debian Squeeze release 6.0. However, it is introduced in one of Debian Squeeze release update 6.0.X. Until Debian Wheezy release 7.0, this issue has not been fixed yet.

After dissecting changes on Debian Squeeze release updates and a lot of trial and error, I managed to find that this issue occurs after the following linux kernel commit.

http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=253e05724f9230910344357b1142ad8642ff9f5a

So, it works like this. When "Safely Remove" is clicked, GNOME (or some other window manager) calls udisks. Udisks will then check whether the running linux kernel has "remove" attribute which was introduced on the linux kernel commit above. If "remove" attribute is found, udisks will then poke it to tell linux kernel to perform safely remove on the USB disk.

My conclusion is this issue might be caused by a bug in the linux kernel. However, since I am no expert, I am unable to debug or provide a fix for this. I can only think of some workarounds for this issue until it is fixed.
  1. Revert the above linux kernel commit and recompile the kernel, or
  2. Patch udisks so that it does not poke the "remove" attribute.
Since recompiling kernel will take a lot of time, I ended up choosing to patch udisks instead.

I have moved on to Jessie. You can get the patched udisks here (i386 build + source): Dropbox

2 comments:

  1. Thanks for the work around. I have not experience this issue yet. If it does happen, I know where to go.

    ReplyDelete
    Replies
    1. If you don't use laptop with nvidia chipsets, you might never encounter this issue.

      Delete