0

Photo of SD card using <code>diskutil list</code>

Do you know how I could easily and portably (ie: work in windows and mac) take a raspbian disk image from an sd card and create an image that I could send to my colleague via dropbox? I need just the boot partition and the linux partition. It needs to be no more than 2gb if possible.

I would prefer to not use a crazy work around. Just a simple shell script would be nice. Or even an rsync workflow that is understandable lol!

Please help me with this problem so I can go to sleep! lol.

THANK YOU!!!

danielbh
  • 1
  • 3

2 Answers2

0

you can create a new 2GB ext4 image, mount it, and copy all the linux partition files over. The boot partition probably is as small as it should be. Or if you put the sd card into a ubuntu computer for example, then use gparted, and see if you can resize the linux partition.

el3ien
  • 126
  • 3
-1

I just realised that provided you don't need to resize any partitions you can actually do it on the Mac.

WARNING Make doubly sure that you don't accidentally write in the wrong place.

The following script I wrote to rearrange Ubuntu MATE partitions and you should be able to adapt this to copy your data.

NOTE All care BUT no responsibility, and you really need to understand partitioning!

#!/bin/bash
# script to create a Ubunutu MATE image with properly aligned partitions
# 2015-11-06

echo
#INPUT_IMG="ubuntu-mate-15.10-desktop-armhf-raspberry-pi-2.img"
INPUT_IMG="PiMate1510back20151106_small.img"
OUTPUT_IMG="ubuntu-mate-15.10.img"

# Partition details of input image
P1START=2048
P1SIZE=131072

P2START=133120
P2SIZE=7546880

# Partition details of output image
P1NEW=8192
P2NEW=139264

# End of user configuration
#let IMG_END=$P2NEW+$P2SIZE+140000
let IMG_END=$P2NEW+$P2SIZE
echo -e $P1START - $P1NEW $P1SIZE
echo -e $P2START - $P2NEW $P2SIZE
echo -e $IMG_END

# Create an empty image file
dd if=/dev/zero of=$OUTPUT_IMG count=$IMG_END

# Create partitions
echo -e "
e 1
0C
n
$P1NEW
$P1SIZE
e 2
83
n
$P2NEW
$P2SIZE
quit" | fdisk -e  $OUTPUT_IMG

echo "Finished Create partitions"
# Copy partitions
dd if=$INPUT_IMG skip=$P1START of=$OUTPUT_IMG seek=$P1NEW count=$P1SIZE
dd if=$INPUT_IMG skip=$P2START of=$OUTPUT_IMG seek=$P2NEW count=$P2SIZE

#fdisk $OUTPUT_IMG
Milliways
  • 62,573
  • 32
  • 113
  • 225