Bootable USB-Stick for my OS

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
HayJayDee
Posts: 1
Joined: Wed Mar 18, 2020 2:33 pm

Bootable USB-Stick for my OS

Post by HayJayDee »

Hi guys,
for the time now I tested my OS with QEMU, but now i want to test it on real hardware. I only have CDs at home wich you can only burn 1 time, so every time I will test my OS 1 CD would be wasted. Thats why I want to make a bootable USB stick which is obviously reusable. I have no clue how to make one of these USB Sticks. I cannot find any tutorial on this and I am lost now. Can someone help me pls [-o<
User avatar
pvc
Member
Member
Posts: 201
Joined: Mon Jan 15, 2018 2:27 pm

Re: Bootable USB-Stick for my OS

Post by pvc »

Try to dd your disk image directly to your USB stick. Most BIOSes should accept it. Make sure to write it to the disk device itself, not the partirion (for example /dev/sdf and not /dev/sdf1). If you are on Windows, use a tool like Win32 Disk Imager or something like that.
The other option is to use USB -> SATA adapter on your development machine and write your image directly to HDD/SSD. Then just connect it to your target machine using SATA cable. eSATA port would be even more convenient if you have one in your target machine.
Your image size doesn't have to match your physical media size. It should just fit on it.
sunnysideup
Member
Member
Posts: 106
Joined: Sat Feb 08, 2020 11:11 am
Libera.chat IRC: sunnysideup

Re: Bootable USB-Stick for my OS

Post by sunnysideup »

Hello!

If you're using linux, dd is one of the best ways to try it out.
Suppose your OS raw binary is this : disk.img.

In the linux terminal, you can:

Code: Select all

sudo dd if=disk.img of=/dev/sdx  (Mostly sdx, where sdx = sda or sdb or sdc or .... depending on the usb disk. You can get this using lsblk)
nlg
Member
Member
Posts: 40
Joined: Mon Mar 14, 2016 5:34 am

Re: Bootable USB-Stick for my OS

Post by nlg »

to keep my USB stick usable for something other than testing my os, i installed grub2 on it and compiled my kernel in multiboot format, and you have to add an entry in the grub.cfg file like that:

Code: Select all

menuentry "Hobby OS" {
multiboot /grub2/hobbyos.bin
boot
}
and you can test multiboot image with QEMU: qemu-system-i386 -k fr -hda hda.img -kernel "C:\hobbyos\hobbyos.bin"


the main difficulty is to return to real mode if you need to start your os in real mode because the boot in multiboot mode is done in protected mode
User avatar
bzt
Member
Member
Posts: 1584
Joined: Thu Oct 13, 2016 4:55 pm
Contact:

Re: Bootable USB-Stick for my OS

Post by bzt »

Hi,
HayJayDee wrote:I have no clue how to make one of these USB Sticks.
Recently there was a thread about this.
HayJayDee wrote:I cannot find any tutorial on this and I am lost now. Can someone help me pls [-o<
Here's an example mkimg.c on how to create an image (hybrid, works for USB sticks and CDROMs too). If you're on Windows, you can also use BenLunt's tool. To write out the generated image file to an USB stick, you can use the "dd" command, or if you prefer a windowed app, use USBImager (available on Linux, Windows, MacOSX).

For a tutorial, see our wiki: Bootable Disk.

Cheers,
bzt
Post Reply