[wplug] filesystems on regular files + compression

Alexandros Papadopoulos apapadop at andrew.cmu.edu
Fri Jul 25 13:39:35 EDT 2003


Hi list!

I hit a snag I need help with.

I'm creating a filesystem on a regular file:

debian-dual:~# dd if=/dev/zero of=virtual_fs count=1 bs=1k
seek=$[2*1024*1024]
1+0 records in
1+0 records out
1024 bytes transferred in 0.000303 seconds (3378995 bytes/sec)
debian-dual:~# ls -lhs virtual_fs
 12K -rw-r--r--    1 root     root         2.1G Jul 25 09:21 virtual_fs
debian-dual:~# mkfs.ext3 virtual_fs
mke2fs 1.34-WIP (21-May-2003)
virtual_fs is not a block special device.
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
262144 inodes, 524288 blocks
26214 blocks (5.00%) reserved for the super user
First data block=0
16 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912

Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 26 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
debian-dual:~# mount -t ext3 -o loop=/dev/loop0 virtual_fs /mnt/loop
debian-dual:~# df -h /mnt/loop
Filesystem            Size  Used Avail Use% Mounted on
/root/virtual_fs      2.0G   33M  1.9G   2% /mnt/loop
debian-dual:~# ls -lhs virtual_fs
 65M -rw-r--r--    1 root     root         2.1G Jul 25 09:22 virtual_fs
debian-dual:~#

All fine till now. The virtual filesystem has 2.0G of room, but currently
occupies just 65M of real disk space. Let's put some stuff in it.

debian-dual:~# cp -a /home/ /mnt/loop/
debian-dual:~# du -sh /home
273M    /home
debian-dual:~# du -sh /mnt/loop/
273M    /mnt/loop
debian-dual:~# df -h /mnt/loop/
Filesystem            Size  Used Avail Use% Mounted on
/root/virtual_fs      2.0G  305M  1.6G  16% /mnt/loop
debian-dual:~#

Okay. Now I want to compress the file that holds the virtual filesystem.

debian-dual:~# ls -lhs virtual_fs
367M -rw-r--r--    1 root     root         2.1G Jul 25 09:22 virtual_fs
debian-dual:~# gzip virtual_fs
debian-dual:~# ls -lhs virtual_fs.gz
173M -rw-r--r--    1 root     root         173M Jul 25 09:22 virtual_fs.gz
debian-dual:~#

The problem, now, is that if I try to uncompress this file, it starts
consuming the full 2.0G space!

debian-dual:~# gunzip virtual_fs.gz &
[1] 1176
debian-dual:~# ls -lhs virtual_fs
206M -rw-------    1 root     root         205M Jul 25 13:01 virtual_fs
debian-dual:~# ls -lhs virtual_fs
557M -rw-------    1 root     root         556M Jul 25 13:01 virtual_fs
debian-dual:~#

How is it possible to compress/uncompress such a file, so that only the
real space needed (367M in our case) is occupied?

I was thinking of doing something like this with disk backups in the TB
scale, but this a show-stopper.

TIA

-A




More information about the wplug mailing list