Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 03-05-2009, 03:14 PM   #1
Registered: Mar 2007
Posts: 192

Rep: Reputation: 17
How to resize vfat disk image made with dd

I made a vfat disk image of a usb using dd. Then I added some space to it like this dd if=/dev/zero bs=3540k count=1024 >> usb.img

I want to resize the vfat partition to fill the rest of the space how can I do this?

I tried parted and gparted usb.img but neither recognize any partition table.


Last edited by lindylex; 03-05-2009 at 03:18 PM.
Old 03-05-2009, 05:52 PM   #2
LQ 5k Club
Registered: May 2003
Location: London, UK
Distribution: Fedora38
Posts: 6,147

Rep: Reputation: 435Reputation: 435Reputation: 435Reputation: 435Reputation: 435
I made a vfat disk image of a usb using dd ...
I hope you mean "I made a disk image of a vfat partition using dd"

If that's what you meant, you can't do it like that.

You cannot add space to your partition with dd You need to use a partition manager eg. fdisk, because this correctly writes the changes to the partition table.

My suggestion:
Create and format the partition you want the files to be on.
Mount the disk image file with the loopback option ( read man mount for the details)
Copy the files across to the newly created and formatted partition.
Old 03-05-2009, 06:07 PM   #3
Registered: Mar 2007
Posts: 192

Original Poster
Rep: Reputation: 17
tredegar, that is what I meant 'I hope you mean "I made a disk image of a vfat partition using dd"'

Will this keep the image a bootable? My goal is to a CD.

Last edited by lindylex; 03-05-2009 at 06:09 PM.
Old 03-05-2009, 06:17 PM   #4
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Data CDs and HD partitions have different filesystems.

If your goal was to image it back to a pendrive after resizing the filesystem, it might be doable.
I'm not certain, but try attaching a loop device to your new (larger) file and run gparted on the loop device.

sudo /sbin/losetup -fs <filename>

If you created an image of a entire disk and not a partition, then use an offset of 63 blocks. Use the file command to test it.
sudo /sbin/losetup -fs <filename> -o $(63*512)
#the -fs option will locate a loop device for you and respond with which loop device it used, e.g. /dev/loop1
file -s /dev/loop1


This is something that I haven't tried, but using losetup instead of mounting the image, you may be able to resize the filesystem in the file using the loop device. Don't have the filesystem mounted however.

Last edited by jschiwal; 03-05-2009 at 06:19 PM.
Old 03-05-2009, 10:25 PM   #5
Registered: Mar 2007
Posts: 192

Original Poster
Rep: Reputation: 17
jschiwal, Gparted still behaves the same way with the /dev/loop0. Thanks for the suggestion.


dd, image, img, resize, usb

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Resize VFAT partition on USB drive jantman Linux - General 3 11-20-2007 02:04 AM
How to resize filesystem (image file)? how to truncate the image? nikov3 Linux - General 4 06-27-2006 03:02 AM
image resize oldstinkyfish Linux - Software 4 12-16-2004 06:00 AM
How do I mount a windows (vfat) disk image under Linux? brownb2 Linux - Software 2 06-19-2004 02:47 PM
Resize image mikeshn Linux - General 5 11-15-2003 11:43 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:52 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration