制作根文件系统
-------------------
$>apt-get install qemu qemu-system qemu-user-static
$>cd /opt/rootfs && debootstrap --arch=amd64 --include=vim,openssh-server,telnet,flex,bison,net-tools,build-essential,make,gdb --foreign buster fs_buster_x86_64 file:opt/buster/v1.6 #不能安装到移动设备,或挂载点.
$>cp /usr/bin/qemu-x86_64-static /opt/rootfs/fs_buster_x86_64/usr/bin
$>DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true LC_ALL=C LANGAGE=C LANG=C chroot /opt/rootfs/fs_buster_x86_64/ debootstrap/debootstrap --second-stage
qemu创建,分区,拷贝
-------------------
$>qemu-img create -f qcow2 rootfs.img 20G
$>modprobe nbd max_part=12
$>qemu-nbd --connect=/dev/nbd0 rootfs.img
$>fdisk /dev/nbd0
$>fdisk -l /dev/nbd0
----
/dev/nbd0p1 2048 41943039 41940992 20G 83 Linux
$>mkfs.ext4 /dev/nbd0p1
$>mount /dev/nbd0p1 /mnt/
$>qemu-nbd --disconnect /dev/nbd0
qemu安装debian-linux系统
-------------------
1.使用debian-10.6.0-amd64-netinst.iso #从网络安装debian->小容量安装光盘或U盘->amd64.
2.开始安装
$>qemu-system-x86_64 -netdev bridge,id=tap0,br=br0 -device e1000,netdev=tap0 -m 1024 -smp `nproc` -boot d -hda rootfs.img -cdrom debian-10.6.0-amd64-netinst.iso
3.安装完成后运行命令
$>qemu-system-x86_64 -netdev bridge,id=tap0,br=br0 -device e1000,netdev=tap0 -m 1024 -smp `nproc` -boot c -hda rootfs.img
$>qemu-system-x86_64 -nographic -netdev bridge,id=tap0,br=br0 -device e1000,netdev=tap0 -m 1024 -smp `nproc` -boot c -hda rootfs.img -append "console=ttyS0"