OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 10:27 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Making bochs disk image with partitions
PostPosted: Tue Mar 14, 2023 11:09 am 
Offline
Member
Member

Joined: Mon Jul 30, 2018 2:58 am
Posts: 45
Do you know any easy to use tool that can create partitions on bochs raw disk images?


Top
 Profile  
 
 Post subject: Re: Making bochs disk image with partitions
PostPosted: Tue Mar 14, 2023 11:54 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
Raw disk images are not specific to Bochs. Any tool that can handle raw disk images will work.

For example, Parted.


Top
 Profile  
 
 Post subject: Re: Making bochs disk image with partitions
PostPosted: Tue Mar 14, 2023 1:43 pm 
Offline
Member
Member

Joined: Fri Aug 26, 2016 1:41 pm
Posts: 671
As Octo suggests `parted` is a good tool. You can specify a file name of an image to partition as well as a device. If you are using Linux you could create a disk image (example 100MiB) with `dd if=/dev/zero of=disk.img bs=1M count=100` . Once you have the disk image you can use parted (or fdisk, or if you want to make partition creation scriptable - sfdisk) specifying the file. Something like: `parted disk.img` . Once it is partitioned you can map the partitions with a loop back device with kpartx. kpartx will look at a specified image and create mapper entries in /dev/mapper for each partition. `sudo kpartx -av disk.img` will do the device mappings. It will print out the partition names and the mapped loop device it is on. In my case it says loop0p1 and loop0p2. You can find the device names in /dev/mapper if it worked as expected.

With partitions now mapped into /dev/mapper you can use those like you'd specify hard drive and floppy device.

If you partitioned and set the type of partition to ext2/Linux (ie partition 1) then you can format it with `sudo mkfs.ext4 /dev/mapper/loop0p1`. You can mount that formatted partition and copy files into it. Make a mount point with `mkdir mnt` (mount point will be a director called `mnt` in current directory) and then mount it the partition to the mount point with `sudo mount /dev/mapper/loop0p1 mnt'. You can then copy files into the mnt directory and they will be wriitten to the disk image. When you have finished copying/adding/deleting/etc files in the mnt directory you have to unmount it with `sudo umount mnt`. Once you are finished with the mapped partitions you can remove the device mappings on a loop device with `sudo kpartx -d /dev/loopX` where X is the loop number used for mapping. You can then disconnect the /dev/loopX device from the image with `sudo losetup -d /dev/loopX` (again X is the device mapped that was used to map to.


Top
 Profile  
 
 Post subject: Re: Making bochs disk image with partitions
PostPosted: Wed Mar 15, 2023 11:35 am 
Offline
Member
Member

Joined: Mon Jul 30, 2018 2:58 am
Posts: 45
Thanks MichaelPetch! It was very useful.


Top
 Profile  
 
 Post subject: Re: Making bochs disk image with partitions
PostPosted: Sun Mar 26, 2023 5:55 am 
Offline
Member
Member

Joined: Mon Jul 30, 2018 2:58 am
Posts: 45
Is there a way to format partition as bare bones FAT32 and not vFAT on linux?


Top
 Profile  
 
 Post subject: Re: Making bochs disk image with partitions
PostPosted: Sun Mar 26, 2023 9:44 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
What do you mean by “barebones FAT32”?


Top
 Profile  
 
 Post subject: Re: Making bochs disk image with partitions
PostPosted: Sun Mar 26, 2023 2:09 pm 
Offline
Member
Member

Joined: Mon Jul 30, 2018 2:58 am
Posts: 45
iansjack wrote:
What do you mean by “barebones FAT32”?


I mean a FAT32 system that does not use long file names extension.


Top
 Profile  
 
 Post subject: Re: Making bochs disk image with partitions
PostPosted: Sun Mar 26, 2023 2:24 pm 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
That’s a function of the file system driver that writes/reads the disk, not the way it is formatted.


Top
 Profile  
 
 Post subject: Re: Making bochs disk image with partitions
PostPosted: Sun Mar 26, 2023 10:54 pm 
Offline
Member
Member

Joined: Sat Feb 04, 2012 5:03 pm
Posts: 111
Matt1223 wrote:
Is there a way to format partition as bare bones FAT32 and not vFAT on linux?

Matt1223, I agree with your use of the terminology.

That is to say, FAT32 is a variant of the FAT filesystems that uses a 32 bit cluster - reference: https://en.wikipedia.org/wiki/File_Allo ... able#FAT32

And vFAT is a means of storing longer filenames in a FAT directory - reference: https://en.wikipedia.org/wiki/File_Allo ... Table#VFAT

However, to attempt to answer your question is tricky because while I get what you're asking, the VFAT extension works on FAT16 and FAT32 filesystems, and is invisible to an OS that is not aware of it. VFAT was introduced with Windows 95 in 1995, and FAT32 was introduced in Windows 95 OSR2 in 1996. Hence it isn't exactly a supported use of FAT32 if what you want is FAT32 which prohibits somehow the use of VFAT filenames.

I actually think you're simply asking how to set up a FAT32 filesystem that doesn't use VFAT at all. That's quite simple: stick to only 8.3 filenames and uppercase characters. VFAT does nothing to filenames if they stick to the restrictions of the original FAT directory entry.


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot] and 50 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