OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 2:52 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Formatting QEMU HDD image as FAT
PostPosted: Mon May 01, 2017 9:40 am 
Offline
Member
Member

Joined: Fri May 20, 2016 2:29 pm
Posts: 77
Location: Paris, France
Hello,

I'm emulating my OS in QEMU and want to test my ATA driver. I created a virtual hard disk image with
Code:
qemu-img create -f raw drive.img 2G

I would like to format this drive as FAT. Is there a utility to format a QEMU virtual drive as FAT, or am I expected to hand-write the MBR, boot record, etc. myself?

Thanks!

_________________
www.github.com/codyd51/axle.git


Top
 Profile  
 
 Post subject: Re: Formatting QEMU HDD image as FAT
PostPosted: Mon May 01, 2017 10:15 am 
Offline
Member
Member

Joined: Tue May 13, 2014 3:02 am
Posts: 280
Location: Private, UK
You can use GNU parted to create the MBR and partition table ("parted drive.img").

Formatting it using native Linux tools will require attaching the image as block device using "kpartx" ("kpartx -a -v drive.img") and then doing something like "mkfs.vfat /dev/mapper/loop0p1". Since this requires root access, I'd suggest making a (possibly compressed) copy of the "empty" image at this point to use as a starting point in future (especially if you're "creating" the image as part of your build system, using root access as part of a build is a bad idea). mtools can be used to copy data to/from a FAT filesystem in a disk image without root access, but unfortunately can't be used to create one.

_________________
Image


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Majestic-12 [Bot], nullplan and 55 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group