shrunk / backup / write / flash / burn raspberry pi image [raspberry pi,ubuntu]

to avoid problems if you remove a sd-card:
rechtsclick auf datenträger > aushängen!!!! (wie bei windows sicher entfernen)

first do steps 1-8
then steps a-f

shrunk image on sd-card [ubuntu]
(worked only on ubuntu, failed for me on debian)
1) install gparted
2) insert sd-card (i had to insert it, eject it and insert it again)
3) start gparted
4) change on the top left to the sd-card  e.g.: /dev/sdb
5) unmount all partition on /dev/sdb
6) click the second partition (the biggest one) and change the size to minimum +200 mb
7) accept with the green button
7) wait ca. 10 minutes
8) ready

copy image from sd-card to pc
inbuild progressbar after dd version 8.24 (check it with dd --version)
sudo dd if=/dev/sdb of=/$HOME/raspbmc-dd.img bs=1M status=progress conv=notrunc,noerror

if you have a version of dd before 8.24 you have to run it without status=progress
then you can check status with iostat:
sudo apt install sysstat
iostat -d sdb

a) [ubuntu]
Open terminal(ctrl+alt+t):
sudo dd if=/dev/sdb of=/$HOME/raspbmc-dd.img bs=1M status=progressconv=notrunc,noerror
a*)[ubuntu](with progress bar for dd)
sudo apt-get install pv dialog

(sudo pv -n /dev/sdb |sudo dd of=/$HOME/raspbmc-dd.img bs=1M conv=notrunc,noerror) 2>&1 | dialog --gauge "Running dd command (cloning), please wait..." 10 70 0

a**)[debian](with progress bar for dd)
su
apt-get install pv dialog

su
(pv -n /dev/sdb | dd of=/home/freddi/raspbmc-dd.img bs=1M conv=notrunc,noerror) 2>&1 | dialog --gauge "Running dd command (cloning), please wait..." 10 70 0

shrunk image on pc [ubuntu]
b)
sudo fdisk -lu raspbmc-dd.img

you should get something like:

Device Boot             Start         End            Blocks       Id       System
raspbmc-dd.img1    8192        122879        57344        c       W95 FAT32 (LBA)
raspbmc-dd.img2   122880     13467647   6672384     83     Linux

sudo truncate --size=$[(13467647+1)*512] raspbmc-dd.img

there is a git repo with a bash script that should also be able to shrink an image:
https://github.com/Drewsif/PiShrink

format sd card [ubuntu]
c)
insert sd (if it does not show on pc: eject sd-card -> insert sd-card again
open gparted
switch on the top left to “sdb”
unmount all partitions on sdb (if that is your sd-card)
delete all partitions on sdb
accept all changes

c*)
or use https://fredfire1.wordpress.com/2013/08/13/format-sd-card-windows/ (has also linux instruction)

write the image to a smaller card
d)[ubuntu]
sudo dd if=/$HOME/raspbmc-dd.img of=/dev/sdb bs=1M status=progress

d*)[ubuntu / debian]
or use “laufwerke” sudo apt install gnome-disk-utility
then rightclick on the image and choose “open with writer of images”

d**)[ubuntu]
or use http://www.pibakery.org

d***) [Windows, Linux]
https://etcher.io/

d****)[ubuntu]
or install usb-imagewriter or install usb-creator-gtk
https://apps.ubuntu.com/cat/applications/precise/usb-imagewriter/

d*****)[ubuntu](with progress bar for dd)
sudo apt-get install pv dialog

(sudo pv -n /$HOME/raspbmc-dd.img | sudo dd of=/dev/sdb bs=1M conv=notrunc,noerror) 2>&1 | dialog --gauge "Running dd command (cloning), please wait..." 10 70 0

d******)[debian](with progress bar for dd)
su
apt-get install pv dialog

(pv -n /home/freddi/raspbmc-dd.img | dd of=/dev/sdb bs=1M conv=notrunc,noerror) 2>&1 | dialog --gauge "Running dd command (cloning), please wait..." 10 70 0

d*******) image burner script
https://github.com/freddii/rpi-image-burner

informs the os about partition changes:
e)
partprobe /dev/sdb

expand image to full sd-card [ubuntu]
f)
do not forget to resize the the image to full sd-card with sudo raspi-config after you have written it to a card.

if ubuntu does not show your sd-card:
tail -f /var/log/messages
(after that ubuntu shows the sd cards most of the time)

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s