LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 04-27-2017, 04:11 PM   #1
drmacro
LQ Newbie
 
Registered: Apr 2017
Posts: 4

Rep: Reputation: Disabled
dd command and unexpected results


This is puzzle ...at least to me.

I dd a rasbian image to a new sd card like so:

sudo dd bs=4M if=2017-04-10-raspbian-jessie.img of=/dev/sdc

First time the image is no good (gets the root partition, but no boot partition, or what's supposed to be the boot partition is full of files with garbled names).

But if I re-do the same command, it works the second time.

Regards,
Mac
 
Old 04-27-2017, 04:15 PM   #2
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,057

Rep: Reputation: Disabled
Hi and welcome to LQ.

After dd, you should issue the command:
Code:
sudo sync
to flush the write buffer. Did you do it?
 
Old 04-27-2017, 04:17 PM   #3
drmacro
LQ Newbie
 
Registered: Apr 2017
Posts: 4

Original Poster
Rep: Reputation: Disabled
yes, I use sync every time.
 
Old 04-27-2017, 04:22 PM   #4
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,057

Rep: Reputation: Disabled
Then, maybe there is an issue with the SD card itself?
 
Old 04-27-2017, 04:36 PM   #5
drmacro
LQ Newbie
 
Registered: Apr 2017
Posts: 4

Original Poster
Rep: Reputation: Disabled
Happened with multiple cards. Latest just yesterday with new card, fresh out of packaging.

Has happened on different writers and different hardware.

I'm wondering if automount is somehow trying to mount before it's done. But, then why does it work the second time...

Or maybe whatever the existing partitioning is messes it up first time around, but since after the first go the partition is screwy and the second time it works.
 
Old 04-27-2017, 04:39 PM   #6
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,057

Rep: Reputation: Disabled
In any case I would disable automount before using dd.
 
Old 04-27-2017, 04:43 PM   #7
drmacro
LQ Newbie
 
Registered: Apr 2017
Posts: 4

Original Poster
Rep: Reputation: Disabled
Yeah, it's on by default in Ubuntu and I've been too lazy to figure out how to temporarily disable it...
 
Old 04-27-2017, 06:08 PM   #8
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,128

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
Looks like a race - the second execution will read the image from page cache. Use "oflag=sync" on the dd command rather than sync afterwards - slows it down (probably what you want in this case), but always works for me.
 
Old 04-27-2017, 07:13 PM   #9
Laserbeak
Member
 
Registered: Jan 2017
Location: Manhattan, NYC NY
Distribution: Mac OS X, iOS, Solaris
Posts: 508

Rep: Reputation: 143Reputation: 143
I've had dd do some weird things before too, but it usually works fine.
 
Old 04-27-2017, 07:42 PM   #10
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,982

Rep: Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625Reputation: 3625
Just for grins.

sudo dd if=2017-04-10-raspbian-jessie.img of=/dev/sdc, sync
 
Old 04-27-2017, 09:20 PM   #11
Ztcoracat
LQ Guru
 
Registered: Dec 2011
Distribution: Slackware, MX 18
Posts: 9,484
Blog Entries: 15

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Quote:
Originally Posted by jefro View Post
Just for grins.

sudo dd if=2017-04-10-raspbian-jessie.img of=/dev/sdc, sync
Grins are generally accompanied by giggles:-
 
Old 04-27-2017, 09:31 PM   #12
Laserbeak
Member
 
Registered: Jan 2017
Location: Manhattan, NYC NY
Distribution: Mac OS X, iOS, Solaris
Posts: 508

Rep: Reputation: 143Reputation: 143
I didn't even know people still had to use sync manually. I don't think I've used it since ancient versions of SunOS (the BSD version, not Solaris SVR4 versions). I thought those problems were fixed.
 
Old 04-27-2017, 11:56 PM   #13
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-15.0
Posts: 11,057

Rep: Reputation: Disabled
Quote:
Originally Posted by jefro View Post
Just for grins.

sudo dd if=2017-04-10-raspbian-jessie.img of=/dev/sdc, sync
A semicolon instead of a comma should separate the commands, see POSIX
 
  


Reply



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
Try_TLS NO gives unexpected results ghughes5669 Linux - Server 1 08-14-2015 06:33 PM
[SOLVED] CAT giving unexpected results danielbmartin Programming 10 03-21-2013 09:33 PM
[SOLVED] unexpected results with --include-from= for rsync help please. lleb Linux - Newbie 11 02-25-2013 09:48 PM
find -mtime gives unexpected results amchargue Linux - Newbie 3 08-12-2010 04:19 PM
find command displays unexpected results helptonewbie Linux - Newbie 5 08-12-2008 02:25 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:02 AM.

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
Open Source Consulting | Domain Registration