northpole
Posts: 5
Joined: Tue May 15, 2012 4:57 pm

Copying RPi image to a smaller SD card

Mon Sep 02, 2013 10:46 am

Hi,

I have been running Raspbian image from a 16GB class 10 SD card for a while and have customized it to my preferences. Now I wanted to copy this image to a 4GB card since total used space was only 2.5GB and use the 16GB card for other purpose.

I tried using the dd command, it saves the image in 16GB size and wouldn't fit in a 4GB card. Now how do I transfer the contents to new card without going through the pain of rebuilding all packages?

Appreciate any help.

I use Ubuntu Linux.

User avatar
RaTTuS
Posts: 10559
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: Copying RPi image to a smaller SD card

Mon Sep 02, 2013 11:10 am

a couple of ways I can say right now
either
make the partitons as you want them on the new SD card and rsync the files over from the original
or shrink the 2nd partition with parted and dd the image over using the new size image values
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

plugwash
Forum Moderator
Forum Moderator
Posts: 3614
Joined: Wed Dec 28, 2011 11:45 pm

Re: Copying RPi image to a smaller SD card

Mon Sep 02, 2013 4:05 pm

Use gparted to shrink the partitions on the existing card I'd suggest making them a bit smaller than the new card to give yourself some wiggle room.
Use dd with the "count" option (note: count is measured in terms of the block size you choose) to make an image of the part of the card you want. Again it's best to leave some wiggle room and make this a bit bigger than the parition. You could try and work things out down to the sector but it's probablly not worth doing so.
Use dd to copy the image to the new card.
Use gpated to enlarge the partition on the new card to fit.

northpole
Posts: 5
Joined: Tue May 15, 2012 4:57 pm

Re: Copying RPi image to a smaller SD card

Mon Sep 02, 2013 4:42 pm

Thanks. Will try gparted and share the results.

northpole
Posts: 5
Joined: Tue May 15, 2012 4:57 pm

Re: Copying RPi image to a smaller SD card

Wed Sep 04, 2013 9:58 am

Thanks for the tip. It worked. I resized the partitions to a around 3GB. Took images of both boot & root partitions and restored them onto 4GB card using the 'partimage' tool.

Return to “General discussion”