# should works on any cloud-init enabled hypervisor (openstack.. ) | |
# start from a normal ubuntu 20.04 install as minimal was not available for ARM64 | |
# Since ARM64 machines has higher RAM, Shrinking is desired but not necessary. Instead we will increase tmpfs to 1700MB | |
# Getting root (if sudo -i doesn't work then set a root password beforehand using 'sudo passwd root' | |
sudo -i | |
# make sure we are on the highest kernel, so we can delete all the others ... | |
sudo apt update && sudo apt dist-upgrade -y && sudo apt install lsof && sudo reboot | |
# snap removal didn't work so proceed without it. | |
sudo snap remove --purge oracle-cloud-agent && sudo snap remove --purge core18 | |
sudo apt purge -y $(dpkg-query -Wf '${Package}\n' | grep header) $(apt list --installed | grep -oP "^linux.*\d\d\d\d-oracle" | grep -v "$(uname -r)") linux-modules-extra-$(uname -r) lxc* lxd* vim* && sudo apt -y autoremove && sudo apt -y autoclean && sudo apt -y clean | |
sudo rm -rf /var/log/* /var/lib/apt/lists/* | |
# use df to check the size. It should be now ~1100MB. If it is higher than 1700 MB then increase the size below | |
# make sure you have root here | |
cd / | |
mount -t tmpfs -o size=1700m 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 / | |
unshare -m | |
pivot_root . old_root | |
# commands below open 1022 port a ssh port. Please ensure the port you select is open under Oracle's VNIC | |
/usr/sbin/sshd -D -p 1022 & | |
iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 1022 -j ACCEPT | |
# reconnect on port 1022: I kept the old putty session (on port 22) open and it didn't disconnect | |
# now the root storage is the RAM | |
pkill agetty | |
pkill dbus-daemon | |
pkill atd | |
pkill iscsid | |
pkill rpcbind | |
pkill unattended-upgrades | |
kill 1 | |
# check with "lsof /old_root" that there is no remaining process | |
umount -l /dev/sda1 | |
# check : | |
df -h | |
lsblk | |
# the disk should be unmount ; for me lsblk showed a /dev/sda1 partiion but it went well. | |
# now, just copy the debian cloud image on the disk. | |
# I wanted an ARM64 image and Debian 10 , therefore I used this one https://cloud.debian.org/cdimage/cloud/buster/latest/debian-10-generic-arm64.tar.xz | |
curl -L https://cloud.debian.org/cdimage/cloud/buster/latest/debian-10-generic-arm64.tar.xz | tar -OJxvf - disk.raw | dd of=/dev/sda bs=1M | |
sync | |
reboot | |
# reboot command didn't work and returned an error "running in chroot, ignoring request" ; I tried exiting as they told here (https://bbs.archlinux.org/viewtopic.php?id=184076) but it was of no use | |
# I forced rebooted it from the Oracle instances' GUI and it seemed stuck on "STOPPING." But after an hour I noticed that the VM was rebooted and running. | |
# I was able to login with the same public key as original ubuntu, but the username that worked was debian | |
# SUCCESS!! I checked with lsb_release -a and it showed Debian 10 (earlier it was showing ubuntu) | |
# Additional things: You may want to reinstall the Oracle cloud agent that was removed in the beginning. |
Thanks.. It works great on OCI !
Hi, thanks by your HowTo!!
Suggestions:
- rename it to .TXT , it´s a howTo and not a script
- maybe we should do a "immediate stop" on OCI interface instead of reboot. After you start a normal reboot you cannot try forced reboot, and since disk are sync, you could stop the VM. Maybe we do not need to wait for 60min (I´m in this time now!)
I have it working, thanks. Another tip: run all commands in CONSOLE of OCI
doesn't work, i have more problems with that
Hi @needforspeed, @sant-sh : Glad that it worked for you.
Hi @jader31 : thanks for the suggestions and the tip and great that it worked for you.
Hi @geek0108 : could you please share what didn't work for you?
It might be worthwhile to know that I have recently experimented with running Debian in a LXD/LXC containers on Ubuntu. So far I managed to run a Debian-only app and with negligible overhead. I am currently using: https://www.nuber.io/ as the GUI but I think https://lxdware.com/installing-the-lxd-dashboard-on-ubuntu-22-04/ will be a better choice. Please do check out LXC/LXD (but of course, the procedure above is so cool!)
Worked perfectly here. :)
But I did it on Ubuntu 22.04
Edit: I used this Debian image instead of the one mentioned in the guide:
https://cdimage.debian.org/images/cloud/bullseye/20220816-1109/debian-11-generic-arm64-20220816-1109.tar.xz
Currently the latest bullseye for ARM64.
#for image - can use latest Debian 11
https://cdimage.debian.org/images/cloud/bullseye/latest/debian-11-generic-arm64.tar.xz
#for reboot - wait you sync and run - rebooted in 1 min
echo b | tee /proc/sysrq-trigger
Hello, I need to make work ¡
I need help, when I arrive to --> mount -t tmpfs -o size=1700m tmpfs mnt, I have this error mount: mnt: mount point does not exist.
I did not any error in the previous steps. Running Ubuntu 20.04 in ARM64, 2C 12gb Oracle free
#for image - can use latest Debian 11 https://cdimage.debian.org/images/cloud/bullseye/latest/debian-11-generic-arm64.tar.xz #for reboot - wait you sync and run - rebooted in 1 min echo b | tee /proc/sysrq-trigger
Another alternative for rebooting is: systemctl reboot
Hi! This should work if i start with ubuntu 22.04 minimal aarch64 ?
Hi! This should work if i start with ubuntu 22.04 minimal aarch64 ?
I recall trying the minimal version, but most likely, it didn't work. Technically, it should not matter whether you use the minimal or standard image initially because the process is meant to replace the old OS. I would go with the standard one to avoid any dependency-related errors.
is there any way to boot from a vmdk disk?
is there any way to boot from a vmdk disk?
vmdk disk image can be easily converted into other raw or qcow2 images using VirtualBox tools.
UPDATE: 22-Mar-2023
While the mentioned method worked, I have been thinking another strategy to change OS by booting the instance into rescue mode and writing an image to the medium (once converted to a raw format) using a dd command and then later adjusting the partition size with tools like GParted.
The good thing about the dd command is that it can also do so remotely. I recently moved OS from one VPS to another (same size and hardware though) using the dd command, and it works well (using this article: https://lowendspirit.com/discussion/3840/migrate-a-kvm-vps-from-one-host-to-another-easy-mode/). I highly encourage you to try this approach as it brings more flexibility (it may even be possible to migrate existing Raspberry Pi image to OCI cloud).
UPDATE: 22-Mar-2023
While the mentioned method worked, I have been thinking another strategy to change OS by booting the instance into rescue mode and writing an image to the medium (once converted to a raw format) using a dd command and then later adjusting the partition size with tools like GParted.
The good thing about the dd command is that it can also do so remotely. I recently moved OS from one VPS to another (same size and hardware though) using the dd command, and it works well (using this article: https://lowendspirit.com/discussion/3840/migrate-a-kvm-vps-from-one-host-to-another-easy-mode/). I highly encourage you to try this approach as it brings more flexibility (it may even be possible to migrate existing Raspberry Pi image to OCI cloud).
is rescue mode equivalent to the local console connection in OCI ?
Nice work. I will give it a try.