tutorial - Building A Linux Filesystem From An Ordinary File

First, create a 20MB file (you could use any size for your FS) by executing the following command:

# dd if=/dev/zero of=disk-image count=40960
40960+0 records in
40960+0 records out
20971520 bytes (21 MB) copied, 0.225793 s, 92.9 MB/s

Next, to format this as an ext3 filesystem, you just execute the following command:
# /sbin/mkfs -t ext3 -q disk-image
disk-image is not a block special device.
Proceed anyway? (y,n)

Next, you need to create a directory that will serve as a mount point for the loopback device.
# mkdir fs

Now mount the this filesystem (file)
# mount -o loop=/dev/loop0 disk-image fs

Check if your FS is mounted
# mount
/dev/hda2 on / type ext3 (rw,noatime,acl,user_xattr)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
debugfs on /sys/kernel/debug type debugfs (rw)
udev on /dev type tmpfs (rw)
devpts on /dev/pts type devpts (rw,mode=0620,gid=5)
/dev/hda5 on /mnt/D type vfat (rw)
/dev/hda1 on /mnt/C type ntfs (rw)
/dev/hda7 on /cache type ext3 (rw,noatime)
/root/disk-image on /root/fs type ext3 (rw,loop=/dev/loop0)

Now, move to the mounted directory and create some directory and files on this new FS which we have created using file.
# ll
total 14
drwx—— 2 root root 12288 Apr 25 23:30 lost+found
drwxr-xr-x 2 root root 1024 Apr 25 23:33 nik
drwxr-xr-x 2 root root 1024 Apr 25 23:33 nikesh


Free, facebook, tips, Links, blogging, Downloads, Google, facebookTips, money, news, apps, Social, Media, Website, Tricks, games, Android, software, PIctures, Internet, Security, Web, codes, Review, bloggers, SAMSUNG, Worldwide, Contest, Exitic, Phones, facebookTricks, hacking, London, Olympics, SEO, Youtube, iOS, Adsense, gadgets, iPHONE, widgets, Doodle, twitter, video, Deals, technology, Aircel, Airtel, iPAD, Angry, Birds, BSNL, TechLife, GMAIL, Idea, Microsoft, SmartPhones, Stress, Buster, Windows, Yahoo, Infolinks, Nokia, Scam, Uninor, browsers, Amazon, Euro, CUP, Chat, IDM, JOBS, Modem, Music, Reliance, Results, SSC, Tata, Docomo, bing, freebie, mobile, placements, AIEEE, AlertPay, Chrome, College, Competetive, Exam, Dehradun, Extension, FireFox, GPRS, HTC, IMPACT, Info, MTS, Mark, Zukerberg, Paypal, Promotional, Post, Torrent, UTU, Unlocking, VodaFone, Wall, Paper, apple, books, engineering, iCAR, iTunes, pinterest, rovio, AVG, Admit, Card, Adobe, Affiliate, Marketing, Akhilesh, Amul, Girl, BlackBerry, ChromeBook, Clixsense, Coupon, Digitallife, Discovery, Emoticons, Festival, GATE, GIMP, Income, Tax, International, JSS, JailBreaking, Kindle, Linux, Local, MAX, PAYNE, Mac, Mango, Memory, Speed, Nexus, Online, Shopping, Raakhi, Report, Rising, Stars, Sample, Science, Sony, Syllabus, TabletBooK, Teamviewer, Templates, Dark, Knight, Rises, USA, UPMT, Virgin, Xperia, ZTE, challan, counselling, course, btech, funny, iMOVE, registration

source:http://linuxpoison.blogspot.com/2008/08/13578175713504.html