Automatic mounting of read only ntfs partition on usb device fails

Bug #435192 reported by Tero miettinen
40
This bug affects 4 people
Affects Status Importance Assigned to Milestone
OEM Priority Project
Fix Released
Medium
Unassigned
Precise
Fix Released
Medium
Ming Lei
udisks
Confirmed
Medium
ntfs-3g (Debian)
Fix Released
Unknown
ntfs-3g (Ubuntu)
Fix Released
Medium
Martin Pitt
Precise
Fix Released
Undecided
Unassigned
Quantal
Fix Released
Medium
Martin Pitt
udisks (Ubuntu)
Invalid
Medium
Ming Lei
Precise
Won't Fix
Medium
Unassigned
Quantal
Invalid
Medium
Ming Lei
udisks2 (Ubuntu)
Won't Fix
Undecided
Unassigned
Quantal
Won't Fix
Undecided
Unassigned

Bug Description

[Impact]
OEM customers raise this issue, thinking that the error message can be misleading to inexperienced users.

[Fix]
See attachment and merge proposals.

[Test Case]
Format a SD card with NTFS, lock the SD card as write-protected, insert the card into the SD card slot. If the card is mounted as read-only, the bug is fixed.

[Regression Potential]
To ensure the patch does not cause mounting to fail completely or mounting of writable devices as readonly, verification should include both writable and readonly NTFS partitions.

[Regression testing]
The udisks2 test suite covers both read-only and writable NTFS partitions:
http://cgit.freedesktop.org/udisks/tree/src/tests/integration-test

You can download it and run it against the installed system binaries; it will use scsi-debug for a virtual hard disk/CD-ROM, and not touch any of your real partitions.

With the current versions in the archive, you get:

======================================================================
ERROR: test_ntfs (__main__.FS)
fs: NTFS
----------------------------------------------------------------------
Traceback (most recent call last):
  File "src/tests/integration-test", line 636, in test_ntfs
    self._do_fs_check('ntfs')
  File "src/tests/integration-test", line 758, in _do_fs_check
    self._do_udisks_check(type)
  File "src/tests/integration-test", line 931, in _do_udisks_check
    mount_path = cd_fs.call_mount_sync(no_options, None)
  File "/usr/lib/python3/dist-packages/gi/types.py", line 47, in function
    return info.invoke(*args, **kwargs)
gi._glib.GError: GDBus.Error:org.freedesktop.UDisks2.Error.Failed: Error
mounting /dev/sr1 at /media/root/2FB591B374B26011: Command-line `mount -t
"ntfs" -o "uhelper=udisks2,nodev,nosuid,uid=0,gid=0,dmask=0077,fmask=0177"
"/dev/sr1" "/media/root/2FB591B374B26011"' exited with non-zero exit status 18:
Error opening '/dev/sr1': Read-only file system
Failed to mount '/dev/sr1': Read-only file system

With the proposed version, the test succeeds.

If you prefer, you can also run the steps manually; described in http://bugs.debian.org/686914

[Original Report]
Mounting of read only NTFS filesystem gives a following error popup:
Cannot mount volume.
Unable to mount the volume '<Volume name>'.
Details:
Error opening '/dev/sdb2': Read-only file system
Failed to mount '/dev/sdb2': Read-only file system

I believe this should be mounted as read-only instead of an error message.

Mounting by hand with the "-o ro" argument works as expected.
---
Architecture: i386
DistroRelease: Ubuntu 10.04
NonfreeKernelModules: fglrx
Package: mountall 2.15
PackageArchitecture: i386
ProcEnviron:
 PATH=(custom, user)
 LANG=en_US.utf8
 SHELL=/bin/bash
ProcVersionSignature: Ubuntu 2.6.32-24.39-generic 2.6.32.15+drm33.5
Tags: lucid
Uname: Linux 2.6.32-24-generic i686
UserGroups: adm admin audio cdrom dialout dip fax fuse lpadmin netdev plugdev sambashare tape video

Related branches

Revision history for this message
Fabio Marconi (fabiomarconi) wrote :

Hello Crazyguy

is this issue present with the latest lucid packages?

Thanks

Changed in ubuntu:
status: New → Incomplete
status: Incomplete → Invalid
status: Invalid → Incomplete
Revision history for this message
Tero miettinen (tero-miettinen) wrote :

I tested this with a USB-stick with a lock switch, a bit different error message but still the same end result.

Error mounting: mount exited with exit code 18: Error opening '/dev/sdb1': Read-only file system
Failed to mount '/dev/sdb1': Read-only file system

Steps to reproduce:
1. Create NTFS on a USB stick with write lock off
2. Remove the stick and switch the lock on
3. Insert the stick back to USB port
4. Result is the error message above

Revision history for this message
Fabio Marconi (fabiomarconi) wrote :

Hello Crazyguy

can you run in a terminal
apport-collect -p mountall 435192

Fabio

affects: ubuntu → mountall (Ubuntu)
Revision history for this message
Tero miettinen (tero-miettinen) wrote : Dependencies.txt

apport information

tags: added: apport-collected
description: updated
Revision history for this message
Fabio Marconi (fabiomarconi) wrote :

Thanks for reporting this bug and any supporting documentation. Since this bug has enough information provided for a developer to begin work, I'm going to mark it as confirmed and let them handle it from here. Thanks for taking the time to make Ubuntu better!

Changed in mountall (Ubuntu):
status: Incomplete → Confirmed
tags: added: lucid
Revision history for this message
Nara Huang (narahuang) wrote :

I got same error in Precise, system tries to mount write-protect SDHC card with NTFS partition.
But if I mount it in read-only mode manually, it can be mounted.

tags: added: blocks-hwcert-enablement
Steve Langasek (vorlon)
affects: mountall (Ubuntu) → udisks2 (Ubuntu)
Kent Lin (kent-jclin)
Changed in oem-priority:
importance: Undecided → Medium
Ming Lei (tom-leiming)
Changed in udisks2 (Ubuntu):
assignee: nobody → Ming Lei (tom-leiming)
Revision history for this message
Ming Lei (tom-leiming) wrote :

It is a bug in udisks.

I have tested the udisks image in below link with integrating the fix.

      http://kernel.ubuntu.com/~ming/bugs/435192/

Anyone could verify the fix?

BTW: the patch is also in the above link.

Revision history for this message
Nara Huang (narahuang) wrote :

I just tried it on a SDXC card with NTFS partition which can reproduce this problem, the udisks_1.0.4-6_amd64.deb fixes this issue, thanks a lot for that!

tags: added: patch
Changed in oem-priority:
status: New → In Progress
Revision history for this message
Anthony Wong (anthonywong) wrote :

I have proposed a merge request using Ming's patch in #7. We need to fix udisks since a fix for Precise's udisks is required for oem projects.

Changed in udisks (Ubuntu):
assignee: nobody → Ming Lei (tom-leiming)
Changed in udisks2 (Ubuntu):
assignee: Ming Lei (tom-leiming) → nobody
Changed in udisks (Ubuntu):
importance: Undecided → Medium
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in udisks (Ubuntu):
status: New → Confirmed
Revision history for this message
In , Anthony Wong (anthonywong) wrote :

Created attachment 65273
patch

Mounting of read only NTFS filesystem gives a following error popup:
Cannot mount volume.
Unable to mount the volume '<Volume name>'.
Details:
Error opening '/dev/sdb2': Read-only file system
Failed to mount '/dev/sdb2': Read-only file system

Mounting by hand with the "-o ro" argument works as expected.

This bug can be duplicated by mounting a write-protected (aka locked) SD card with NTFS partition.

Please also see https://bugs.launchpad.net/ubuntu/+source/udisks/+bug/435192

A patch to fix udisks is attached, which is written by Ming Lei <email address hidden>

Changed in udisks:
importance: Unknown → Medium
status: Unknown → Confirmed
Bryce Harrington (bryce)
Changed in udisks (Ubuntu Precise):
status: New → Confirmed
importance: Undecided → Medium
Changed in udisks2 (Ubuntu Precise):
status: New → Confirmed
description: updated
tags: added: rls-q-incoming
Martin Pitt (pitti)
no longer affects: udisks2 (Ubuntu Precise)
Changed in udisks (Ubuntu Quantal):
status: Confirmed → Invalid
Revision history for this message
James M. Leddy (jm-leddy) wrote :

Hi Martin,

Why is this invalid for Quantal?

description: updated
Ming Lei (tom-leiming)
description: updated
Revision history for this message
Martin Pitt (pitti) wrote :

I'd call this a bug in ntfs-3g -- it should automatically default to mounting the device read-only if it is read-only, just as mount does for any other file system.

Unfortunately ntfs-3g does not have a bug tracker. I'll ask the Debian maintainer about how to submit bugs to ntfs3-g, but adding a distro task for now.

I don't really like that patch. udisks should not silently modify explicitly given options, i. e. turn "rw" into "ro". I could live with a workaround that appends "ro" if "rw" is not given, and the file system is NTFS, once the bug is reported upstream. I asked the primary upstream maintainer whether he'd be okay with this.

@James: the udisks task is invalid for quantal because the "udisks" source is the obsolete 1.x version. We are using udisks2 now, which has its own task with quantal only. However, when this gets fixed properly in ntfs-3g, it will work for any udisks version.

Changed in ntfs-3g (Ubuntu Quantal):
importance: Undecided → Medium
status: New → Triaged
Changed in ntfs-3g (Ubuntu Precise):
status: New → Triaged
Revision history for this message
Ming Lei (tom-leiming) wrote : Re: [Bug 435192] Re: Automatic mounting of read only ntfs partition on usb device fails

On Thu, Sep 6, 2012 at 6:28 PM, Martin Pitt <email address hidden> wrote:
> I'd call this a bug in ntfs-3g -- it should automatically default to
> mounting the device read-only if it is read-only, just as mount does for
> any other file system.

IMO, udisks has already seen it is a read-only block device, why not
pass 'ro' to mount?

Thanks,
--
Ming Lei

Revision history for this message
Martin Pitt (pitti) wrote :

Upstream rejected it because it's just a workaround. Also, doing this workaround in udisks would still cause other usages of "mount" (fstab, manual invocation, etc.) to fail for the same reason.

We can apply a downstream patch to Debian/Ubuntu, but the bug should be reported to ntfs-3g as well.

Revision history for this message
Martin Pitt (pitti) wrote :

Reported ntfs-3g bug to Debian, as I can't for the live of it find an upstream bug tracker.

I'll add the -ro workaround to Debian, but not the part that modifies explicit mount options. Thanks!

Changed in udisks2 (Ubuntu Quantal):
assignee: nobody → Martin Pitt (pitti)
status: Confirmed → In Progress
Revision history for this message
Jean-Pierre (jean-pierre-andre) wrote :

Please test the attached patch

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "Patch for mounting a read-only device" of this bug report has been identified as being a patch. The ubuntu-reviewers team has been subscribed to the bug report so that they can review the patch. In the event that this is in fact not a patch you can resolve this situation by removing the tag 'patch' from the bug report and editing the attachment so that it is not flagged as a patch. Additionally, if you are member of the ubuntu-reviewers team please also unsubscribe the team from this bug report.

[This is an automated message performed by a Launchpad user owned by Brian Murray. Please contact him regarding any issues with the action taken in this bug report.]

Changed in ntfs-3g (Debian):
status: Unknown → New
Revision history for this message
Martin Pitt (pitti) wrote :

Thanks Jasper! I'll test this first thing on Monday.

So with that I'd call this 'wontfix' in udisks, let's fix it properly.

Changed in ntfs-3g (Ubuntu Quantal):
status: Triaged → In Progress
Changed in udisks (Ubuntu Precise):
status: Confirmed → Won't Fix
Changed in udisks2 (Ubuntu Quantal):
assignee: Martin Pitt (pitti) → nobody
status: In Progress → Won't Fix
Changed in udisks2 (Ubuntu):
status: In Progress → Won't Fix
Changed in ntfs-3g (Ubuntu Quantal):
assignee: nobody → Martin Pitt (pitti)
Changed in udisks2 (Ubuntu):
assignee: Martin Pitt (pitti) → nobody
Martin Pitt (pitti)
description: updated
Martin Pitt (pitti)
description: updated
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ntfs-3g - 1:2012.1.15AR.5-4ubuntu3

---------------
ntfs-3g (1:2012.1.15AR.5-4ubuntu3) quantal; urgency=low

  * Add readonly-devices.patch: Mount read-only devices as read-only instead
    of failing. Thanks to Jean Pierre Andre for the patch! (LP: #435192)
 -- Martin Pitt <email address hidden> Mon, 10 Sep 2012 07:37:38 +0200

Changed in ntfs-3g (Ubuntu Quantal):
status: In Progress → Fix Released
Revision history for this message
Martin Pitt (pitti) wrote :

I also uploaded the fix to the precise-proposed queue, where the SRU team will review it.

Changed in ntfs-3g (Ubuntu Precise):
status: Triaged → In Progress
Revision history for this message
Adam Conrad (adconrad) wrote : Please test proposed package

Hello Tero, or anyone else affected,

Accepted ntfs-3g into precise-proposed. The package will build now and be available at http://launchpad.net/ubuntu/+source/ntfs-3g/1:2012.1.15AR.1-1ubuntu1.2 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please change the bug tag from verification-needed to verification-done. If it does not, change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in ntfs-3g (Ubuntu Precise):
status: In Progress → Fix Committed
tags: added: verification-needed
Revision history for this message
James M. Leddy (jm-leddy) wrote :

This is great news. Kent, please make sure the OEM is happy with this fix in -proposed. If it works, mark sru-verified as directed in comment #22.

Changed in oem-priority:
status: In Progress → Fix Committed
Revision history for this message
James M. Leddy (jm-leddy) wrote :

I'm marking incomplete until someone that has an oneiric install handy and access to a ntfs filesystem can verify and mark verification-done. For more information about the stable release update processs, please see : https://wiki.ubuntu.com/StableReleaseUpdates

Changed in oem-priority:
status: Fix Committed → Incomplete
Revision history for this message
James M. Leddy (jm-leddy) wrote :

s/oneiric/precise/ in my previous comment :)

Revision history for this message
Nara Huang (narahuang) wrote :

Verified ntfs-3g 1:2012.1.15AR.1-1ubuntu1.2 fix this issue.

tags: added: verification-done
Colin Watson (cjwatson)
tags: removed: rls-q-incoming verification-needed
Revision history for this message
Colin Watson (cjwatson) wrote : Update Released

The verification of this Stable Release Update has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regresssions.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ntfs-3g - 1:2012.1.15AR.1-1ubuntu1.2

---------------
ntfs-3g (1:2012.1.15AR.1-1ubuntu1.2) precise-proposed; urgency=low

  * Add readonly-devices.patch: Mount read-only devices as read-only instead
    of failing. Thanks to Jean Pierre Andre for the patch! (LP: #435192)

ntfs-3g (1:2012.1.15AR.1-1ubuntu1.1) precise-proposed; urgency=low

  * ntfs-3g-junction-point-fix.patch: Return the correct type (DT_LINK) for
    NTFS Junction points, in readdir(). (LP: #997391) Junction points are the
    NTFS equivalent of symlinks and should be listed as such. Fixes an
    infinite loop in baobab when scanning a Windows 7 root file system.
 -- Martin Pitt <email address hidden> Tue, 11 Sep 2012 05:49:00 +0200

Changed in ntfs-3g (Ubuntu Precise):
status: Fix Committed → Fix Released
Changed in ntfs-3g (Debian):
status: New → Fix Released
Changed in oem-priority:
status: Incomplete → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.