mood
Posts: 6
Joined: Mon Oct 29, 2012 9:35 pm

Downsize Debian image

Thu Nov 08, 2012 2:23 pm

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?

User avatar
topguy
Posts: 6491
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Downsize Debian image

Thu Nov 08, 2012 3:16 pm

Du you use a linux or windows machine to write your SD-cards ?

Mantrid
Posts: 33
Joined: Thu Jun 21, 2012 8:44 am
Location: Middlesbrough/Armagh

Re: Downsize Debian image

Thu Nov 08, 2012 3:31 pm

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

mood
Posts: 6
Joined: Mon Oct 29, 2012 9:35 pm

Re: Downsize Debian image

Thu Nov 08, 2012 4:22 pm

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!

Mantrid
Posts: 33
Joined: Thu Jun 21, 2012 8:44 am
Location: Middlesbrough/Armagh

Re: Downsize Debian image

Thu Nov 08, 2012 4:39 pm

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

obcd
Posts: 917
Joined: Sun Jul 29, 2012 9:06 pm

Re: Downsize Debian image

Thu Nov 08, 2012 5:23 pm

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.

Joe Schmoe
Posts: 4277
Joined: Sun Jan 15, 2012 1:11 pm

Re: Downsize Debian image

Thu Nov 08, 2012 5:37 pm

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
And some folks need to stop being fanboys and see the forest behind the trees.

(One of the best lines I've seen on this board lately)

mood
Posts: 6
Joined: Mon Oct 29, 2012 9:35 pm

Re: Downsize Debian image

Thu Nov 08, 2012 7:53 pm

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.

Mantrid
Posts: 33
Joined: Thu Jun 21, 2012 8:44 am
Location: Middlesbrough/Armagh

Re: Downsize Debian image

Fri Nov 09, 2012 3:13 pm

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

Return to “Troubleshooting”