Jump to content

DD clone boots but files are missing and with wrong permissions, why?


Recommended Posts

Posted

Hi,

 

I've got Armbian Jessie setup as I want and wanted to clone it for backup. But when I boot the clone I get errors that lightdm can not start and my home dir is owned by root and is empty. The sudoers file is missing etc etc. Any ideas why this is happening? I've cloned Raspberry images hundreds of times and never seen this. The original card still boots perfectly?

 

I've used this line to clone (on a Ubuntu machine)

sudo  dd if=/dev/sdc of=~/sdclone.img

and when writing back

sudo  dd if=~/sdclone.img of=/dev/sdc

I've also tried with bs=4M, notrunc,noerrors etc etc

 

What should I do?

Posted

What should I do?

 

Neither trust in SD cards (crappy consumer technology and most cards die pretty early) nor dd. Always verify after reading from or writing to unreliable storage (AKA SD card).

 

It's very well known that dd fails with SD cards and you can consider yourself lucky that you realized it that early this time. Most of the times when cloning goes wrong you realize that way too late since the fs errors are too subtle to be spotted immediately. Also most people don't test their 'backups' so it's always a nice surprise when the main SD card fails to realize that the copy is also corrupted.

 

TL;DR: Most SD cards are unreliable crap. Any copy/clone/backup mechanism that does not do a verify afterwards (comparing source and destination) is also crap. Combining both attempts is known to not work reliably. :)

 

Unfortunately my tool of choice (Etcher) still doesn't provide such reliable clone/backup functionality (planned for past 1.0) but I really hope that Armbian only supports the .etch format and does not provide OS images in any other format as soon as Etcher 1.0 is released (our users waste so much time simply since they don't want to accept that most SD cards are unreliable crap, that sometimes downloads break, that their card readers corrupt data on the fly -- all of this could be addressed by switching to .etch since then both download and writing to the media are verified)

Posted

@tkaiser: OK, etcher looks nice but what do you recommend to make the image with? Because when I look inside the image I can see that files are missing already...

Posted

what do you recommend to make the image with? Because when I look inside the image I can see that files are missing already...

 

Always do a verify since otherwise you never know when your hardware and/or dd failed. The following might require an

apt-get install gddrescue p7zip

first. And then given we're talking about an SD card available as /dev/sda it's just:

root@ubuntu:~# cat /proc/partitions 
major minor  #blocks  name

 179        0    3887104 mmcblk0
 179        1    3686400 mmcblk0p1
   8        0     500224 sda
   8        1       1024 sda1

root@ubuntu:~# md5sum /dev/sda
19d9508a47b1469dc5570c2e8507112c  /dev/sda

root@ubuntu:~# ddrescue /dev/sda SD-card.img SD-card.log
GNU ddrescue 1.19
Press Ctrl-C to interrupt
rescued:   512229 kB,  errsize:       0 B,  current rate:    7798 kB/s
   ipos:   512163 kB,   errors:       0,    average rate:    7214 kB/s
   opos:   512163 kB, run time:    1.18 m,  successful read:       0 s ago
Finished                                     

root@ubuntu:~# md5sum SD-card.img
19d9508a47b1469dc5570c2e8507112c  SD-card.img

root@ubuntu:~# 7zr a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on SD-card-19d9508a47b1469dc5570c2e8507112c.7z SD-card.img

7-Zip (A) 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18
p7zip Version 9.20 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,4 CPUs)
Scanning

Creating archive SD-card-19d9508a47b1469dc5570c2e8507112c.7z

Compressing  SD-card.img      

Everything is Ok
root@ubuntu:~# ls -al SD-card-19d9508a47b1469dc5570c2e8507112c.7z
-rw-r--r-- 1 root root 192350156 Dec  8 11:35 SD-card-19d9508a47b1469dc5570c2e8507112c.7z

So you end up with a verified and compressed card image. And since MD5 hash is incuded in filename you could also check integrity after unpacking again.

 

TL;DR: Do not use dd to either write OS images (use Etcher!) or read from devices (use GNU ddrescue!). Using dd is ALWAYS wrong. Verify reading and writing stuff. And in case you plan to do anything that should serve as backup then TEST it afterwards.

Posted

An update to my issue, I tried to make a image with ddrescue from my card but the hash did not match. I then tried to make a new hash from the card and surprise surprise the hash was not the same as the first time.

I replaced the card and tried md5sum again and now I get the same hash everytime, so you were correct the SD was crap :)  And that is why I couldn't clone it either...

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines