Create a empty file with the mount of disk space you need. Here I have created a 1G file.
[[email protected] ~]# dd if=/dev/zero of=/root/myfs1 bs=1024 count=1048576
1048576+0 records in
1048576+0 records out
[[email protected] ~]# ls -l /root/myfs1
-rw-r–r– 1 root root 1073741824 Jun 25 08:32 /root/myfs1
Create a filesystem on the virtual device (/root/myfs1). I have selected ext3 , whereas you can create the filesystem of your choice.
[[email protected] ~]# mkfs.ext3 /root/myfs1
mke2fs 1.35 (28-Feb-2004)
/root/myfs1 is not a block special device.
Proceed anyway? (y,n) y
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
131072 inodes, 262144 blocks
13107 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=268435456
8 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 28 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
- Mount the filesystem as a loopback device.[[email protected] ~]# mount -o loop /root/myfs1 /mnt
- If you need this permanantly , you can add this to /etc/fstab.
Sometimes you may need additional local partition or local mountable drives, but you dont have free blocks in the parition table. In that case virtual filesystem helps. You can create a virtual filesystem and mount them as a loopback device. Here are the steps to do it.
You can even create this virtual filesytem on a nfs mounted directory and again loopback-mount it on the machine.