0

I have a backup system file, I would like to shrink a ntfs partition inside the system file in order to copy it into a new smaller disk.

I mounter the ntfs partition with losetup and used ntfsresize in order to shrink the filesystem.

BUT, by unmounting and watching the disk with gdisk, the partition is still the same size.

I read somewhere, I need to shrink the partition too. I thought it was same... Then I would like to know how I could get the final sector of the filesystem in order to resize the partition at the same size.

It is a little bit weird for me because we shrink the ntfs filesystem and then remove the partition and create a new one with a smaller size, I don't understand how it is possible to not loose data.

  • You’re shrinking the filesystem, not the partition. – Daniel B Jul 18 '16 at 5:23
0

I thought it was same...

That's not quite right. The size of the partition is determined by the partition table in the MBR. And the size of the file system is determined by the Partition Boot Sector. They are different. But the size of the fs should not exceed the size of the partition.

Then I would like to know how I could get the final sector of the filesystem in order to resize the partition at the same size.

In my case, normally, I would shrink the fs a little more and then extend it to fit the new size of the partition. For example. We want to shrink the fs from 200GB to 100GB, I would shrink the fs to 90GB and then shrink the partition to 100GB. After that, I extend the fs to all available space so that the fs will use all of the unallocated space.

It is a little bit weird for me because we shrink the ntfs filesystem and then remove the partition and create a new one with a smaller size, I don't understand how it is possible to not loose data.

That's not correct too. The shrink process will not delete the existing partition. Actually, it does the following steps:

  1. Move the data from the tail of the partition to the unallocated space in the front. So that it will leave a continuous set of rooms in the tail of the partition.
  2. Shrink the FS. So that the space in the tail of the partition is released by the FS.

After that, we are able to modify the size of the existing partition.

  • I see, then when I use ntfsresize, it acts a little bit like a de-fragmentation. Then I can know the last sector by adding the size to the start sector of the fs ? – Alexis_FR_JP Jul 18 '16 at 5:13
  • It may not be accurate. Why don't you follow the steps which I stated above? "In my case, normally, I would shrink the fs a little more and then extend it to fit the new size of the partition." – Steven Lee - MSFT Jul 18 '16 at 5:16
  • To be sure I won't resize smaller than the fs. Of course I shrinked the fs with more space. I'd like to understand in a low-level. I don't know the space for now. Anyway, I'll do your technique ! Thank you. – Alexis_FR_JP Jul 18 '16 at 5:28
0

When you shrink a partition, you are left with some unallocated space. Create a new partition with this and then transfer all the data into it. this is a workaround, because some HDDs can be buggy when trying to do stuff with partitions.

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.