目標:GUI が使えない手元 KVM に ubuntu 仮想マシンをセットアップしたい。X を飛ばすとかは無しで。
前回よりも、もっと手っ取り早い方法を見つけたような気がする。
92.cfg
というファイルを用意して 90_dpkg.cfg
の中身を上書きする。
92.cfg
#cloud-config
datasource_list: [ None ]
ssh_pwauth: True
password: password
lock_passwd: False
virt-sysprep
で潜り込ませる。書き換える前の test.img
は前回同様 ubuntu-cloud のイメージをコピーしておく。
virt-sysprep --copy-in $PWD/92.cfg:/etc/cloud/cloud.cfg.d/ \
-a /var/lib/libvirt/images/test.img
libvirt に登録し、インストールを行う。
virt-install --virt-type kvm --name test --ram 2048 \
--disk path=/var/lib/libvirt/images/test.img,size=16 \
--graphics none --console pty,target_type=serial --import --network network=default
ログインし、cloud-init を無効化する
sudo touch /etc/cloud/cloud-init.disabled