[TriLUG] using parted to change the size of a loop mounted filesystem

Robert Dale robdale at gmail.com
Fri Mar 16 08:58:35 EDT 2012


On Fri, Mar 16, 2012 at 7:56 AM, Joseph Mack NA3T <jmack at wm7d.net> wrote:
> On Wed, 14 Mar 2012, Robert Dale wrote:
>
>> Note our 96M filesystem.  Now let's grow it!
>>
>> # umount /mnt
>> # dd if=/dev/zero of=foo.part bs=1M count=100 seek=100
>> 100+0 records in
>> 100+0 records out
>> 104857600 bytes (105 MB) copied, 0.152461 s, 688 MB/s
>
>
> At this stage I have the unchanged original filesystem followed by by 100M
> of 0x00. I had thought that if I mouunted it, I would see only the original
> 100M filesystem. However I get "not an ext2 filesystem" and errors about no
> superblook etc. Presumably the only thing wrong is that the filesize doesn't
> match the filesystem size. The superblocks etc are still there and in the
> right place. If I understood filesystems better, presumably the problem
> would be obvious, but I don't. What's the problem?

Are you sure you used dd with seek=100 to grow?

#  dd if=/dev/zero of=foo.part bs=1M count=100
100+0 records in
100+0 records out
104857600 bytes (105 MB) copied, 1.15978 s, 90.4 MB/s

Verify 100M file size.

# ls -lh foo.part
-rw-r--r--. 1 root root 100M Mar 16 08:46 foo.part

# mkfs.ext3 foo.part
...

# mount foo.part /mnt
# df -h
Filesystem                        Size  Used Avail Use% Mounted on
/dev/loop0                         96M  4.1M   87M   5% /mnt

# umount /mnt

Grow.

#  dd if=/dev/zero of=foo.part bs=1M count=100 seek=100
100+0 records in
100+0 records out
104857600 bytes (105 MB) copied, 0.680898 s, 154 MB/s

Verify file size grew.

# ls -lh foo.part
-rw-r--r--. 1 root root 200M Mar 16 08:47 foo.part

Did the file type change?

# file foo.part
foo.part: Linux rev 1.0 ext3 filesystem data,
UUID=041fefd0-211a-4cdd-89ae-8ca987179761

No. Can we mount it?

# mount foo.part /mnt
# df -h
Filesystem                        Size  Used Avail Use% Mounted on
/dev/loop0                         96M  4.1M   87M   5% /mnt

Yes. Note the file system size has not changed yet.

Continue resizing fs....


-- 
Robert Dale



More information about the TriLUG mailing list