-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathubuntu-image-custom
31 lines (21 loc) · 1.57 KB
/
ubuntu-image-custom
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
export LIBGUESTFS_BACKEND=direct
export image_name='focal-server-cloudimg-amd64.img'
virt-customize -a $image_name --run-command 'sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak'
virt-customize -a $image_name --upload /root/cloud-images/sources.list:/etc/apt/sources.list
virt-customize -a $image_name --run-command 'sudo sed "13a apt_preserve_sources_list: true" -i /etc/cloud/cloud.cfg'
virt-customize -a $image_name --install qemu-guest-agent
virt-customize -a $image_name --run-command 'systemctl enable qemu-guest-agent'
virt-customize -a $image_name --timezone "Asia/Shanghai"
virt-customize -a $image_name --edit '/etc/ssh/sshd_config:s/PasswordAuthentication no/PasswordAuthentication yes/'
virt-customize -a $image_name --edit '/etc/ssh/sshd_config:s/#PermitRootLogin prohibit-password/PermitRootLogin yes/'
virt-customize -a $image_name --run-command ' touch /root/.hushlogin'
virt-customize -a $image_name --append-line '/etc/profile:alias c="clear"'
#inatall agent only zstack . openstack no need
virt-customize -a $image_name --run-command 'mkdir -p /var/lib/cloud/scripts/per-once'
virt-customize -a $image_name --upload /root/cloud-images/zstack.sh:/var/lib/cloud/scripts/per-once/zstack.sh
virt-customize -a $image_name --run-command 'chmod +x /var/lib/cloud/scripts/per-once/zstack.sh'
#extend disk only zstack ,opnestack no need
qemu-img info focal-server-cloudimg-amd64.img
qemu-img resize focal-server-cloudimg-amd64.img +78g
## 参考下面文章,命令可以多条一起运行。如果需要。
https://platform9.com/blog/how-to-create-customized-qcow-images/