At the time of writing, Oracle Cloud have a highly generous ‘always free’ tier that includes 4 Ampere Altra vCPUs (the same ARM Neoverse N1 core used in Graviton 2), 24 GB RAM, 200GB block device, and 2x IPv4 addresses. It can be used to create one large VM or 4x small ones.
The only available aarch64 templates are for Enterprise Linux distros (Oracle Linux or CentOS). However it is possible to convert a running VM from CentOS to Debian.
The process is as follows:
Create the VM
In the Oracle Cloud web interface,
- Create the instance using Oracle Linux 8 (it uses LVM, 7 does not).
- Create the disk to be the full free 200GB (or 199GB for a safety margin).
- Change the shape to 4c 24GB RAM
It should be done in this order, to prevent later steps from overwriting previous steps.
SSH into the VM
SSH in as
sudo su -
Create a partition for Debian
The VM is created with a 50GB disk partition, but we created a full 200GB block device. This needs some attention to fix.
# Extend the disk partition to use the full block device cfdisk # Extend the LVM PV to encompass the full physical disk partition pvresize /dev/sda3
With usual disk partitioning, we could only create a Debian partition “to the right” of this existing OS install partition. But because this is using LVM2, we can create a new partition for Debian within the LVM2 pool without worrying about having to move it leftwards at a later time.
# Create a new LV for debian lvcreate -size 50G --name debian ocivolume
After the LV partition is created we can format it and mount it:
# Create filesystem mkfs.ext4 /dev/mapper/ocivolume-debian # Mount mount /dev/mapper/ocivolume-debian /mnt
We can’t easily run the usual debian installer, but we can run debootstrap.
Debootstrap doesn’t seem to be available in the Oracle Linux package repository, but Fedora does have debootstrap packages that seem to work.
# Download and install debootstrap wget https://download-ib01.fedoraproject.org/pub/epel/8/Everything/aarch64/Packages/d/dpkg-1.18.25-12.el8.aarch64.rpm wget https://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/d/debootstrap-1.0.109-2.el7.noarch.rpm yum install ./*.rpm # Create a debian filesystem on our new mounted partition debootstrap bullseye /mnt http://deb.debian.org/debian
The resulting Debian installation isn’t specifically ready to use yet. We need to set up several things before it’s a full replacement for our current temporary Oracle Linux installation.
# Set up chroot mount --bind /dev /mnt/dev mount --bind /sys /mnt/sys mount --bind /proc /mnt/proc # Enter Debian chroot chroot /mnt
Once inside the debian installation, there are several things that should be done prior to rebooting:
- Set up system services and passwords
adduser YOURNAME apt install ssh sudo usermod -a -G sudo YOURNAME
- Copy SSH key
# Copy your SSH key mkdir -p /root/.ssh chmod 0700 /root/.ssh echo 'ssh-rsa YOUR_SSH_PUBLIC_KEY' > /root/.ssh/authorized_keys chmod 0600 /root/.ssh/authorized_keys
Alternatively you can set up the SSH key for root instead, but Debian will prevent all root SSH logins by default, even using a private key. It’s easy to enable in
/etc/sshd_config and updating the
PermitRootLogin prohibit-password line.
- Set up fstab
The existing fstab inside this container is minimal. It needs to be configured so that the Debian LV is mounted on
/etc/fstab from outside the chroot into the Debian chroot.
If you look at this file, it’s configured so that the Oracle Linux LV is to be mounted on
/ by it’s UUID. Use
blkid to find the UUID of the Debian LV, and update the fstab so that the
/ mount points to the Debian LV instead.
- Set up dhcpd/networking
This is essential so that when we reboot into this Debian, the VM gets an IP address from DHCP.
echo 'auto enp0s3' > /etc/network/interfaces.d/repair echo 'iface enp0s3 inet dhcp' >> /etc/network/interfaces.d/repair systemctl enable systemd-networkd
- Set up bootloader
The existing bootloader will load an initramfs containing the previous Oracle Linux boot process and fstab. Now that we’ve customized the fstab, we need to regenerate the initramfs at least.
Switching fully to Debian’s boot process means we get to use their kernels as well.
apt install lvm2 mount -a apt install grub-efi-arm64 linux-image-arm64 grub-install /dev/sda #dpkg-reconfigure linux-image-5.10.0-7-arm64 update-grub
This is the critical moment. If all steps are followed, the VM should reboot into the Debian LV instead of the Oracle Linux LV.
Troubleshooting after reboot
If you can’t access by SSH after about 30 seconds, perhaps the networking is broken?
Oracle Cloud has a SSH serial rescue console feature and a VNC feature where you upload a public key (or generate a new keypair) and SSH to a special address.
When using the rescue SSH feature, the generated command-line is actually not usable as-is. You have to edit it in two places to add a
-i parameter to specify the keypair as per the
“using OpenSSH on Mac OS X or Linux” documentation.
At this point you can use LVM2 commands to delete the pre-installed Oracle Linux LV and grow the Debian LV to the full 200GB size.
# Remove the Oracle Linux LV lvremove ... # Grow the Debian LV to the full size of the LVM PV lvresize ... # Grow the running ext4 filesystem inside this LV resize2fs ...