-
Create a empty file with the mount of disk space you need. Here I have created a 1G file.
[root@unixfoo23 ~]# dd if=/dev/zero of=/root/myfs1 bs=1024 count=1048576
1048576+0 records in
1048576+0 records out[root@unixfoo23 ~]# ls -l /root/myfs1
-rw-r–r– 1 root root 1073741824 Jun 25 08:32 /root/myfs1[root@unixfoo23 ~]# du -sh /root/myfs1
1.1G /root/myfs1
[root@unixfoo23 ~]# -
Create a filesystem on the virtual device (/root/myfs1). I have selected ext3 , whereas you can create the filesystem of your choice.
[root@unixfoo23 ~]# mkfs.ext3 /root/myfs1
mke2fs 1.35 (28-Feb-2004)
/root/myfs1 is not a block special device.
Proceed anyway? (y,n) y
Filesystem label=
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, 229376Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: doneThis filesystem will be automatically checked every 28 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.[root@unixfoo23 ~]# file /root/myfs1
/root/myfs1: Linux rev 1.0 ext3 filesystem data (large files)
[root@unixfoo23 ~]# - Mount the filesystem as a loopback device.[root@unixfoo23 ~]# mount -o loop /root/myfs1 /mnt
[root@unixfoo23 ~]# df /mnt
Filesystem 1K-blocks Used Available Use% Mounted on
/root/myfs1 1032088 34092 945568 4% /mnt
[root@unixfoo23 ~]# - 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.