Friday, May 21, 2010

How to create ramfs filesystem

There are few simple steps to create the ramfs filesystem:-

1) dd if=/dev/zero of=image_name bs=1M count=35
where bs -> block size and 1M-M-means Megabyte or if we want in kb we can directly write the figures.
count = number of times to be multiply the "bs".
So the result of above image will be 35M.

2) mke2fs -m 0 image_name
where "mke2fs" which is a tool that allows you to create a second extended (ext2) file system on any block device.

3)mount -o loop image_name /dev/dir_name
After then load the file system directories in this directory with required libraries.

After mount change in the filesystem whatever change needed after then we will umount the directory.

4)gzip -v -9 image_name
This command will generate the file with the name "image_name.gz".
After all that you will get a file with image_name.gz i.e. your required image you wanting.

5) mkimage -T ramdisk -C gzip -n 'RISHABH Testing Image' -d rishabh.gz uRamdisk

where:-
-T ==> set image type to 'type'. (Here it is ramdisk)
-C ==> set compression type 'comp'.
-n ==>no-name do not save or restore the original name and time stamp .
-d ==> decompress.

So after that you will get the image prepared for use.

After that you will umount that directory.
Work completed.


IF YOU WANT TO MODFIY THE EXISTED EXT2 FILESYSTEM IMAGE:-

1) Extract compressed ramdisk image (ramdisk.gz)
bash$:- dd if=uRamsdisk bs=64 skip=1 of=ramsdisk.gz

2) Uncompress ramdisk image (if it was a compressed one).

bash$:- gunzip -v ramdisk.gz

3) Mount ramdisk image

bash$:- mount -o loop ramsdisk dir_name/
Here we will now make the changes in the filesystem.

4) After then we will follow the same steps as above from step 4.

No comments:

Post a Comment