The officially official Devuan Forum!

You are not logged in.

#1 2020-10-06 08:25:57

emojifreak
Member
Registered: 2020-10-06
Posts: 15  

unofficial SD card images and their builder for RPi series (inc. RPi4)

Edit: A bug-fixed version is available at https://github.com/emojifreak/debian-rpi-image-script
Edit: Built images are available at https://drive.google.com/drive/folders/ … sp=sharing

Hi everyone,

I made an automated shell script for building an SD card image
of pure Devuan Chimaera for Raspberry Pi 4 (and maybe 0, 1, 2, and 3)
as follows. It runs on a (Intel/AMD) computer with an SD card slot running Devuan
(or Debian or Ubuntu) with recent versions of qemu-user-static and
mmdebstrap packages. I tested it only on Raspberry Pi 4B (8GB model).
Created SD card does not have GUI, and it can be installed by tasksel etc.

An SD card should be accessible as /dev/mmcblk0, otherwise change the script.
The following script should be run as root.

#!/bin/bash

apt-get -q -y install mmdebstrap qemu-user-static binfmt-support
mkdir /mnt /mnt2 2>/dev/null

echo -n "Swap partition size in GB, 0 means no swap partition: "
read SWAPGB

DEVFILE=/dev/mmcblk0
#DEVFILE=/dev/loop2
#rm $IMGFILE
#dd if=/dev/zero of=$IMGFILE count=1 seek=`expr 4096 \* 1024 - 1`
#losetup -P $DEVFILE $IMGFILE
#losetup -l
fdisk $DEVFILE <<EOF
o
n
p
1

+256M
a
t
c
n
p
2

-${SWAPGB}GiB
p
w
EOF
partx $DEVFILE
if [ $SWAPGB -gt 0 ]; then
  fdisk $DEVFILE <<EOF
n
p
3

t
3
82
p
w
EOF
partx $DEVFILE
  mkswap -f -L RASPISWAP ${DEVFILE}p3
fi
   
echo -n "Filesystem type of the root partition (ext4 or btrfs): "
read FSTYPE
eval mkfs.${FSTYPE} -L RASPIROOT ${DEVFILE}p2

echo -n "Variant of mmdebstrap (apt, required, important, or standard): "
read MMVARIANT
cat <<EOF
Explanation of architectures:
armeb for Raspberry Pi Zero, Zero W and 1,
armhf for Raspberry Pi 2,
arm64 for Raspberry Pi 3 and 4.
32-bit kernel is unsupported on 64-bit ARM CPUs.
EOF
#echo -n 'Architecture ("armeb", "armhf", "arm64", or "armhf,arm64"):'
echo -n 'Architecture ("armeb", "armhf", or "arm64"):'
read MMDEBARCH
if [ $MMDEBARCH == armeb ]; then
    KERNELPKG=linux-image-rpi
elif [ $MMDEBARCH == armhf ]; then
    KERNELPKG=linux-image-armmp-lpae
else
    KERNELPKG=linux-image-arm64
fi
echo "Selected kernel package is $KERNELPKG."
    
mount -o async,lazytime,discard,noatime ${DEVFILE}p2 /mnt
mmdebstrap --architectures=$MMDEBARCH --variant=$MMVARIANT --components="main contrib non-free" --include=${KERNELPKG},eudev,kmod,e2fsprogs,btrfs-progs,sysvinit-core,locales,tzdata,apt-utils,whiptail,ifupdown,wpasupplicant,crda,raspi-firmware,firmware-brcm80211,firmware-linux-free,firmware-misc-nonfree,keyboard-configuration,console-setup chimaera /mnt http://deb.devuan.org/merged/

