Create Filesystem on Sparse Files

Create an ext4 filesystem on a file.

[code language="bash"]
[root@server ~]# truncate -s 1G foo
[root@server ~]# losetup --find --show ./foo
/dev/loop3
[root@server ~]# mkfs -t ext4 /dev/loop3
[root@server ~]# mount /dev/loop3 /mnt
[root@server ~]# ls /mnt
lost+found
[root@server ~]# df -h |grep loop3
/dev/loop3 976M 1.3M 908M 1% /mnt
[/code]

One thought on “Create Filesystem on Sparse Files

Leave a Reply