1/28/2016 - 3:27 PM

Instructions to replace a live Debian installation with Arch

Instructions to replace a live Debian installation with Arch

# Download latest archlinux bootstrap package, see
wget '*-x86_64.tar.gz'

# Make sure you'll have enough entropy for pacman-key later.
apt-get install haveged

# Install the arch bootstrap image in a tmpfs.
mount -t tmpfs none /mnt
cd /mnt
tar xvf ~/archlinux-bootstrap-*-x86_64.tar.gz --strip-components=1
cp -r /root/.ssh root
cp /etc/resolv.conf etc
vi etc/pacman.d/mirrorlist # Uncomment one or more mirrors.

# Swap / and /mnt
mount --make-rprivate /
for i in run proc sys dev; do mount --move /$i /mnt/$i; done
pivot_root . mnt
exec chroot .

# Setup pacman and install the tools we need.
pacman-key --init
pacman-key --populate archlinux
pacman -Sy psmisc openssh

# Restart sshd in the new root.
cp /mnt/etc/ssh/* /etc/ssh
killall -HUP sshd
# You'll have to reconnect at this point. Let's hope it works.

# Make sure nothing is using the old filesystem anymore.
killall haveged agetty cron rsyslogd systemd-udevd systemd-journald
systemctl daemon-reexec

# Unmount the old filesystem.
umount /mnt

# If umount complains that /mnt is still busy, install and use
# lsof to check which other processes you need to kill:
#   pacman -S lsof
#   lsof +f -- /mnt
#   kill ...
#   umount /mnt

# Install arch as usual: (See
mkfs.ext4 /dev/xvda2
mount /dev/xvda2 /mnt
pacstrap /mnt base openssh grub vim
genfstab /mnt >> /mnt/etc/fstab
cp -r /root/.ssh /mnt/root
arch-chroot /mnt
echo archbox > /etc/hostname
ln -s /usr/share/zoneinfo/Europe/Amsterdam /etc/localtime
vim /etc/locale.gen
echo LANG=en_GB.UTF-8 > /etc/locale.conf
mkinitcpio -p linux
grub-mkconfig -o /boot/grub/grub.cfg
grub-install /dev/... # No need for grub-install when Xen Pygrub is used.
systemctl enable sshd
vim /etc/netctl/internet
netctl enable internet
systemctl reboot # And pray it'll boot.