有没有预先构建的QEMU Ubuntu图像(32位)在线?

我在玩QEMU。 在这里,我发现了一些预构建的操作系统映像

http://docs.openstack.org/trunk/openstack-compute/admin/content/starting-images.html

但它们都适用于64位系统,而我的系统是32位。 有谁知道在线是否有任何32位预建图像?

所以我可以直接使用它们而不需要打扰安装。

谢谢。

谷歌快速搜索显示以下内容(我没有尝试过任何一种)

  • stacklet.com
  • Ubuntu云图像

此外,您可以使用vmbuilder (此处称为ubuntu-vmbuilder )快速创建Ubuntu映像到KVM,VirtualBox等。

作为最后的手段,您可以使用qemu-img命令将VirtualBox / VMware中的磁盘映像转换为更适合QEMU / KVM的格式(可能不需要这样:我认为QEMU / KVM可以与其他图像类型一起使用,如vdi或VMDK)。

 $ qemu-img convert -f [vdi|vmdk|...] -O qcow2 OriginalImage NewImage 

注意 :如果您使用的是32位操作系统,则无法运行带有KVM的64位虚拟机。 但是QEMU是一个模拟器,所以它应该让你在32位操作系统上运行64位vm。 但性能开销可能会很大!

debootstrap Ubuntu 18.04

它不是预先制作的图像,而是下载所有预先构建的软件包,因此它也很快,但也更加可配置和有用。

 #!/usr/bin/env bash set -eux debootstrap_dir=debootstrap root_filesystem=debootstrap.ext2.qcow2 sudo apt-get install \ debootstrap \ libguestfs-tools \ qemu-system-x86 \ ; if [ ! -d "$debootstrap_dir" ]; then # Create debootstrap directory. # - linux-image-generic: downloads the kernel image we will use under /boot # - network-manager: automatically starts the network at boot for us sudo debootstrap \ --include linux-image-generic \ bionic \ "$debootstrap_dir" \ http://archive.ubuntu.com/ubuntu \ ; sudo rm -f "$root_filesystem" fi linux_image="$(printf "${debootstrap_dir}/boot/vmlinuz-"*)" if [ ! -f "$root_filesystem" ]; then # Set root password. echo 'root:root' | sudo chroot "$debootstrap_dir" chpasswd # Remount root filesystem as rw. cat << EOF | sudo tee "${debootstrap_dir}/etc/fstab" /dev/sda / ext4 errors=remount-ro,acl 0 1 EOF # Automaticaly start networking. # Otherwise network commands fail with: # Temporary failure in name resolution # https://askubuntu.com/questions/1045278/ubuntu-server-18-04-temporary-failure-in-name-resolution/1080902#1080902 cat << EOF | sudo tee "$debootstrap_dir/etc/systemd/system/dhclient.service" [Unit] Description=DHCP Client Documentation=man:dhclient(8) Wants=network.target Before=network.target [Service] Type=forking PIDFile=/var/run/dhclient.pid ExecStart=/sbin/dhclient -4 -q [Install] WantedBy=multi-user.target EOF sudo ln -sf "$debootstrap_dir/etc/systemd/system/dhclient.service" \ "${debootstrap_dir}/etc/systemd/system/multi-user.target.wants/dhclient.service" # Why Ubuntu, why. # https://bugs.launchpad.net/ubuntu/+source/linux/+bug/759725 sudo chmod +r "${linux_image}" # Generate image file from debootstrap directory. # Leave 1Gb extra empty space in the image. sudo virt-make-fs \ --format qcow2 \ --size +1G \ --type ext2 \ "$debootstrap_dir" \ "$root_filesystem" \ ; sudo chmod 666 "$root_filesystem" fi qemu-system-x86_64 \ -append 'console=ttyS0 root=/dev/sda' \ -drive "file=${root_filesystem},format=qcow2" \ -enable-kvm \ -serial mon:stdio \ -m 2G \ -kernel "${linux_image}" \ -device rtl8139,netdev=net0 \ -netdev user,id=net0 \ ; 

GitHub上游 。

此引导没有任何系统错误或警告。

现在从终端,使用root / root登录,然后使用以下命令检查Internet是否正常工作:

 printf 'GET / HTTP/1.1\r\nHost: example.com\r\n\r\n' | nc example.com 80 apt-get update apt-get install hello hello 

我们使用了https://stackoverflow.com/questions/32341518/how-to-make-an-http-get-request-manually-with-netcat/52662497#52662497中解释的nc ,因为:

  • 默认情况下不安装wgetcurl
  • 默认情况下, ping无法在QEMU中运行: https : //unix.stackexchange.com/questions/473448/how-to-ping-from-the-qemu-guest-to-an-external-url

类比Debian版本: https : //unix.stackexchange.com/questions/275429/creating-bootable-debian-image-with-debootstrap/473256#473256

在Ubuntu 18.04主机上测试。

构建自己的内核

既然我们在这里:

 git clone git://kernel.ubuntu.com/ubuntu/ubuntu-bionic.git cd ubuntu-bionic # Tag matches the working kernel that debootstrap downloaded for us. git checkout Ubuntu-4.15.0-20.21 fakeroot debian/rules clean debian/rules updateconfigs fakeroot debian/rules build-generic linux_image="$(pwd)/debian/build/build-generic/arch/x86_64/boot/bzImage" 

这产生了完全相同的配置,我相信使用了与debootstrap下载的打包的Ubuntu完全相同的源代码,如下所述: 我在哪里可以获得11.04内核.config文件?

然后我修补它:

 diff --git a/init/main.cb/init/main.c index b8b121c17ff1..542229349efc 100644 --- a/init/main.c +++ b/init/main.c @@ -516,6 +516,8 @@ asmlinkage __visible void __init start_kernel(void) char *command_line; char *after_dashes; + pr_info("I'VE HACKED THE LINUX KERNEL!!!"); + set_task_stack_end_magic(&init_task); smp_setup_processor_id(); debug_objects_early_init(); 

和重建:

 fakeroot debian/rules build-generic 

它确实在启动时打印了我的消息:

 I'VE HACKED THE LINUX KERNEL!!! 

虽然重建速度不是很快,所以也许有更好的命令? 我等着它说:

 Kernel: arch/x86/boot/bzImage is ready (#3) 

并继续奔跑。

arm64

该过程类似于amd64,但有以下区别:

1)

我们必须做两个阶段的debootstrap

  • 首先使用--foreign来下载软件包
  • 然后我们将QEMU static安装到chroot
  • 然后我们使用QEMU用户模式仿真+ binfmt_misc进行带有--second-stage的软件包安装

另请参阅: 什么是debootstrap - 第二阶段

2)默认内核启动最终失败:

 [ 0.773665] Please append a correct "root=" boot option; here are the available partitions: [ 0.774033] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0) 

空分区列表表明磁盘驱动程序出现严重错误,在尝试丢失选项后:

 CONFIG_VIRTIO_BLK=y 

我认为它在我使用ISO时有效,因为模块必须从initrd加载。

我尝试使用其他磁盘类型,但virtio是-drive if=的唯一有效值-drive if= when -M virt ,这是现在更理智的机器类型。

因此,我们必须在启用该选项的情况下重新编译我们自己的内核,如下所述: 内核构建 - 交叉编译

Ubuntu开发人员默认情况下应该调整此配置! 这非常有用!

TODO:网络不能正常工作,错误信息是:

 root@ciro-p51:~# systemctl status dhclient.service root@ciro-p51:~# cat f ● dhclient.service - DHCP Client Loaded: loaded (/etc/systemd/system/dhclient.service; enabled; vendor preset: enabled) Active: failed (Result: protocol) since Sun 2018-01-28 15:58:42 UTC; 2min 2s ago Docs: man:dhclient(8) Process: 171 ExecStart=/sbin/dhclient -4 -q (code=exited, status=0/SUCCESS) Jan 28 15:58:40 ciro-p51 systemd[1]: Starting DHCP Client... Jan 28 15:58:42 ciro-p51 dhclient[171]: No broadcast interfaces found - exiting. Jan 28 15:58:42 ciro-p51 systemd[1]: dhclient.service: Can't open PID file /var/run/dhclient.pid (yet?) after start: No such file or directory Jan 28 15:58:42 ciro-p51 systemd[1]: dhclient.service: Failed with result 'protocol'. Jan 28 15:58:42 ciro-p51 systemd[1]: Failed to start DHCP Client. 

