Example of how to use debootstrap --second-stage
If you want to debootstrap an arm64 Ubuntu 18.04 image from an Ubuntu 18.04 amd64 host, you would do:
sudo apt-get install \
debootstrap \
qemu-user-static \
;
debootstrap_dir=debootstrap
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"
The qemu-user-static
package in Ubuntu 18.04 also comes with a qemu-debootstrap
script that does basically the same thing as we did, but generalized to all archs. It is not in the QEMU main source tree however.
Here is my full setup to run the generated system on QEMU full system emulation: Is there any prebuilt QEMU Ubuntu image(32bit) online?
Tested on Ubuntu 18.04.