Technitium DNS server zone high-availability

Install Debian 11 on Oracle Cloud

Oracle Cloud is one of the many cloud provider that is available in the market. By default, it offer few official platform images (CentOS, Oracle Linux, Ubuntu, Windows) for it compute instance.

As of now, there is no official Debian image for Oracle Cloud compute instance. Follow below step to install latest Debian on Oracle Cloud.

Credit to ishad0w for the step and installation scripts.

1. Setup Ubuntu 22.04 minimal instance Oracle Cloud. Double check the instance is running the latest software and reboot afterward.

sudo apt-get update && sudo apt-get dist-upgrade -y && sudo reboot

2. Once login again, run a bash session with root access.

sudo bash

3. Run below one-line script to remove redundant packages on the current system and create a 700MB tmpfs from the current running Ubuntu instance.

export DEBIAN_FRONTEND=noninteractive; apt-get update && apt-get install -y lsof && \
snap remove --purge oracle-cloud-agent && snap remove --purge core18 && \
apt-get purge -y $(dpkg-query -Wf '${Package}\n' | grep header) $(dpkg-query -Wf '${Package}\n' | grep -oP "^linux.*\d\d\d\d-oracle" | grep -v "$(uname -r)") linux-modules-extra-$(uname -r) lxc* lxd* vim* snapd* python* && \
apt-get -y autoremove --purge && apt-get -y autoclean && rm -rf /var/log/* /var/lib/apt/* /var/cache/apt/* && cd / && \
mount -t tmpfs -o size=700m tmpfs mnt && tar --one-file-system -c . | tar -C /mnt -x && \
mount --make-private -o remount,rw / && \
mount --move dev mnt/dev && mount --move proc mnt/proc && \
mount --move run mnt/run && mount --move sys mnt/sys && \
sed -i '/^[^#]/d;' mnt/etc/fstab && \
echo 'tmpfs / tmpfs defaults 0 0' >> mnt/etc/fstab && \
cd mnt && mkdir old_root && \
mount --make-private /

4. Create a new namespace.

unshare -m

5. Change the root mount to /mnt/old_root directory.

pivot_root . old_root

6. Optional, start SSHD on port 1022 (you need to reconnect to this ssh instance for the next steps).

iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 1022 -j ACCEPT; /usr/sbin/sshd -D -p 1022 &

7. Optional, kill all unwanted process.

for i in agetty dbus-daemon atd iscsid rpcbind unattended-upgrades; do pkill $i; done; kill 1; 

8. Un-mount disk /dev/sda1.

umount -l /dev/sda1

9. Download latest Debian 11 cloud image and flash the images files to the cloud instance's drive.

# debian 11 install (for ARM64/aarch64)
curl -L https://cloud.debian.org/cdimage/cloud/bullseye/latest/debian-11-genericcloud-arm64.tar.xz | tar -OJxvf - disk.raw | dd of=/dev/sda bs=1M && sleep 10 && sync && echo "Done!"

# debian 11 install (for AMD64/x86_64)
curl -L https://cloud.debian.org/cdimage/cloud/bullseye/latest/debian-11-genericcloud-amd64.tar.xz | tar -OJxvf - disk.raw | dd of=/dev/sda bs=1M && sleep 10 && sync && echo "Done!"

10. Force reboot the instance via oci-cli or webui.

11. Re-login via SSH connection using the "debian" username.

ssh -i oracle-cloud.key debian@instance_public_ip

12. If encounter any system local issue, fix it by reconfigure system locale and reboot the instance.

sudo dpkg-reconfigure locales

#nano /etc/default/locale

LANG=en_US.UTF-8
LANGUAGE=en_US.UTF-8
LC_ALL=en_US.UTF-8
LC_ADDRESS=en_US.UTF-8
LC_NAME=en_US.UTF-8
LC_MONETARY=en_US.UTF-8
LC_PAPER=en_US.UTF-8
LC_IDENTIFICATION=en_US.UTF-8
LC_TELEPHONE=en_US.UTF-8
LC_MEASUREMENT=en_US.UTF-8
LC_TIME=en_US.UTF-8
LC_NUMERIC=en_US.UTF-8

 

Comments