Making bochs disk image with partitions
Making bochs disk image with partitions
Do you know any easy to use tool that can create partitions on bochs raw disk images?
-
- Member
- Posts: 5562
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Making bochs disk image with partitions
Raw disk images are not specific to Bochs. Any tool that can handle raw disk images will work.
For example, Parted.
For example, Parted.
-
- Member
- Posts: 797
- Joined: Fri Aug 26, 2016 1:41 pm
- Libera.chat IRC: mpetch
Re: Making bochs disk image with partitions
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.
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.
Re: Making bochs disk image with partitions
Thanks MichaelPetch! It was very useful.
Re: Making bochs disk image with partitions
Is there a way to format partition as bare bones FAT32 and not vFAT on linux?
Re: Making bochs disk image with partitions
What do you mean by “barebones FAT32”?
Re: Making bochs disk image with partitions
I mean a FAT32 system that does not use long file names extension.iansjack wrote:What do you mean by “barebones FAT32”?
Re: Making bochs disk image with partitions
That’s a function of the file system driver that writes/reads the disk, not the way it is formatted.
Re: Making bochs disk image with partitions
Matt1223, I agree with your use of the terminology.Matt1223 wrote:Is there a way to format partition as bare bones FAT32 and not vFAT on linux?
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.