User avatar
GeertVc
Posts: 27
Joined: Fri Apr 12, 2013 7:45 am
Location: Belgium

Duplicate an image using Win32DiskImager doesn't work

Fri Nov 09, 2018 8:40 am

I'm trying to duplicate an RPi image (based on Raspbian Lite) on another, identical SD card but that fails.

Steps taken:

  • Initial start to create the first image: download Raspbian Lite and use Win32DiskImager to create the image on a 64GB SD card (Transcend Premium 400x 64GB Class 10 micro SD XC1)
  • Among other things, expanded the filesystem through raspi-config
  • Once all the stuff I needed was on the SD card, I halted the RPi
    I removed the SD card from the RPi and used Win32DiskImager to read the card (that is, copy the whole content to an img on my PC; takes a long time for a 64GB card)
  • I took the other, identical SD card and used again Win32DiskImager to write the image from the other SD card onto the new one. When the write action started, Win32DiskImager warned me that the image to be written on the new SD card was too big but that the part that couldn't be written was not containing any data.
    ==> Question: How is that possible? Why is the image copied from my initial SD card not fitting onto the new card which is identical in size?
  • Since Win32DiskImager informed me that the "extended" part didn't contain any data, I commanded it to continue with the write action (also took a very long time.
  • The end result is that the new SD card that contained (or should contain) the image of the original SD card, didn't start up. Finally, I had to do the installation from scratch again, doubling all the actions I did for the first SD card to get my second system up and running in (hopefully) the same condition/situation as my first system.

Since it's apparently not possible to use Win32DiskImager to take an exact copy of an existing system, what tool(s) should be used then for that purpose? I'm on a Windows 10 system, but a Linux solution (dd?) is also welcome...

B.Goode
Posts: 6537
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Duplicate an image using Win32DiskImager doesn't work

Fri Nov 09, 2018 9:27 am

Raspbian has an SD Card Copier utility that will make a working copy of a microSD card for you.

User avatar
GeertVc
Posts: 27
Joined: Fri Apr 12, 2013 7:45 am
Location: Belgium

Re: Duplicate an image using Win32DiskImager doesn't work

Fri Nov 09, 2018 9:50 am

B.Goode wrote:
Fri Nov 09, 2018 9:27 am
Raspbian has an SD Card Copier utility that will make a working copy of a microSD card for you.
Can this be used from the command line too? I'm running all my RPi's headless.

User avatar
ksharindam
Posts: 76
Joined: Sat Jan 09, 2016 4:16 pm

Re: Duplicate an image using Win32DiskImager doesn't work

Fri Nov 09, 2018 9:58 am

GeertVc wrote:
Fri Nov 09, 2018 8:40 am
[*]I took the other, identical SD card and used again Win32DiskImager to write the image from the other SD card onto the new one. When the write action started, Win32DiskImager warned me that the image to be written on the new SD card was too big but that the part that couldn't be written was not containing any data.
Which you are saying identical SDCard may have few bytes of differences in size.
You have to shrink the image , then truncate it using fdisk. then you can write it using Win32DiskImager.

Simplest way to copy SDcard will be using SD card copier of Raspbian.
My Qt projects at ... https://github.com/ksharindam

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 11004
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Duplicate an image using Win32DiskImager doesn't work

Fri Nov 09, 2018 10:28 am

SD-cards always have multiple non working sectors, so "identical sized" cards, are never exactly the same size.

Herbaldew
Posts: 23
Joined: Wed Feb 07, 2018 2:59 pm
Location: US Mid-Atlantic

Re: Duplicate an image using Win32DiskImager doesn't work

Fri Nov 09, 2018 3:10 pm

I have not used the built in SD card copier, but I assume it just copies from one card to another.

If you want to have a file copy of the image to burn to a card at will, use pishrink. It will shrink the image you have already made so that it will go back on any card regardless of the small differences in size. By default, it will expand the root filesystem to fill the card on first boot similar (or maybe the same) to what happens on first boot with a fresh Rapsbian image. You can use it headless.

https://github.com/Drewsif/PiShrink

n67
Posts: 839
Joined: Mon Oct 30, 2017 4:55 pm

Re: Duplicate an image using Win32DiskImager doesn't work

Fri Nov 09, 2018 3:31 pm

SD CARD COPIER is the standard advice given by the help-givers on the forum, because, assuming you are running the Raspbian GUI, it will "just work". Be aware, though, that it take a long time to run (since it is copying zillions of files) with no good user feedback. Meaning, the few times I've run it, it sure looked like it had become "hung". You have to be patient...

That said, the best good advice is: Learn how to do this yourself. I've posted instructions on various threads showing how you can easily copy a Raspbian bootable SD card using, basically, just two "cp" commands. You will learn how to do yourself (from the command line) what SD CARD COPIER is doing for you "behind the GUI".
"L'enfer, c'est les autres"

