Page 1 of 1

Downsize Debian image

Posted: Thu Nov 08, 2012 2:23 pm
by mood
I'd like to transfer my rpi debian syatem from a 8 Gb sd card to a 4Gb card.
Any pointers on how to do this?

Re: Downsize Debian image

Posted: Thu Nov 08, 2012 3:16 pm
by topguy
Du you use a linux or windows machine to write your SD-cards ?

Re: Downsize Debian image

Posted: Thu Nov 08, 2012 3:31 pm
by Mantrid
if linux just run gparted to resize your file system partition (it'll be the larger one), no idea how on windows or mac i'm afraid

then just dd if=<for each sd partition> of=<somefilename> for both your partitions then dd them back across to the new sd card at a guess

Re: Downsize Debian image

Posted: Thu Nov 08, 2012 4:22 pm
by mood
topguy wrote:Du you use a linux or windows machine to write your SD-cards ?
I use win32duskimager. I can boot my machine with ubuntu, but I'm not an expert!

Re: Downsize Debian image

Posted: Thu Nov 08, 2012 4:39 pm
by Mantrid
can probably run gparted on the pi itself to resize the bigger partition, not sure how you'd then transfer these partitions to a smaller card, unless you plug the card into the pi using a usb card reader

I've only done pi card stuff with my opensuse machine I'm afraid, Windows is my primary OS but it just seemed easier the other way, I'm sure someone will know

Re: Downsize Debian image

Posted: Thu Nov 08, 2012 5:23 pm
by obcd
I think you can only run gparted on a partition that isn't mounted.
So, running ubuntu on your pc, connecting the sd card and unmounting the partition should work.
You can shrink the partition with gparted, and copy it with dd.

Re: Downsize Debian image

Posted: Thu Nov 08, 2012 5:37 pm
by Joe Schmoe
If I were doing this, I'd just do it the old-fashioned way:

0) Connect the USB card reader to the Pi and boot the Pi.
1) Setup the target card (fdisk, mke2fs)
2) Use "cp -a" to copy the files from the FAT partition to the card
3) Use "cp -a" to copy the files from the ext4 partition to the card

Re: Downsize Debian image

Posted: Thu Nov 08, 2012 7:53 pm
by mood
Joe Schmoe wrote:If I were doing this, I'd just do it the old-fashioned way:

0) Connect the USB card reader to the Pi and boot the Pi.
1) Setup the target card (fdisk, mke2fs)
2) Use "cp -a" to copy the files from the FAT partition to the card
3) Use "cp -a" to copy the files from the ext4 partition to the card
Sorry, I didn't make clear, I've only one (built-in) SD card reader.

Re: Downsize Debian image

Posted: Fri Nov 09, 2012 3:13 pm
by Mantrid
in that case log into ubuntu and run gparted on your sd card ("fdisk -l" will show you what drive you're looking for), make sure you make your filesystem (larger partition) as small as it can get, within reason, maybe a few hundred meg over what's in use, as your new sd card won't be EXACTLY 4gb

after resizing the drive go into a directory and type

dd if=/dev/sdd1 (for example, depending on your drive name) of=boot (or some descriptive name)
dd if=/dev/sdd2 of=filesystem

then put in your 4gb card and switch the if and of values listed above around, run gparted again and expand your filesystem partition to fill your new card

that oughta do it i think, if I'm wrong someone can correct me but it should at least give you a basic idea of what'll be involved