> > Hi, > > > > How can I create an image file system that can grow bigger as > > required? > > > > Vmware, qemu, kvm, etc all can create file systems in an > > image file which > > is initially small, but grow bigger as required. I want to do > > that too, > > but > > > > dd if=/dev/zero of=file-fs.ext2 bs=1k count=20k > > mke2fs file-fs.ext2 > > > > would only create an image file initially as big as the full size. > > > > please help, thanks > > I haven't tried this myself, but how about appending extra > space to the end > of the file, then calling resize2fs?
Actually, I just reread your message, and it seems you want the filesystem to automatically grow as needed, and not do it manually. I just did a little experiment with sparse files, and it seems to work as you want. ke...@htpc:~$ dd bs=1 count=1 if=/dev/zero of=sparse seek=5GB 1+0 records in 1+0 records out 1 byte (1 B) copied, 5.4523e-05 s, 18.3 kB/s ke...@htpc:~$ ls -lh sparse -rw-r--r-- 1 kevin kevin 4.7G 2009-07-26 19:02 sparse ke...@htpc:~$ du -h sparse 4.0K sparse Here you can see that I allocated a maximum of 5 GB to this file, but it is really only taking up 4K of disk space. ke...@htpc:~$ /sbin/mke2fs sparse (a bunch of mke2fs output...) ke...@htpc:~$ du -h sparse 77M sparse It created the filesystem. It now takes up about 77M. ke...@htpc:~$ sudo mount -t ext2 -o loop sparse tmp ke...@htpc:~$ df -h tmp Filesystem Size Used Avail Use% Mounted on /home/kevin/sparse 4.6G 9.4M 4.4G 1% /home/kevin/tmp ke...@htpc:~$ du -h sparse 77M sparse The filesystem has 4.4 GB available to it, but it's currently only taking up 77 MB of disk space. I think this should work for you. -- Kevin -- To UNSUBSCRIBE, email to [email protected] with a subject of "unsubscribe". Trouble? Contact [email protected]

