Page 1 of 1
Bootable USB-Stick for my OS
Posted: Wed Mar 18, 2020 2:38 pm
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
Re: Bootable USB-Stick for my OS
Posted: Thu Mar 19, 2020 12:55 am
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.
Re: Bootable USB-Stick for my OS
Posted: Thu Mar 19, 2020 1:56 am
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)
Re: Bootable USB-Stick for my OS
Posted: Thu Mar 19, 2020 6:58 am
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
Re: Bootable USB-Stick for my OS
Posted: Thu Mar 19, 2020 7:39 am
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
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