LinuxQuestions.org
Register a domain and help support LQ
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 11-16-2006, 03:20 AM   #1
lbdgwgt
Member
 
Registered: Aug 2006
Distribution: Open Suse 10.1, Ubuntu (Feisty Fawn)
Posts: 87

Rep: Reputation: 15
make complete image file from partition file for qemu


Hi all,

I am working on a project building small linux system on Compact Flash (CF) card. I just found the qemu emulation software, and I reallty think it is very nice. I want to use it for my project.

So until now i always install my file system on the first primary partition of the CF card (/dev/sdb1) . I usually make an image file first-e.g. linux.img file-, copy it to the first partition of CF card (/dev/sdb1).

But I notice that qemu needs the whole image file (/dev/sdb - including the bootloader) to emulate the system.
As far as I know (I am newbee), that the whole partition contains the MBR where the bootloader stays.

So it will work if first i copy the image file linux.img to the /dev/sdb1:
Code:
dd if=linux.img of=/dev/sdb1
then setup bootloader on CF card, then recopy the CF card to a new image file:
Code:
dd if=/dev/sdb of=image.img
Can i directly make the new complete image file of CF card (/dev/sdb) from the image file linux.img for /dev/sdb1?

The problem is:
- the size of /dev/sdb1 image file is 518160384 bytes
- the size of /dev/sdb is 523321344 bytes
so the difference is not really the size of MBR (512 bytes).

a friend suggested me to first get the MBR and concatenate with the image of first partition:
Code:
dd if=/dev/sdb of=mbr.img bs=512 count=1
cat mbr.img linux.img >> cf.img
it didnt work, it gives the error "GRUB error 16" with qemu.

Then i tried also to use the same method but different size of mbr.img which is the difference of image files of /dev/sdb and dev/sdb1:
Code:
dd if=/dev/sdb of=mbr.img bs=512 count=10080
cat mbr.img linux.img >> cf.img
It didnt work either, it gives endless "GRUB GRUB GRUB ..." text with qemu.

So any hints how to do it?

thanks for any help
 
Old 11-16-2006, 08:30 AM   #2
aus9
LQ Guru
 
Registered: Oct 2003
Posts: 5,124

Rep: Reputation: Disabled
you have not stated if you can boot the current raw image in qemu.

1 lets pretend you can....then allow a live cd to boot and then run the live cd with grub to modify the hd image file.

eg let file be linux.img on your first drive hda
let the optical be /dev/hdd

insert knoppix cd etc

cd /pathway/to/linux.img
qemu -hda linux.img -cdrom /dev/hdd -boot d -net none

knoppix (etc) will detect the partitions of the emulated drive
open a terminal and its commands are
su
grub
root (hd0,0)
setup (hd0)
quit

change hd0,0 to suit your /boot partition as per my tutorial

close down knoppix and qemu and boot to test
qemu -hda linux.img -boot c -net none
 
Old 11-16-2006, 09:04 AM   #3
lbdgwgt
Member
 
Registered: Aug 2006
Distribution: Open Suse 10.1, Ubuntu (Feisty Fawn)
Posts: 87

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by aus9
you have not stated if you can boot the current raw image in qemu.
Hi,

i could not boot the image of linux.img directly with qemu. Because it contains only the root file system to be copied on the first (and the only) primary partition of Compact Flash Card, and no boot loader.

So basically i need an idea how to add the bootloader to this image file (linux.img) so i can boot it using qemu.

I can boot it using qemu, if I copy first linux.img to my first partition of my CF card (/dev/sdb1), setup bootloader there, and re-copy the whole CF card (/dev/sdb) to a new image file, and then emulate the new image file.
Can i do that just manipulate the linux.img without writing to the CF card?

I dont get it the way you told me using live cd.
 
  


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
Do Linux have software can make a ISO image file in KDE? explorer1979 Linux - General 5 06-02-2006 03:01 AM
How to make a image file for my disk( Including win2000&Redhat Linux system)? teradyne Linux - Software 3 06-02-2004 05:25 AM
get .config file for make from builted Image luponec Slackware 1 05-02-2004 02:52 PM
Hard Disk Partition&Make File System Problem jooj Linux - Hardware 3 02-23-2004 05:27 PM
How to grub install to a partition on an image file via a loopback Owen LaGarde Linux - Software 2 12-26-2003 10:06 AM


All times are GMT -5. The time now is 02:30 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