1

I have a semi theoretical question regarding ntfs partitions.

Assume we create a ntfs partition inside a file

    dd if=/dev/zero of=test.img count=40960
    mkfs.ntfs -F test.img

for testing purposes i've added some files

    sudo mount -o loop test.img mnt
    mkdir -p mnt/test_dir/doc
    echo "this is a test file" > mnt/test_dir/doc/README.txt
    sudo umount mnt

so here comes my question. Assume i have just one part of my partition

    dd if=test.img of=test_part.img count=40952

is it possible to repair this part, in order to mount it again.

In my understanding in the test_part.img one cluster is missing, since the count parameter is 40952, which is 8 less than the original size. And with a sector size of 512, 8*512=4096 is one ntfs cluster.

I've tried the ntfsfix utility which did not work.

I've also looked into the documentation of testdisk and it seems you can change the partition geometry manually with this tool. However i had no success.

So please help me. Is there a way to repair test_part.img so that i can mount it again and get the README.txt file.

2
  • AFAIR CloneZilla uses ntfsresize for similar cases, you could give it a try.
    – gronostaj
    Commented Mar 21, 2016 at 2:22
  • Yey! Thank you it worked. I hope this will also work for my real problem.
    – MechaTheo
    Commented Mar 21, 2016 at 2:34

1 Answer 1

0

(reposting my comment as an answer

As far as I remember CloneZilla uses ntfsresize for similar cases, you could give it a try.

It's as simple as running:

ntfsresize /dev/sda1

Where sda1 is the partition you want to fix. You'll need root privileges.

2
  • After further investigation, i've found out that ntfsresize does not completely fix the problem. When running ntfsresize -s 6709248 test_part.img i'm able to mount the partition and the test file is still there. However ntfsinfo -m test_part.img returns that the volume size is clusters is 5119, which is the same as of the original non damaged image. After running ntfsfix on test_part.img, the volume size in clusters is displayed correctly, however parted still reports a size of 21.0 MB.
    – MechaTheo
    Commented Mar 21, 2016 at 11:08
  • Ok, i think it's correct though. I've doublechecked the size in bytes and it seems all right.
    – MechaTheo
    Commented Mar 21, 2016 at 11:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .