我从这里下载了 qcow2 ubuntu 18.04 img:https://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64.img
我想在将 qcow2 映像用作基础映像在其上创建 vms 之前,在其中添加一些包。
此命令更新 repos 成功:
> virt-customize -a ubuntu18.04-zsh.img --run-command 'apt update -y'
[ 0.0] Examining the guest ...
[ 4.7] Setting a random seed
virt-customize: warning: random seed could not be set for this type of
guest
[ 4.7] Running: apt update -y
[ 65.5] Finishing off
但是当我尝试安装 zsh 时,它无法连接到互联网:
> virt-customize -a ubuntu18.04-zsh.img --install zsh
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/z/zsh/zsh-common_5.4.2-3ubuntu3.1_all.deb Temporary failure resolving 'archive.ubuntu.com'
E: Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/z/zsh/zsh_5.4.2-3ubuntu3.1_amd64.deb Temporary failure resolving 'archive.ubuntu.com'
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
virt-customize: error:
export DEBIAN_FRONTEND=noninteractive
apt_opts='-q -y -o Dpkg::Options::=--force-confnew'
apt-get $apt_opts update
apt-get $apt_opts install 'zsh'
: command exited with an error
If reporting bugs, run virt-customize with debugging enabled and include
the complete output:
virt-customize -v -x [...]
ubuntu18.04-zsh.img 上没有运行虚拟机。有没有办法自定义 qcow2 img?
答案1
quanlm@quan-laptop:/works/home/quan/Downloads$ sudo virt-customize -a xenial-server-cloudimg-amd64-disk01.img --run-command 'sudo apt update -y'
[ 0,0] Examining the guest ...
[ 2,1] Setting a random seed
[ 2,1] Running: sudo apt update -y
[ 14,3] Finishing off
quanlm@quan-laptop:/works/home/quan/Downloads$ sudo virt-customize -a xenial-server-cloudimg-amd64-disk01.img --install htop
[ 0,0] Examining the guest ...
[ 2,1] Setting a random seed
[ 2,1] Installing packages: htop
[ 30,8] Finishing off
quanlm@quan-laptop:/works/home/quan/Downloads$ sudo virt-customize -a xenial-server-cloudimg-amd64-disk01.img --install zsh
[ 0,0] Examining the guest ...
[ 2,2] Setting a random seed
[ 2,2] Installing packages: zsh
[ 43,2] Finishing off
您确定 zsh 在 ubuntu18.04 中有不同的包名称吗?此图像是 16.04,并且也尝试使用 sudo 命令?