From 039906a9b009d9387d798421b5e62daa16e17c41 Mon Sep 17 00:00:00 2001 From: Caspar Zhang Date: Tue, 2 Jul 2019 12:21:51 +0800 Subject: [PATCH] add image.md Signed-off-by: Caspar Zhang --- image.md | 145 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ os.md | 3 +- zh/os.md | 3 +- 3 files changed, 149 insertions(+), 2 deletions(-) create mode 100644 image.md diff --git a/image.md b/image.md new file mode 100644 index 000000000000..47b25bbc66a4 --- /dev/null +++ b/image.md @@ -0,0 +1,145 @@ +Alibaba Cloud Linux 2 On-Premise Image +====================================== + +[ 中文版 ](https://github.com/alibaba/cloud-kernel/wiki/Aliyun-Linux-2-On-Premise-Image) + +We provide Alibaba Cloud Linux 2 virtual machine images for on-premises development and testing. To use the VM image, you need to do the following steps: + ++ Step 1: Download the Alibaba Cloud Linux 2 VM Image; ++ Step 2: Prepare the seed.img Boot Image; ++ Step 3: Boot the New VM. + +## Step 1: Download the Alibaba Cloud Linux 2 VM Image + +Currently the image is available for QEMU/KVM virtualization platform only, the image format is `qcow2`, and `virtio` drivers are used in guest operating system. + +| File | SHA256SUM | +|------|-----------| +| [seed.img](https://alinux2.oss-cn-hangzhou.aliyuncs.com/seed.img) | 7fd5c245c2daef9454b98b251215f5f667d415d5759389f12d0de77d15225586 | +| [aliyun_2_1903_64_20G_alibase_20190619.onprem.qcow2](https://alinux2.oss-cn-hangzhou.aliyuncs.com/aliyun_2_1903_64_20G_alibase_20190619.onprem.qcow2) | 1e0d7620fc34f928666ce945f2da9583b126a40638b20b79c7c17142aefcb638 | + +## Step 2: Prepare the seed.img Boot Image + +To boot your new VM and get the configurations initialized, you should prepare a `seed.img` boot image, which will be used by [cloud-init](https://cloudinit.readthedocs.io/en/latest/), to set up network configrations, host name, YUM source, etc. It is highly recommended to read cloud-init documentations before getting started. + +We use NoCloud data source in cloud-init, which requires a virtual disk drvier attached to VM, including two configuration files: `meta-data` and `user-data`. + ++ Create a plain-text file named `meta-data`, fill the contents as follows: + +```yaml +#cloud-config +#vim:syntax=yaml + +local-hostname: alinux-host +# FIXME: does not work for systemd-networkd +#network-interfaces: | +# iface eth0 inet static +# address 192.168.122.68 +# network 192.168.122.0 +# netmask 255.255.255.0 +# broadcast 192.168.122.255 +# gateway 192.168.122.1 +``` + ++ Create a plain-text file named `user-data`, fill the contents as follows: + +```yaml +#cloud-config +#vim:syntax=yaml + +# add a new account alinux, allow sudo priv +users: + - default + - name: alinux + sudo: ['ALL=(ALL) ALL'] + plain_text_passwd: aliyun + lock_passwd: false + +# add yum source +yum_repos: + base: + baseurl: https://mirrors.aliyun.com/alinux/$releasever/os/$basearch/ + enabled: true + gpgcheck: true + gpgkey: https://mirrors.aliyun.com/alinux/RPM-GPG-KEY-ALIYUN + name: Aliyun Linux - $releasever - Base - mirrors.aliyun.com + updates: + baseurl: https://mirrors.aliyun.com/alinux/$releasever/updates/$basearch/ + enabled: true + gpgcheck: true + gpgkey: https://mirrors.aliyun.com/alinux/RPM-GPG-KEY-ALIYUN + name: Aliyun Linux - $releasever - Updates - mirrors.aliyun.com + extras: + baseurl: https://mirrors.aliyun.com/alinux/$releasever/extras/$basearch/ + enabled: true + gpgcheck: true + gpgkey: https://mirrors.aliyun.com/alinux/RPM-GPG-KEY-ALIYUN + name: Aliyun Linux - $releasever - Extras - mirrors.aliyun.com + plus: + baseurl: https://mirrors.aliyun.com/alinux/$releasever/plus/$basearch/ + enabled: true + gpgcheck: true + gpgkey: https://mirrors.aliyun.com/alinux/RPM-GPG-KEY-ALIYUN + name: Aliyun Linux - $releasever - Plus - mirrors.aliyun.com + +# FIXME: This is a workaround for network settings since the steps in +# meta-data fail to work. Blame cloud-init or systemd-networkd :) +write_files: + - path: /etc/systemd/network/20-eth0.network + permissions: 0644 + owner: root + content: | + [Match] + Name=eth0 + + [Network] + Address=192.168.122.68/24 + Gateway=192.168.122.1 + +# FIXME: this is also a workaround for network settings. +runcmd: + - ifdown eth0 + - systemctl restart systemd-networkd +``` + +> You should at least adjust the network sections to match the real network configurations you have. + ++ Create the `seed.img` with the tool `cloud-localds` provided in `cloud-utils` package: + +Install `cloud-utils` package by: + +```bash +yum install -y cloud-utils +``` + +Then execute the following command at the same directory level as the files `meta-data` and `user-data`: + +```bash +cloud-localds seed.img user-data meta-data +``` + +to produce a `seed.img`. Note this image only includes configuration information required to boot the VM by cloud-init, it does not include the Alibaba Cloud Linux 2 operating system files. + +You could also download a `seed.img` from the table provided in Step 1. Please avoid using it if network access is mandatory but your network configuration is not `192.168.122.0/24`. + +## Step 3: Boot the New VM. + +You should attach `seed.img` to a KVM virtual machine running with Alibaba Cloud Linux 2 on-premise image. + +- If you created the VM with GUI, like virt-manager, please add a new virtual disk driver with `seed.img`, then boot the VM; + +- If you created it with a Libvirt XML, you need to add the following section to the XML file: + +```xml + + + + + +``` +- If you run the VM directly with a qemu-kvm command line, you should append the following options: + +```bash +-drive file=/path/to/your/seed.img,if=none,id=drive-virtio-disk1,format=raw,cache=none,aio=native \ +-device virtio-blk-pci,scsi=off,x-data-plane=on,config-wce=off,bus=pci.0,addr=0x6,drive=drive-virtio-disk1,id=virtio-disk1 +``` diff --git a/os.md b/os.md index b05bcfb7ad79..eb5a3c0354c7 100644 --- a/os.md +++ b/os.md @@ -25,7 +25,8 @@ Current released version is Alibaba Cloud Linux OS version 2, or known as 'Aliyu ## 2. How to use -Simply buy an ECS instance and get started: [chs](https://ecs-buy.aliyun.com/), [eng](https://ecs-buy-intl.aliyun.com/). +- Simply buy an ECS instance and get started: [chs](https://ecs-buy.aliyun.com/), [eng](https://ecs-buy-intl.aliyun.com/); +- Or download an on-premise virtual machine image and run on your own QEMU/KVM virtualization system, instructions could be found via [chs](https://github.com/alibaba/cloud-kernel/wiki/Aliyun-Linux-2-On-Premise-Image), [eng](image). ## 3. Getting source diff --git a/zh/os.md b/zh/os.md index 032e37610b9f..d20a191548a3 100644 --- a/zh/os.md +++ b/zh/os.md @@ -27,7 +27,8 @@ Alibaba Cloud Linux 2 是 Alibaba Cloud Linux 的下一代版本,其开发团 ## 2. 如何使用 Alibaba Cloud Linux 2 -当前我们随阿里云 ECS 实例免费提供 Alibaba Cloud Linux 2 操作系统镜像。如需使用,可以通过以下链接购买 ECS 实例:[中文站](https://ecs-buy.aliyun.com/), [eng](https://ecs-buy-intl.aliyun.com/). +- 当前我们随阿里云 ECS 实例免费提供 Alibaba Cloud Linux 2 操作系统镜像。如需使用,可以通过以下链接购买 ECS 实例:[中文站](https://ecs-buy.aliyun.com/), [eng](https://ecs-buy-intl.aliyun.com/); +- 也可以通过我们提供的独立虚拟机本地镜像,在支持 QEMU/KVM 虚拟化技术的操作系统中,启动 Alibaba Cloud Linux 2 操作系统镜像。操作说明可参考:[中文版](https://github.com/alibaba/cloud-kernel/wiki/Aliyun-Linux-2-On-Premise-Image), [English version](../image). ## 3. 获取源码 -- GitLab