Mounting ntfs issue

Sometimes, when booting NixOS system goes down to emergency mode.
journalctl -xb reports

máj 24 21:37:14 nixos mount[981]: NTFS signature is missing.
máj 24 21:37:14 nixos mount[981]: Failed to mount ‘/dev/sda7’: Invalid argument
máj 24 21:37:14 nixos mount[981]: The device ‘/dev/sda7’ doesn’t seem to have a valid NTFS.
máj 24 21:37:14 nixos mount[981]: Maybe the wrong device is used? Or the whole disk instead of a
máj 24 21:37:14 nixos mount[981]: partition (e.g. /dev/sda, not /dev/sda1)? Or the , code=exited, status

Relevant part of the /etc/nixos/configuration.nix

boot.supportedFilesystems = [ “ntfs” ];
fileSystems.“/ppmm” = {
device = “/dev/sda7”;
fsType = “ntfs-3g”;
options = [ “rw” “uid=1000” ];
};

What is wrong?

shouldn’t fsType be ntfs3? also, can you mount it manually? like mount /dev/sda7 -t ntfs3 /ppmm

According NTFS - NixOS Wiki is

fsType = “ntfs-3g”;

When trying

mount /dev/sda7 /ppmm -t ntfs3

in emergency mode
mount: wrong fs type, bad option, bad superblock on /dev/sda7

Are you sure that /dev/sda7 is an NTFS partition? You can check this by running sudo fdisk -l and looking at its Type.

If yes, there might be something wrong with the parition itself and you can try using ntfsfix and see if that fixes it. You probably want to run sudo ntfsfix --no-action /dev/sda7 first to get more info without modifying anything, though.

If that doesn’t work, you can alternatively boot Windows, Windows PE or one of the Windows PE-based ISOs on a live USB/CD and run chkdsk on the partition.

@eljamm.

Good hint. I have checked partitions on my PC under win11 and Gentoo linux,
/dev/sda7 is NTFS formated partition. But Gentoo see /dev/sda disc as /dev/sdb.

And Nixos boot and mounts 7th partition sometimes as /dev/sda and sometimes as /dev/sdb. Why?

Gentoo’s fdisk -l looks like that

Disk /dev/nvme0n1: 465.76 GiB, 500107862016 bytes, 976773168 sectors
Disk model: CT500P5PSSD8
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 4FADB7C3-1AE4-4D56-BAF5-4527C8AD862F

Device Start End Sectors Size Type
/dev/nvme0n1p1 2048 485375 483328 236M EFI System
/dev/nvme0n1p2 485376 518143 32768 16M Microsoft reserved
/dev/nvme0n1p3 518144 311668735 311150592 148.4G Microsoft basic data
/dev/nvme0n1p4 311668736 312983551 1314816 642M Windows recovery environment
/dev/nvme0n1p5 312985600 508297215 195311616 93.1G Linux filesystem
/dev/nvme0n1p6 508297216 703608831 195311616 93.1G Linux filesystem
/dev/nvme0n1p7 703608832 976771071 273162240 130.3G Linux filesystem

Disk /dev/sda: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: SanDisk SDSSDH31
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x66c58bda

Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 209717247 209715200 100G 83 Linux
/dev/sda2 209717248 419432091 209714844 100G 83 Linux
/dev/sda3 * 419432448 629147647 209715200 100G 83 Linux
/dev/sda4 629147648 1953525167 1324377520 631.5G 5 Extended
/dev/sda5 629149696 838864895 209715200 100G 83 Linux
/dev/sda6 838866944 1048582143 209715200 100G 83 Linux
/dev/sda7 1048584192 1258299391 209715200 100G 83 Linux
/dev/sda8 1258301440 1533028351 274726912 131G 83 Linux
/dev/sda9 1533030400 1953525167 420494768 200.5G 83 Linux

Disk /dev/sdb: 1.82 TiB, 2000398934016 bytes, 3907029168 sectors
Disk model: ST2000LM015-2E81
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0xd714433e

Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 419432447 419430400 200G 7 HPFS/NTFS/exFAT
/dev/sdb2 419432448 838862847 419430400 200G 83 Linux
/dev/sdb3 838862848 1107298303 268435456 128G 82 Linux swap / Solaris
/dev/sdb4 1107300350 3907029167 2799728818 1.3T 5 Extended
/dev/sdb5 1107300352 1526730751 419430400 200G 83 Linux
/dev/sdb6 1526732800 1946163199 419430400 200G 7 HPFS/NTFS/exFAT
/dev/sdb7 1946165248 2365595647 419430400 200G 7 HPFS/NTFS/exFAT
/dev/sdb8 2365597696 3907029167 1541431472 735G 7 HPFS/NTFS/exFAT

Partition 4 does not start on physical sector boundary.

Nixos is installed on /dev/nvme0n1p6 and Gentoo on /dev/nvme0n1p7

1 Like

Well, in that case I think it would be better if you try mounting the partition using its UUID, instead:

-  device = “/dev/sda7”;
+  device = "/dev/disk/by-uuid/<UUID Here>";

Which you can get by running blkid.

This way you’ll avoid naming conflicts.

1 Like