Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I saved a disk partition to an .IMG file, but it's only 128MB. What tool can I use to resize it to 256MB and keep it still bootable?

share|improve this question
1  
I've only had experience resizing on disk, not 'images' but regardless... Keep a backup before attempting it! –  PriceChild Jun 30 '11 at 10:10

1 Answer 1

I'm not aware of any Windows tools able to deal with raw filesystem images, so here's a Linux answer. Use any Live CD – Gparted, Ubuntu, etc.

  1. Expand the "partition" by appending 128 MB of any data:

    $ set -o noclobber
    
    $ dd if=/dev/zero bs=1M count=128 >> imagefile.img
    
  2. Expand the inside filesystem:

    $ sudo -s
    
    # device=$(losetup -f)
    # losetup $device imagefile.img
    
    # bytes=$(stat -c %s imagefile.img) 
    

    ('dd' uses binary megabytes while 'ntfsresize -s' takes decimal ones; therefore -s 256M would not work as expected and you have to specify the size in bytes.)

    # ntfsresize -s $bytes -n $device
    # ntfsresize -s $bytes $device
    

    (The first command, with -n, does a test run. The second, without -n, actually resizes the filesystem.)

    # losetup -d $device
    
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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