0

I created a FAT 32 partition on my SD card and extracted the alpine rpi 3.12.3 tarball onto the 256mb partition. I then added a wifi.txt, usercfg.txt, and the headless executable script to the root of the partition, according to the official alpine wiki. When I insert the sd card into the pi, I get the 4 green blinks over and over. I have looked over questions pertaining to this problem with other distros but none seem to be relevant with alpine linux.

Has anyone loaded Alpine linux 3.12.* onto a pi4B?

1
0

(As I am writing a full guide about this topic at this moment, I will anticipate here the part that satisfies your question.)

Create a bootable MicroSD card

To identify the MicroSD card, do not plug the MicroSD car into your computer and run the command:

lsblk

Take note of the output, plug the MicroSD card into your computer and run lsblk again. Sample output:

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 223,6G  0 disk 
├─sda1   8:1    0   600M  0 part /boot/efi
├─sda2   8:2    0     1G  0 part /boot
└─sda3   8:3    0   222G  0 part /home
sdb      8:16   0 465,8G  0 disk 
└─sdb1   8:17   0 465,8G  0 part 
sdc      8:32   0 465,8G  0 disk 
└─sdc1   8:33   0 465,8G  0 part 
sdd      8:48   1  59,5G  0 disk 
└─sdd1   8:49   1  59,5G  0 part /run/media/rossijonas/67E7-60D4
zram0  252:0    0     4G  0 disk [SWAP]

Notice that sdd is the 64gb MicroSD card (at this case), and it has one partion sdd1 mounted.

(From now on, you may copy/paste the commands, but remember to replace sdd with the MicroSD disk name identified on your machine.)

Unmount the partition(s):

sudo umount /dev/sdd1

(You may need to repeat this command for other partitions, sdd2, sdd3 If more than one partition was shown with lsblk command.)

Remove the partition(s):

sudo parted /dev/sdd rm 1

(Repeat this for other existent partitions if needed, replacing 1 with the partition number.)

Erase filesystem/partition-table signatures:

sudo wipefs -af /dev/sdd

Verify that the device has no label applied and an empty partition table:

sudo parted /dev/sdd print

Sample output:

Error: /dev/sdd: unrecognised disk label
Model: Generic STORAGE DEVICE (scsi)      
Disk /dev/sdd: 63,9GB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags: 

Create MBR partitioning scheme on the MicroSD card:

sudo parted /dev/sdd mklabel msdos

(You may run sudo parted /dev/sdd print anytime to observe if changes were applied.)

Create a 500mb boot partition, with boot and lba flags:

sudo parted /dev/sdd mkpart primary 1 500m

Add boot and lba flags to the partition:

sudo parted /dev/sdd set 1 boot on sudo parted /dev/sdd set 1 lba on

Create another partition to be used for persistency: (This part will be covered on the full blog post.)

sudo parted /dev/sdd mkpart primary 501 64g

(Replace 64g with the size of your MicroSD card, ex.: 16g.)

Build a fat32 filesystem on partition 1 and a ext4 filesystem on partition 2:

sudo mkfs.vfat -F 32 /dev/sdd1 sudo mkfs.ext4 /dev/sdd2

Checking with sudo parted /dev/sdd print again, the MicroSD will end up with a scheme like this:

Model: Generic STORAGE DEVICE (scsi)
Disk /dev/sdd: 63,9GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number Start  End    Size   Type    File system  Flags
1      1049kB 500MB  499MB  primary fat32        boot, lba
2      501MB  63,9GB 63,4GB primary ext4

Flash Alpine Linux into the MicroSD

Eject and remove the MicroSD, and then plug it again.

Run lsblk to verify both partitions mountpoints.

Sample output:

sdd      8:48   1  59,5G  0 disk 
├─sdd1   8:49   1   476M  0 part /run/media/rossijonas/4F85-22E7
└─sdd2   8:50   1  59,1G  0 part /run/media/rossijonas/6a9f9b14-628b-431f-9f3c-721d526

Download Alpine Linux for Raspberry Pi (aarch64 for Raspberry Pi 4 B).

Extract the tarball into the fat32 boot partition:

cd /run/media/rossijonas/4F85-22E7

tar -zxvf ~/Downloads/alpine-rpi-3.14.0-aarch64.tar.gz

(Replace directories and filenames.)

Since it will be a headless install (without an external monitor plugged in) you can setup minimum memory usage for the GPU, maximizing available memory, via a user custom config file:

