Skip to content

Instantly share code, notes, and snippets.

@yelizariev
Last active February 14, 2019 02:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yelizariev/798667efd9a618178f572d7707da6e64 to your computer and use it in GitHub Desktop.
Save yelizariev/798667efd9a618178f572d7707da6e64 to your computer and use it in GitHub Desktop.
backup disk
# https://help.ubuntu.com/community/BackupYourSystem/TAR
# Archive
tar -cvpzf backup.tar.gz --one-file-system /
# Restore
sudo tar -xvpzf /path/to/backup.tar.gz -C /media/whatever --numeric-owner
# based on https://unix.stackexchange.com/questions/132797/how-to-dd-a-remote-disk-using-ssh-on-local-machine-and-save-to-a-local-disk
# and https://www.linuxquestions.org/questions/linux-general-1/how-to-mount-img-file-882386/
# remote backup
ssh user@remote "dd if=/dev/sda | gzip -1 -" | dd of=image.gz
# mounting
# * unzip the image.gz to image.img
gunzip < image.gz > image.img
# * calculate offset
fdisk -l image.img
# Check for start start sector and sector size. Multiply those, e.g. 2048 * 512
sudo mount -o loop,offset=1048576 image.img /path/to/mount-point/
#
# https://help.ubuntu.com/community/Grub2/Installing#via_ChRoot
# https://ubuntuforums.org/showthread.php?t=1692144
sudo mount /dev/sda1 /mnt
sudo mount --bind /dev /mnt/dev
sudo mount --bind /proc /mnt/proc
sudo mount --bind /sys /mnt/sys
sudo chroot /mnt
update-grub
sudo grub-install /dev/sda
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment