OSDev.org

The Place to Start for Operating System Developers
It is currently Wed Apr 24, 2024 10:03 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: make bootable grub hd image
PostPosted: Tue May 29, 2018 10:53 pm 
Offline

Joined: Thu Feb 15, 2018 12:49 pm
Posts: 1
I'm trying to create a hd image with my own bootable os.

I have the following files:

Code:
build/iso/
  - os.kernel
  - boot/grub/grub.cfg
  - a few extra files


I'm able to create a working bootable iso file with this:

Code:
grub-mkrescue -o build/nopsys.iso build/iso


now, I want to create a hard disk image instead of an iso file. I didn't find a way to convert an iso to a fat32 hd image, so thought about
using grub-mkimage. However, I couldn't make it work.

I've tried the following with no luck, any help very much appreciated

Code:
grub-mkimage -p build/iso -o build/nopsys.raw -O i386-pc fat


thanks for reading!

EDIT: there's one more requirement, I'd like to be able to avoid needing sudo, that's why I'm not trying mounting a loopback device.


Top
 Profile  
 
 Post subject: Re: make bootable grub hd image
PostPosted: Fri Jun 22, 2018 3:34 pm 
Offline
Member
Member
User avatar

Joined: Sat Nov 22, 2014 6:33 pm
Posts: 934
Location: USA
This happens to be one of the most asked questions here. A FAQ in fact.

First, did you see https://wiki.osdev.org/Disk_Images?

One of the first things an OS Developer must do is create a disk image on some form of bootable media. To do so, he/she must understand the media as well as, and more importantly, the file system or storage array of the media. Where is my boot code? Where is my second stage code? Where is my kernel? etc.

Another very important part of media creation is how long and how difficult is it to change a file upon that media? For example, I have created my boot code, second/third/etc stage loader code, my kernel code, and some drivers, and have put them all on my media (which could simply be a hard drive image on the local host machine). However, I have made a simple change to the X-stage loader code and need to update the image file. Do I need to recreate the whole image or just the file in question? How many utilities do I need to do so?

Lots of questions.

So, here are a few solutions:
1) You need to following utilities to create/modify a FAT hard drive image:
a) A utility to create an empty image
b) A utility to create an empty FAT image on that image (format)
c) A utility to copy files to that formatted image
Utilities a) and b) can be combined as one if needed.

Now, when you make a modification to one of the files on the hard drive image, you only need utility c).

There are many utilities already created for this, or you can create your own.

I have created many myself, specifically for my specific needs. An older version of this set is at http://www.fysnet.net/mtools.htm, it comes with source code and hopefully can be mostly portable. I targeted Window XP since that is my development platform.

Those whom have a copy of one of my books, specifically Volumes 1 and 2 (http://www.fysnet.net/osdesign_book_series.htm), also have more detailed and updated utilities to do this.

For example, my current work involves a FAT12 image for testing and I use the mkdosfs utility from the latter URL above.

For your question, as far as placing Grub on that image, there are utilities, including the GRUB utility itself (I presume) that will do this.

Ben
- http://www.fysnet.net/osdesign_book_series.htm

P.S. I am not a Linux user, though I have dabbled with it on occasion, though I have found that you don't need full access to the host development machine, i.e.: sudo, to simply modify an image file and execute an emulator, do you?


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: Bing [Bot], Yahoo [Bot] and 204 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