LoginSignup
3
2

More than 5 years have passed since last update.

XenServer6.5にDebian 9, Ubuntu 16.04, 17.04のテンプレートを追加する

Last updated at Posted at 2016-04-25

本稿では,XenServerにおいて,デフォルトで存在しないバージョンのDebianやUbuntuのインストール時に,Network Installation Notes1を使用できるようにする方法を説明します.やり方はその辺でよくスクリプトがあったりするので,どういう仕組みなのかについても加えて説明します2

仕組み

XenServerのテンプレートのうち,Debianをベースとするディストリビューションでは,パラメータother-configdebian-releaseを参照して,インストールに使用するレポジトリ上のディレクトリを決定します.
eliloaderのコードを確認すると,other_configdebianlikeが指定されたディストリビューションはdebian_first_boot_handlerが呼び出されようにコードされています(721行目).そして,debian_first_boot_handlerにおいて,other-configdebian-releaseによってdistsを特定しています.

eliloader
    if other_config['install-repository'] == "cdrom":
        cdrom_dirs = { 'i386': 'install.386/xen/',
                       'amd64': 'install.amd/xen/',
                       'x86_64': 'install.amd/xen/' }
        vmlinuz_url = repo_url + cdrom_dirs[other_config['install-arch']] + "vmlinuz"
        ramdisk_url = repo_url + cdrom_dirs[other_config['install-arch']] + "initrd.gz"
    else:
        boot_dir = "dists/%s/main/installer-%s/current/images/netboot/xen/" % (other_config['debian-release'], other_config['install-arch'])
        vmlinuz_url = repo_url + boot_dir + "vmlinuz"
        ramdisk_url = repo_url + boot_dir + "initrd.gz"

    # download the kernel and ramdisk:
    vmlinuz_file = close_mkstemp(dir = BOOTDIR, prefix = "vmlinuz-")
    ramdisk_file = close_mkstemp(dir = BOOTDIR, prefix = "ramdisk-")

このような仕組みで動作するため,下記コードで正しいパスが生成されるように,debian-releaseを与えればよいとわかります.Debian Wheezyであれば,wheezyを,Ubuntu Xenial Xerusであれば,xenialを与えればよいということになります.

        boot_dir = "dists/%s/main/installer-%s/current/images/netboot/xen/" % (other_config['debian-release'], other_config['install-arch'])

方法

シェル関数の登録

XenServer構築直後に実施するような作業なので,最初にシェル関数を一時的に登録して一気にテンプレートを作ります.

XenServerのコンソールで下記コマンドを実行します.

template_add
function template_add () {
    MIRROR=$1
    BASE_TPL=$2
    NEW_TPL=$3
    DEBIAN_RELEASE=$4

    BASEUUID=$(xe template-list name-label="$BASE_TPL" --minimal)
    if [[ -z $BASEUUID ]] ; then
        echo "Cant find \"$BASE_TPL\ template."
        exit 1
    fi
    NEWUUID=$(xe vm-clone uuid=$BASEUUID new-name-label="$NEW_TPL")
    xe template-param-set uuid=$NEWUUID other-config:default_template=true
    xe template-param-set uuid=$NEWUUID other-config:debian-release=$DEBIAN_RELEASE
    xe template-param-set uuid=$NEWUUID other-config:install-methods=http other-config-install-repository=$MIRROR
    echo $NEWUUID
}

Debianのテンプレートの追加

XenServerのコンソールから下記コマンドを実行してテンプレートを追加します.

MIRROR=http://cdn.debian.or.jp/debian/
WHEEZY="Debian Wheezy 7.0 (64-bit)"

template_add $MIRROR "$WHEEZY" "Debian Jessie 8.0 (64-bit) (Fixed)" jessie
template_add $MIRROR "$WHEEZY" "Debian Stretch 9.0 (64-bit) (Fixed)" stretch

Ubuntuのテンプレートの追加

XenServerのコンソールから下記コマンドを実行してテンプレートを追加します.

MIRROR=http://jp.archive.ubuntu.com/ubuntu/
PRECISE="Ubuntu Precise Pangolin 12.04 (64-bit)"

template_add $MIRROR "$PRECISE" "Ubuntu Trusty Tahr 14.04 LTS (64-bit) (Fixed)" trusty
template_add $MIRROR "$PRECISE" "Ubuntu Wily Werewolf 15.10 (64-bit) (Fixed)" wily
template_add $MIRROR "$PRECISE" "Ubuntu Xenial Xerus 16.04 LTS (64-bit) (Fixed)" xenial
template_add $MIRROR "$PRECISE" "Ubuntu Zesty Zapus 17.04 (64-bit) (Fixed)" zesty

テンプレートの名前変更

テンプレートの名前を変更するときは下記コマンドを実行する.

xe template-param-set uuid=`xe template-list name-label="<元の名前>" --minimal` name-label="<新しい名前>"

  1. 表記ゆれがありますが,netboot, network install, webinstall, netinstallなんて言葉で呼ばれてるようです. 

  2. コード読んでこういう動作だろって解釈してるだけで間違ってるかも知れません.あしからず. 

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2