Setting Alpine armhf on mmc in sys mode

2020-11-14

this example is for RPi zero w

make partitions

device=mmcblk0
parted -s /dev/$device mktable msdos
parted -s /dev/$device unit s -- mkpart primary fat32 2048 1050623
parted -s /dev/$device unit s -- mkpart primary ext4 1050624 9439231
parted -s /dev/$device -- set 1 boot on

make filesystems on partions (mkfs.FSTYPE params)

mount root partition and do basic install

mount /dev/mmcblk0p2 /mnt
apk --root /mnt --arch armhf --allow-untrusted --initdb \
  -X http://dl-cdn.alpinelinux.org/alpine/v3.12/main \
  -X http://dl-cdn.alpinelinux.org/alpine/v3.12/community \
  add alpine-base alpine-baselayout alpine-conf kmod openrc dbus \
  sysfsutils ssl_client ca-certificates-bundle alpine-mirrors alpine-keys

modprobe vfat
sync
mount /dev/mmcblk0p1 /mnt/boot
mount -t proc none mnt/proc
mount -o bind /sys mnt/sys
mount -o bind /dev mnt/dev
chroot /mnt /bin/ash -l
exit

when in chroot do some of needed changes

vi etc/inittab
vi etc/securetty
cd
sync
cd /mnt/boot
vi extlinux/extlinux.conf
vi cmdline.txt

after exiting from chroot do next

umount mnt/dev
umount mnt/sys
umount mnt/proc
umount /mnt/boot
umount /mnt