# burning bin files to raw hard disk on ubantu linux

Status
Not open for further replies.

#### sagar474

##### Full Member level 5
I need to burn the bin file directly to hard disk.

#### bigdogguru

Try this or some variant of:

Code:
dd if=/home/file.bin of=/dev/sdb

You may need to set various options to obtain the desired result.

Learn the DD command

5 Useful Linux DD Command Examples

Wiki dd (Unix)

dd is a fantastic command, I've used it on all types UNIX and Linux platforms. It's a great way to make an exact copy of a harddrive for cloning.

Hope the info helps.

Last edited:
sagar474

### sagar474

Points: 2

#### sagar474

##### Full Member level 5
i tried the dd command but i got the message

'dev/sda' permission denied:

#### bigdogguru

Be careful!

The dd command is very powerful and can wipe all contents of your drive, if used inappropriately.

Before going further, first please tell me what the "bin" file is exactly. Is it an operating system, a harddrive backup, a boot disk or something else.

Your current OS is Ubuntu correct? How many drives are in your system?

'dev/sda' permission denied:

This message indicates two things:

1. You entered the something like the follow command "dd if=/home/file.bin of=/dev/sda" ,
which means roughly take the bin file and copy it over the disk you booted from, replacing its contents with the contents of the bin file.

2. You did not have root permissions, probably a good thing this time.

BigDog

#### sagar474

##### Full Member level 5
the bin file is a boot sector program which is of 512 bytes.

i need to write the contents of the bin file to first sector of an empty hard disk.

the command i used is dd if=/home/myboot.bin of=dev/ada

I'm having 2 hard disks.

the hard disk that I'm trying to use is fully empty. not formatted no partitions.

#### bigdogguru

Are you sure the /dev/sda is not your disk with your OS? If it is you'll wipe out the boot sector of you OS disk.

If your sure it's the disk you want to write to here is the general format of the command you'll use for writing the myboot.bin to the boot sector of a harddrive:

dd if=/home/myboot.bin of=/dev/sda bs=512 count=1

You'll have to either sudo or login as root before issuing the command.

Here are a few useful links using dd with boot sectors:

Boot Sector Management

In this example, sda is the source. sdb is the target. Do not reverse the intended source and target. Surprisingly many people do. notrunc means to not truncate. noerror means to keep going if there is an error. Normally dd stops at any error. if you have a question about a hard drive on whether or not it works, you can try to use it as the source drive for the dd command. You should get an error if it is not working. target drives need to be really messed up to give an error in dd.

Copy MBR only of a hard drive:

dd if=/dev/sda of=/home/sam/MBR.image bs=446 count=1

this will copy the first 446 bytes of the hard drive to a file. If you haven't already guessed, reversing the objects of if and of, in the dd command line reverses the direction of the write.

Wipe a hard drive of all data (you would want to boot from a cd to do this)

http://www.efense.com/helix is a good boot cd

The helix boot environment contains the DoD version of dd called dcfldd. It works the same way, but is has a progress bar.

dd if=/dev/zero of=/dev/sda conv=notrunc

Do Eveything With DD

Good Luck and Be Careful!

sagar474

### sagar474

Points: 2

#### bigdogguru

Are you logged in as root or with root privileges?

If not use sudo:

sudo dd if=/home/sagar/myboot.bin of=/dev/sda bs=512 count=1

The system will then ask you to enter the root password before running the command.

Also, you are sure your not writing to your current OS harddrive?

---------- Post added at 19:25 ---------- Previous post was at 19:13 ----------

Before you go any further run this command:

sudo fdisk -l

It will list all installed drives formatted or not and their mounting points.

Send me a screen capture of the outputted list.

sagar474

### sagar474

Points: 2

#### bigdogguru

Ok, I just want to make sure you were actually booting off /dev/sdb.

So can you boot off of /dev/sda?

sagar474

### sagar474

Points: 2

#### sagar474

##### Full Member level 5
no i cant run the boot sector at start up
the program working in qemu but it is not working in real hard disk.

sagar474

### sagar474

Points: 2

#### sagar474

##### Full Member level 5
yes this is my test code
Code:
BITS 16

;------------------------------message set to display on the screen--------------
wellcome_msg db 'wellcome to Sagar cool new operating system',13,10,0,
reboot_msg db   'Your system is going to reboot now....',13,10,0,
reboot_key	db 'Press any key to reboot',13,10,0,
resetmsg	db 'Press any key to reset flopy',13,10,0,
reset_success 	db 'reset successful',13,10,0,

start:
mov ax, 07C0h		; Set data segment to where we're loaded
mov ds, ax		;
mov ax,9000h		;initlise the stack
mov ss,ax		;
mov sp,100h		;

mov al,41h
mov ah,0eh
int 10h

times 510-($-$\$) db 0	; Pad remainder of boot sector with 0s
dw 0xAA55		; The standard PC boot signature

out put of the program

but it is not working with real hardisk

#### bigdogguru

I believe I might still have the code for a bootloader I wrote a few years back. I've only tested it on CF, SD and MMCs. But in theory it should work fine on a standard HD. If I find it I'll upload the source here for you.

sagar474

### sagar474

Points: 2
Status
Not open for further replies.

Replies
8
Views
7K
Replies
17
Views
7K
Replies
7
Views
10K
Replies
1
Views
1K
Replies
9
Views
4K