[PLUG] resizing vfat filesystem

Robert Citek robert.citek at gmail.com
Mon Sep 24 19:36:32 UTC 2007


On 09/24/2007 02:25 PM, Aaron Burt wrote:
> On Sat, Sep 22, 2007 at 06:45:20PM -0500, Robert Citek wrote:
>> Hello all,
>>
>> Are there any scriptable tools for resizing vfat filesystems?
> 
> Parted should cover it.  I think it has FAT32/VFAT support built-in.

Here's a bit more detail of what I'm trying to do.  On Ubuntu as root, I 
use the following scripts to demonstrate creating, expanding, and 
resizing filesystems in a file:

# creating, expanding, and shrinking an NTFS image
dd bs=1M count=30 if=/dev/zero of=ntfs.img
loop=$(losetup -f)
losetup $loop ntfs.img
mkfs.ntfs $loop
losetup -d $loop
dd bs=1M count=30 if=/dev/zero >> ntfs.img
ntfsresize -fi ntfs.img             # query
ntfsresize -f ntfs.img              # expand
ntfsresize -fi ntfs.img             # query
yes | ntfsresize -f -s 30M ntfs.img # shrink
ntfsresize -fi ntfs.img             # query


# creating and expanding an ext3 image
dd bs=1M count=30 if=/dev/zero of=ext3.img
mkfs.ext3 -F ext3.img
dd bs=1M count=30 if=/dev/zero >> ext3.img
tune2fs -l ext3.img  | grep -e ^Block -e ^Free  # query
resize2fs ext3.img                              # expand
tune2fs -l ext3.img  | grep -e ^Block -e ^Free  # query
resize2fs ext3.img 30000                        # shrink
tune2fs -l ext3.img  | grep -e ^Block -e ^Free  # query

I'm now looking for an equivalent set of commands for operating on vfat 
filesystems and haven't found anything.  Unfortunately, when I try 
parted, it doesn't work:

dd bs=1M count=30 if=/dev/zero of=vfat.img
mkfs.vfat -F 32 vfat.img
dd bs=1M count=30 if=/dev/zero >> vfat.img
parted vfat.img unit b print        # query
parted vfat.img resize 1 0M 62M     # expand

You found a bug in GNU Parted! Here's what you have to do:

Don't panic! The bug has most likely not affected any of your data.
Help us to fix this bug by doing the following:

Check whether the bug has already been fixed by checking
the last version of GNU Parted that you can find at:

         http://ftp.gnu.org/gnu/parted/

Please check this version prior to bug reporting.

If this has not been fixed yet or if you don't know how to check,
please visit the GNU Parted website:

         http://www.gnu.org/software/parted

for further information.

Your report should contain the version of this release (1.7.1)
along with the error message below, the output of

         parted DEVICE unit co print unit s print

and additional information about your setup you consider important.

There are no possible configurations for this FAT type.

Ignore/Cancel?


I'm guessing that parted doesn't understand that a filesystem can be 
smaller than the partition/image containing it.  Or my version is a bit 
too old, given that the current version is 1.8.8.

Regards,
- Robert



More information about the PLUG mailing list