User:CandyAngel/KVM Host Tutorial: Difference between revisions
CandyAngel (talk | contribs) (Add post-install configuration of host) |
m (properly escape equal signs (fixes error)) |
||
Line 19: | Line 19: | ||
== Variables == | == Variables == | ||
{{Cmd| | {{Cmd|<nowiki>export _DRIVE1=/dev/sdb | ||
export _DRIVE2=/dev/sde | export _DRIVE2=/dev/sde | ||
}} | </nowiki>}} | ||
== Partitioning == | == Partitioning == | ||
Line 56: | Line 56: | ||
== RAID1 == | == RAID1 == | ||
{{Cmd| | {{Cmd|<nowiki>modprobe raid1 | ||
echo raid1 >> /etc/modules | echo raid1 >> /etc/modules | ||
Line 62: | Line 62: | ||
mdadm --create --level=1 --raid-devices=2 --metadata=1.0 /dev/md1 ${_DRIVE1}1 ${_DRIVE2}1 | mdadm --create --level=1 --raid-devices=2 --metadata=1.0 /dev/md1 ${_DRIVE1}1 ${_DRIVE2}1 | ||
mdadm --create --level=1 --raid-devices=2 /dev/md2 ${_DRIVE1}2 ${_DRIVE2}2 | mdadm --create --level=1 --raid-devices=2 /dev/md2 ${_DRIVE1}2 ${_DRIVE2}2 | ||
}} | </nowiki>}} | ||
{{Cmd|y}} | {{Cmd|y}} | ||
{{Cmd| | {{Cmd| | ||
mdadm --detail --scan > /etc/mdadm.conf | mdadm --detail --scan > /etc/mdadm.conf | ||
rc-update add mdadm-raid boot | rc-update add mdadm-raid boot | ||
Line 73: | Line 73: | ||
== LVM == | == LVM == | ||
{{Cmd| | {{Cmd|apk add lvm2 e2fsprogs syslinux | ||
pvcreate /dev/md2 | pvcreate /dev/md2 | ||
vgcreate vg0 /dev/md2 | vgcreate vg0 /dev/md2 | ||
Line 83: | Line 83: | ||
== Filesystems == | == Filesystems == | ||
{{Cmd| | {{Cmd|mkfs.ext3 /dev/md1 | ||
mkfs.ext3 /dev/vg0/alpine-host | mkfs.ext3 /dev/vg0/alpine-host | ||
mount -t ext3 /dev/vg0/alpine-host /mnt | mount -t ext3 /dev/vg0/alpine-host /mnt | ||
Line 96: | Line 96: | ||
== Install MBR == | == Install MBR == | ||
{{Cmd| | {{Cmd|<nowiki>dd bs=440 conv=notrunc count=1 if=/usr/share/syslinux/gptmbr.bin of=${_DRIVE1} | ||
dd bs=440 conv=notrunc count=1 if=/usr/share/syslinux/gptmbr.bin of=${_DRIVE2} | dd bs=440 conv=notrunc count=1 if=/usr/share/syslinux/gptmbr.bin of=${_DRIVE2} | ||
}} | </nowiki>}} | ||
== Reboot == | == Reboot == | ||
Line 106: | Line 106: | ||
== Sudo == | == Sudo == | ||
{{Cmd| | {{Cmd|<nowiki>apk add sudo | ||
visudo | visudo | ||
}} | </nowiki>}} | ||
* Uncomment # %wheel ALL=(ALL) ALL | * Uncomment # %wheel ALL=(ALL) ALL | ||
{{Cmd|:wq}} | {{Cmd|:wq}} | ||
Line 114: | Line 114: | ||
== Add user == | == Add user == | ||
{{Cmd| | {{Cmd|<nowiki> | ||
export _USER=candyangel | export _USER=candyangel | ||
adduser $_USER | adduser $_USER | ||
addgroup $_USER wheel | addgroup $_USER wheel | ||
exit | exit | ||
}} | </nowiki>}} | ||
== Setup X == | == Setup X == | ||
{{Cmd| | {{Cmd|sudo setup-xorg-base | ||
sudo apk add xf86-video-intel | sudo apk add xf86-video-intel | ||
echo i915 | sudo tee -a /etc/modules | echo i915 | sudo tee -a /etc/modules | ||
Line 131: | Line 131: | ||
}} | }} | ||
* Add 'kms' before 'ata' | * Add 'kms' before 'ata' | ||
{{Cmd| | {{Cmd|:wq | ||
sudo mkinitfs | sudo mkinitfs | ||
sudo reboot | sudo reboot | ||
Line 141: | Line 141: | ||
== KVM == | == KVM == | ||
{{Cmd| | {{Cmd|sudo modprobe kvm-intel | ||
sudo addgroup candyangel kvm | sudo addgroup candyangel kvm | ||
exit | exit | ||
Line 148: | Line 148: | ||
== QEMU == | == QEMU == | ||
{{Cmd| | {{Cmd|sudo apk add qemu-system-x86_64 qemu-gtk | ||
}} | }} | ||
== Alpine Guest == | == Alpine Guest == | ||
{{Cmd| | {{Cmd|<nowiki>wget http://wiki.alpinelinux.org/cgi-bin/dl.cgi/v3.2/releases/x86_64/alpine-3.2.3-x86_64.iso | ||
sudo lvcreate -n alpine-guest -L8G vg0 | sudo lvcreate -n alpine-guest -L8G vg0 | ||
sudo chown candyangel:candyangel /dev/vg0 alpine-guest | sudo chown candyangel:candyangel /dev/vg0 alpine-guest | ||
qemu-system-x86_64-gtk -enable-kvm -cpu host -m 1024 -drive file=/dev/vg0/alpine-guest,format=raw,cache=none -cdrom alpine-3.2.3-x86_64.iso | qemu-system-x86_64-gtk -enable-kvm -cpu host -m 1024 -drive file=/dev/vg0/alpine-guest,format=raw,cache=none -cdrom alpine-3.2.3-x86_64.iso | ||
}} | </nowiki>}} | ||
* Install Alpine as desired | * Install Alpine as desired | ||
{{Cmd| | {{Cmd|<nowiki>apk add gvncviewer | ||
qemu-system-x86_64 -enable-kvm -cpu host -m 1024 -vga qxl -drive file=/dev/vg0/alpine-guest,format=raw,cache=none -usb -usbdevice tablet}} | qemu-system-x86_64 -enable-kvm -cpu host -m 1024 -vga qxl -drive file=/dev/vg0/alpine-guest,format=raw,cache=none -usb -usbdevice tablet</nowiki>}} | ||
{{Note|Install 'xf86-video-qxl' in the Alpine guest}} | {{Note|Install 'xf86-video-qxl' in the Alpine guest}} |
Latest revision as of 23:36, 24 August 2023
This material is work-in-progress ... Instructions may be unexplained. |
Goal setup:
Alpine Linux as KVM host on LVM on RAID1 on GPT disks.
Windows as KVM guest, with VGA passthrough (gaming).
Linux as KVM guest.
Instructions
- Boot Alpine
- Log in as root
setup-alpine
Variables
export _DRIVE1=/dev/sdb export _DRIVE2=/dev/sde
Partitioning
apk add gptfdisk gdisk $_DRIVE1
o y n 1 +128M n 2 +930G x a 1 2 w y
sgdisk $_DRIVE1 -R $_DRIVE2 sgdisk -G $_DRIVE2
RAID1
modprobe raid1 echo raid1 >> /etc/modules apk add mdadm mdadm --create --level=1 --raid-devices=2 --metadata=1.0 /dev/md1 ${_DRIVE1}1 ${_DRIVE2}1 mdadm --create --level=1 --raid-devices=2 /dev/md2 ${_DRIVE1}2 ${_DRIVE2}2
y
mdadm --detail --scan > /etc/mdadm.conf rc-update add mdadm-raid boot
LVM
apk add lvm2 e2fsprogs syslinux pvcreate /dev/md2 vgcreate vg0 /dev/md2 lvcreate -n alpine-host -L 8G vg0 vgchange -ay rc-update add lvm
Filesystems
mkfs.ext3 /dev/md1 mkfs.ext3 /dev/vg0/alpine-host mount -t ext3 /dev/vg0/alpine-host /mnt mkdir /mnt/boot mount -t ext3 /dev/md1 /mnt/boot
Install Alpine
setup-disk -m sys /mnt
Install MBR
dd bs=440 conv=notrunc count=1 if=/usr/share/syslinux/gptmbr.bin of=${_DRIVE1} dd bs=440 conv=notrunc count=1 if=/usr/share/syslinux/gptmbr.bin of=${_DRIVE2}
Reboot
reboot
Sudo
apk add sudo visudo
- Uncomment # %wheel ALL=(ALL) ALL
:wq
Add user
export _USER=candyangel adduser $_USER addgroup $_USER wheel exit
Setup X
sudo setup-xorg-base sudo apk add xf86-video-intel echo i915
- Add 'kms' before 'ata'
:wq sudo mkinitfs sudo reboot sudo apk add fluxbox st echo exec startfluxbox > .xinitrc
KVM
sudo modprobe kvm-intel sudo addgroup candyangel kvm exit
QEMU
sudo apk add qemu-system-x86_64 qemu-gtk
Alpine Guest
wget http://wiki.alpinelinux.org/cgi-bin/dl.cgi/v3.2/releases/x86_64/alpine-3.2.3-x86_64.iso sudo lvcreate -n alpine-guest -L8G vg0 sudo chown candyangel:candyangel /dev/vg0 alpine-guest qemu-system-x86_64-gtk -enable-kvm -cpu host -m 1024 -drive file=/dev/vg0/alpine-guest,format=raw,cache=none -cdrom alpine-3.2.3-x86_64.iso
- Install Alpine as desired
apk add gvncviewer qemu-system-x86_64 -enable-kvm -cpu host -m 1024 -vga qxl -drive file=/dev/vg0/alpine-guest,format=raw,cache=none -usb -usbdevice tablet