Creating Bootable USB from ISO

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.
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Creating Bootable USB from ISO

Post by Octacone »

Hey everyone. I need a quick tip.

How do I create a bootable USB from my bootable ISO file that contains GRUB.
I tried dd, nothing, tried rufus nothing, tried just iso file nothing. Can't get my bootable ISO file to boot on real hardware.
I just want to insert my USB with iso image of my OS on it and press enter to select my menuenetery and boot my OS.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
SpyderTL
Member
Member
Posts: 1074
Joined: Sun Sep 19, 2010 10:05 pm

Re: Creating Bootable USB from ISO

Post by SpyderTL »

Blocks are typically larger on a CD than they are on any other device, so just simply copying bytes from one to another probably won't work. You'll need to adjust your grub configuration and build a new disk image with a different file system to be able to boot from a USB drive.

You may, however, be able to mount both file systems and copy the files from your CD image to your USB drive.
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: Creating Bootable USB from ISO

Post by Octacone »

SpyderTL wrote:Blocks are typically larger on a CD than they are on any other device, so just simply copying bytes from one to another probably won't work. You'll need to adjust your grub configuration and build a new disk image with a different file system to be able to boot from a USB drive.
Right now I don't have any file system implementations. I am using RAW as my format. When I build my OS grub outputs single .iso file that contains my os and grub2 bootloader, I can boot that with qemu and bochs but can't boot it off my USB (aka real hardware).
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
SpyderTL
Member
Member
Posts: 1074
Joined: Sun Sep 19, 2010 10:05 pm

Re: Creating Bootable USB from ISO

Post by SpyderTL »

GRUB probably expects a partition table if you are booting from a hard drive, so copying a CD image will probably never work.

You can either configure GRUB to build you a disk image (instead of an ISO file), or you can copy your ISO file to your formatted USB drive, and install GRUB on it, as well, and have GRUB mount your ISO file at boot time, and run the other GRUB boot loader.

I'm not a GRUB expert, though. Maybe someone else can be more helpful.
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
Octocontrabass
Member
Member
Posts: 5587
Joined: Mon Mar 25, 2013 7:01 pm

Re: Creating Bootable USB from ISO

Post by Octocontrabass »

If you're creating the ISO with grub-mkrescue, it should be a hybrid ISO image and "just work" when you copy it to your flash drive with dd.

Does the ISO contain a MBR? If not, it isn't a hybrid ISO and can't be used on a flash drive. Verify using a hex editor or xxd or something.

Are you copying it to the correct device with dd? If you send it to /dev/sdb1 instead of /dev/sdb, it won't work.

Is your hardware capable of booting from USB? Try booting some other hybrid ISO to see if there might be some compatibility issues. (This is pretty unlikely to be the problem; isohybrid is very good at what it does.)
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: Creating Bootable USB from ISO

Post by Octacone »

SpyderTL wrote:GRUB probably expects a partition table if you are booting from a hard drive, so copying a CD image will probably never work.

You can either configure GRUB to build you a disk image (instead of an ISO file), or you can copy your ISO file to your formatted USB drive, and install GRUB on it, as well, and have GRUB mount your ISO file at boot time, and run the other GRUB boot loader.

I'm not a GRUB expert, though. Maybe someone else can be more helpful.
Hmm, to create a disk image. :idea: I can try that and then just use "dd".
Great idea.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: Creating Bootable USB from ISO

Post by Octacone »

Octocontrabass wrote:If you're creating the ISO with grub-mkrescue, it should be a hybrid ISO image and "just work" when you copy it to your flash drive with dd.

Does the ISO contain a MBR? If not, it isn't a hybrid ISO and can't be used on a flash drive. Verify using a hex editor or xxd or something.

Are you copying it to the correct device with dd? If you send it to /dev/sdb1 instead of /dev/sdb, it won't work.

Is your hardware capable of booting from USB? Try booting some other hybrid ISO to see if there might be some compatibility issues. (This is pretty unlikely to be the problem; isohybrid is very good at what it does.)
MBR (Master Boot Record), I don't see MBR anywhere around, I only have: BasicOS.bin, boot and boot.catalog files on my USB.
Yeah, I am sure about my USB location (verified w/ GParted).
Both my PC and laptop can boot operating systems off an USB drive, not a compatibility issue, USB booting is enabled inside BIOS.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
Octocontrabass
Member
Member
Posts: 5587
Joined: Mon Mar 25, 2013 7:01 pm

Re: Creating Bootable USB from ISO

Post by Octocontrabass »

The MBR is not a file in the ISO, it's the first 512 bytes of the ISO.
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: Creating Bootable USB from ISO

Post by Octacone »

Octocontrabass wrote:The MBR is not a file in the ISO, it's the first 512 bytes of the ISO.
:oops: :oops: :oops:
This makes me feel noobish. I thought you were talking about MBR bootloader that Windows uses. *Insert facepalm here*

I guess I will have to use xxd and see what does my iso look like.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
max
Member
Member
Posts: 616
Joined: Mon Mar 05, 2012 11:23 am
Libera.chat IRC: maxdev
Location: Germany
Contact:

Re: Creating Bootable USB from ISO

Post by max »

I do it like this, works quite well: https://github.com/maxdev1/ghost/blob/m ... SBSTICK.md
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: Creating Bootable USB from ISO

Post by Octacone »

max wrote:I do it like this, works quite well: https://github.com/maxdev1/ghost/blob/m ... SBSTICK.md
Thank you max, definitely going to try that one out.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
Ch4ozz
Member
Member
Posts: 170
Joined: Mon Jul 18, 2016 2:46 pm
Libera.chat IRC: esi

Re: Creating Bootable USB from ISO

Post by Ch4ozz »

Rufus works perfectly fine for me.
Maybe check your grub version?
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: Creating Bootable USB from ISO

Post by Octacone »

max wrote:I do it like this, works quite well: https://github.com/maxdev1/ghost/blob/m ... SBSTICK.md
@max
I don't own a Mac. I can not use those commands with Linux.
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
Octacone
Member
Member
Posts: 1138
Joined: Fri Aug 07, 2015 6:13 am

Re: Creating Bootable USB from ISO

Post by Octacone »

Ch4ozz wrote:Rufus works perfectly fine for me.
Maybe check your grub version?
GRUB2, what settings do you use?
OS: Basic OS
About: 32 Bit Monolithic Kernel Written in C++ and Assembly, Custom FAT 32 Bootloader
User avatar
Ch4ozz
Member
Member
Posts: 170
Joined: Mon Jul 18, 2016 2:46 pm
Libera.chat IRC: esi

Re: Creating Bootable USB from ISO

Post by Ch4ozz »

octacone wrote:
Ch4ozz wrote:Rufus works perfectly fine for me.
Maybe check your grub version?
GRUB2, what settings do you use?
I used standard settings.
Did you change the boot order in bios?
Booting from USB is usually the last option, before it is HDD, DVD/CD
Post Reply