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 32 33
| virt-customize -a debian-13-genericcloud-amd64.qcow2 \ --smp 2 --verbose \ --append-line "/etc/default/grub:# disable os-prober to avoid loopback detection issues" \ --append-line "/etc/default/grub:GRUB_DISABLE_OS_PROBER=true" \ --run-command "update-grub || true" \ --run-command "sed -i 's|Types: deb deb-src|Types: deb|g' /etc/apt/sources.list.d/debian.sources 2>/dev/null || true" \ --run-command "sed -i 's|generate_mirrorlists: true|generate_mirrorlists: false|g' /etc/cloud/cloud.cfg.d/01_debian_cloud.cfg 2>/dev/null || true" \ --run-command "printf 'APT::Install-Recommends \"0\";\\nAPT::Install-Suggests \"0\";\\n' > /etc/apt/apt.conf.d/99norecommends" \ --run-command "printf 'path-exclude=/usr/share/man/*\\npath-exclude=/usr/share/doc/*\\npath-exclude=/usr/share/info/*\\npath-exclude=/usr/share/locale/*\\npath-include=/usr/share/locale/en*\\npath-include=/usr/share/locale/zh*\\npath-include=/usr/share/locale/zh_TW*\\n' > /etc/dpkg/dpkg.cfg.d/01_nodoc" \ \ --update \ --install "openssh-server,qemu-guest-agent,sudo,ca-certificates,curl" \ --run-command "systemctl enable qemu-guest-agent || true" \ \ --run-command "mkdir -p /etc/cloud/cloud.cfg.d" \ --run-command "printf 'manage_resolv_conf: true\nresolv_conf:\n nameservers:\n - 1.1.1.1\n - 8.8.8.8\n - 2606:4700:4700::1111\n options:\n timeout: 2\n attempts: 3\n' > /etc/cloud/cloud.cfg.d/99-resolvconf.cfg" \ \ --run-command "mkdir -p /etc/systemd/resolved.conf.d" \ --run-command "printf '[Resolve]\nDNSStubListener=no\nLLMNR=no\nMulticastDNS=no\n' > /etc/systemd/resolved.conf.d/00-no-stub-no-mdns.conf" \ --run-command "ln -sf /dev/null /etc/systemd/system/avahi-daemon.service 2>/dev/null || true" \ --run-command "ln -sf /dev/null /etc/systemd/system/avahi-daemon.socket 2>/dev/null || true" \ \ --run-command "rm -rf /var/log/journal/* /var/log/journal || true" \ --run-command "rm -rf /var/lib/cloud/* || true" \ --run-command "cloud-init clean --logs || true" \ --run-command "sed -ri 's/^#?\\s*PermitRootLogin\\s+.*/PermitRootLogin yes/' /etc/ssh/sshd_config; sed -ri 's/^#?\\s*PasswordAuthentication\\s+.*/PasswordAuthentication yes/' /etc/ssh/sshd_config" \ --run-command "apt-get -y purge man-db info locales-all 2>/dev/null || true" \ --run-command "apt-get -y autoremove --purge && apt-get -y clean" \ --delete "/var/log/*.log" \ --delete "/var/lib/apt/lists/*" \ --delete "/var/cache/apt/*" \ --truncate "/etc/machine-id"
|