mkfs.vfat -v -F 32 -n RASPIFIRM ${DEVFILE}p1
mount -o async,discard,lazytime,noatime ${DEVFILE}p1 /mnt2
cp -Rp /mnt/boot/firmware/* /mnt2
rm -rf /mnt/boot/firmware/*
umount /mnt2
mount -o async,discard,lazytime,noatime ${DEVFILE}p1 /mnt/boot/firmware

echo -n "Choose hostname: "
read YOURHOSTNAME
echo "$YOURHOSTNAME" >/mnt/etc/hostname
cat >/mnt/etc/fstab <<EOF
LABEL=RASPIROOT / ${FSTYPE} rw,async,lazytime,discard 0 1
LABEL=RASPIFIRM /boot/firmware vfat rw,async,lazytime,discard 0 2
EOF
if [ $SWAPGB -gt 0 ]; then
  echo 'LABEL=RASPISWAP none swap sw,discard 0 0' >>/mnt/etc/fstab
fi

echo "IPv4 DHCP is assumed. Otherwise edit /etc/network/interfaces"
echo -n "Name of the primary network interface (eth0, wlan0, none): "
read NETIF

if [ $NETIF != none ]; then
  cat >>/mnt/etc/network/interfaces <<EOF
auto $NETIF
iface $NETIF inet dhcp
EOF
  if [ $NETIF == wlan0 ]; then
    echo -n "Your Wireless LAN SSID: "
    read SSID
    echo -n "Your Wireless LAN passphrease: "
    read PSK
    cat >>/mnt/etc/network/interfaces <<EOF
    wpa-ssid $SSID
    wpa-psk $PSK
EOF
  fi
fi

set -x
#chroot /mnt pam-auth-update
chroot /mnt passwd root
chroot /mnt dpkg-reconfigure tzdata
chroot /mnt dpkg-reconfigure locales
chroot /mnt dpkg-reconfigure keyboard-configuration

#chroot /mnt apt-get -y --purge --autoremove purge python2.7-minimal

echo 'console=tty0 console=ttyS1,115200 root=LABEL=RASPIROOT rw fsck.repair=yes net.ifnames=0 rootwait' >/mnt/boot/firmware/cmdline.txt

umount /mnt/boot/firmware/
umount /mnt

Last edited by emojifreak (2020-10-15 09:20:12)

Offline

#2 2020-10-06 14:10:27

tuxd3v
Member
Registered: 2019-11-14
Posts: 183  

Re: unofficial SD card images and their builder for RPi series (inc. RPi4)

hello emojifreak,
I am using crossdebootstrap on Edev1, how does mmdebstrap achieves the same?
I mean, if you are on x86, debootstraping for lets say arm64?

Thanks for your work smile


Best Regards,
tux

Offline

#3 2020-10-06 23:35:41

emojifreak
Member
Registered: 2020-10-06
Posts: 15  

Re: unofficial SD card images and their builder for RPi series (inc. RPi4)

I mean, if you are on x86, debootstraping for lets say arm64?

Thanks for your interest. Yes. mmdebstrap can handle different host and target architectures.
I am using an Intel laptop, and I can build a bootable filesystem of arm64 (and armhf, armeb etc...).
It is similar to qemu-debootstrap.

mmdebstrap can also install 64-bit kernel linux-image-arm64 and 32-bit armhf binaries by
giving --arcitectures=armhf,arm64. But due to the bug (?) in raspi-firmware
https://bugs.debian.org/cgi-bin/bugrepo … bug=971748
the resulting SD card does not boot (manual fix required to the SD card).

On the other hand, armhf emulation on Intel had been a bit buggy. One might
need a newer versions of qemu-user-static for armhf emulation.
Devuan qemu-user-static 5.1 or later are fine.

Offline

#4 2020-10-07 05:37:39

emojifreak
Member
Registered: 2020-10-06
Posts: 15  

Re: unofficial SD card images and their builder for RPi series (inc. RPi4)

I have no experience with ARM 32-bit computers, but Devuan Chimaera (arm64) seems to work fine on RPi 4B 8GB model.

Last edited by emojifreak (2020-10-07 05:38:53)

Offline

#5 2020-10-07 07:50:45

emojifreak
Member
Registered: 2020-10-06
Posts: 15  

Re: unofficial SD card images and their builder for RPi series (inc. RPi4)

I forgot to include isc-dhcp-client package in my above script. A corrected one is available at https://github.com/emojifreak/debian-rpi-image-script

Offline

#6 2020-12-03 15:05:32

csillag
Member
Registered: 2020-12-03
Posts: 2  

Re: unofficial SD card images and their builder for RPi series (inc. RPi4)

The referenced GitHub repo has a link to a google drive folder, with a bunch of pre-built images.
From that folder, I picked Raspberry_Pi_Devuan_beowulf_arm64_ext4_root_password_is_root.img.xz (built on the 16th of October), and booted in on a rPi 4b board.

It does boot, but wired networking doesn't work. As far as I can tell, no eth0 device is being created.

Is that a known issue? Thanks.

Last edited by csillag (2020-12-03 15:05:55)

Offline

#7 2020-12-03 19:54:40

csillag
Member
Registered: 2020-12-03
Posts: 2  

Re: unofficial SD card images and their builder for RPi series (inc. RPi4)

I must correct my own post. That was a false alarm. The actual problem was a wrongly written SD card.

Offline

Board footer