Skip to content

Instantly share code, notes, and snippets.

@yelizariev
Last active Feb 14, 2019
Embed
What would you like to do?
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