:: [DNG] Devuan KVM guest install usin…
Góra strony
Delete this message
Reply to this message
Autor: Andrew McGlashan
Data:  
Dla: Devuan DNG
Temat: [DNG] Devuan KVM guest install using ISO, virt-install and text based installation
Hi All,


Purpose:

Devuan guest install for web server on Devuan KVM Box.


Used this ISO:

https://files.devuan.org/devuan_jessie_beta/devuan_jessie_1.0.0-beta_amd64_CD.iso

Mounted it at /cdrom (just a directory mount, simple enough).

Created LV for guest.

Adjusting the ISO to allow text install wasn't necessary.

The script (attached) that I crafted, feel free to adjust as required
for your own needs (obviously). But here is the resultant virt-instsall
command:


virt-install \
    --virt-type kvm \
    --os-variant=debianwheezy \
    --name=www-affinityvision-com-au
    --cpu=host --vcpus=2 --memory 2048
    --disk path=/srv/kvm/images/www-affinityvision-com-au--disk0 \
    --cdrom /path/to/Devuan-ISO-FILE \
    --graphics none --network bridge=br0 \
    --boot
kernel=/cdrom/install.amd/vmlinuz,initrd=/cdrom/install.amd/initrd.gz,kernel_args='console=ttyS0'



All the research I had done trying to find the "right" way to do the
install had issues that I needed to resolve. Using "console" and/or
"--extra-args", would not work unless you used "--location" and then it
had to be an install tree, not an ISO file. Otherwise a graphical
install with vnc -- and I wanted a simpler text install only.

I probably could have just copied the vmlinux and initrd files from the
ISO (once it was mounted at /cdrom) and then umounted it.

Once the install was done, I dumped the xml, edited it, undefined the
guest and then re-created it from the adjusted xml. The changes
required (to the xml exported file) were to stop it booting the
installer and to boot from the disk image instead.

Kind Regards
AndrewM

#!/usr/bin/env bash


# Script used to install VMs.
# You have to lvcreate the disk(s) first!
# lvcreate -L sizeG -n $name vg0

dummy() {
####

# uname -a
Linux kvm-affinity-devuan-a 3.16.0-4-amd64 #1 SMP Debian 3.16.36-1+deb8u1 (2016-09-03) x86_64 GNU/Linux

# vgs
  VG   #PV #LV #SN Attr   VSize   VFree  
  vg0    1   2   0 wz--n- 232.48g 213.85g


# lvcreate -L 12G -n www-affinityvision-com-au--disk0 vg0
Logical volume "www-affinityvision-com-au--disk0" created

# ls -lart /dev/mapper/vg0-www--affinityvision--com--au----disk0
lrwxrwxrwx 1 root root 7 Sep 30 00:01 /dev/mapper/vg0-www--affinityvision--com--au----disk0 -> ../dm-3


# lvdisplay /dev/mapper/vg0-www--affinityvision--com--au----disk0
  --- Logical volume ---
  LV Path                /dev/vg0/www-affinityvision-com-au--disk0
  LV Name                www-affinityvision-com-au--disk0
  VG Name                vg0
  LV UUID                ffN5RP-YNZI-iSkz-PXb1-8o8A-CHh3-LlPIbq
  LV Write Access        read/write
  LV Creation host, time kvm-affinity-devuan-a, 2016-09-30 00:01:22 +1000
  LV Status              available
  # open                 0
  LV Size                12.00 GiB
  Current LE             3072
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:3



# ls -lart /srv/kvm/images/www-affinityvision-com-au--disk0
lrwxrwxrwx 1 root root 53 Sep 29 16:56 /srv/kvm/images/www-affinityvision-com-au--disk0 -> /dev/mapper/vg0-www--affinityvision--com--au----disk0

# mkdir /cdrom && mount -o ro /srv/ISO-files/devuan/devuan_jessie_1.0.0-beta_amd64_DVD.iso /cdrom

# df -PTah /cdrom
Filesystem     Type     Size  Used Avail Use% Mounted on
/dev/loop0     iso9660  4.4G  4.4G     0 100% /cdrom


####
}

set -e


variant="--os-variant=debianwheezy"

name="--name=www-affinityvision-com-au"

cpus="--cpu=host --vcpus=2"
memory="--memory 2048"
disk="--disk path=/srv/kvm/images/www-affinityvision-com-au--disk0"

location="--cdrom /srv/ISO-files/devuan/devuan_jessie_1.0.0-beta_amd64_DVD.iso"

graphics="--graphics none"
network="--network bridge=br0"

boot="--boot kernel=/cdrom/install.amd/vmlinuz,initrd=/cdrom/install.amd/initrd.gz,kernel_args='console=ttyS0'"

CMD="virt-install --virt-type kvm ${variant}    ${name}    ${cpus} ${memory} ${disk}    ${location}    ${graphics} ${network}   ${boot}"
echo "${CMD}"
eval ${CMD}