User Tools

Site Tools


Create a Swap File

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

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


Refer to `df` or `mount -l`, my excludes:


Then just `tar cf` as root(-X the excludes rule file).


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 -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 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


linux.txt · Last modified: 2020/05/11 13:15 by felixonmars