Linux filesystems normally exist on devices such as disks or memory sticks. A file can also be mounted as a filesystem. This filesystem-in-a-file can be used for testing, for customized filesystems, or even as an encrypted disk for confidential information.
Using loopback files
How to do it...
To create a 1 GB ext4 filesystem in a file, follow these steps:
- Use dd to create a 1 GB file:
$ dd if=/dev/zero of=loobackfile.img bs=1G count=1 1024+0 records in 1024+0 records out 1073741824 bytes (1.1 GB) copied, 37.3155 s, 28.8 MB/s
 The size of the created file exceeds 1 GB because the hard disk is a block device, and hence, storage must be allocated by integral multiples of blocks size.
- Format the 1 GB file to ext4 using the mkfs...