Quick tip: Shrink 2G to fit on 1.8GB SD Card.

Raspberry Pi related support

Quick tip: Shrink 2G to fit on 1.8GB SD Card.

Postby cyber7 » 01 Jul 2015, 08:18

Hi Guys
Here is a quick tip I posted on my blog: http://aubreykloppers.wordpress.com

Here’s the thing:
You bought a Raspberry Pi, a 2GB SD card and downloaded a 2GB IMG to create your awesome project, just to find the card is too small to write the IMG file to! The reason for this is that you bought a 2GB SD card, but technically it is only about 1.8G in size! (1MB=1024768b, work it out from there!)

Software/Hardware used for this example:
    Raspberry Pi
    2GB SD Card
    RuneAudio (2GB image)
    Win32DiskImager
    I used a Generic Turnkey Linux OS to shrink the IMG.


Steps (as root):
Enable loopback:
Code: Select all
modprobe loop

Create a 1.8G image:
Code: Select all
dd bs=1M count=1700 if=/dev/zero of=NEW.img

Mount image as /dev/loop0:
Code: Select all
losetup -f --show NEW.img

Unzip 2GB image:
Code: Select all
gunzip RuneAudio_rpi_0.3-beta_20141029_2GB.img.gz

Mount image as /dev/loop1:
Code: Select all
losetup -f --show RuneAudio_rpi_0.3-beta_20141029_2GB.img

Write 2GB image onto 1.8GB image:
Code: Select all
dd if=/dev/loop1 of=/dev/loop0

Check the different sizes:
Code: Select all
fdisk -l /dev/loop1
fdisk -l /dev/loop0

Unmount the images and zip your new image:
Code: Select all
losetup -d /dev/loop0 /dev/loop1
mv NEW.img RuneAudio_rpi_0.3-beta_20141029_1.8GB.img
gzip RuneAudio_rpi_0.3-beta_20141029_1.8GB.img

You now have a 1.8G image fitting on a 2GB SD Card. Neat, hey?
To err is human, to err again is machine!
User avatar
cyber7
 
Posts: 28
Joined: 04 Feb 2014, 14:49
Location: Cape Town, South Africa

Re: Quick tip: Shrink 2G to fit on 1.8GB SD Card.

Postby ACX » 03 Jul 2015, 20:09

Hey cyber7, thank you for the tip! I'm sure it will be useful to several people.
User avatar
ACX
RuneAudio co-founder
 
Posts: 1693
Joined: 29 Nov 2013, 02:25
Location: Udine, Italy

Re: Quick tip: Shrink 2G to fit on 1.8GB SD Card.

Postby bo.vestergaard » 16 Mar 2016, 18:37

I get the following:

bo@NP550:~/Downloads$ sudo dd if=/dev/loop1 of=/dev/loop0
dd: writing to ‘/dev/loop0’: No space left on device
3891201+0 records in
3891200+0 records out
1992294400 bytes (2.0 GB) copied, 78.4085 s, 25.4 MB/s
bo@NP550:~/Downloads$

Don't know if beta 0.3 is too big to fit on a 2Gb drive. Has anyone tried this?
bo.vestergaard
 
Posts: 9
Joined: 17 Feb 2016, 22:04

Re: Quick tip: Shrink 2G to fit on 1.8GB SD Card.

Postby ingohz » 16 Mar 2016, 19:31

IMHO there is no difference between copying the original image to a smaller CF and the method explained by cyber7. The partition table remains the same in NEW.img and the end of part2 points behind the end of the CF. You won't get a clean partition this way.
  • HiFi 1: Alix/voyage-mpd, MusicalFidelity M1 DAC (RP2/HifiBerry Digi+), Accuphase DP-67, Accuphase E-212, Infinity Kappa 8.2i
  • HiFi 2: RP2/7" Touchscreen/IQaudIO Pi-DAC+, Philips Fidelio X1
ingohz
 
Posts: 45
Joined: 22 Feb 2016, 12:11

support RuneAudio Donate with PayPal


Return to Raspberry Pi

Who is online

Users browsing this forum: No registered users and 1 guest