How I Backup and Shrink My SD Card Images [Raspberry Pi | Armbian]
#Compact #Backup #Shrink #SDCards
Full steps can be found at https://i12bretro.github.io/tutorials/0735.html
--------------------------------------------------------------------
What is Win32DiskImager?
--------------------------------------------------------------------
[Win32DiskImager] is designed to write a raw disk image to a removable device or backup a removable device to a raw image file. It is very useful for embedded development, namely Arm development projects (Android, Ubuntu on Arm, etc). - https://sourceforge.net/projects/win32diskimager/
--------------------------------------------------------------------
Things You Will Need
--------------------------------------------------------------------
- A microSD card to backup https://amzn.to/36CpShC | https://amzn.to/3CXJngt | https://amzn.to/3JqyxSP
- A Linux based VirtualBox VM https://youtu.be/V4pNO3amhV4 | https://youtu.be/wIa07KhkQOg | https://youtu.be/mmTCh1NG3AM
--------------------------------------------------------------------
Creating the Base Image
--------------------------------------------------------------------
01. Insert the SD card into the Windows PC
02. Download Win32DiskImager https://sourceforge.net/projects/win32diskimager/files/Archive/Win32DiskImager-1.0.0-binary.zip/download
03. Extract the downloaded .zip file
04. Run Win32DiskImager.exe
05. Select the SD card from the Device dropdown
06. Click the folder icon ≫ Browse to a location to save the SD card image ≫ Enter a file name ≫ Click Open
07. Click the Read button at the bottom of the application window
08. Wait while the contents of the SD card image is read
--------------------------------------------------------------------
What is PiShrink?
--------------------------------------------------------------------
PiShrink is a bash script that automatically shrinks a pi image that will then resize to the max size of the SD card on boot. This will make putting the image back onto the SD card faster and the shrunk images will compress better. In addition the shrunk image can be compressed with gzip and xz to create an even smaller image. Parallel compression of the image using multiple cores is supported. - https://github.com/Drewsif/PiShrink
--------------------------------------------------------------------
Shrinking the Image Partitions
--------------------------------------------------------------------
01. Launch VirtualBox
02. Select the Linux based VM ≫ Settings ≫ Shared Folders
03. Click the Add Share icon to the right
04. Click the Folder Path dropdown ≫ Other... ≫ Browse to the folder containing the Win32DiskImager .img
05. Check the Auto-mount box, set the Mount point to /host and check the Make Permanent box ≫ Click OK
06. Right click the VM ≫ Start
07. Log into the guest OS
08. Launch a terminal and run the following commands
# install prerequisites
sudo apt install parted xz-utils
# download the pishrink script
wget -O ./pishrink.sh https://raw.githubusercontent.com/Drewsif/PiShrink/master/pishrink.sh
# make the script executable
chmod +x ./pishrink.sh
# run pishrink on the .img file
sudo ./pishrink.sh -v /host/≪%imagename.img%≫
09. PiShrink should complete in just a minute or two
10. If no errors occurred, shutdown the VM
--------------------------------------------------------------------
Compressing the Image Further
--------------------------------------------------------------------
01. Download and install 7-zip https://www.7-zip.org/download.html
02. Right click on the shrunken .img file ≫ 7-Zip ≫ Add to archive...
03. Set the Archive format to xz and the Compression level to 9 - Ultra ≫ Click OK
04. Wait while 7-Zip compresses .img file
### Connect with me and others ###
★ Discord: https://discord.com/invite/EzenvmSHW8
★ Reddit: https://reddit.com/r/i12bretro
★ Twitter: https://twitter.com/i12bretro