Linux 101 : Turning a regular file into a disk partition - Loop device, losetup -
The loop device is a virtual device, that is used to "turn" a regular file into a block device.
We can make a file in our system look and behave like a disk partition using the below commands.
We start by creating a 2GB file and, we "zero" it out using the below command:
- if : the input file.
- of : the output file.
- bs : the block size.
- count : the number of block sizes.
Then we create an ext4 filesystem on our file block-file using the below command:
Then we mount our file, in order to be able to use it:
- The system uses the first free loop device it finds
When we are done using our block-file, we can unmount it using the below command:
Comments