Write .iso to hard disk image

Programming, for all ages and all languages.
Post Reply
User avatar
mrjbom
Member
Member
Posts: 301
Joined: Sun Jul 21, 2019 7:34 am

Write .iso to hard disk image

Post by mrjbom »

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.
PeterX
Member
Member
Posts: 590
Joined: Fri Nov 22, 2019 5:46 am

Re: Write .iso to hard disk image

Post by PeterX »

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
User avatar
bzt
Member
Member
Posts: 1584
Joined: Thu Oct 13, 2016 4:55 pm
Contact:

Re: Write .iso to hard disk image

Post by bzt »

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
User avatar
mrjbom
Member
Member
Posts: 301
Joined: Sun Jul 21, 2019 7:34 am

Re: Write .iso to hard disk image

Post by mrjbom »

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.
Octocontrabass
Member
Member
Posts: 5513
Joined: Mon Mar 25, 2013 7:01 pm

Re: Write .iso to hard disk image

Post by Octocontrabass »

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.
Post Reply