Raspberry Pi: Resize Shrink SDCard Image Clone Backup Noobs

If you own a raspberry pi, in some cases it is useful to shrink the sdcard, cause you need often not more than 8/16GB.

What do you need and how to solve shinking or extending the OS:

Hardware you need:

  • 2 empty SDCards (Source + Dest.)
  • 2 SDCard Adaptors Micro-SD to SD Fullsize
  • 2 SD-USB Card Readers, i use them for stable work, cause USB SDCard Readers on Laptops often fails (Shared Sources)
  • 1 Laptop with Ubuntu CD inside the CD-Rom or installed ubuntu with gparted
gparted raspian shrink sdcard
gparted raspian shrink sdcard
gparted shrink progress pi
gparted shrink progress pi

Howto:

  • Plug the Cards into the Adaptors and into the Readers, connect to the Laptop
  • Boot ubuntu and rund $sudo gparted
  • On the destination SDCard (/dev/sdd) create a new msdos Partition Table, (Top Menu gparted)
  • Switch on gparted to Source SDCard (/dev/sdc) where noobs / raspian is
  • Copy first the primary and the last partition to the sdd-disk on same area! (start Bootloader + end Config)
  • Create on sdd at the middle area a new “extended” partition
  • Go to Source Card sdc and Shrink the patition at the middle near to the “yellow” area!
  • Enter at Menu the green arrow to start gparted work! Take a coffee now..
  • If gparted is ready the LED Controls of the Adaptors stop blinking! Copy the shrinked partition to sdd paste it into the extended partition
  • Here you can expand the middle partition to all free grey space
  • Enter the green arrow on menu to start gparted work again..
  • If ready (LEDS not blinking), close gparted plug out the cards, and use them to boot the PI

Remark:

  •   Do ALWAYS have a 2nd working Card for the PI as FULL BACKUP!! If a Update fails you are online by restore the SDCard in 10Minutes!!!

Feedback:

  • Mail me Errors if iam wrong..

Rasperry Pi: SD Card Partitions Layout Noobs Backup Restore

If you use a raspberry pi for projects which is shipped with a 8GB SDCard it is very useful to know basics about the root, file and recovery system on the preinstalled card.

  • Major Basics about the Partitioning you find here
  • To save time the raspberry pi offers possibility to run a Full Backup if the pi is ONLINE! Cause the OS is running from RAM like Live Mode!
  • For Backup you need a USB to SDCard Reader with Adaptor Micro SD to SD, and a second SDCard i use 16GB Class 10
  • Plugin the new SDCard into the Adaptor and into the Reader and connect to the raspi USB Hub
  • Open Terminal and run  Full Backup $sudo dd if=/dev/mmcblk0 of=/dev/sda bs=1M
  • Take a Cup of Coffee and wait..~17000sec/8GB  after finish plug off the SDcard Adaptor and keep save
  • If you want to migrate from 8GB to 16Gb Card do a dd-dump and replace the Card inside the pi, after sucessful boot on the 16GB Card, you can allocate a fresh 8gb primary partition with $sudo fdisk /dev/mmcblk0 and do $sudo mkfs.ext4 /dev/mmcblk4 (cause noobs place it into 4!!)

Noobs Partition Layout:

Remark:

  • A firmware upgrade will override the recovery.img on partition_1 too
  • Prefer a full recovery reset  after a raspian version upgrade! (wheezy > jessie)
  • A Kernel Only upgrade can be runned with $sudo rpi-update NO OS UPDATE!
  • Backup can be started over SSH Login to, here you need a program called “tmux” to hold the process online on disconnect!

Amazon: Cloud Drive Sharing with NFS on Local Network as Photo Uploader Backup

Current the acd_cli tool for amazon drive mount offers no “fsid” (device /dev) point, that you cant export and share the amazon drive at your home local network.

On the latest raspberry pi OS (jessie) you can use a small workaround to get a NFS Shared Amazon Cloud Backup Uploader (needs python3.4 !)

  • install acd_cli tools, create the auth file (read) and  run $ sudo acd_cli mount /amazoncloud
  • now create a second Folder /sendtoamazon
  • install nfs-kernel-Server and share this Folder with NFS exports to your LAN
  • on the raspberrypi you can use a cron “move” Job running every 10 Minutes:
    #crontab -e
    */10 * * * * mv /sendtoamazon/* /amazoncloud
    

If you now put files on the /sendtoamazon nfs share from a PC,  the raspberry pi will grab and push it into the cloud via the “acd_cli mount” a python3 script, remark 10 minutes is ok for small files! on bigger files use over “40” minutes between pushes. If acd_cli fails check for correct python version! and last python modules!!! (python3-appdirs python3-dateutil python3-requests python3-sqlalchemy python3-pip pip3)

If you have a SMALL BANDWITH for upload you can use “rsync -avz” instead mv (move) with “throttle” option to upload files slowly!!

Links:

Howto acd_cli for amazon mount on git