(Make sure you're still on the same working directory as the previous command.)

echo "gpu_mem=32" > usercfg.txt

Set up for the headless installation

Install nmap from the package manager:

RHEL/CentOS/Fedora/RockyLinux - sudo dnf install nmap

Ubuntu/Mint/Kali/Debian(or other Debian based) - sudo apt install nmap

Verify the IP address of your computer on the subnet it is connected:

hostname -I

Sample output:

192.168.0.129 192.168.122.1 10.19.0.12 100.85.0.1 fdeb:446c:912d:8da:: fdeb:446c:912d:8da:: 

What you need is the fisrt IP from the output, 192.168.0.129 (on this example), and from that, assuming the computer is connected with standard configuration, gateway IP address will be 192.168.0.1.

Scan the local subnet, to identify IPs currently in use:

nmap -sn 192.168.0.0/24

Sample output:

Starting Nmap 7.80 ( https://nmap.org ) at 2021-06-22 10:01 -03
Nmap scan report for _gateway (192.168.0.1)
Host is up (0.00036s latency).
Nmap scan report for 192.168.0.128
Host is up (0.0053s latency).
Nmap scan report for fd2lm (192.168.0.129)
Host is up (0.000038s latency).
Nmap scan report for 192.168.0.145
Host is up (0.0053s latency).
Nmap done: 256 IP addresses (4 hosts up) scanned in 3.26 seconds
Verify what IPs are in use and must not be reassigned. On the example, it is the IPs ending in .128, .129 and .145.

Download this repository to your machine https://github.com/mesca/alpine_headless.

(This is a crafted solution to simplify the creation of an overlay file that sets up a temporary network configuration and SSH server for the Alpine's fisrt boot on the Raspberry Pi.)

With the repository on your machine, edit the following file on your code editor:

alpine_headless/ovl/etc/network/interfaces

Replace gateway address with your subnet gateway address (192.168.0.1 in this example), and assign a static IP adress by fullfilling address with an available IP address as previously verified. I will use the ending .125 for this example.

The file will look similar to this:

auto lo
iface lo inet loopback

auto eth0
#iface eth0 inet dhcp
iface eth0 inet static
  address 192.168.0.125
  netmask 255.255.255.0
  gateway 192.168.0.1

auto wlan0
iface wlan0 inet dhcp

If the Raspberry Pi will connect via Wi-fi, edit the following file on your code editor:

(You may skip this step if the Raspberry Pi will connect via network cable.)

alpine_headless/ovl/etc/wpa_supplicant/wpa_supplicant.conf

Change the local Wi-fi network name (ssid) and the password (psk).

Example:

network={
  ssid="change_me"
  psk="change_me"
}

Build the overlay file and copy it to MicroSD boot patition's root.

(Make sure you are at the repository's alpine_headless/ folder, and run:)

./make.sh

And then copy it to the MicroSD boot partition:

cp localhost.apkovl.tar.gz /run/media/rossijonas/4F85-22E7

(Replace the MicroSD mountpoint. Check again with 'lsblk' if needed.)

Double check the MicroSD boot partition, it must contain the Alpine Linux files, the usercfg.txt file and the localhost.apkovl.tar.gz file:

ls -la /run/media/rossijonas/4F85-22E7

Output should look similar to this:

total 5548
drwxr-xr-x. 5 rossijonas rossijonas    4096 dez 31  1969 .
drwxr-x---+ 4 root       root            80 jun 22 11:09 ..
drwxr-xr-x. 3 rossijonas rossijonas    4096 jun 15 11:35 apks
drwxr-xr-x. 2 rossijonas rossijonas    4096 jun 15 11:35 boot
drwxr-xr-x. 2 rossijonas rossijonas   20480 jun 15 11:35 overlays
-rw-r--r--. 1 rossijonas rossijonas      25 jun 15 11:35 .alpine-release
-rw-r--r--. 1 rossijonas rossijonas   26894 jun 11 05:10 bcm2710-rpi-2-b.dtb
-rw-r--r--. 1 rossijonas rossijonas   28392 jun 11 05:10 bcm2710-rpi-3-b.dtb
-rw-r--r--. 1 rossijonas rossijonas   29011 jun 11 05:10 bcm2710-rpi-3-b-plus.dtb
-rw-r--r--. 1 rossijonas rossijonas   26890 jun 11 05:10 bcm2710-rpi-cm3.dtb
-rw-r--r--. 1 rossijonas rossijonas   49214 jun 11 05:10 bcm2711-rpi-400.dtb
-rw-r--r--. 1 rossijonas rossijonas   49218 jun 11 05:10 bcm2711-rpi-4-b.dtb
-rw-r--r--. 1 rossijonas rossijonas   49892 jun 11 05:10 bcm2711-rpi-cm4.dtb
-rw-r--r--. 1 rossijonas rossijonas   20120 jun 11 05:10 bcm2837-rpi-3-a-plus.dtb
-rw-r--r--. 1 rossijonas rossijonas   20525 jun 11 05:10 bcm2837-rpi-3-b.dtb
-rw-r--r--. 1 rossijonas rossijonas   20989 jun 11 05:10 bcm2837-rpi-3-b-plus.dtb
-rw-r--r--. 1 rossijonas rossijonas   19852 jun 11 05:10 bcm2837-rpi-cm3-io3.dtb
-rw-r--r--. 1 rossijonas rossijonas   52456 jun 15 06:06 bootcode.bin
-rw-r--r--. 1 rossijonas rossijonas      60 jun 15 11:34 cmdline.txt
-rw-r--r--. 1 rossijonas rossijonas     408 jun 15 11:34 config.txt
-rw-r--r--. 1 rossijonas rossijonas    5448 jun 15 06:06 fixup4.dat
-rw-r--r--. 1 rossijonas rossijonas    7314 jun 15 06:06 fixup.dat
-rw-r--r--. 1 rossijonas rossijonas     927 jun 22 11:10 localhost.apkovl.tar.gz
-rw-r--r--. 1 rossijonas rossijonas 2229120 jun 15 06:06 start4.elf
-rw-r--r--. 1 rossijonas rossijonas 2953312 jun 15 06:06 start.elf
-rw-r--r--. 1 rossijonas rossijonas      11 jun 21 12:11 usercfg.txt

Eject and remove the MicroSD card, you're finally ready for the first boot!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.