LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 07-13-2011, 05:29 AM   #1
chethankp
LQ Newbie
 
Registered: Jul 2011
Posts: 13

Rep: Reputation: Disabled
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 ..?
 
Old 07-13-2011, 05:41 AM   #2
nicolasdiogo
Member
 
Registered: Oct 2003
Location: UK
Distribution: debian lenny x64
Posts: 130

Rep: Reputation: 20
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
 
Old 07-13-2011, 05:52 AM   #3
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,130
Blog Entries: 2

Rep: Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825
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
 
Old 07-13-2011, 06:37 AM   #4
chethankp
LQ Newbie
 
Registered: Jul 2011
Posts: 13

Original Poster
Rep: Reputation: Disabled
Hi,
Thanks for the reply , I could create the image , now How to put data in to that .?
 
Old 07-13-2011, 06:48 AM   #5
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,130
Blog Entries: 2

Rep: Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825
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

Last edited by TobiSGD; 07-13-2011 at 06:49 AM.
 
Old 07-17-2011, 06:53 AM   #6
chethankp
LQ Newbie
 
Registered: Jul 2011
Posts: 13

Original Poster
Rep: Reputation: Disabled
Hi,
I cloud create this , But How to write this using 'C' code ,

Last edited by chethankp; 08-05-2011 at 11:15 AM.
 
Old 07-17-2011, 08:11 AM   #7
nicolasdiogo
Member
 
Registered: Oct 2003
Location: UK
Distribution: debian lenny x64
Posts: 130

Rep: Reputation: 20
i love question are clear from the start..
 
0 members found this post helpful.
Old 07-17-2011, 08:42 AM   #8
chethankp
LQ Newbie
 
Registered: Jul 2011
Posts: 13

Original Poster
Rep: Reputation: Disabled
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 ..?

Last edited by chethankp; 08-05-2011 at 11:14 AM.
 
Old 07-17-2011, 08:51 AM   #9
David2010
Member
 
Registered: May 2009
Posts: 255

Rep: Reputation: 23
Quote:
Originally Posted by chethankp View Post
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

Last edited by David2010; 07-17-2011 at 08:52 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cp of dd image failed, better to mount image and then copy? bmcws Linux - Newbie 5 06-23-2009 07:41 PM
create image from a part of big image myrmidon Programming 3 07-11-2007 03:00 PM
Trying to create PXE server and can't mount initrd image Nylex Slackware 6 07-08-2007 02:10 PM
How to create a multi-file-image and mount it as a loopback device (on xbox debian) El_Oy Linux - Software 1 06-14-2006 03:05 AM
Can Mac OS X create & mount ext2 image? deoren Other *NIX 1 05-23-2005 10:31 PM


All times are GMT -5. The time now is 12:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration