Create A File And Loop It As A Filesystem in Linux

by Ras 25. March 2012 20:13

You can create a file system in a file within the current file system on linux.

1. Creating an initialized file
dd if=/dev/zero of=/tmp/fstest.img bs=1024 count=5000
file /tmp/fstest.img
losetup /dev/loop0 /tmp/fstest.img

2. Creating an ext2 file system with the loop device
mke2fs /dev/loop0
file /tmp/fstest.img

3. Creating a mount point and mounting the file system through the loop device
mkdir /mnt/fsttestimage
mount /dev/loop0 /mnt/fstestimage
df -h /mnt/fstestimage
cd /mnt/fstestimage
ls
mount -o loop /tmp/fstest.img /mnt/fstestimage/
dumpe2fs /tmp/fstest.img

Tags:

Linux

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

About the author

Ras is a network/Security professional working on multiple areas with multiple certificates like CCNP, CCIP, CCSP, CCSA, CCSE, LPI, PM, IPv6, ..

Month List