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
mount myfilesys /mnt -o loop=/dev/loop0 # mounting it as a loop de犀利士
06
07
vice
08
09
10
mkdir /mnt/point1 # creating a mount point
11
12
mount /dev/loop0 /mnt/point1 # mounting 
13
14
df /mnt/point1/ # its alive!
15