Tag Archives: loop

Create a filesystem in a file

Some times you need a new filesystem, for testing purposes or for whatever and you dont have access to a physical device. You can create a filesystem within  a file as follows:

 bash | 
 
 copy code |
?

01
dd if=/dev/zero of=myfsys bs=512M count=1 # creating a 512M zeros file
02
mke2fs myfilesys # creating a file system out of the file
03
04
05
06
mount myfilesys /mnt -o loop=/dev/loop0 # mounting it as a loop device
07
08
09
mkdir /mnt/point1 # creating a mount point
10
11
mount /dev/loop0 /mnt/point1 # mounting 
12
13
df /mnt/point1/ # its alive!
14