Create Alpine Linux PV DomU

source :http://wiki.alpinelinux.org/wiki/Create_Alpine_Linux_PV_DomU

To create an Alpine Linux PV DomU you will need a Dom0 and an Alpine Linux iso, here we will use the “mini” iso.

== Copy the kernel ==
The first step it to mount the image and extract the kernel and initramfs:

<Terminal>
# 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
# rm -rf /mnt/alpine_iso
</Terminal>

Now we have the kernel at /path/to/save/kernel/grsec and the initramfs at /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, you can also use a physical partition if you like (in this example we are using a 3GB disk):

<Terminal>
# dd if=/dev/zero of=/path/to/disk.img bs=1M count=3000
</Terminal>

== Configure for booting ISO image ==
The next step is to create a basic configuration file, so we can launch the DomU (save it where you like, although the most common place is /etc/xen/).

<Terminal>
# 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 = [
‘file:/path/to/disk.img,xvda,w’,
‘file:/path/to/the/iso,xvdc:cdrom,r’
]

# Network configuration
vif = [‘bridge=br0’]

# DomU settings
memory = 128
name = “alpine”
vcpus = 1
</Terminal>

== Install the guest ==
Now that we have all the necessary files, we can start the DomU to proceed with the install:

<Terminal>
# xl create -c /path/to/conf
</Terminal>

Login into the system with user “root” and no password, and proceed with the normal install:

<Terminal>
# setup-alpine
</Terminal>

After configuring the basic system, you will be asked where would you like to install Alpine, choose xvda and sys, as shown above:

<Terminal>
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.
</Terminal>

== Adjust for booting from disk ==
As the installation suggests, halt the DomU machine and edit the config file, to remove the xvdc disk (iso image), and change to use pygrub. At the end it should look similar to this:

<Terminal>
# Alpine Linux PV DomU

bootloader = ‘/usr/bin/pygrub’

# Path to HDD and iso file
disk = [
‘file:/path/to/disk.img,xvda,w’,
]

# Network configuration
vif = [‘bridge=br0’]

# DomU settings
memory = 128
name = “alpine”
vcpus = 1
</Terminal>

So now you are good to go, you can boot into your new Alpine Linux DomU:

<pre>
# xl create -c /path/to/conf
</pre>

[[Category:Virtualization]]

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: