Posted by banchieri on Thu 20 Jan 2011 at 09:52
Recently, my focus of interest turned to volume management. Since with Linux, LVM2 seems to be the only viable solution (unless you go for cluster filesystems), I started reading about LVM. Somewhere, I read about setting up a loop device as PV and that's where I got intrigued: Couldn't I just use a sparse file with one single large hole and let my ext4 fill that when there's actually something written onto the loop device?
So for proof of concept, I created the volume with:(1)
dd if=/dev/zero of=FILE bs=X seek=Y-1 count=1, did the
losetup /dev/loop0 FILE,
mount /dev/loop0 /mnt,
du -k FILEand filesystem usage with
df -k /mnt.
Guess what? It worked!
For further testing, I started copying files into my "dynamic volume", watched it grow, and ultimately unmounted it.
Since that worked out so well, I'm gonna use that trick in the Linux Containers setup I'm currently working on, because it
(a) lets the volume grow dynamically and
(b) puts an upper limit on volume size.
Ah, and: With ext3/4 as underlying filesystem, ext2 within the loop device is enough. Why journal twice?