Created
March 2, 2018 23:24
-
-
Save msebolt/223cdc40527e3bd51d505262051ef59c to your computer and use it in GitHub Desktop.
(Pi) Server Image Backup Process
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dd if=/dev/zero of=test.img bs=4096 count=10240 (can make larger) | |
fdisk test.img | |
use 'o' | |
then 'n', 'p', '1', '8192', '122879' | |
then 't', '1', 'c' | |
look up 'End' sector number of first partition, add 1 | |
then 'n', 'p', '2', 'number calculated above', default full space end | |
then 'w' | |
... | |
firstnumber=Start sector (partition 1) * 512 (unit size) | |
secondnumber=Second Start sector (partition 2) * 512 (unit size) | |
losetup -o firstnumber /dev/loop1 ./test.img | |
losetup -o secondnumber /dev/loop2 ./test.img | |
mkfs.vfat -F32 /dev/loop1 | |
mkfs.ext4 /dev/loop2 | |
mkdir one; mkdir two | |
mount -o offset=firstnumber -t vfat test.img one | |
mount -o offset=secondnumber -t ext4 test.img two | |
...mount physical copy | |
rsync -r source destination | |
...shrink file system | |
resize2fs | |
...shrink partition | |
fdisk |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment