Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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:
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
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 .
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.