Create Alpine Linux PV DomU: Difference between revisions
ScrumpyJack (talk | contribs) |
ScrumpyJack (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
To create an Alpine Linux PV DomU you will need | To create an Alpine Linux PV DomU you will need an Alpine Linux iso. | ||
== | Download the latest and greatest iso from the [http://alpinelinux.org/ Alpine Linux] website. | ||
== Extract the xen-aware linux kernel == | |||
Next, mount the iso and extract the kernel and initramfs: | |||
<pre> | <pre> | ||
Line 13: | Line 16: | ||
</pre> | </pre> | ||
Now we have the kernel | Now we have the kernel in /path/to/save/kernel/grsec and initramfs in /path/to/save/kernel/grsec.gz. | ||
== Create the disk image == | == Create the disk image == | ||
Now we should create an empty file, that will be the hard drive of the DomU | Now we should create an empty file, that will be the hard drive of the DomU (in this example we are using a 3GB disk): | ||
<pre> | <pre> | ||
Line 22: | Line 25: | ||
</pre> | </pre> | ||
== | == Create a DomU config file that boots the ISO image == | ||
The next step is to create a basic configuration file, so we can launch the | The next step is to create a basic DomU configuration file, so we can launch the pv guest iso (save it where you like, although the most common place is /etc/xen/). | ||
<pre> | <pre> | ||
Line 35: | Line 38: | ||
# Path to HDD and iso file | # Path to HDD and iso file | ||
disk = [ | disk = [ | ||
'format=raw, vdev= | 'format=raw, vdev=xvda, access=w, target=/path/to/disk.img', | ||
'format=raw, vdev=xvdc, access=r, devtype=cdrom, target=/path/to/the/iso' | 'format=raw, vdev=xvdc, access=r, devtype=cdrom, target=/path/to/the/iso' | ||
] | ] | ||
Line 82: | Line 85: | ||
Installation is complete. Please reboot. | Installation is complete. Please reboot. | ||
# halt | |||
</pre> | </pre> | ||
== Adjust the domU config file to boot from fresh install == | |||
In your Dom0, edit your DomU config file to boot from the fresh install | |||
<pre> | <pre> | ||
# Alpine Linux PV DomU | # Alpine Linux PV DomU | ||
# Kernel paths for install | |||
kernel = "/path/to/save/kernel/grsec" | |||
ramdisk = "/path/to/save/kernel/grsec.gz" | |||
extra="modules=sd-mod,usb-storage,ext4,squashfs console=hvc0 root=/dev/xvda3" | |||
# Path to HDD and iso file | # Path to HDD and iso file | ||
disk = [ | disk = [ | ||
' | 'format=raw, vdev=xvda, access=w, target=/path/to/disk.img' | ||
] | |||
# Network configuration | # Network configuration | ||
Line 103: | Line 113: | ||
# DomU settings | # DomU settings | ||
memory = | memory = 512 | ||
name = "alpine" | name = "alpine" | ||
vcpus = 1 | vcpus = 1 | ||
maxvcpus = 1 | |||
</pre> | </pre> | ||
==Adding a grub config file to boot with pvgrub== | |||
Now boot the VM once more to add a grub.conf file so that we may load the xen-aware kernel from within the VM. | |||
This means that upgrading the kernel will not mean copying it to the dom0. | |||
<pre> | <pre> | ||
# xl create -f /path/to/conf -c | # xl create -f /path/to/conf -c | ||
</pre> | </pre> | ||
Log in as root and create the file /boot/grub.conf with the following content | |||
<pre> | |||
#/boot/grub.conf | |||
default 0 | |||
timeout 5 | |||
title alpine-xen-pv | |||
root (hd0,0) | |||
kernel /boot/grsec modules=sd-mod,usb-storage,ext4,squashfs console=hvc0 root=/dev/xvda3 | |||
initrd /boot/grsec.gz | |||
</pre> | |||
Halt your VM one last time | |||
<pre> | |||
# halt | |||
</pre> | |||
==Adjust the DomU config file one last time to use pvgrub== | |||
Your final xen DomU config file should look something like this. | |||
<pre> | |||
# Alpine Linux PV DomU | |||
disk = [ | |||
'format=raw, vdev=xvda, access=w, target=/path/to/alpine.img' | |||
] | |||
kernel = "/usr/lib/xen/boot/pv-grub-x86_64.gz" | |||
extra="(hd0,0)/boot/grub.conf" | |||
vif = [ 'bridge=br0' ] | |||
memory = 1024 | |||
name = "alpine" | |||
vcpus = 1 | |||
maxvcpus = 1 | |||
</pre> | |||
When you next boot, you will be presented with the grub boot menu, and your VM will boot. | |||
[[Category:Virtualization]] | [[Category:Virtualization]] |
Revision as of 15:01, 11 June 2014
To create an Alpine Linux PV DomU you will need an Alpine Linux iso.
Download the latest and greatest iso from the Alpine Linux website.
Extract the xen-aware linux kernel
Next, mount the iso and extract the kernel and initramfs:
# mkdir -p /mnt/alpine_iso # mount -o loop /path/to/the/iso /mnt/alpine_iso # cp /mnt/alpine_iso/boot/grsec /path/to/save/kernel/ # cp /mnt/alpine_iso/boot/grsec.gz /path/to/save/kernel/ # umount /mnt/alpine_iso # rmdir /mnt/alpine_iso
Now we have the kernel in /path/to/save/kernel/grsec and initramfs in /path/to/save/kernel/grsec.gz.
Create the disk image
Now we should create an empty file, that will be the hard drive of the DomU (in this example we are using a 3GB disk):
# dd if=/dev/zero of=/path/to/disk.img bs=1M count=3000
Create a DomU config file that boots the ISO image
The next step is to create a basic DomU configuration file, so we can launch the pv guest iso (save it where you like, although the most common place is /etc/xen/).
# Alpine Linux PV DomU # Kernel paths for install kernel = "/path/to/save/kernel/grsec" ramdisk = "/path/to/save/kernel/grsec.gz" extra="alpine_dev=xvdc:iso9660 modules=loop,squashfs,sd-mod,usb-storage modloop=/boot/grsec.modloop.squashfs console=hvc0" # Path to HDD and iso file disk = [ 'format=raw, vdev=xvda, access=w, target=/path/to/disk.img', 'format=raw, vdev=xvdc, access=r, devtype=cdrom, target=/path/to/the/iso' ] # Network configuration vif = ['bridge=br0'] # DomU settings memory = 512 name = "alpine" vcpus = 1 maxvcpus = 1
Install the guest
Now that we have all the necessary files, we can start the DomU to proceed with the install:
# xl create -f /path/to/conf -c
Login into the system with user "root" and no password, and proceed with the normal install:
# setup-alpine
After configuring the basic system, you will be asked where would you like to install Alpine, choose xvda and sys.
This will create three partitions on your disk, xvda1 for /boot, xvda2 for swap and xvda3 for /
Available disks are: xvda (3.1 GB ) Which disk(s) would you like to use? (or '?' for help or 'none') [none] xvda The following disk is selected: xvda (3.1 GB ) How would you like to use it? ('sys', 'data' or '?' for help) [?] sys WARNING: The following disk(s) will be erased: xvda (3.1 GB ) WARNING: Erase the above disk(s) and continue? [y/N]: y Initializing partitions on /dev/xvda... Creating file systems... Installing system on /dev/xvda3: Installation is complete. Please reboot. # halt
Adjust the domU config file to boot from fresh install
In your Dom0, edit your DomU config file to boot from the fresh install
# Alpine Linux PV DomU # Kernel paths for install kernel = "/path/to/save/kernel/grsec" ramdisk = "/path/to/save/kernel/grsec.gz" extra="modules=sd-mod,usb-storage,ext4,squashfs console=hvc0 root=/dev/xvda3" # Path to HDD and iso file disk = [ 'format=raw, vdev=xvda, access=w, target=/path/to/disk.img' ] # Network configuration vif = ['bridge=br0'] # DomU settings memory = 512 name = "alpine" vcpus = 1 maxvcpus = 1
Adding a grub config file to boot with pvgrub
Now boot the VM once more to add a grub.conf file so that we may load the xen-aware kernel from within the VM.
This means that upgrading the kernel will not mean copying it to the dom0.
# xl create -f /path/to/conf -c
Log in as root and create the file /boot/grub.conf with the following content
#/boot/grub.conf default 0 timeout 5 title alpine-xen-pv root (hd0,0) kernel /boot/grsec modules=sd-mod,usb-storage,ext4,squashfs console=hvc0 root=/dev/xvda3 initrd /boot/grsec.gz
Halt your VM one last time
# halt
Adjust the DomU config file one last time to use pvgrub
Your final xen DomU config file should look something like this.
# Alpine Linux PV DomU disk = [ 'format=raw, vdev=xvda, access=w, target=/path/to/alpine.img' ] kernel = "/usr/lib/xen/boot/pv-grub-x86_64.gz" extra="(hd0,0)/boot/grub.conf" vif = [ 'bridge=br0' ] memory = 1024 name = "alpine" vcpus = 1 maxvcpus = 1
When you next boot, you will be presented with the grub boot menu, and your VM will boot.