Running Alpine in Live mode in QEMU: Difference between revisions

From Alpine Linux
m (typo)
m (Update qemu command, use current alpine version.)
 
(11 intermediate revisions by 3 users not shown)
Line 1: Line 1:
If your just want to give Alpine Linux a try, qemu can be used without a disk image and further configuration.
To just give Alpine Linux a try in diskless mode, qemu can be used to boot the .iso file without any need for a virtual HDD image or further configuration.


{{Cmd|qemu -m 512 -cdrom alpine-3.2.0-x86_64.iso}}
{{Cmd|qemu-system-x86_64 -m 512 -nic user -boot d -cdrom alpine-{{AlpineLatest}}-x86_64.iso --accel kvm}}
== Letting the .iso image load an apkovl ==


You need to issue {{Cmd|grsec nomodeset}} at boot prompt to avoid being forced in graphical mode and loosing access.
This works by mounting a persistent filesystem under /media and selecting it to store the '''apkovl''' and the '''apkcache'''.


<u>Question</u>: Is there a way to pass an apkovl as paramater at this stage?<br/>
Preparing a KVM with a virtual drive:
<u>Response</u> ''to self'': Yes. I do it like this and I mount /dev/vda1 as /media/config to store the '''apkovl''' and the '''apkcache''': <pre>
{{cmd|mkdir -p /media/usb/images
mkdir -p /media/usb/images
qemu-img create -f raw /media/usb/images/mykvm.config 32M
qemu-img create -f raw /media/usb/images/mykvm.config 32M
qemu-system-x86_64 -enable-kvm -m 384 \
qemu-system-x86_64 -enable-kvm -m 384 \
-name mykvm \
-name mykvm \
-cdrom /media/usb/images/alpine-3.2.0-x86_64.iso \
-cdrom /media/usb/images/alpine-{{AlpineLatest}}-x86_64.iso \
-drive file=/media/usb/images/mykvm.config,if=virtio \  
-drive file{{=}}/media/usb/images/mykvm.config,if{{=}}virtio \  
-net lan \
-net lan \
-boot d &
-boot d &}}
</pre> And inside the KVM <pre>
 
fdisk /dev/vda
And inside the KVM (running Alpine Linux):
 
<pre>
fdisk /dev/vda #creating a partition
mkdosfs /dev/vda1
mkdosfs /dev/vda1
mkdir -p /media/config
mkdir -p /media/vda1
echo "/dev/vda1 /media/config vfat rw 0 0" >> /etc/fstab
echo "/dev/vda1 /media/vda1 vfat rw 0 0" >> /etc/fstab
mount /media/config
mount -a
setup-alpine
setup-alpine # (select vda1 for saving configs)
lbu ci
lbu commit
</pre> At next reboot, it will use the newly generated apkovl and apkcache stored on /dev/vda1 running in ''run-from-ram'' from the latest official ISO.
</pre>
 
The next reboot then loads the generated apkovl and apkcache found on /dev/vda1 -- completely ''running-from-ram'' based on the latest official ISO.


[[Category:Virtualization]]
[[Category:Virtualization]]

Latest revision as of 17:31, 21 January 2024

To just give Alpine Linux a try in diskless mode, qemu can be used to boot the .iso file without any need for a virtual HDD image or further configuration.

qemu-system-x86_64 -m 512 -nic user -boot d -cdrom alpine-3.19.1-x86_64.iso --accel kvm

Letting the .iso image load an apkovl

This works by mounting a persistent filesystem under /media and selecting it to store the apkovl and the apkcache.

Preparing a KVM with a virtual drive:

mkdir -p /media/usb/images qemu-img create -f raw /media/usb/images/mykvm.config 32M qemu-system-x86_64 -enable-kvm -m 384 \ -name mykvm \ -cdrom /media/usb/images/alpine-3.19.1-x86_64.iso \ -drive file=/media/usb/images/mykvm.config,if=virtio \ -net lan \ -boot d &

And inside the KVM (running Alpine Linux):

fdisk /dev/vda  #creating a partition
mkdosfs /dev/vda1
mkdir -p /media/vda1
echo "/dev/vda1 /media/vda1 vfat rw 0 0" >> /etc/fstab
mount -a
setup-alpine  # (select vda1 for saving configs)
lbu commit

The next reboot then loads the generated apkovl and apkcache found on /dev/vda1 -- completely running-from-ram based on the latest official ISO.