There is no WSL or Multipass on Guix, but we can get the same thing with QEmu (and a lot more). But it’s a bit trickier to get started!
Guix packages required:
- qemu (possibly can get away with minimal package)
- cloud-utils (for cloud-localds)
- cdrkit-libre (for genisoimage, used by cloud-localds)
Create the following user data file - there may be more in this than you need.
#cloud-config
hostname: testhost
timezone: Europe/London
manage_etc_hosts: true
ssh_pwauth: true
users:
- default
- name: ubuntu
sudo: ALL=(ALL) NOPASSWD:ALL
groups: users, wheel, sudo
lock_passwd: false
passwd: secret1
ssh_authorized_keys:
- ssh-ed25519 AAAAC8..
disable_root: false
chpasswd:
list: |
ubuntu:secret1
root:secret2
expire: False
Then create an image from this file:
cloud-localds seed.img user-data.yaml
Then download your qcow2 images from Ubuntu - they have an .img extension - you need to get specific ones. Go here: https://cloud-images.ubuntu.com/
And click on the daily builds you want, eg for 20.04, click focal, then current: https://cloud-images.ubuntu.com/focal/current/
Daily just means has latest package updates from that day.
Then you’re looking for the xxxxx-server-cloudimg-amd64.img (NOT the one with kvm in the name), eg: focal-server-cloudimg-amd64.img
eg:
wget https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img
Then you can run the image using:
sudo qemu-system-x86_64 \ -machine accel=kvm,type=q35 \ -cpu host \ -m 2G \ -nographic \ -nic user,id=vmnic,hostfwd=tcp::2222-:22 \ -drive if=virtio,format=qcow2,file=focal-server-cloudimg-amd64.img \ -drive if=virtio,format=raw,file=seed.img
Remember it’s ctrl-a x
to exit or ctrl-a c
to get qemu menu.
To ssh you want:
ssh -v -o "StrictHostKeyChecking no" -i /home/foo/.ssh/foo_ed25519 -p 2222 ubuntu@localhost
Before you install anything you’ll want to resize the volumes inside the Ubuntu image!
No very easy way to do this on Guix - easiest way is to use https://www.libguestfs.org/
The follow steps take place on one of my virtual Ubuntu boxes:
On Ubuntu virtual server only, you need to install the kernel as well as the package to avoid the virt-resize: error: libguestfs error: /usr/bin/supermin exited with error status 1
error:
sudo apt install libguestfs-tools sudo apt install linux-image-generic-hwe-20.04 sudo chmod go+r /boot/vmlinuz-*
Now we can extend our image from Ubuntu.
First we make a copy of our image:
cp focal-server-cloudimg-amd64.img focal-server-cloudimg-amd64.orig.img
Then we extend the target:
qemu-img resize focal-server-cloudimg-amd64.img +20G
And we can see the original /dev/sda1 root file system, at only 2.1GB, and our extended space at the end:
$ sudo virt-filesystems --long -h --all -a focal-server-cloudimg-amd64.orig.img Name Type VFS Label MBR Size Parent /dev/sda1 filesystem ext4 cloudimg-rootfs - 2.1G - /dev/sda14 filesystem unknown - - 4.0M - /dev/sda15 filesystem vfat UEFI - 106M - /dev/sda1 partition - - - 2.1G /dev/sda /dev/sda14 partition - - - 4.0M /dev/sda /dev/sda15 partition - - - 106M /dev/sda /dev/sda device - - - 20G -
Now we extend /dev/sda1 to use the new space:
$ sudo virt-resize --expand /dev/sda1 focal-server-cloudimg-amd64.orig.img focal-server-cloudimg-amd64.img [ 0.0] Examining focal-server-cloudimg-amd64.orig.img 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00 ********** Summary of changes: /dev/sda14: This partition will be left alone. /dev/sda15: This partition will be left alone. /dev/sda1: This partition will be resized from 2.1G to 15.9G. The filesystem ext4 on /dev/sda1 will be expanded using the ‘resize2fs’ method. ********** [ 55.3] Setting up initial partition table on focal-server-cloudimg-amd64.img [ 91.6] Copying /dev/sda14 [ 92.1] Copying /dev/sda15 [ 93.9] Copying /dev/sda1 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00 [ 183.2] Expanding /dev/sda1 (now /dev/sda3) using the ‘resize2fs’ method Resize operation completed with no errors. Before deleting the old disk, carefully check that the resized disk boots and works correctly.
Note in the logs “Expanding /dev/sda1 (now /dev/sda3)” - so if you try to run this you’ll just get the “grub rescue”. This is because it’s still pointing to /dev/sda1 - we need to repoint it to /dev/sda3.
You can rerun this at any time to see the changes:
sudo virt-filesystems --long -h --all -a focal-server-cloudimg-amd64.img
To repoint grub we do this - the commands to type in start mkdir /mnt
, we exit using ctrl d
.
$ sudo virt-rescue focal-server-cloudimg-amd64.img Could not access KVM kernel module: No such device qemu-system-x86_64: failed to initialize KVM: No such device qemu-system-x86_64: Back to tcg accelerator supermin: mounting /proc supermin: ext2 mini initrd starting up: 5.1.20 insmod: init_module: crc32-pclmul.ko: No such device insmod: init_module: crct10dif-pclmul.ko: No such device Starting /init script ... [/usr/lib/tmpfiles.d/static-nodes-permissions.conf:12] Unknown group 'audio'. [/usr/lib/tmpfiles.d/static-nodes-permissions.conf:13] Unknown group 'audio'. [/usr/lib/tmpfiles.d/static-nodes-permissions.conf:14] Unknown group 'disk'. [/usr/lib/tmpfiles.d/static-nodes-permissions.conf:17] Unknown group 'kvm'. [/usr/lib/tmpfiles.d/systemd.conf:11] Unknown group 'utmp'. [/usr/lib/tmpfiles.d/systemd.conf:19] Unknown user 'systemd-network'. [/usr/lib/tmpfiles.d/systemd.conf:20] Unknown user 'systemd-network'. [/usr/lib/tmpfiles.d/systemd.conf:21] Unknown user 'systemd-network'. [/usr/lib/tmpfiles.d/systemd.conf:22] Unknown user 'systemd-network'. [/usr/lib/tmpfiles.d/systemd.conf:26] Unknown group 'systemd-journal'. [/usr/lib/tmpfiles.d/systemd.conf:27] Unknown group 'systemd-journal'. Failed to parse ACL "d:group::r-x,d:group:adm:r-x,group::r-x,group:adm:r-x": No such file or directory. Ignoring Failed to parse ACL "d:group:adm:r-x,group:adm:r-x": No such file or directory. Ignoring Failed to parse ACL "group:adm:r--": No such file or directory. Ignoring Failed to parse ACL "d:group::r-x,d:group:adm:r-x,group::r-x,group:adm:r-x": No such file or directory. Ignoring Failed to parse ACL "d:group:adm:r-x,group:adm:r-x": No such file or directory. Ignoring Failed to parse ACL "group:adm:r--": No such file or directory. Ignoring Starting version 245.4-4ubuntu3.15 /init: line 116: echo: write error: Invalid argument /init: line 116: echo: write error: Invalid argument mdadm: No arrays found in config file or automatically /init: line 144: lvmetad: command not found /init: line 147: modprobe: command not found mdadm: No arrays found in config file or automatically [ ] lvm_system_dir = /tmp/lvm The virt-rescue escape key is ‘^]’. Type ‘^] h’ for help. ------------------------------------------------------------ Welcome to virt-rescue, the libguestfs rescue shell. Note: The contents of / (root) are the rescue appliance. You have to mount the guest’s partitions under /sysroot before you can examine them. groups: cannot find name for group ID 0 ><rescue> mkdir /mnt ><rescue> mount /dev/sda3 /mnt ><rescue> mount --bind /dev /mnt/dev ><rescue> mount --bind /proc /mnt/proc ><rescue> mount --bind /sys /mnt/sys ><rescue> chroot /mnt ><rescue> grub-install /dev/sda Installing for i386-pc platform. Installation finished. No error reported. ><rescue> ><rescue> exit virt-rescue: Syncing the disk now before exiting ... /init: line 264: reboot: command not found [ 134.527776] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00007f00 [ 134.531740] CPU: 0 PID: 1 Comm: init Not tainted 5.13.0-39-generic #44~20.04.1-Ubuntu [ 134.532359] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014 [ 134.533008] Call Trace: [ 134.533983] <TASK> [ 134.534758] dump_stack+0x7d/0x9c [ 134.536018] panic+0x101/0x2e3 [ 134.536204] do_exit.cold+0x60/0xb0 [ 134.536395] do_group_exit+0x43/0xb0 [ 134.536605] __x64_sys_exit_group+0x18/0x20 [ 134.536823] do_syscall_64+0x61/0xb0 [ 134.537014] ? irqentry_exit_to_user_mode+0x9/0x20 [ 134.537256] ? irqentry_exit+0x19/0x30 [ 134.537462] ? exc_page_fault+0x8f/0x170 [ 134.537668] ? asm_exc_page_fault+0x8/0x30 [ 134.537890] entry_SYSCALL_64_after_hwframe+0x44/0xae [ 134.538303] RIP: 0033:0x7f7873c9b176 [ 134.539130] Code: fa 41 b8 e7 00 00 00 be 3c 00 00 00 eb 15 66 0f 1f 44 00 00 89 d7 89 f0 0f 05 48 3d 00 f0 ff ff 77 22 f4 89 d7 44 89 c0 0f 05 <48> 3d 00 f0 ff ff 76 e2 f7 d80 [ 134.540326] RSP: 002b:00007fff43410788 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7 [ 134.541454] RAX: ffffffffffffffda RBX: 00007f7873da08a0 RCX: 00007f7873c9b176 [ 134.541820] RDX: 000000000000007f RSI: 000000000000003c RDI: 000000000000007f [ 134.542178] RBP: 000000000000007f R08: 00000000000000e7 R09: ffffffffffffff80 [ 134.542548] R10: 0000000000000008 R11: 0000000000000246 R12: 00007f7873da08a0 [ 134.542898] R13: 0000000000000001 R14: 00007f7873da92e8 R15: 0000000000000000 [ 134.543367] </TASK> [ 134.544770] Kernel Offset: 0x29a00000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbfffffff) [ 134.545797] Rebooting in 1 seconds..
Now we should see /dev/sda3 expanded:
$ sudo virt-filesystems --long -h --all -a focal-server-cloudimg-amd64.img Name Type VFS Label MBR Size Parent /dev/sda1 filesystem unknown - - 4.0M - /dev/sda2 filesystem vfat UEFI - 106M - /dev/sda3 filesystem ext4 cloudimg-rootfs - 20G - /dev/sda1 partition - - - 4.0M /dev/sda /dev/sda2 partition - - - 106M /dev/sda /dev/sda3 partition - - - 20G /dev/sda /dev/sda device - - - 20G -
Copy it back to Guix and give it a whirl:
sudo qemu-system-x86_64 \ -machine accel=kvm,type=q35 \ -cpu host \ -m 2G \ -nic user,id=vmnic,hostfwd=tcp::2222-:22 \ -drive if=virtio,format=qcow2,file=focal-server-cloudimg-amd64.img \ -drive if=virtio,format=raw,file=seed.img \ -nographic
Now we can login using SSH to port 2222 and forward X-Windows with -Y:
ssh -Y -o "StrictHostKeyChecking no" -p 2222 ubuntu@localhost
Check X-Windows is working - by rendering a wee clock:
sudo apt install x11-apps xclock
Now for Cuis Smalltalk - following these instructions: https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev/blob/master/Documentation/GettingStarted.md
But first we need to install libgl1.
sudo apt-get install libgl1 mkdir MyProject cd MyProject/ git clone --depth 1 https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev.git cd Cuis-Smalltalk-Dev/ ./clonePackageRepos.sh cd .. wget -O cogspur.tgz https://github.com/OpenSmalltalk/opensmalltalk-vm/releases/download/202112201228/squeak.cog.spur_linux64x64.tar.gz tar -xvzf cogspur.tgz mv sqcogspur64linuxht cogspur cogspur/squeak Cuis-Smalltalk-Dev/Cuis6.0-5069.image &
Some References:
- https://powersj.io/posts/ubuntu-qemu-cli/
- https://gist.github.com/leogallego/a614c61457ed22cb1d960b32de4a1b01
- https://askubuntu.com/questions/281763/is-there-any-prebuilt-qemu-ubuntu-image32bit-online/1081171#1081171
- https://askubuntu.com/questions/507345/how-to-set-a-password-for-ubuntu-cloud-images-ie-not-use-ssh
- https://stackoverflow.com/questions/68512432/cannot-login-to-vm-using-qemu-nocloud-cloud-init-on-macos-with-ubuntu-cloud-imag
- https://cloudinit.readthedocs.io/en/latest/index.html
- https://fadeevab.com/how-to-setup-qemu-output-to-console-and-automate-using-shell-script/
- https://subscription.packtpub.com/book/virtualization_and_cloud/9781788294676/1/ch01lvl1sec16/running-virtual-machines-with-qemu-system
Expanding the filesystem: