1 (edited by Bodena 2012-12-13 02:09:53)

Topic: [SOLVED] Error mounting a NTFS partition, yet readable.

Hi, I need some help for this issue, I really apreciate it, although I think maybe this is not the correct forum because is not a derivated GParted problem, but I'd like someone can point me in the right way.

So my problem is using ntfs-3g after install it, for be able to write, before that I could to mount the external disk (a 2TB WD Elements) in readable mode. Now, if I uninstall the package I could mount the disk again, and all this time I have no problem plugin it in my Windows XP PC, detects it without problems.

I have look Tuxera forums, superuser, and one solution is reformat and change partitions, ok but I have not space for a backup, but another solution I more like is changing the partition table, because the error I have is:

sudo mount /media/
Failed to read last sector (3907027119): Invalid argument
HINTS: Either the volume is a RAID/LDM but it wasn't setup yet,
   or it was not setup correctly (e.g. by not using mdadm --build ...),
   or a wrong device is tried to be mounted,
   or the partition table is corrupt (partition is smaller than NTFS),
   or the NTFS boot sector is corrupt (NTFS size is not valid).
Failed to mount '/dev/sda1': Invalid argument
The device '/dev/sda1' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?

And my disk is very simple, one partition:

sudo fdisk -lu /dev/sda

Disk /dev/sda: 2000.4 GB, 2000396746752 bytes
255 heads, 63 sectors/track, 243201 cylinders, total 3907024896 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0002de0f

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048  3907029167  1953513560    7  HPFS/NTFS/exFAT

Looks to me like a volume/device limits incosistency. I have read solutions for fixing extended partition size with sfdisk, and others using dd for to write the table after a bad ntfs shrink, but because my disk just comes preformated like this I don't know if these solutions are applicables to me.

Any advices? (I hope my english can be understable).

2

Re: [SOLVED] Error mounting a NTFS partition, yet readable.

I think you have certainly discovered a problem with the partitioning of this disk.
How can the end of the partition be beyond the end of the physical disk drive?
3,907,024,896 total sectors
3,907,029,167 end sector of first partition

Note that disk sectors begin numbering at zero, so the last sector is the total sectors minus one sector.

You can use a tool such as sfdisk to fix this problem.

The steps needed are as follows:

1)  Make a backup of all your data.  This is important in case something goes wrong.

2)  Make an editable file copy of the partition layout.

sudo sfdisk -d /dev/sda > backup-sda.txt

3)  Edit the backup-sda.txt file so that the end of the partition will fit within the total sectors of the disk device.

sudo leafpad backup-sda.txt

4)  Write the new partition layout to the disk device.

sudo sfdisk /dev/sda < backup-sda.txt

3 (edited by Bodena 2012-12-13 02:13:01)

Re: [SOLVED] Error mounting a NTFS partition, yet readable.

I would like to say that it works like a charm but, well, it works like a first step, this is what happened:

I used sfdisk to change the size of the partition to 3907022848 with this result:

sudo sfdisk /dev/sda < sda-mod.txt
Checking that no-one is using this disk right now ...
OK

Disk /dev/sda: 243201 cylinders, 255 heads, 63 sectors/track
Old situation:
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/sda1          0+ 243201- 243201- 1953511423+   7  HPFS/NTFS/exFAT
/dev/sda2          0       -       0          0    0  Empty
/dev/sda3          0       -       0          0    0  Empty
/dev/sda4          0       -       0          0    0  Empty
New situation:
Units = sectors of 512 bytes, counting from 0

   Device Boot    Start       End   #sectors  Id  System
/dev/sda1          2048 3907024895 3907022848   7  HPFS/NTFS/exFAT
/dev/sda2             0         -          0   0  Empty
/dev/sda3             0         -          0   0  Empty
/dev/sda4             0         -          0   0  Empty
Warning: partition 1 does not end at a cylinder boundary
Warning: no primary partition is marked bootable (active)
This does not matter for LILO, but the DOS MBR will not boot this disk.
Successfully wrote the new partition table

Re-reading the partition table ...

If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
to zero the first 512 bytes:  dd if=/dev/zero of=/dev/foo7 bs=512 count=1
(See fdisk(8).)


sudo fdisk -l

Disk /dev/sda: 2000.4 GB, 2000396746752 bytes
255 heads, 63 sectors/track, 243201 cylinders, total 3907024896 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0002de0f

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048  3907024895  1953511424    7  HPFS/NTFS/exFAT

Okey, it looks fine, inside the boundaries, I thought, but...

sudo mount /dev/sda1 /media/
Failed to read last sector (3907027119): Invalid argument
HINTS: Either the volume is a RAID/LDM but it wasn't setup yet,
   or it was not setup correctly (e.g. by not using mdadm --build ...),
   or a wrong device is tried to be mounted,
   or the partition table is corrupt (partition is smaller than NTFS),
   or the NTFS boot sector is corrupt (NTFS size is not valid).
Failed to mount '/dev/sda1': Invalid argument
The device '/dev/sda1' doesn't seem to have a valid NTFS.
Maybe the wrong device is used? Or the whole disk instead of a
partition (e.g. /dev/sda, not /dev/sda1)? Or the other way around?

Mmmh, same error and nothing happened? Now is when I shutdown, I take the disk and connect it to the Windows PC, double click on the unit and then, prompt me to format the disk!, I feel a shiver and try keep calm. I try with chkdsk but warning me that can not work with RAW data...

Uff, so I return to Linux and use one last thing:

sudo ntfsfix /dev/sda1
Mounting volume... Failed to read last sector (3907027119): Invalid argument
HINTS: Either the volume is a RAID/LDM but it wasn't setup yet,
   or it was not setup correctly (e.g. by not using mdadm --build ...),
   or a wrong device is tried to be mounted,
   or the partition table is corrupt (partition is smaller than NTFS),
   or the NTFS boot sector is corrupt (NTFS size is not valid).
FAILED
Attempting to correct errors... Failed to read last sector (3907027119): Invalid argument
HINTS: Either the volume is a RAID/LDM but it wasn't setup yet,
   or it was not setup correctly (e.g. by not using mdadm --build ...),
   or a wrong device is tried to be mounted,
   or the partition table is corrupt (partition is smaller than NTFS),
   or the NTFS boot sector is corrupt (NTFS size is not valid).
FAILED
Failed to startup volume: Invalid argument
Failed to read last sector (3907027119): Invalid argument
HINTS: Either the volume is a RAID/LDM but it wasn't setup yet,
   or it was not setup correctly (e.g. by not using mdadm --build ...),
   or a wrong device is tried to be mounted,
   or the partition table is corrupt (partition is smaller than NTFS),
   or the NTFS boot sector is corrupt (NTFS size is not valid).
Trying the alternate boot sector
The alternate bootsector is usable
Set sector count to 3907022847 instead of 3907027119
Rewriting the bootsector
The boot sector has been rewritten

Processing $MFT and $MFTMirr...
Reading $MFT... OK
Reading $MFTMirr... OK
Comparing $MFTMirr to $MFT... OK
Processing of $MFT and $MFTMirr completed successfully.
Setting required flags on partition... OK
Going to empty the journal ($LogFile)... OK
Checking the alternate boot sector... FIXED
NTFS volume version is 3.1.
NTFS partition /dev/sda1 was processed successfully.

and guess what? It works! This is just I wanted, it served like the second step. Now I can mount it in Read/Write mode, and data remains in, it's fantastic.

Thanks for all.
Cheers, Victor.

4

Re: [SOLVED] Error mounting a NTFS partition, yet readable.

Thank you Victor for reporting back with how you resolved the problem.

Also by editing the initial post and prefixing SOLVED in front of the title, you likely will help others searching for answers to similar problems.  :-)