Port 2222
LogLevel VERBOSE
PermitRootLogin no
PasswordAuthentication no
MaxAuthTries 3
MaxSessions 1
PubkeyAuthentication yes
PermitEmptyPasswords no
X11Forwarding no
AllowUsers <NEW_USERNAME>
以下のコマンドで LXD をインストールします。ほとんどの質問には Enter キーだけを押してデフォルトを適用します。
sudo snap install lxd
sudo lxd init
Would you like to use LXD clustering? (yes/no) [default=no]:
Do you want to configure a new storage pool? (yes/no) [default=yes]:
Name of the new storage pool [default=default]:
Name of the storage backend to use (btrfs, dir, lvm, zfs, ceph) [default=zfs]:
Create a new ZFS pool? (yes/no) [default=yes]:
Would you like to use an existing empty block device (e.g. a disk or partition)? (yes/no) [default=no]:
Size in GiB of the new loop device (1GiB minimum) [default=30GiB]: 800GiB
Would you like to connect to a MAAS server? (yes/no) [default=no]:
Would you like to create a new local network bridge? (yes/no) [default=yes]:
What should the new bridge be called? [default=lxdbr0]:
What IPv4 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]:
What IPv6 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]:
Would you like the LXD server to be available over the network? (yes/no) [default=no]: yes
Would you like stale cached images to be updated automatically? (yes/no) [default=yes]:
Would you like a YAML "lxd init" preseed to be printed? (yes/no) [default=no]:
lxc network set lxdbr0 ipv4.firewall false
lxc network set lxdbr0 ipv6.firewall false
ufw コマンドで LXD のブリッジネットワークのルーティングを許可する。
# allow the guest to get an IP from the LXD host
sudo ufw allow in on lxdbr0 to any port 67 proto udp
sudo ufw allow in on lxdbr0 to any port 547 proto udp
# allow the guest to resolve host names from the LXD host
sudo ufw allow in on lxdbr0 to any port 53
# allow the guest to have access to outbound connections
CIDR4="$(lxc network get lxdbr0 ipv4.address | sed 's|\.[0-9]\+/|.0/|')"
CIDR6="$(lxc network get lxdbr0 ipv6.address | sed 's|:[0-9]\+/|:/|')"
sudo ufw route allow in on lxdbr0 from "${CIDR4}"
sudo ufw route allow in on lxdbr0 from "${CIDR6}"
以下のコマンドで Windows 仮想マシンを LXD にインポートできる形式にコンバートします。Linux 仮想マシンも同じコマンドでコンバートできます。
mkdir ./os
sudo virt-v2v --block-driver virtio-scsi -o local -of raw -os ./os -i vmx ./test-vm.vmx
[ 0.0] Setting up the source: -i vmx ./test-vm.vmx
[ 1.0] Opening the source
[ 13.5] Inspecting the source
[ 15.1] Checking for sufficient free disk space in the guest
[ 15.1] Converting Windows 10 Pro to run on KVM
virt-v2v: This guest has virtio drivers installed.
[ 24.7] Mapping filesystem data to avoid copying unused and blank areas
[ 25.6] Closing the overlay
[ 25.7] Assigning disks to buses
[ 25.7] Checking if the guest needs BIOS or UEFI to boot
virt-v2v: This guest requires UEFI on the target to boot.
[ 25.7] Setting up the destination: -o disk -os ./os
[ 26.8] Copying disk 1/1
100% [****************************************]
[ 275.0] Creating output metadata
[ 275.0] Finishing off
cd ~/tmp
wget https://github.com/canonical/lxd/releases/latest/download/bin.linux.lxd-migrate.x86_64
chmod u+x ./bin.linux.lxd-migrate.x86_64
マイグレーションツールを実行して仮想マシンをインポートします。
sudo ./bin.linux.lxd-migrate.x86_64
Please provide LXD server URL: https://192.168.1.101:8443
Certificate fingerprint: xxxxxxxxxxxxxxxxxxxxxxxxxxxx
ok (y/n)? y
1) Use a certificate token
2) Use an existing TLS authentication certificate
3) Generate a temporary TLS authentication certificate
Please pick an authentication mechanism above: 3
Your temporary certificate is:
-----BEGIN CERTIFICATE-----
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-----END CERTIFICATE-----
It is recommended to have this certificate be manually added to LXD through `lxc config trust add` on the target server.
Alternatively you could use a pre-defined trust password to add it remotely (use of a trust password can be a security issue).
Would you like to use a trust password? [default=no]: yes
Trust password: [core.trust_password に設定したパスワード]
Remote LXD server:
Hostname: lxd-server
Version: 5.21.1
Would you like to create a container (1) or virtual-machine (2)?: 2
Name of the new instance: test-vm
Please provide the path to a disk, partition, or image file: /path/to/disk/image/test-vm-sda (コンバートしたディスクファイルを指定する)
Does the VM support UEFI Secure Boot? [default=no]:
Instance to be created:
Name: test-vm
Project: default
Type: virtual-machine
Source: /path/to/disk/image/test-vm-sda
Config:
security.secureboot: "false"
Additional overrides can be applied at this stage:
1) Begin the migration with the above configuration
2) Override profile list
3) Set additional configuration options
4) Change instance storage pool or volume size
5) Change instance network
Please pick one of the options above [default=1]: 3
Please specify config keys and values (key=value ...): limits.cpu=2
Instance to be created:
Name: test-vm
Project: default
Type: virtual-machine
Source: /path/to/disk/image/test-vm-sda
Config:
limits.cpu: "2"
security.secureboot: "false"
Additional overrides can be applied at this stage:
1) Begin the migration with the above configuration
2) Override profile list
3) Set additional configuration options
4) Change instance storage pool or volume size
5) Change instance network
Please pick one of the options above [default=1]: 3
Please specify config keys and values (key=value ...): limits.memory=4GB
Instance to be created:
Name: test-vm
Project: default
Type: virtual-machine
Source: /path/to/disk/image/test-vm-sda
Config:
limits.cpu: "2"
limits.memory: 4GB
security.secureboot: "false"
Additional overrides can be applied at this stage:
1) Begin the migration with the above configuration
2) Override profile list
3) Set additional configuration options
4) Change instance storage pool or volume size
5) Change instance network
Please pick one of the options above [default=1]: 4
Please provide the storage pool to use: default
Do you want to change the storage size? [default=no]:
Instance to be created:
Name: test-vm
Project: default
Type: virtual-machine
Source: /path/to/disk/image/test-vm-sda
Storage pool: default
Config:
limits.cpu: "2"
limits.memory: 4GB
security.secureboot: "false"
Additional overrides can be applied at this stage:
1) Begin the migration with the above configuration
2) Override profile list
3) Set additional configuration options
4) Change instance storage pool or volume size
5) Change instance network
Please pick one of the options above [default=1]: 5
Please specify the network to use for the instance: lxdbr0
Instance to be created:
Name: test-vm
Project: default
Type: virtual-machine
Source: /path/to/disk/image/test-vm-sda
Storage pool: default
Network name: lxdbr0
Config:
limits.cpu: "2"
limits.memory: 4GB
security.secureboot: "false"
Additional overrides can be applied at this stage:
1) Begin the migration with the above configuration
2) Override profile list
3) Set additional configuration options
4) Change instance storage pool or volume size
5) Change instance network
Please pick one of the options above [default=1]: 1
Transferring instance: test-vm: 1.03GB (257.25MB/s)
Instance test-vm successfully created
Automatically including '/usr/share/nftables.d/table-post/20-miniupnpd.nft'
Automatically including '/usr/share/nftables.d/chain-post/dstnat/20-miniupnpd.nft'
Automatically including '/usr/share/nftables.d/chain-post/forward/20-miniupnpd.nft'
Automatically including '/usr/share/nftables.d/chain-post/srcnat/20-miniupnpd.nft'
Include '/usr/share/miniupnpd/firewall.include' failed with exit code -9
# Example for a system wide configuration file
# A system wide configuration file is optional.
# If it exists, it usually defines a default account.
# This allows msmtp to be used like /usr/sbin/sendmail.
account default
# The SMTP smarthost
host smtp.gmail.com
# Use TLS on port 465
port 587
tls on
tls_starttls off
# Construct envelope-from addresses of the form "user@oursite.example"
from username@gmail.com
auth on
user username
password PASSWORD
# Syslog logging with facility LOG_MAIL instead of the default LOG_USER
syslog LOG_MAIL
さくらメールの場合の例は以下です。
# Example for a system wide configuration file
# A system wide configuration file is optional.
# If it exists, it usually defines a default account.
# This allows msmtp to be used like /usr/sbin/sendmail.
account default
# The SMTP smarthost
host example.sakura.ne.jp
# Use TLS on port 465
port 587
tls on
tls_starttls on
auth on
user router-admin@hogepiyo.com
password myPasswordHere
# Construct envelope-from addresses of the form "user@oursite.example"
from router-admin@hogepiyo.com
# Syslog logging with facility LOG_MAIL instead of the default LOG_USER
syslog LOG_MAIL