我正在 UML 内构建 Debian 虚拟机,但它挂起。
这是我的构建 shell 脚本:
#!/bin/bash
# Let's make sure we're updated
printf "\nUpdating...\n"
apt update
apt upgrade
# Next let's collect some tools we may need
printf "\nInstalling tcpdump, nmap, wireshark, qemu, debootstrap.\n"
apt install tcpdump nmap wireshark qemu debootstrap
# We need a tarball of the linux kernel. We use the current mainline as of this writing.
printf "\nDownloading mainline linux kernel...\n"
curl -o kernelpackage https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/snapshot/linux-4.18-rc4.tar.gz
# And we'll extract it to the current directory.
printf "\nExtracting linux kernel...\n"
tar -zxvf kernelpackage
# Next let's start with configuring UML default.
# This line changes dependent on your kernel release.
cd linux-4.18-rc4
# Set up some configuration.
printf "\nConfiguring kernel...\n"
make defconfig ARCH=um
# This summons up the kernel. Don't be afraid, this will take some time.
printf "\nBuilding kernel...\n"
make ARCH=um linux
# We need to make modules BEFORE we strip. Ignore the book.
printf "\nBuilding kernel modules...\n"
make ARCH=um modules
# Let's get a debian distribution to run in the virtual machine.
printf "\nDownloading and constructing debian image for VM...\n"
sudo debootstrap --arch amd64 --variant minbase wheezy wheezy-uml http://mirror.switch.ch/ftp/mirror/debian
# And let's ensure that UML will have write permissions.
sudo chown -R $USER:$USER wheezy-uml
# Finally, we can start the UML VM. We will be giving it a gigabyte of ram.
printf "\nStarting virtual machine...\n"
# Boot debian in the virtual machine.
./linux rootfstype=hostfs rootflags=$(pwd)/wheezy-uml init=/sbin/init rw mem=1024M
现在,这是启动 Debian 时的结果:
所以我随机挂起: crng init Done
任何帮助和建议都会很棒——我是仿真领域的新手。谢谢你!