LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-14-2014, 09:25 AM   #1
daf1kpp
LQ Newbie
 
Registered: Feb 2013
Posts: 19

Rep: Reputation: Disabled
Using DD to write some data to USB flash memory


Hi. I want to write some data (mbr) to first sector (sector number 0) of USB memory drive.

I do such command:

Code:
dd if=~/file_mbr_copy of=/dev/sdc3 seek=0 bs=512 count=1
By default when no (seek=0) it chooses fist sector of partition (in my case it's sector number 128, VBR). When seek=0 then it also chooses first sector of partition (first sector of logical drive = sector number 128), so it's same as above.

How to force DD to use first sector (sector number 0, MBR) of physical drive ?

Thank you for help.
 
Old 01-14-2014, 10:34 AM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 14,932

Rep: Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520
To write data to the MBR you need to specify the device vs a partition.

dd if=~/file_mbr_copy of=/dev/sdc bs=512 count=1

This will overwrite both the MBR and the partition table. Make sure this what you want to accomplish and verify that sdc is the correct device.

Last edited by michaelk; 01-14-2014 at 10:40 AM.
 
2 members found this post helpful.
Old 01-14-2014, 12:08 PM   #3
qrange
Member
 
Registered: Jul 2006
Location: Belgrade, Yugoslavia
Distribution: Debian stable, amd64
Posts: 805

Rep: Reputation: 32
if you don't want to overwrite partition table, use 'bs=446 count=1' instead.
 
2 members found this post helpful.
Old 01-14-2014, 12:13 PM   #4
daf1kpp
LQ Newbie
 
Registered: Feb 2013
Posts: 19

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
To write data to the MBR you need to specify the device vs a partition.

dd if=~/file_mbr_copy of=/dev/sdc bs=512 count=1

This will overwrite both the MBR and the partition table. Make sure this what you want to accomplish and verify that sdc is the correct device.
Thank you for it, I didn't know "sdc" is referencing physical drive and sdc1/sdc2/... are referencing partitions. Thank you!


Quote:
Originally Posted by qrange View Post
if you don't want to overwrite partition table, use 'bs=446 count=1' instead.
Yea, I know about that, but it's original copy of MBR's taht drive so all will be ok by loading fully sector of 512 byte, but thank you for noticing me.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to write data into memory location in 32-bit microcontrollers grsandeep85 Linux - Embedded & Single-board computer 2 03-04-2010 07:27 PM
USB Flash Drive, write protect, and flash file system questions storkus Linux - Hardware 4 12-01-2008 05:32 AM
Cannot write to a USB flash disk yiux Linux - Hardware 2 04-30-2007 12:33 AM
USB memory, Compact Flash, Memory Stick energiza Linux - Hardware 2 08-22-2006 10:29 PM
Missing memory in USB stick, flash memory, removable hd etc bamboo_spider Linux - Newbie 3 06-14-2006 06:39 PM


All times are GMT -5. The time now is 11:56 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration