<a href="Non-Sumou.html">Other Qemu tips</a></p>

To create a disk raw image, which can be read by Qemu, and then mounted and files copied to/from it under GNU/Linux you should:</p> <ul> <li>Create the image file: <table bgcolor="#000000" border="1"><tr><td border="0"><font color="#FFFF00"><b># qemu-img create -f raw file.raw 20G</b></td></tr></table> where the last element is the file size, in the example above it is 20 GB.</li> <li>Loop-mount it: <table bgcolor="#000000" border="1"><tr><td border="0"><font color="#FFFF00"><b># losetup /dev/loop7 file.raw</b></td></tr></table></li> <li>Create a file system on it: <table bgcolor="#000000" border="1"><tr><td border="0"><font color="#FFFF00"><b># fdisk /dev/loop7</b></td></tr></table></li> <li>Then in fdisk, create a new partition table, and a new partition in it.</li> <li>Unmount it: <table bgcolor="#000000" border="1"><tr><td border="0"><font color="#FFFF00"><b># losetup -d /dev/loop7</b></td></tr></table></li> <li>Run Qemu with the file.raw attached as a hard disk. This is usually done for Windows, so then in Qemu under Windows, format this new disk, which will show as unformatted. Format it as fat32.</li> </ul>

To mount it under GNU/Linux, when finished working with it, and having exited Qemu, check which block the partition in the file starts at. This only needs to be done before mounting it for the first time. For this:</p> <ul> <li>Loop-mount it again: <table bgcolor="#000000" border="1"><tr><td border="0"><font color="#FFFF00"><b># losetup /dev/loop7 file.raw</b></td></tr></table></li> <li>Run fdisk and look in the partition table, which block it starts on, usually it is block 63.</li> <li>Obtain the starting offset, by multiplying the number from the above step by 512. In this case it is: 63*512=32256.</li> <li>Unmount it again: <table bgcolor="#000000" border="1"><tr><td border="0"><font color="#FFFF00"><b># losetup -d /dev/loop7</b></td></tr></table></li> </ul>

Utilizing the offset number, you can then mount the disk file:

<ul> <li><table bgcolor="#000000" border="1"><tr><td border="0"><font color="#FFFF00"><b># mount -o loop,offset=32256,defaults,utf8,gid=046,uid=1000 file.raw /mnt/1</b></td></tr></table> where the 32256 is the offset obtained above and /mnt/1 the directory you want to mount the disk image file at.</li> </ul> <!— Page published by Emacs Muse ends here —> </div> <i>To send me feedback about this page, use the below email.</i><br /> <b>&copy; sumoudou.org 2010</b><br /> <img style="border:0" alt="sumoudou.org" src="email.gif" width="129" height="10" /><br /> <a href="http://www.gnu.org/" style="text-decoration: none;"><img style="border:0" alt="GNU" src="powered-by-gnu.png" />]] <a href="http://www.gnu.org/software/emacs/emacs.html" style="text-decoration: none;"><img style="border:0" alt="GNU Emacs" src="made-with-emacs.png" />]] <a href="http://hcoop.net/" style="text-decoration: none;"><img style="border:0" alt="HCoop" src="hcoop-proud-member.png" />]] <a href="http://hcoop.net/" style="text-decoration: none;"><img style="border:0" alt="HCoop" src="hosted-by-hcoop.png" />]] <a href="http://mwolson.org/projects/EmacsMuse.html" style="text-decoration: none;"><img style="border:0" alt="Emacs Muse" src="made-with-muse.png" />]] <a href="http://mwolson.org/projects/EmacsMuse.html" style="text-decoration: none;"><img style="border:0" alt="Emacs Muse" src="powered-by-muse.png" />]] <br /> <a href="http://www.fsf.org/resources/formats/playogg" style="text-decoration: none;"><img style="border:0" alt="Ogg" src="play-ogg.png" />]] <a href="http://www.catb.org/hacker-emblem/" style="text-decoration: none;"><img style="border:0" alt="Glider" src="glider.png" />]] <a href="http://ubuntu.com/" style="text-decoration: none;"><img style="border:0" alt="Ubuntu" src="ubuntu.png" />]] <a href="http://validator.w3.org/check?uri=referer" style="text-decoration: none;"><img style="border:0" alt="Valid XHTML 1.0 Strict!" src="valid-xhtml10-blue.png" />]] <a href="http://jigsaw.w3.org/css-validator/check/referer" style="text-decoration: none;"><img style="border:0" alt="Valid CSS!" src="valid-css-blue.png" />]] <br />Last updated November 6, 2009 </div> <br />. </body> </html>

.