debootstrap arm64
1)
-- foreign 패키지 다운로드.
-- chroot 사용
-- --second-stage + QEMU 사용자 모드 에물레이션 사용.(binfmt_misc)
2) 커널 vfs 패닉
[ 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
initrd에서 모듈이 로드되어야 하기 때문에 ISO 이미지를 사용해서 동작 시켜야 할 듯 함.
다른 유형의 파일시스템 유형을 사용하려고 시도했지만 커널 지원 문제가 있어, 커널 컴파일을 해야함.
-drive if= -M virt
데비안 계열 우분투 패키지 커널을 사용할 때 arm64 커널 빌드 명령어.
처음 빌드 시
export ARCH=arm64
export $(dpkg-architecture -aarm64); export CROSS_COMPILE=aarch64-linux-gnu-
fakeroot debian/rules clean
debian/rules build
fakeroot debian/rules binary
두번째 이상 빌드시.
rm debian/stamps/stamp-build*
debian/rules build
fakeroot debian/rules binary
커널 설정 옵션에서 개발자 모드를 활성화.
Ubuntu devs, CONFIG y
인터넷 동작 문제.
systemctl status dhclient.service
cat f
자동 설치 스크립트
#!/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
# 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"
# 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
# 커널 컴파일.
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
cat << EOF | patch -p1
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
#linux_image=/home/ciro/bak/git/linux-kernel-module-cheat/out/linux/default/aarch64/arch/arm64/boot/Image
#linux_image=/home/ciro/bak/git/linux-kernel-module-cheat/submodules/linux/debian/build/build-generic/arch/arm64/boot/Image
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 \
;
댓글 없음:
댓글 쓰기