User Tools

Site Tools


linux

This is an old revision of the document!


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

Mount Target System For Chroot

TARGET=/target
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/lib/pacman/*
/var/cache/pacman/pkg/*
/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 Zesty Kernel (4.9) on Xenial

echo 'deb http://archive.ubuntu.com/ubuntu/ zesty main' >> /etc/apt/sources.list.d/zesty.list
echo -e 'Package: *\nPin: release a=zesty\nPin-Priority: 100\n' >> /etc/apt/preferences.d/zesty.pref
apt-get update
apt-get install -t zesty linux-image-generic linux-generic linux-headers-generic linux-libc-dev

References:

linux.1484994414.txt.gz · Last modified: 2017/01/21 10:26 by felixonmars