If a post offends you, just put that poster on your foes list, and be done with it (and with them).

To do otherwise, risks being banned.

wolf.z
Posts: 85
Joined: Thu Dec 24, 2015 8:34 pm

Re: Duplicate an image using Win32DiskImager doesn't work

Fri Nov 09, 2018 5:26 pm

Summing up, quite often a direct copy with tools like win32imager fails, since SD cards of equally promoted size may have few kBytes differences in capacity. If the target is smaller in size than the source, an imager fails. Now there's two ways for a headless system for proceeding. If you want just another backup bootable SD card, use rpiclone. If you want distribute your image file, use pishrink. Both scripts are enabled to make a full copy of your SD card to smaller storage devices if data content is smaller in size than target capacity. rpiclone shrinks the "system" to a backup target's size. pishrink squeezes out every bit of unused space of an image. The workflow simply put is:

rpiclone:
clone SD card to additional SD card in SD card reader (or other storage, say USB stick)

pishrink:
create image file on additional storage device with dd or win32imager or...
shrink image file with pishrink
for creating another bootable storage from image, you'll have to involve again dd or win32imager or...

But there's much more. See:
https://github.com/billw2/rpi-clone
https://github.com/Drewsif/PiShrink

User avatar
GeertVc
Posts: 27
Joined: Fri Apr 12, 2013 7:45 am
Location: Belgium

Re: Duplicate an image using Win32DiskImager doesn't work

Fri Nov 09, 2018 6:30 pm

n67 wrote:
Fri Nov 09, 2018 3:31 pm
That said, the best good advice is: Learn how to do this yourself. I've posted instructions on various threads showing how you can easily copy a Raspbian bootable SD card using, basically, just two "cp" commands. You will learn how to do yourself (from the command line) what SD CARD COPIER is doing for you "behind the GUI".
You have 830+ posts. Tried to search but that's quite cumbersome to find any relevant ones.

Any change you can point to one of them for the corret 'cp' commands?

n67
Posts: 839
Joined: Mon Oct 30, 2017 4:55 pm

Re: Duplicate an image using Win32DiskImager doesn't work

Fri Nov 09, 2018 8:59 pm

Check out:

viewtopic.php?p=1205053

Though, I haven't seen old Marty around these parts in quite some time...
"L'enfer, c'est les autres"

If a post offends you, just put that poster on your foes list, and be done with it (and with them).

To do otherwise, risks being banned.

Milliways
Posts: 315
Joined: Fri Apr 25, 2014 12:18 am

Re: Duplicate an image using Win32DiskImager doesn't work

Sat Nov 10, 2018 6:25 am

All the comments which state SD Cards may differ by a few kb are WRONG.

SD Cards (even of the same nominal size) may differ but will ALWAYS differ by some multiple of the Erase Block Size (usually 4MB).

wolf.z
Posts: 85
Joined: Thu Dec 24, 2015 8:34 pm

Re: Duplicate an image using Win32DiskImager doesn't work

Sat Nov 10, 2018 11:41 am

OK, thank you for clarification. However, in this context, the difference makes no difference. Besides: At least there were times, when erase block sizes equalled far less multiples of the NAND page size, starting with few kB long ago.

Concerning wear optimization: Which one method cloning an SD card is best, concerning erase block sizes: The rpiclone or the diskimager way? Is there any optimization at all?

Milliways
Posts: 315
Joined: Fri Apr 25, 2014 12:18 am

Re: Duplicate an image using Win32DiskImager doesn't work

Sat Nov 10, 2018 10:55 pm

wolf.z wrote:
Sat Nov 10, 2018 11:41 am
Concerning wear optimization: Which one method cloning an SD card is best, concerning erase block sizes: The rpiclone or the diskimager way? Is there any optimization at all?
It will make little difference. Imaging programs transfer blocks, the optimum would be blocks of 4M (Erase Block Size) - but the number which need to be erased would remain the same.

Copying programs perform a number of smaller writes and MAY need need to re-write blocks, although normal buffering will minimise this, so the difference should be negligible. It is even possible, through re-allocation of space to files there could be less need to erase blocks, particularly on a SD Card with lots of free space.

LTolledo
Posts: 715
Joined: Sat Mar 17, 2018 7:29 am

Re: Duplicate an image using Win32DiskImager doesn't work

Sun Nov 11, 2018 1:56 pm

Despite what has been presented, if the algorithm used in Win32DiskImager's see a failure in size comparison, then image duplication fails.

Some may argue more.... and more.... because of this....because of that.....but:

If the condition(s) are not met, then image duplication using Win32DiskImager will always fail!
If condition(s) are met, then image duplication using Win32DiskImager will proceed.

Simple as that.....
"Don't come to me with 'issues' for I don't know how to deal with those
Come to me with 'problems' and I'll help you find solutions"

Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"

Return to “Raspbian”