0

After a failed resizing operation, mount operation is failing with:

Failed to read last sector (718198764): Invalid argument

The partition is not accessible with Gparted and other GUI tools. How can we fix such issue?

0

Analyse

ntfsfix -n /dev/sda5 the n parameter will make the tool output the repair solution without applying it (be very prudent using such tool as automated repair tools can choose the wrong decision to repair the partition)

ntfsresize -if /dev/sda5 this will tell us what's going on exactly...

Backup

First thing first before doing anything a full image backup is recommended... otherwise just backup the partition table with

sfdisk -d /dev/sda > sda.partition.table.txt

Explanation

In this particular case Failed to read last sector (345345...) this mean that the partition is bigger than what's indicated on the partition table, this can happen when the partition is resized (shrinked) without shrinking the file-system (ntfs here)... the solution is to revert the resize (on the partition table)... Note that ntfsfix may guess the good old value and restore it BUT the tool can also guess a wrong value and make you loose part/all of your datas... if the partition can be mounted after the repair that does not mean you did not lost any datas especially when chkdsk is correcting a lot of errors...

Solution

  • Backup the current partition table with sfdisk -d /dev/sda > sda.partition.table.txt

  • Failed to read last sector (345345...) indicate that the real partition end sector is [start.sector]+[345345...] thus, we need to calculate the real end sector location by adding the start sector of the partition and the last sector shown on the error

  • Edit sda.partition.table.txt and replace the end sector with the new calculated one... (for the sda5)

  • Restore the partition table with sfdisk /dev/sda < sda.partition.table.txt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.