Alpine Qcow2

0 views
Skip to first unread message

Avice

unread,
Aug 4, 2024, 9:17:26 PM8/4/24
to tricmasschamisp
nic user,model=virtio: Adds a virtual network interfacecontroller, using a virtual LAN emulated by qemu. This is the moststraightforward way to get internet in a guest, but there are other options (forexample, you will probably want to use -nic tap if you want the guest to donetworking directly on the host NIC). model=virtio specifies a specialvirtio NIC model, which is used by the virtio kernel module in the guest toprovide faster networking.

When you run this command, the SDL window will appear and Alpine will boot! Youcan complete the Alpine installation normally, using setup-alpine to installit to the attached disk. When you shut down Alpine, run qemu again without-cdrom to start the VM.


The simplest way to obtain a virtual machine image that works withOpenStack is to download one that someone else has alreadycreated. Most of the images contain the cloud-init package tosupport the SSH key pair and user data injection.Because many of the images disable SSH password authenticationby default, boot the image with an injected key pair.You can SSH into the instance with the private key and defaultlogin account. See Configure access and security for instancesfor more information on how to create and inject key pairs with OpenStack.


Debian provides images for direct download.They are made at the same time as the CD and DVD images of Debian.Therefore, images are available on each point release of Debian. Also,weekly images of the testing distribution are available.


Cloudbase Solutions provides the last available trial versionof Windows Server 2012 R2.This image includes cloudbase-init plus VirtIO drivers on KVM.You can build your own image based on Windows Server 2016, 2019,Windows 10 etc) with Cloudbase Imaging Tools.


Images are arranged by Ubuntu release, and by image release date,with current being the most recent.For example, the page that contains the most recently built image forUbuntu 24.04 Noble Numbat is Ubuntu 24.04 LTS (Noble Numbat) Daily Build.Scroll to the bottom of the page for links to the images that can bedownloaded directly.


If your deployment uses QEMU or KVM, we recommend using the imagesin qcow2 format, with name ending in .img.The most recent version of the 64-bit amd64-arch QCOW2 image forUbuntu 24.04 isnoble-server-cloudimg-amd64.img.


A friend of mine recently made me aware of Oracle Cloud's free tier, which allows you to get a limited amount of virtual servers, for free, forever.And it's not even too bad spec-wise! They offer ARM servers (either one server up to 4 cores and 24GB RAM or four servers with 1/4 of that), and more traditionalx86 servers, based on previous-gen AMD CPUs (1 core, 1GB of RAM). I registered at their page, created an Instance (their in-house name for a VPS, which is still better than ""EC2"")and was greeted with a.. limited selection of operating systems to choose from. You could either go with Canonical Ubuntu, CentOS, one of their Red Hat forks(they call it "Oracle Linux", I call it an outdated scam RedHat wannabe) or - for an additional fee - Windows Server.Suffice to say, their offering wasn't satisfying. These days, my go-to server OS is Alpine, with Debian as a fallback; They didn't offer either of those, and I chose to change that.


