Dev/Embedded/Rootfs/Devuan/FromScratch: Difference between revisions
No edit summary |
|||
(6 intermediate revisions by the same user not shown) | |||
Line 15: | Line 15: | ||
And once you get the prompt, execute the end of the installation : | And once you get the prompt, execute the end of the installation : | ||
<pre> | |||
export PATH=/usr/sbin:/usr/bin:/sbin:/bin | |||
mount -o remount,rw / | |||
mount -t proc none /proc | |||
mount -t sysfs none /sys | |||
mountpoint -q /dev || mount -t devtmpfs none /dev | |||
[ ! -d /dev/pts ] && mkdir /dev/pts | |||
mount -t devpts none /dev/pts | |||
trap -- '' SIGUSR1 # Avoid getting killed by SIGUSR1 sent to restart init | |||
You should then | /debootstrap/debootstrap --second-stage | ||
</pre> | |||
You should then '''set the root password''', and then stop the board (halt -f). | |||
==== Solution 2 : mount on existing system ==== | ==== Solution 2 : mount on existing system ==== | ||
Line 34: | Line 36: | ||
mount -o bind /dev/pts /mnt/tmp/dev/pts | mount -o bind /dev/pts /mnt/tmp/dev/pts | ||
chroot /mnt/tmp /bin/bash | chroot /mnt/tmp /bin/bash | ||
export PATH= | export PATH=/usr/sbin:/usr/bin:/sbin:/bin | ||
/debootstrap/debootstrap --second-stage | /debootstrap/debootstrap --second-stage | ||
=== Part 3 : Config === | |||
'''Before rebooting''', you must modify inittab in order to get a login prompt : | |||
T0:12345:respawn:/sbin/getty -L ttyS0 115200 vt100 | |||
And reboot the board once the process has completed. | And reboot the board once the process has completed. |
Latest revision as of 13:49, 8 November 2024
Using debootstrap
Part 1 : on any computer (running debian based distribution of course)
Use the following debootstrap command :
debootstrap --foreign --arch=arm64 --include=vim,bsdutils,openssh-client,openssh-server --exclude=ed,nano,tasksel,tasksel-data,vim-tiny --verbose ceres rootfs/ http://fr.deb.devuan.org/merged
You can add some of these (and many more) depending on your needs :
locales,file,net-tools,ca-certificates,bzip2,devuan-keyring,debian-archive-keyring,debian-keyring,diffutils,findutils,iptables,isc-dhcp-client,netbase,ntp,openssh-sftp-server,screen,wireless-tools,minicom
Do not add udev !
It may be possible to add eudev, but somtimes the second stage fails when it is included, so it may be better to add it after the second stage successfully completed (with apt-get install).
Part 2 : on the target
Solution 1 : "init=" kernel parameter
Add "init=/bin/bash" to your kernel command line (in the bootloader configuration), to get something like this (modify and/or add any required option according to your system) :
console=ttyS0,115200n8 root=/dev/mmcblk0p2 rw init=/bin/bash
And once you get the prompt, execute the end of the installation :
export PATH=/usr/sbin:/usr/bin:/sbin:/bin mount -o remount,rw / mount -t proc none /proc mount -t sysfs none /sys mountpoint -q /dev || mount -t devtmpfs none /dev [ ! -d /dev/pts ] && mkdir /dev/pts mount -t devpts none /dev/pts trap -- '' SIGUSR1 # Avoid getting killed by SIGUSR1 sent to restart init /debootstrap/debootstrap --second-stage
You should then set the root password, and then stop the board (halt -f).
Solution 2 : mount on existing system
If you've got a running system (any kind of Linux distribution or custom image) for your board and have a solution to mount some external device or remote filesystem on it, then you can use it to run the second stage :
mount /path/to/remote/or/external /mnt/tmp mount -o bind /proc /mnt/tmp/proc mount -o bind /sys /mnt/tmp/sys mount -o bind /dev /mnt/tmp/dev mount -o bind /dev/pts /mnt/tmp/dev/pts chroot /mnt/tmp /bin/bash export PATH=/usr/sbin:/usr/bin:/sbin:/bin /debootstrap/debootstrap --second-stage
Part 3 : Config
Before rebooting, you must modify inittab in order to get a login prompt :
T0:12345:respawn:/sbin/getty -L ttyS0 115200 vt100
And reboot the board once the process has completed.
Using multistrap
Multistrap is a tool that does essentially the same job as debootstrap using an entirely different method, and then extends the functionality to support automated creation of complete, bootable, root filesystems.
Its main limitation compared to debootstrap is that it uses apt and dpkg directly so can only work on a debian system - debootstrap depends on nothing but shell, wget, binutils and thus can run pretty-much anywhere.
Part 1 : on the host
Install multistrap and refer to information from Multistrap debian wiki in order to create your configuration file.
Warning, in order to avoid a lengthy second stage I recomend adding "addimportant=true" in the "General" section of the configuration file.
Then proceed with the first part of the installation :
multistrap -a armhf -d rootfs/ -f my.config.multistrap
Of course set architecture and destination directory according to your needs (this can be done in the configuration file too).
Part 2 : on the target
You must then complete the installation on the target :
mount -o remount,rw / mount -t proc none /proc mount -t sysfs none /sys mount -t devtmpfs none /dev [ ! -d /dev/pts ] && mkdir /dev/pts mount -t devpts none /dev/pts export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true export LC_ALL=C LANGUAGE=C LANG=C dpkg --configure -a
Another Way using live-build
Another solution is presented here : Debian on BeagleBone.
This solution uses live-build and qemu.