Mike Chirico on 8 Dec 2003 19:56:02 -0500


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[PLUG] Thoughts on creating a virtual file system


I just wanted so share a few thoughts here on creating a virtual file system.
 
I move around from computer to computer, and it's nice to have access to all my files, along with the symbolic links etc.  So what I did was create a file and mounted it as a drive.  Then, when I moved to another computer for a few hours, I just copied the file and mounted in again on the second computer.  True, I could have used ssh; but, it was kind of nice to have the speed of accessing it locally.  Anyway, it works well for me...these are the steps I use:
 
1. Construct a 10MB file, or bigger:
 
  dd if=/dev/zero of=/tmp/disk-work count=20480
 
By the way, dd defaults to blocks of 512 so the above will = 10MB = 20480*512.  The "if=/dev/zero"  stand for read from file, and /dev/zero will zero everything out.  As you can probably guess, "of=/tmp/disk-work" creates the file.  You should probably create it in your home directory "of=/home/<your name>/disk-work" since you'll have more space and it won't get deleted.
 
2. Make an ext2 (or ext3 if you want) file system. I believe the difference is ext3 is a journaling filesystem; but, it doesn't handle recovery as well as ext2.
 
    mke2fs -q /tmp/disk-work
 
Hit yes for confirmation, and it's going to ask this because it's a file and not a drive.
 
3. Create a directory, su -l to root, and mount.
 
   mkdir /work
   su -l
   mount -o loop=/dev/loop0  /tmp/disk-work  /work
  
Now to use it, cd /work and create files etc.
  
4. When you're done with it, unmount
 
   umount /work
 
 
What's nice is it's mounted similar to a drive.  A "lost+found" directory is created.  In addition, if more drives are needed, use /dev/loop1, /dev/loop1 etc.  By the way, CD-ROM's can be copied to a file and mounted as well for faster access.        
 
Regards,
 
Mike Chirico