Monday, 2 December 2013

Creating A Sample Filesystem Image

    Following is the procedure to creating a sample filesystem ( ext2,ext3 etc) image for testing purpose. You can mount them also.Follow below steps in your terminals to make it possible.

$ dd if=/dev/zero of=/tmp/test bs=1k count=10000

   Above command will create a file called 'test' and fills it with zeros with block size of 1Kb. So 'dd' command will create empty filesystem.



$ mkfs -t ext3 -i 1024 -b 1024 -F /tmp/test
  
   Above command will build filesystem of type 'ext3' (specified by -t option). You can change it based upon your need.


    Now we have to create mount point to mount this filesystem. Use 'mkdir' to do that.

$ mkdir /tmp/testmnt

$ sudo mount -o loop /tmp/test /tmp/testmnt

   Above command will mount the file using the loopack interface.Loop option in mount command tells mount about loopback device and it treats file as a block device.You have to provide device type information( e.g loop) otherwise it will give message as shown in below snap. You can check your filesystem by executing 'df -h' command

 

$ df -h

   You can check your filesystem by executing 'df -h' command in available disk space usage list.
   
     


No comments:

Post a Comment