Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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

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

You must log in to answer this question.

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