OSDev.org
https://forum.osdev.org/

Write .iso to hard disk image
https://forum.osdev.org/viewtopic.php?f=13&t=36994
Page 1 of 1

Author:  mrjbom [ Sat Jul 11, 2020 7:27 am ]
Post subject:  Write .iso to hard disk image

Hi.
This question is not really related to programming...
After compiling the kernel, I will convert it to a .iso file.
It contains the boot folder and the boot.cfg file (I use GRUB). I'm going to upload the image to a flash drive(using balenaEther) and upload from it.
I had an idea that it would be nice to be able to manage files on the same flash drive using the file system driver.

I have this idea: write it down .iso as a hard disk image, for example, 4 GB in size, and then upload this hard disk image to a flash drive. I would like to be able to immediately write some files to the flash drive image and then use them in the OS.

What tools can you use to implement this?

P.S. when using balenaEther or other programs, the file system is "damaged" even after writing .iso on a flash drive I can't access it.

Author:  PeterX [ Sat Jul 11, 2020 8:56 am ]
Post subject:  Re: Write .iso to hard disk image

You seem to try to write a CD files system to a flash drive.

And writing files to an existing file system: Simply mount it with the OS you are developing on (You probably just have to plug it in and Windows or Linux will mount the drive.) Then you can write files to it using the shell or script(s) or the file manager.

Greetings
Peter

Author:  bzt [ Sat Jul 11, 2020 9:46 am ]
Post subject:  Re: Write .iso to hard disk image

mrjbom wrote:
Hi.
This question is not really related to programming...
After compiling the kernel, I will convert it to a .iso file.
It contains the boot folder and the boot.cfg file (I use GRUB). I'm going to upload the image to a flash drive(using balenaEther) and upload from it.
You should not use that program, it has serious privacy concerns (sad, but true).
mrjbom wrote:
I had an idea that it would be nice to be able to manage files on the same flash drive using the file system driver.

I have this idea: write it down .iso as a hard disk image, for example, 4 GB in size, and then upload this hard disk image to a flash drive. I would like to be able to immediately write some files to the flash drive image and then use them in the OS.

What tools can you use to implement this?
That's exactly what my mkbootimg tool does. It creates a hybrid CDROM ISO / flash drive image out of a directory. Then you can use dd or my other tool, USBImager to write it to a flash drive (both available as portable executable for Windows, Linux and MacOS).

Note: my mkbootimg tool uses my boot loader, so either you switch to that, or (being MIT licensed) you could study the code to write your own image creator using any boot loader you'd like. The code is well written, easy to follow, and full of comments. It currently supports creating FAT, tar and FS/Z partitions from directory contents, and any file system with a partition image. Study the code if you'd like. The part where it creates a FAT16/32 partition and copies the loader files to it is here. Use esp_mkdir() and esp_addfile() to put any files you'd like there. Other partitions are created using a very simple fs interface, described in the README.

mrjbom wrote:
P.S. when using balenaEther or other programs, the file system is "damaged" even after writing .iso on a flash drive I can't access it.
Yet another reason why not to use that spyware. Not because I wrote it, but you should really check out USBImager.

Cheers,
bzt

Author:  mrjbom [ Sat Jul 11, 2020 2:49 pm ]
Post subject:  Re: Write .iso to hard disk image

bzt wrote:
mrjbom wrote:
Hi.
This question is not really related to programming...
After compiling the kernel, I will convert it to a .iso file.
It contains the boot folder and the boot.cfg file (I use GRUB). I'm going to upload the image to a flash drive(using balenaEther) and upload from it.
You should not use that program, it has serious privacy concerns (sad, but true).
mrjbom wrote:
I had an idea that it would be nice to be able to manage files on the same flash drive using the file system driver.

I have this idea: write it down .iso as a hard disk image, for example, 4 GB in size, and then upload this hard disk image to a flash drive. I would like to be able to immediately write some files to the flash drive image and then use them in the OS.

What tools can you use to implement this?
That's exactly what my mkbootimg tool does. It creates a hybrid CDROM ISO / flash drive image out of a directory. Then you can use dd or my other tool, USBImager to write it to a flash drive (both available as portable executable for Windows, Linux and MacOS).

Note: my mkbootimg tool uses my boot loader, so either you switch to that, or (being MIT licensed) you could study the code to write your own image creator using any boot loader you'd like. The code is well written, easy to follow, and full of comments. It currently supports creating FAT, tar and FS/Z partitions from directory contents, and any file system with a partition image. Study the code if you'd like. The part where it creates a FAT16/32 partition and copies the loader files to it is here. Use esp_mkdir() and esp_addfile() to put any files you'd like there. Other partitions are created using a very simple fs interface, described in the README.

mrjbom wrote:
P.S. when using balenaEther or other programs, the file system is "damaged" even after writing .iso on a flash drive I can't access it.
Yet another reason why not to use that spyware. Not because I wrote it, but you should really check out USBImager.

Cheers,
bzt


I expected that there are tools that can do this using GRUB.
It is a pity that I will have to give up GRUB in this case and write my own loader...
Thanks you.

Author:  Octocontrabass [ Sat Jul 11, 2020 10:32 pm ]
Post subject:  Re: Write .iso to hard disk image

mrjbom wrote:
I expected that there are tools that can do this using GRUB.

It sounds like you're using grub-mkrescue, which is designed to create a read-only rescue disk.

Have you tried taking your partitioned/formatted disk and using grub-install to install GRUB on it? That way the disk will remain writable.

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/