jimmy1991
Posts: 2
Joined: Mon Oct 22, 2018 1:45 pm

SD card copying problem rpi3

Mon Oct 22, 2018 2:00 pm

hello I have an RPI 3 that I programmed to make it work out automatically without problems the last two years. but I would like to make a copy of the SD card that my rpi 3 uses

I have two identical sd cards 16gb. one is the one in my rpi every day and the other one is brand new.

The problem I have is that I have made an img file of my current SD card that is on 16gb sd card. but when i try to enter the file on my new 16gb sd card. it says there is not enough space the file is too big ... what has happened here ?? The file will fit on my original SD card but not on my new. both of them are identical as big 16gb i have tried to reformat my new SD card but same again.

how can you solve this?

how can one img file fit on one 16 sd card but not on anothor 16 sd card ... ?

both sd cards are

16gb
kingmax
micro sd 10hc

pcmanbob
Posts: 4460
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: SD card copying problem rpi3

Mon Oct 22, 2018 4:16 pm

Hi.

No 2 SD card are exactly the same size they vary but just a few bytes normally which is why you can flash your image to the new SD card,

if you are using the desktop version of raspbian stretch you could use the SD card software that you will find in the menu.

If you have a Linux based desktop pc you could shrink you image file using this

Code: Select all

#!/bin/bash

IMG="$1"

if [[ -e $IMG ]]; then
	P_START=$( fdisk -lu $IMG | grep Linux | awk '{print $2}' ) # Start of 2nd partition in 512 byte sectors
	P_SIZE=$(( $( fdisk -lu $IMG | grep Linux | awk '{print $3}' ) * 1024 )) # Partition size in bytes
	losetup /dev/loop2 $IMG -o $(($P_START * 512)) --sizelimit $P_SIZE
	fsck -f /dev/loop2
	resize2fs -M /dev/loop2 # Make the filesystem as small as possible
	fsck -f /dev/loop2
	P_NEWSIZE=$( dumpe2fs /dev/loop2 2>/dev/null | grep '^Block count:' | awk '{print $3}' ) # In 4k blocks
	P_NEWEND=$(( $P_START + ($P_NEWSIZE * 8) + 1 )) # in 512 byte sectors
	losetup -d /dev/loop2
	echo -e "p\nd\n2\nn\np\n2\n$P_START\n$P_NEWEND\np\nW\n" | fdisk $IMG
	I_SIZE=$((($P_NEWEND + 1) * 512)) # New image size in bytes
	truncate -s $I_SIZE $IMG 
else
	echo "Usage: $0 filename"
fi
# sudo ./shrink-img-file.sh name of file #
on the first boot you have to run raspi-config and expand the OS to use all the card.
Remember we want information.......................no information no help
The use of crystal balls & mind reading is not supported

jimmy1991
Posts: 2
Joined: Mon Oct 22, 2018 1:45 pm

Re: SD card copying problem rpi3

Mon Oct 22, 2018 5:46 pm

hi i using raspbian jessie and my rpi is now connected do not have any screen normally :P When I have tried to copy the content from my old SD card to my new one, I have used win32 disk imager . and i have used this site :)

https://www.howtogeek.com/341944/how-to ... backup/

pcmanbob
Posts: 4460
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: SD card copying problem rpi3

Mon Oct 22, 2018 6:11 pm

Well Jessie does not have the SD card copier if I remember correctly , so your only option is to shrink your existing image file using a Linux desktop pc and the script I posted then you can write the image to your new card and expand it.
Remember we want information.......................no information no help
The use of crystal balls & mind reading is not supported

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

Re: SD card copying problem rpi3

Mon Oct 22, 2018 6:24 pm

pcmanbob wrote:
Mon Oct 22, 2018 6:11 pm
Well Jessie does not have the SD card copier if I remember correctly , so your only option is to shrink your existing image file using a Linux desktop pc and the script I posted then you can write the image to your new card and expand it.


Raspbian Jessie was released in September 2015.

The SD Card Copier utility was added in May 2016.

Raspbian Stretch was released in August 2017.

DarkPlatinum
Posts: 404
Joined: Thu Nov 02, 2017 2:30 pm
Contact: Website

Re: SD card copying problem rpi3

Mon Oct 22, 2018 7:57 pm

Plug the SD card into a computer and use an image copier program to copy the file. It is best if you just se the sd copier program on raspbian stretch (Upgrade to it)
1 * Raspberry Pi Zero W, 1 * Raspberry Pi 2, 1 * Raspberry Pi 3 1 * Raspberry Pi 3B + :mrgreen:

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

Re: SD card copying problem rpi3

Mon Oct 22, 2018 8:21 pm

pcmanbob wrote:
Mon Oct 22, 2018 6:11 pm
Well Jessie does not have the SD card copier if I remember correctly

Mine do.
(All running Jessie; all have SD card copier)
"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.

Return to “Beginners”