LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to create FS image and mount (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-create-fs-image-and-mount-891447/)

chethankp 07-13-2011 04:29 AM

How to create FS image and mount
 
Hi,
How to create the FS image and mount the same ..?

I need to store some data in the image which I'll be creating ..?

nicolasdiogo 07-13-2011 04:41 AM

create a file-system image?

you can look into:

Code:

dd if=/dev/your-device of=~/Desktop/your-device-image.img
for a complete explanation see this post:
http://www.andremiller.net/content/m...ns-using-linux

with regards,


www.brainpowered.net

TobiSGD 07-13-2011 04:52 AM

To craete a new file-system image you have to first create a new container for that image, for example an image which is 1000 MB in size:
Code:

dd if=/dev/zero of=~/myimage bs=1M count=1000
This will create the file myimage in your home-directory and fill it with zeroes. Now you have to format that container with the filesystem you want to use, in this example ext4:
Code:

mkfs -t ext4 ~/myimage
Now your filesystem-image is complete and you can mount it and fill it with data:
Code:

mount -o loop ~/myimage /mnt/tmp

chethankp 07-13-2011 05:37 AM

Hi,
Thanks for the reply , I could create the image , now How to put data in to that .?

TobiSGD 07-13-2011 05:48 AM

If you have mounted the image, in my example at /mnt/tmp, you can simply copy data into it, using the commandline or a graphical file-manager. If your work is done you can simply unmout the image
Code:

umount /mnt/tmp

chethankp 07-17-2011 05:53 AM

Hi,
I cloud create this , But How to write this using 'C' code ,

nicolasdiogo 07-17-2011 07:11 AM

i love question are clear from the start..

chethankp 07-17-2011 07:42 AM

Hi,

Now I have written C code which acquire the data but I dont know how to run the terminal command from the C code to create the FS image or copy the data to created Image .

how to do this ..?

David2010 07-17-2011 07:51 AM

Quote:

Originally Posted by chethankp (Post 4417229)
Hi,

I acquire the data from serial port and have to save it FS image data block ,

So I could create the FS image data block through terminal ( as per the above guide lines ) ,
Now I have written C code which acquire the data but I dont know how to run the terminal command from the C code to create the FS image or copy the data to created Image .

how to do this ..?

The functionality you are looking for is called "popen" and is located in "stdio.h".

Popen executes a shell command and returns a pointer to it's I/O stream.

http://pubs.opengroup.org/onlinepubs...ons/popen.html


All times are GMT -5. The time now is 01:08 PM.