这是完全自动化的脚本:

 #!/usr/bin/env bash # https://askubuntu.com/questions/281763/is-there-any-prebuilt-qemu-ubuntu-image32bit-online/1081171#1081171 set -eux debootstrap_dir=debootstrap root_filesystem=debootstrap.ext2.qcow2 sudo apt-get install \ gcc-aarch64-linux-gnu \ debootstrap \ libguestfs-tools \ qemu-system-aarch64 \ qemu-user-static \ ; if [ ! -d "$debootstrap_dir" ]; then sudo debootstrap \ --arch arm64 \ --foreign \ bionic \ "$debootstrap_dir" \ http://ports.ubuntu.com/ubuntu-ports \ ; sudo mkdir -p "${debootstrap_dir}/usr/bin" sudo cp "$(which qemu-aarch64-static)" "${debootstrap_dir}/usr/bin" sudo chroot "$debootstrap_dir" /debootstrap/debootstrap --second-stage sudo rm -f "$root_filesystem" fi linux_image="$(printf "${debootstrap_dir}/boot/vmlinuz-"*)" if [ ! -f "$root_filesystem" ]; then # Set root password. echo 'root:root' | sudo chroot "$debootstrap_dir" chpasswd # Remount root filesystem as rw. cat << EOF | sudo tee "${debootstrap_dir}/etc/fstab" /dev/sda / ext4 errors=remount-ro,acl 0 1 EOF # Automaticaly start networking. # Otherwise network commands fail with: # Temporary failure in name resolution # https://askubuntu.com/questions/1045278/ubuntu-server-18-04-temporary-failure-in-name-resolution/1080902#1080902 cat << EOF | sudo tee "${debootstrap_dir}/etc/systemd/system/dhclient.service" [Unit] Description=DHCP Client Documentation=man:dhclient(8) Wants=network.target Before=network.target [Service] Type=forking PIDFile=/var/run/dhclient.pid ExecStart=/sbin/dhclient -4 -q [Install] WantedBy=multi-user.target EOF sudo ln -sf "${debootstrap_dir}/etc/systemd/system/dhclient.service" \ "${debootstrap_dir}/etc/systemd/system/multi-user.target.wants/dhclient.service" # Why Ubuntu, why. # https://bugs.launchpad.net/ubuntu/+source/linux/+bug/759725 sudo chmod +r "${linux_image}" # Generate image file from debootstrap directory. # Leave 1Gb extra empty space in the image. sudo virt-make-fs \ --format qcow2 \ --size +1G \ --type ext2 \ "$debootstrap_dir" \ "$root_filesystem" \ ; sudo chmod 666 "$root_filesystem" fi # Build the Linux kernel. linux_image="$(pwd)/linux/debian/build/build-generic/arch/arm64/boot/Image" if [ ! -f "$linux_image" ]; then git clone --branch Ubuntu-4.15.0-20.21 --depth 1 git://kernel.ubuntu.com/ubuntu/ubuntu-bionic.git linux cd linux patch -p1 << EOF diff --git a/debian.master/config/config.common.ubuntu b/debian.master/config/config.common.ubuntu index 5ff32cb997e9..8a190d3a0299 100644 --- a/debian.master/config/config.common.ubuntu +++ b/debian.master/config/config.common.ubuntu @@ -10153,7 +10153,7 @@ CONFIG_VIDEO_ZORAN_ZR36060=m CONFIG_VIPERBOARD_ADC=m CONFIG_VIRTIO=y CONFIG_VIRTIO_BALLOON=y -CONFIG_VIRTIO_BLK=m +CONFIG_VIRTIO_BLK=y CONFIG_VIRTIO_BLK_SCSI=y CONFIG_VIRTIO_CONSOLE=y CONFIG_VIRTIO_INPUT=m EOF export ARCH=arm64 export $(dpkg-architecture -aarm64) export CROSS_COMPILE=aarch64-linux-gnu- fakeroot debian/rules clean debian/rules updateconfigs fakeroot debian/rules DEB_BUILD_OPTIONS=parallel=`nproc` build-generic cd - fi qemu-system-aarch64 \ -append 'console=ttyAMA0 root=/dev/vda rootfstype=ext2' \ -device rtl8139,netdev=net0 \ -drive "file=${root_filesystem},format=qcow2" \ -kernel "${linux_image}" \ -m 2G \ -netdev user,id=net0 \ -serial mon:stdio \ -M virt,highmem=off \ -cpu cortex-a57 \ -nographic \ ; 

GitHub上游 。

在QEMU上运行常规ISO

请参阅: 如何在QEMU上运行Ubuntu 16.04 Desktop?

它确实需要手动完成安装程序,但它是您可能做的最稳定的事情,如果您只是想让运行的VM不时运行,那就完全没问题了。

https://www.turnkeylinux.org/已存在多年。 他们有一个巨大的目录下载,预制的“设备”像多种格式的图像(ova,iso,vdmk,openstack,xen)。 他们甚至可以在AWS中为您启动图像。

当我想开始探索特定的堆栈或需要解决问题时,我经常会下载他们的图像,将其转换为cow2并使用它。

您还可以从https://app.vagrantup.com/boxes/search或https://virtualboxes.org/images/获取图像并进行转换。

请参阅http://cloud-images.ubuntu.com/ ,其中包含可与qemu / kvm一起使用的云图像。