Forked from m-ou-se/replace-debian-with-arch.txt
Last active
October 6, 2022 04:10
-
-
Save MarkWalters-dev/808e60a322d8e4ffe121229b52a91748 to your computer and use it in GitHub Desktop.
Instructions to replace a live Debian installation with Arch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I am using this to install arch on an ionos vps | |
# manjaro doesn't work beause it uses the manjaro config | |
# The debian iso doesn't have apt nor ssh. I need ssh because I can't paste in their web kvm. | |
# Using the ubuntu iso, use the help menu, enter shell | |
# In the kvm console, manually type the following: | |
useradd -m john | |
passwd | |
passwd john | |
# Then run stage1.sh on your localmachine | |
# Of course vps needs to be set in your .ssh/config | |
# and either set $password, replace it, or remove sshpass and manually type it | |
# Running this stage2.sh will wipe out all data on /dev/sda |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Now ssh into the vps | |
sshpass -p $password ssh-copy-id -i ~/.ssh/id_rsa.pub vps # for some reason it wants to send my dsa key | |
scp stage2.sh vps: | |
ssh vps chmod +x stage2.sh | |
ssh vps su - -s /bin/bash -c "/home/john/stage2.sh" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Allows you to download the same file from multiple sites. Faster download. | |
apt -y install aria2 | |
# Grab and prepare chroot to install from | |
aria2c http://mirror.arizona.edu/archlinux/iso/latest/archlinux-bootstrap-x86_64.tar.gz http://dfw.mirror.rackspace.com/archlinux/iso/latest/archlinux-bootstrap-x86_64.tar.gz http://mirrors.xmission.com/archlinux/iso/latest/archlinux-bootstrap-x86_64.tar.gz http://iad.mirror.rackspace.com/archlinux/iso/latest/archlinux-bootstrap-x86_64.tar.gz http://repo.miserver.it.umich.edu/archlinux/iso/latest/archlinux-bootstrap-x86_64.tar.gz http://mirror.math.princeton.edu/pub/archlinux/iso/latest/archlinux-bootstrap-x86_64.tar.gz | |
mount -t tmpfs none /mnt | |
cd /mnt | |
tar xf ~/archlinux-bootstrap-x86_64.tar.gz --strip-components=1 | |
cp /etc/resolv.conf etc | |
# Configure pacman | |
sed -i "s/#ParallelDownloads = 5/ParallelDownloads = 10/" /mnt/etc/pacman.conf | |
sed -i "s/#Color/Color/" /mnt/etc/pacman.conf | |
cat <<EOF > etc/pacman.d/mirrorlist | |
Server = http://mirrors.xmission.com/archlinux/\$repo/os/\$arch | |
Server = http://mirrors.rutgers.edu/archlinux/\$repo/os/\$arch | |
Server = http://dfw.mirror.rackspace.com/archlinux/\$repo/os/\$arch | |
Server = http://iad.mirror.rackspace.com/archlinux/\$repo/os/\$arch | |
Server = http://ord.mirror.rackspace.com/archlinux/\$repo/os/\$arch | |
Server = http://mirrors.ocf.berkeley.edu/archlinux/\$repo/os/\$arch | |
Server = http://mirrors.mit.edu/archlinux/\$repo/os/\$arch | |
Server = http://mirrors.kernel.org/archlinux/\$repo/os/\$arch | |
Server = http://mirrors.gigenet.com/archlinux/\$repo/os/\$arch | |
Server = https://america.mirror.pkgbuild.com/\$repo/os/\$arch | |
Server = http://mirror.arizona.edu/archlinux/\$repo/os/\$arch | |
Server = http://distro.ibiblio.org/archlinux/\$repo/os/\$arch | |
Server = https://arch.mirror.constant.com/\$repo/os/\$arch | |
EOF | |
# Prepare drive | |
# TODO: might need sfdisk here incase the table is lost... like today | |
mkswap /dev/sda1 | |
swapon /dev/sda1 | |
mkfs.ext4 /dev/sda2 | |
mount /dev/sda2 /mnt/mnt | |
# Install arch | |
usr/bin/arch-chroot . -c /bin/bash -c " | |
pacman-key --init | |
pacman-key --populate archlinux | |
usr/bin/pacstrap /mnt base openssh grub neovim linux linux-headers networkmanager git base-devel | |
genfstab /mnt > /mnt/etc/fstab | |
" | |
# Configure pacman | |
sed -i "s/#ParallelDownloads = 5/ParallelDownloads = 10/" ./mnt/etc/pacman.conf | |
sed -i "s/#Color/Color/" ./mnt/etc/pacman.conf | |
# Basic setup | |
echo vps > ./mnt/etc/hostname | |
echo "LANG=en_US.UTF-8" > ./mnt/etc/locale.conf | |
echo "john ALL=(ALL:ALL) NOPASSWD: ALL" > ./mnt/etc/sudoers.d/john | |
sed -i "s/#en_US.UTF-8/en_US.UTF-8/" ./mnt/etc/locale.gen | |
mkdir -p ./mnt/boot/grub | |
usr/bin/arch-chroot ./mnt -c /bin/bash -c " | |
ln -s /usr/share/zoneinfo/America/Boise /etc/localtime | |
locale-gen | |
useradd -m john | |
# Not using passwords so they wont be set | |
grub-mkconfig -o /boot/grub/grub.cfg | |
grub-install /dev/sda | |
systemctl enable sshd NetworkManager | |
# Install paru | |
su - john -s /bin/bash -c ' | |
git clone --depth=1 https://aur.archlinux.org/paru-bin.git | |
cd paru-bin | |
makepkg --needed --noconfirm -si | |
cd .. | |
rm -rf paru-bin | |
' | |
" | |
# Copy .ssh/authorized_keys so I can log back in | |
cp -R /home/john/.ssh ./mnt/home/john | |
chown -R 1000:1000 ./mnt/home/john | |
# Configure sshd | |
sed -i "s/^UsePAM yes/UsePAM no" ./mnt/etc/ssh/sshd_config | |
cat <<EOF >>./mnt/etc/ssh/sshd_config | |
PubkeyAuthentication yes | |
PermitRootLogin no | |
IgnoreRhosts yes | |
PasswordAuthentication no | |
MaxAuthTries 1 | |
LoginGraceTime 15s | |
EOF | |
systemctl reboot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment