==== Create a Swap File ==== SWAPFILE=/swapfile1 dd if=/dev/zero of=$SWAPFILE bs=1024 count=1048576 mkswap $SWAPFILE chown root:root $SWAPFILE chmod 0600 $SWAPFILE swapon $SWAPFILE === Add to /etc/fstab to make it persistent === echo "$SWAPFILE none swap sw 0 0" >> /etc/fstab ==== Mount Target System For Chroot ==== TARGET=/mnt mount /dev/sdxn $TARGET mount -t proc proc $TARGET/proc mount -t sysfs sys $TARGET/sys mount -o bind /dev $TARGET/dev mount -t devpts pts $TARGET/dev/pts/ chroot $TARGET ==== Backup/Restore ==== Refer to `df` or `mount -l`, my excludes: /proc/* /dev/* /sys/* /tmp/* /mnt/* /media/* /run/* /var/lock/* /var/run/* /var/log/*.gz /var/log/**/*.gz /var/cache/pacman/pkg/* /home/**/.cache/chromium/* /home/**/.ccache/* /home/**/.avfs /home/**/.gvfs /lost+found Then just `tar cf` as root(-X the excludes rule file). Restore: Boot livecd/liveusd, `cfdisk` and `mkfs`, then mount it(see instructions above) to /target. Then: tar xf /path/to/your/backup.tar -C /target or get backup and extract in pipe: ssh user@host cat /path/to/your/backup.tar |tar x -C /target Rsync: # rsync -aAXvzP --delete / /target/ --exclude-from=/path/to/backup.excludes Get UUID using `blkid` and change `/etc/fstab` of target accordingly. If newly-installed, `chroot` into it, run `grub-install` and `update-grub`, give it a `reboot` and it would work! Else, just update UUIDs in /boot/grub/menu.lst for grub-legacy. ==== update-grub For Grub2 ==== For those who doesn't have this: grub-mkconfig -o /boot/grub/grub.cfg ==== Don't Stop at Grub Screen FOREVER (WTF Ubuntu) ==== echo "GRUB_RECORDFAIL_TIMEOUT=5" >> /etc/default/grub ==== Specify I/O Scheduler For Drive Specified By Partition UUID ==== echo "noop" > /sys/block/`readlink /dev/disk/by-uuid/$UUID|sed "s/.*\(sd[a-z]\).*/\1/"`/queue/scheduler ==== Install Artful Kernel (4.13) on Xenial ==== echo 'deb http://archive.ubuntu.com/ubuntu/ artful main' >> /etc/apt/sources.list.d/artful.list echo -e 'Package: *\nPin: release a=artful\nPin-Priority: 100\n' >> /etc/apt/preferences.d/artful.pref apt-get update apt-get install -t artful linux-image-generic linux-generic linux-headers-generic linux-libc-dev References: * http://apt-blog.net/backup_or_migrate_linux_system_using_tar * http://www.cyberciti.biz/faq/linux-add-a-swap-file-howto/ * https://axebase.net/blog/2016/12/27/zesty-kernel-in-yakkety-und-xenial/