2

I have a 2TB external drive with an NTFS partition. If I connect it to my main desktop, it mounts fine in Dolphin - I just click the drive when it appears on the sidebar, and I can see all the files, navigate, work with them etc. This computer is running Kubuntu 22.04, and it might be useful to know that it was the first computer I used this drive with.

When I connect the drive to a laptop, running a newly-installed Kubuntu 23.10, the drive appears, but clicking it on Dolphin's sidebar gives me an error message:

Error mounting /dev/sdb1: GDBus.Error:org.freedesktop.UDisks2.Error.Failed: Error mounting /dev/sdb1 at /media/root/TOSHIBA EXT: wrong fs type, bad option, bad superblock on /dev/sdb1, missing codepage or helper program, or other error

I was scared of disk/partition failure, but it's a brand new external drive; I took it back to the desktop machine and it operated just fine.

I then took it back to the laptop and tried mounting it with udiskctl, it not only didn't work but gave me the same error message - so I know Dolphin is probably using it as a backend, which means it's not a KDE problem but a udisks or permissions problem.

Finally I used a simple mount command. Terminal told me I had to be root. I then ran

sudo mount /dev/sdb1 /media/mountpoint

and it worked fine! I could even operate the files inside without any complaints regarding permissions.

I tested the external HD in another laptop, also running 23.10 (although this is an upgraded system). I got the same error, and the same solution applied.

I searched Google and AskUbuntu for an answer. The closest scenario I found gave me some ideas; I tried:

  • deleting /media/"username" so the system could create it anew;
  • chowning /media/"username" to username:username and later username:root; and
  • chowning /media to username:username and later username:root.

Nothing worked, and I returned /media to full root ownership, deleting the username's folder inside (it has since been recreated by a new attempt to mount the drive, which failed as per the error message above. It's always the same error message).

Notice that when I mounted it with 'sudo mount' Dolphin turns the drive's sidebar entry into the mounted kind, where I can see its free space, etc. - and it allows me to unmount the drive graphically, but it asks for my password. Even though it wouldn't be optimal behaviour, I don't understand why it couldn't ask for my password to mount the damn thing in the first place...

I am aware I could add the partition's UUID to fstab in both laptops, but this wouldn't really solve the issue - this is not supposed to happen! Besides, I'm tidying up the first laptop for a person who's not going to mess with the terminal in case she's unable to plug in e.g. a friend's external drive.

I should also add that fat32 pen drives don't present a similar issue, they mount just fine.

Thanks in advance!

  • 1
    You cannot chown NTFS as that is not supported. You only get ownership & permission by mount command. If default mount does not work, is it hibernated by Windows? And Windows fast startup sets hibernation flag. And may be reset with updates. That Linux NTFS driver will not mount read/write is to prevent loss of data when Windows restores hibernation. https://askubuntu.com/questions/843153/unable-to-mount-windows-10-partition-it-is-in-an-unsafe-state & https://askubuntu.com/questions/145902/unable-to-mount-windows-ntfs-filesystem-due-to-hibernation – oldfred Jan 23 '24 at 17:21
  • switch from wayland session to x11 please. Error mounting /dev/sdb1 at /media/root/TOSHIBA EXT this part is strange why /media/root? – nobody Jan 23 '24 at 17:28
  • Hi @oldfred thanks for the comment! (1) I was not chowning the drive, I was trying to chown the directory it was supposed to be mounted into before the mounting happened, just to see if that was blocking the mounting. (2) It's not hibernated by Windows, it's an external HD which has never touched a Windows machine. Plus it's mounted normally in my 22.04 system, and manually in the laptops, so mounting is not an issue, just that I have to sudo it in the terminal – Peterson Silva Jan 23 '24 at 17:35
  • Hi @nobody thanks for the comment! About /media/root, this was the error message from the udiskctl command when I ran it with sudo in the terminal (it wouldn't let me run it as the user). But in Dolphin it's the same message, only it really tries to mount it in the right place (/media/username). I'll try X, especially because my 22.04 system is using X, this might be the problem!! – Peterson Silva Jan 23 '24 at 17:38
  • Erm, this is awkward, but hey @nobody, the X11 session... Does not work? I can't login into it. It's a hell of a thing to declare but we're in an age where Wayland works and X11 doesn't LOL (It's an old Celeron with HD integrated graphics) – Peterson Silva Jan 23 '24 at 17:52
  • So I can't test the theory but I'm assuming now it's a Wayland + udisks bug. But if that's the case it should be a big deal, why can't I find anything about it elsewhere in the internet? I'm still hoping there's some configuration I can switch to fix it, but if not I'll file a bug report – Peterson Silva Jan 23 '24 at 17:54
  • Ok, I WAS WRONG. I was able to log into an X11 session in the second laptop, which is running 23.10. Still had the SAME failure message to mount it via GUI (Dolphin). So it's really a udisks problem, unrelated to Wayland – Peterson Silva Jan 23 '24 at 17:59
  • 1
    You typically do not want sudo to use root in many cases. I think it is sudo -H to get your user id. But why NTFS if not using with Windows? Better to use a Linux format like ext4, also typically faster. You have to have Windows to run chkdsk & defrag periodically on NTFS as you cannot fix NTFS from Linux., – oldfred Jan 23 '24 at 18:27
  • @oldfred this is a shared external HD with files that are larger than 4GB (so it can't be fat). It has to be accessible from anywhere, even if I personally don't use Windows I might wanna take it to a friend's house, or access it at work, etc. If you know a linux fs that doesn't care about who owns what file and opens in Windows I'm all ears. – Peterson Silva Jan 23 '24 at 18:39
  • Plus this particular HD is beside the point. The layperson that will be using the laptop might want to open other NTFS drives from other people in the future. – Peterson Silva Jan 23 '24 at 18:40
  • Something in journal? – nobody Jan 23 '24 at 18:52
  • I found the issue! Will write an answer seeing as it might be useful for others. Thank you oldfred and nobody for the effort to troubleshoot this with me =D – Peterson Silva Jan 23 '24 at 19:06

1 Answers1

4

I asked this question in another forum (in a different language) and over there they put me in the right path. I'm going to describe the path in question so that other people facing something similar may know whether this solution would work for them or not.

Apparently in 2021 there was a whole thing that required a change to the file /etc/udisks2/mount_options.conf (which by default I don't think exists in a newly-installed Ubuntu; I had to create it). It should be populated with:

[defaults]
ntfs_defaults=uid=$UID,gid=$GID

This (and variations, such as a backslash before the $s and a "ntfs:" opening the line) did not work.

But wait: I realised this tip was from 2021. My 22.04 Dolphin was mounting the HD just fine; it should also be affected by the bug but isn't. How? Then I found a complaint by someone somewhere in 2021 or 2022 that Ubuntu was still using ntfs-3g despite the availability of ntfs3 in its kernel. This led me to search for ways to force the 23.10 udisks to use ntfs-3g, which I presumed (but never found out if it was actually the case) my 22.04 machine was doing. Apparently I only had to remove the ntfs3 module from the kernel so that the alternative (ntfs-3g) would be used.

But I never got to do any of that, as I found something else.

Somebody in the udisks github was complaining that ntfs3, unlike ntfs-3g, refuses to mount any partition flagged as damaged, even if it obviously isn't (seeing as ntfs-3g was able to handle it normally). The solution was simple: running

ntfsfix -d

on the affected partition (as root / with sudo)

I did and it worked! Now both laptops running Kubuntu 23.10 mount the HD in Dolphin perfectly.

I didn't check if KDE's Partition Manager can do it, but if anyone's suffering from this in Ubuntu/Gnome, I know Gnome Disks has a menu option to repair a partition, which in the case of ntfs ones I guess it does the same thing. It worked for this person here in AskUbuntu, a post that I missed because it was about a pen drive.

Here's what I take away from this:

  1. I didn't check the filesystem because it was working so well in another linux machine, but I guess one shouldn't count on that. The partition might still be marked as damaged and ntfs3 will not mount it... Or, well, udisks won't, as the mount command worked fine.
  2. I was also only confident enough to use ntfsfix because I knew the partition was good, so I didn't feel there was any serious risk of data loss.
  3. Hence this is still kind of an issue; this laptop will be used by a layperson and if they try to access an actually damaged ntfs filesystem (say, a friend's or a coworker's) I will NOT tell them to try to fix it to mount it. But I guess that's for the best...
  • 1
    I have not heard of ntfs3 and 22.04 synaptic only shows ntfs-3g. But this does mention ntfs3 cat /etc/udisks2/mount_options.conf.example which are examples of lines to add to file:///etc/udisks2/udisks2.conf – oldfred Jan 23 '24 at 20:19
  • 1
    https://wiki.archlinux.org/title/NTFS. – nobody Jan 23 '24 at 21:01
  • 1
    I had the exact same issue and this solved it. Thanks for looking that much into it! – YumTum Jan 25 '24 at 20:41
  • For the future, I need to regularly remove the device before unplugging it or avoid situations where the system needs to be forced down. – ChrisoLosoph Mar 22 '24 at 03:07