Debootstrap Ubuntu And Debian Armhf Arm64 Rootfs

19 Feb 2023 - Linux Mobile

If you have armhf or arm64 GNU/Linux available, it’s quite easy, if you don’t have to install more binfmt and dependent packages.

Debootstrap
Debootstrap armhf and arm64

You can use directory to create rootfs and then compress tar.gz or use loop to create image and install rootfs in image. This article shows you how to use loop quickly.

...

# sudo apt update

# sudo apt upgrade

# sudo apt install binfmt loop gparted debootstrap

# if dd=/dev/zero of=/path/to/image bs=512 count=1

# sudo modprobe loop

# sudo losetup -f

loop0

# sudo losetup /dev/loop0 /path/to/image

# sudo partprobe /dev/loop0

# sudo garted /dev/loop0

Create pmOS_boot (flags boot) and pmOS_root partition

# sudo mount -t ext2 -o loop /dev/loop0p1 /media/boot

Copy /boot to pmOS_boot

Now we debootstrap rootfs to pmOS_root

# sudo mount -t ext4 -o loop /dev/loop0p2 /media/rootfs

Ubuntu Lunar Lobster and others
# debootstrap lunar /media/rootfs http://ports.ubuntu.com

Debian Bookworm and others
# debootstrap bookworm $D http://ftp.debian.org/debian

After debootstrap, we chroot to update and upgrade

# mount -t proc none $D/proc

# mount -o bind /sys $D/sys

# mount -o bind /dev $D/dev

# mount -o bind /dev/pts $D/dev/pts

# nano $D/etc/apt/sources.list


Ubuntu: with [distro-version] such as: jammy, kinetic, lunar

deb http://ports.ubuntu.com/ubuntu-ports/ [distro-version] main restricted universe multiverse

# deb-src http://ports.ubuntu.com/ubuntu-ports/ [distro-version] main restricted universe multiverse

deb http://ports.ubuntu.com/ubuntu-ports/ [distro-version]-updates main restricted universe multiverse

# deb-src http://ports.ubuntu.com/ubuntu-ports/ [distro-version]-updates main restricted universe multiverse

deb http://ports.ubuntu.com/ubuntu-ports/ [distro-version]-backports main restricted universe multiverse

# deb-src http://ports.ubuntu.com/ubuntu-ports/ [distro-version]-backports main restricted universe multiverse

deb http://ports.ubuntu.com/ubuntu-ports/ [distro-version]-security main restricted universe multiverse

# deb-src http://ports.ubuntu.com/ubuntu-ports/ [distro-version]-security main restricted universe multiverse

Debian:

deb http://deb.debian.org/debian bookworm main contrib non-free

deb http://security.debian.org/debian-security bookworm-security main contrib non-free

deb http://deb.debian.org/debian bookworm-backports main contrib non-free

deb http://deb.debian.org/debian bookworm-updates main contrib non-free

# chroot /media/rootfs

# apt update

# apt upgrade

Ubuntu:

# apt -y install ubuntu-standard initramfs-tools language-pack-en

Debian:

# apt -y install locales initramfs-tools

# tasksel install standard

# tasksel --list-tasks

# dpkg-reconfigure tzdata

# dpkg-reconfigure locales

en_US.UTF-8

# apt install suckless-tools dmenu term lightdm lightdm-settings onboard iwd nano htop neofetch blueman iio-sensors-proxy alsa-utils xfonts-base xfonts-75dpi xfonts-100dpi xfonts-cyrillic

# sudo nano $D/etc/fstab

LABEL=pmOS_root      /               ext4    defaults,noatime            0   0

LABEL=pmOS_boot      /boot           ext2    defaults                            0   1

tmpfs                /tmp            tmpfs   defaults,noatime,mode=1777          0   0

tmpfs                /var/tmp        tmpfs   defaults,noatime,mode=1777          0   0

# tmpfs                /var/spool      tmpfs   defaults,noatime,mode=1777          0   0

tmpfs                /var/log        tmpfs   defaults,noatime,mode=0755          0   0

# nano $D/etc/environment

MOZ_USE_XINPUT2=1

MOZ_X11_EGL=1

Create oem user and password

# useradd -mG sudo <username>

# passwd <username>

New passwd: <password>

# usermod -a -G adm,dialout,cdrom,audio,video,plugdev,dip,root,input <username>

Copy kernel folder to /media/rootfs

# cp -r /etc/* /media/rootfs/etc/

# cp -r /lib/* /media/rootfs/lib/

# cp -r /usr/* /media/rootfs/usr/

# cp -r /var/* /media/rootfs/var/

# umount /media/rootfs/proc

# umount /media/rootfs/sys

# umount /media/rootfs/dev/pts

# umount /media/rootfs/dev/

# umount /media/rootfs/

...

We had image including /boot and /rootfs partition now. We can push image to device and fastboot flash boot.img to boot partition. Restart to testing That’s all steps…

The reference link: Bootstrapping Ubuntu MATE for an armhf base

 

Recent Posts:

First of all, GNU/Linux running mainline kernel has 2 main... more

Because Android is a fork of GNU/Linux, that means only... more

When I created my personal blog from basic jekyll barebone,... more

U Boot On Tegra Soc

12 Feb 2023 - tegra

As mentioned in the previous post, Nexus 7 2012 grouper/tilapia... more

Fosdem 2023

05 Feb 2023 - linuxmobile

This event could view online at this link. They... more

I finished barebone static blog from Jekyll documents and... more

This is hard part about Tegra 3 T30L, which I... more

This post, I share my experiences from I/O and CPU... more

I wrote some lk2nd experiences at previous post. Xiaomi Redmi... more

How the system booting!? Let’s start, since Google created compatible... more

This is the first SoC on ARM. Nvidia made ULP... more

When I wanna push source code to git, I saw... more

When I was online, I saw some github.io website. I’ve... more

 
More articles