Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

burning bin files to raw hard disk on ubantu linux

Status
Not open for further replies.

bigdogguru

Administrator
Joined
Mar 12, 2010
Messages
9,831
Helped
2,348
Reputation
4,690
Reaction score
2,274
Trophy points
1,413
Location
Southwest, USA
Activity points
62,510
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

Full Member level 5
Joined
Oct 18, 2009
Messages
286
Helped
5
Reputation
10
Reaction score
5
Trophy points
1,318
Location
India,kakinada
Activity points
3,122
i tried the dd command but i got the message

'dev/sda' permission denied:
 

bigdogguru

Administrator
Joined
Mar 12, 2010
Messages
9,831
Helped
2,348
Reputation
4,690
Reaction score
2,274
Trophy points
1,413
Location
Southwest, USA
Activity points
62,510
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
Joined
Oct 18, 2009
Messages
286
Helped
5
Reputation
10
Reaction score
5
Trophy points
1,318
Location
India,kakinada
Activity points
3,122
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

Administrator
Joined
Mar 12, 2010
Messages
9,831
Helped
2,348
Reputation
4,690
Reaction score
2,274
Trophy points
1,413
Location
Southwest, USA
Activity points
62,510
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

Full Member level 5
Joined
Oct 18, 2009
Messages
286
Helped
5
Reputation
10
Reaction score
5
Trophy points
1,318
Location
India,kakinada
Activity points
3,122
Screenshot.png
 

bigdogguru

Administrator
Joined
Mar 12, 2010
Messages
9,831
Helped
2,348
Reputation
4,690
Reaction score
2,274
Trophy points
1,413
Location
Southwest, USA
Activity points
62,510
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.
 

bigdogguru

Administrator
Joined
Mar 12, 2010
Messages
9,831
Helped
2,348
Reputation
4,690
Reaction score
2,274
Trophy points
1,413
Location
Southwest, USA
Activity points
62,510
Ok, I just want to make sure you were actually booting off /dev/sdb.

So can you boot off of /dev/sda?
 

sagar474

Full Member level 5
Joined
Oct 18, 2009
Messages
286
Helped
5
Reputation
10
Reaction score
5
Trophy points
1,318
Location
India,kakinada
Activity points
3,122
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

Full Member level 5
Joined
Oct 18, 2009
Messages
286
Helped
5
Reputation
10
Reaction score
5
Trophy points
1,318
Location
India,kakinada
Activity points
3,122
yes this is my test code
Code:
BITS 16

jmp start			;jump to actual executing code

;------------------------------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,
read_sectors    db 'Press any key to read sector',13,10,0
read_success  	db 'Sector read successful....',13,10,0,


;------------------------------Main Bootloading process starts hear---------------
	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
Screenshot-1.png


but it is not working with real hardisk
 

bigdogguru

Administrator
Joined
Mar 12, 2010
Messages
9,831
Helped
2,348
Reputation
4,690
Reaction score
2,274
Trophy points
1,413
Location
Southwest, USA
Activity points
62,510
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.
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top