Friday, June 6, 2014

Resizing Partition with Bad Sectors in GParted

Recently I tried to expand a Windows 2003 system drive on a VM using GParted but was not able to as it kept complaining about bad sectors. The recommended fix was to run chkdsk /f /r on Windows and then reboot it twice. After applying the recommended fix and rebooting back into Gparted, the error remains and I was unable to proceed with expanding the drive. Luckily, we are able to override the bad-sectors error and proceed with the drive expansion.


Solution:

  1. While booted into the GParted X environment, open the terminal window.
  2. Navigate to /sbin: cd /sbin 
  3. Rename ntfsresize: sudo mv ntfsresize ntfsresize.orig
  4. Create new ntfsresize: sudo touch ntfsresize
  5. Edit ntfsresize with vi: sudo vi ntfsresize
  6. Add the following lines into ntfsresize and save the file:
    1. #!/bin/bash
    2. exec ntfsresize.orig --bad-sectors “$@”   (Note the double "-" before bad-sectors)
  7. Add permissions to run the resize: sudo chmod 777 ntfsresize
  8. Go back into the GParted wizard and expand the disk as you normally would

No comments:

Post a Comment