Poking around in the web console looking for a way to import a custom image revealed that they do support this kind of deployment scenario. After preparing a qcow2 Alpine image and uploading itto a bucket in their cloud storage (because they insist you *can't* import an image from any HTTP server, no, it needs to be *their bucket storage*), the only step left was to import it as a boot image.The whole process (upload and import) took over 30 minutes, but I finally could create a VM using the custom image... Or could I?


As it turns out, Oracle only supports UEFI boot on their free Ampere and AMD64 machines, and my alpine was installed w/ BIOS. This meant that the only machine that could be actually usedwas their Intel offering, which didn't get included into the Free Tier. Bummer!

The image ended up working, but I wasn't satisfied. I came for the free stuffs, so it's not like I'm settling for the paid option! Additionally, the whole process took *way* too long from start to finish,so it didn't make much sense to develop an UEFI-based image.


I don't like poking around EFI on virtual machines. QEMU requires you to manually download TianoCore and hack your way through setting it all up, while with SeaBIOS, it can boot with just one parameter pointing at a boot image.This meant that I'd much prefer to develop and test the whole process directly on their VMs, as they're already set up. If we allow Oracle to install their default OS on an Amperemachine, we get a partition table that looks more or less like this:/dev/sda1 - 200MB, EFI/dev/sda2 - 8GB, SWAP/dev/sda3 - rest of the drive, XFS

The 2nd partition is great news, because we can use the 8GB of SWAP as a new root fs! After destroying the swap, making a new ext4 partition and unpacking the alpine minirootfs, I could chroot to the new OS without a problem.Technically, the alpine is already there, so we could *just* chroot every time.. but this is boooriiiing and proves to be difficult if you actually need to deploy any services. Instead, I chose to make Alpine a stand-alone OS,via booting from GRUB.


Debugging the boot process was hard at first (the machine kept booting back to RH), but I found a way to access the VM's screen through their cloud console. They offer two options for debugging OS issues -VNC or serial console, both proxied over SSH. It's worth noting that Ampere's VNC connection option is utterly broken - it proxies the screen just fine, but it doesn't catch any keyboard inputs. This can be mitigatedby using the serial console, which is only slightly less broken - some special keys (del, esc, bckspc) are mismatched. (ORACLE PLS FIX)


Finally, it boots... on Ampere, at least. As Oracle also offers free x86 servers, it wouldn't be fair if the script didn't support those, right? :3

Well, those beasts required a bit more hacking to get them to work. Those machines don't even boot with the default Alpine virt kernel, and I couldn't figure out why (Dear Reader, if you can, get in touch). As a workaround,I decided that copying stock kernel and modules to the Alpine partition would suffice. It may prove to be difficult to update in the future, but - for now - it works quite well!


Overally, Oracle Cloud has a nice free offering, but it reassured me to stay with selfhosting my servers physically and/or rent VPSes from more experienced hosting companies. My biggest problem with Oracle Cloud (apart fromnot having the OS I wanted) was them being non-transparent about how much I may pay for what. This was seemingly copy-pasted from other cloud providers like AWS, which would rather provide a spendings calculator instead ofa known, set price.


One small remark: the script from this article does not work if you install Oracle Linux 8 during creating your instance. You have to install Oracle Linux 7 in order to use the script.The underlying reason is that Oracle Linux 8 image uses file (/.swapfile) as a swap, while Oracle Linux 7 uses a partition. The script needs this partition to store image of AlpineLinux.


QEMU (Quick EMUlator) is a generic and open source machine emulator originally developed by Fabrice Bellard (this same guy is also the original author of FFMPEG, insanely). It is a powerful and versatile tool that has gained widespread recognition and adoption in the world of virtualization. It provides a platform for creating and managing virtual machines, enabling users to emulate various hardware architectures, operating systems, and software environments.


One of the notable features of QEMU is its ability to provide full system emulation, allowing users to run unmodified guest operating systems on different host platforms. Additionally, QEMU supports a variety of virtualization techniques, such as hardware-assisted virtualization (e.g., Intel VT-x, AMD-V) and software based emulation, providing a range of options for running virtual machines efficiently.


QEMU also includes a suite of user-level emulation modes, enabling users to run software applications compiled for a different architecture without the need for complete system emulation. This feature is particularly useful for software developers who need to test their applications on different platforms without the overhead of running a full virtual machine.


Furthermose, QEMU integrates with the popular KVM hypervisor on Linux, allowing it to take advantages of hardware virtualization extensions and deliver near-native performance for virtualized workloads. This combination of QEMU and KVM has become a robust and widely adopted solution for virtualization in cloud computing environments.


Next, we craft a virtual hard drive for out Linux virtual machine. QEMU supports a long list of image formats. Among those, qcow2 is the most versatile format with the best feature set. We are going to use qcow2 format for our virtual machine.


This projects builds custom Alpine Linux images with the alpine-make-vm-image utility, but it uses Docker and a simplified interface so that it can run easily on systems other than Alpine Linux that support Docker, such as for example macOS or other Linux distros.


Note that the Windows builds are broken due to a change in how WSL works; it is no longer supported since WSL2, the new Docker backend in Windows, uses a Kernel without nbd support. If you just want a quick Alpine VM on Windows, I recommend using Alpine WSL instead until Microsoft resolve the issue.


Custom Images are images to be used to install Cloud VPS or VDS. These Custom Images are not provided by Contabo but are provided by the customer. Please note that a paid addon is required to upload and use Custom Images. It allows you to upload up to 25 GB of Custom Images (which can be extended of course).

3a8082e126
Reply all
Reply to author
Forward
0 new messages