Here’s my first post.
Problem
I’ve recent PV’d a failing server to VMware, however the old server had a 250GB disk but only was using 10GB of it.
VMware converter wouldn’t let me re-size the disk so I ended up just doing a full copy, now the disk is a thin disk but is taking up 250GB.
The server only needs a 40GB disk so I tried to shrink it with gparted but I was getting an error about bad sectors, as per the warning message I ran chkdsk /r /f several times but all was ok, however gparted wouldn’t run.
I know I could have used ntfsresize -bad-sectors, but I know the disk doesn’t have bad sectors.
This made m start thinking if I could reset the bad sector count on the partition, I’ve written how I did this below.
Instructions
The instructions below assume the NTFS partition is on /dev/sda1
-
Make sure you have a full backup before proceeding
-
Download gparted live cd
-
When the cd has booted click on terminal type:
ntfsinfo -i 8 /dev/sda1
-
The command will output similar to the below screenshot
-
Make a note of the Allocated size for the ‘$Bad’ attribute, as indicated by the red line above type:
ntfstruncate /dev/sda1 8 0x80 '$Bad' 0
-
In the next command you will need to use the allocated size from the previous step type:
ntfstruncate /dev/sda1 8 0x80 '$Bad' <value from previous step> ntfstruncate /dev/sda1 8 0x80 '$Bad' 250048479232
Screenshot
-
You can now size the partition with gparted
I hope others find this useful.
Matt