OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 8:12 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: How to copy Bootloader to first sector of USB Flash Drive.
PostPosted: Sat Aug 02, 2014 5:11 am 
Offline
Member
Member
User avatar

Joined: Mon Jun 16, 2014 5:59 am
Posts: 543
Location: Shahpur, Layyah, Pakistan
I want to make a boot loader to load files from USB Stick. How do I copy bootloader to first sector of USB flash?
"dd if=bootload.bin of=/dev/sdb" not working on real hardware.


Top
 Profile  
 
 Post subject: Re: How to copy Bootloader to first sector of USB Flash Driv
PostPosted: Sat Aug 02, 2014 7:41 am 
Offline
Member
Member

Joined: Tue Nov 08, 2011 11:35 am
Posts: 453
It's very unlikely that `dd' is not working. IMHO, it actually works (i.e. writes your file to block device `sdb') but something goes wrong at a further stage: BIOS wrongly detects boot type emulation for your flash drive (USB-HDD vs USB-FDD == superfloppy) or your bootloader is doing something wrong.


Top
 Profile  
 
 Post subject: Re: How to copy Bootloader to first sector of USB Flash Driv
PostPosted: Sat Aug 02, 2014 8:25 am 
Offline
Member
Member
User avatar

Joined: Mon Jun 16, 2014 5:59 am
Posts: 543
Location: Shahpur, Layyah, Pakistan
Nable wrote:
It's very unlikely that `dd' is not working. IMHO, it actually works (i.e. writes your file to block device `sdb') but something goes wrong at a further stage: BIOS wrongly detects boot type emulation for your flash drive (USB-HDD vs USB-FDD == superfloppy) or your bootloader is doing something wrong.

My bootloader simply prints something. I know hot to emulate USB-Floppy, But How do i emulate USB-HDD or USB CD or DVD.


Top
 Profile  
 
 Post subject: Re: How to copy Bootloader to first sector of USB Flash Driv
PostPosted: Sat Aug 02, 2014 10:59 am 
Offline
Member
Member

Joined: Tue Nov 08, 2011 11:35 am
Posts: 453
muazzam wrote:
My bootloader simply prints something. I know hot to emulate USB-Floppy, But How do i emulate USB-HDD or USB CD or DVD.
I mean that BIOS emulates FDD/HDD for you so you can read from USB devices via INT 0x13 interface. As I've seen in some BIOSes, by default they choose emulation types for flash drives depending on drive size. So if you attach ~large flash stick then BIOS may set emulation type to USB-HDD and then refuse to boot from it if 0th sector doesn't contain valid MBR with 1 bootable partition entry. Forcing the correct mode (HDD if you have MBR and partitions, FDD if filesystem begins from 0th sector) helped me several times.


Top
 Profile  
 
 Post subject: Re: How to copy Bootloader to first sector of USB Flash Driv
PostPosted: Thu Aug 14, 2014 11:05 am 
Offline
User avatar

Joined: Wed Aug 13, 2014 1:15 pm
Posts: 15
If using linux:
1. Find your output device (usb flash drive in your case) by looking into /dev while inserting and removing drive
2. 'dd if=<path to your mbr flat binary file> of=<path to the usb drive e.g. /dev/sdb> bs=512 count=1'

If you are using VMware emulating Linux on a Windows machine:
1. Forget about it, just brings you pain.

If you are using windows:
1. Download dd for windows here http://uranus.chrysocome.net/linux/rawwrite/
2. Find your output device (usb flash drive in your case) by using 'dd --list'
3. 'dd if=<path to your mbr flat binary file> of=<path to the usb drive e.g. \\.\PhysicalDrive2> bs=512 count=1 conv=notrunc'

Be very careful when using dd !

Regards,
StaringL


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: SemrushBot [Bot] and 66 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