Andreas Gustafsson

debootstrap Debian Buster on imx8mminievk

Discussion created by Andreas Gustafsson on Apr 5, 2019
Latest reply on Nov 8, 2019 by Sebastian Götz

This guide will show you how to debootstrap Debian Buster on imx8mminievk on a SD-card, but will very likely help you on other systems as well. First you need a Linux installation present on the imx8mminievk.

 

Follow the Getting Started guide to install a Linux System on the board. In short it is done in the following 5 steps:

  1.  Download L4.14.78_1.0.0_ga_images_MX8MMEVK.zip
  2. Download uuu
  3. Put board in download mode (SDP) [1010xxxxxx] [xxxxxxxxx0]
  4. run uuu with L4.14.78_1.0.0_ga_images_MX8MMEVK.zip as argument
  5. plug in and turn on the board

 

Now put the board back in eMMC boot mode [0110110001] [0001010100] and start up the supplied Linux system. All logins are done with root (no password).

 

Plug in a SD-card and copy the partition table:

sfdisk -d /dev/mmcblk2 | sfdisk /dev/mmcblk1

Copy data from the boot partition:

dd if=/dev/mmcblk2p1 of=/dev/mmcblk1p1 bs=1M

Resize data partition on the target (SD-card):

echo ",+" | sfdisk -N2 /dev/mmcblk1

Create file system and mount it:

mkfs.ext4 /dev/mmcblk1p2
mkdir /mnt/target
mount /dev/mmcblk1p2 /mnt/target

To be able to bootstrap the system we need debootstrap and binutils, (1), (2) available on the system. Use ar to extract the data.tar on another computer (or 7zip if you use Windows), copy the tar-files with scp/winscp onto the board and extract with tar -xf. (Because 7zip/windows cant handle symlinks).

 

Set up symbolic links for debootstrap, ar and libbfd:

ln -s /home/root/usr/sbin/debootstrap /usr/sbin/
ln -s /home/root/usr/share/debootstrap /usr/share/
ln -s /home/root/usr/bin/ar /usr/bin/
ln -s /home/root/usr/lib/aarch64-linux-gnu/libbfd-2.31.1-system.so /usr/lib/

 

Start the debootstrap:

debootstrap --arch arm64 buster /mnt/target http://ftp.debian.org/debian

Configuring the target:

#copy mtab (will be overwritten later at restart)
cp /etc/mtab /mnt/target/etc/mtab

#bind virtual file systems
mount -o bind /dev /mnt/target/dev
mount -o bind /proc /mnt/target/proc
mount -o bind /sys /mnt/target/sys

#enter target
chroot /mnt/target /bin/bash

#set up fstab
echo UUID=$(blkid /dev/mmcblk1p2 -o value|head -n1) / ext4 defaults,errors=remount-ro 0 1 > /etc/fstab

#put hostname in /etc/hosts
sed -i "1 a 127.0.0.1 $(cat /etc/hostname)" /etc/hosts

#install sudo
apt install sudo

#remove root login
passwd -d root
passwd -l root
#add new user
adduser debian

Don't forget:

addgroup debian sudo

Install more packages (not necessary):

tasksel --new-install

Exit the chroot:

exit

 

You're now ready to boot your new Debian installation. Put the card in MicroSD boot mode [0110110010] [0001101000]. And issue a reboot command:

reboot

If everything went smoothly you should now see your system start with Debian Buster. It's also possible to debootstrap Ubuntu or other Debian based systems.

Feel free to comment or ask questions.

 

I'll soon put up a guide how to build the linux kernel from source.

Building the imx8mminievk kernel from source 

 

With inspiration from: HOW-TO: Install Debian using debootstrap.

Outcomes