Skip to content

Instantly share code, notes, and snippets.

@br0kenpixel
Last active May 10, 2023 11:03
Show Gist options
  • Save br0kenpixel/bd9f8e0dfb3e702fc85b05497325b720 to your computer and use it in GitHub Desktop.
Save br0kenpixel/bd9f8e0dfb3e702fc85b05497325b720 to your computer and use it in GitHub Desktop.
Alpine linux headless install on RPi
  1. Download Alpine Linux from here.
  2. Connect your SD Card to your PC.
  3. Format the card. Create a single FAT32 partition.
  4. Extract the contents of the downloaded tar.gz archive.
  5. Copy the contents to the root of the SD Card.
  6. Add headless configuration if needed.
  7. Connect to the SD Card to your Raspberry Pi.
  8. Power it on.

Run the following commands in the shell:

setup-interfaces

setup-apkrepos

apk update

apk add cfdisk e2fsprogs nano

Using cfdisk /dev/mmcblk0 repartition your SD card such that:

  • The first partition can be resized to something small, like 2G (2 GB) but it can be as low as 128M (128MB).
  • The second partition should take up the rest of the free space on the SD Card.

Afterwards, format the secondary partition using mkfs.ext4 /dev/mmcblk0p2.

Now edit /etc/fstab using nano /etc/fstab. Add the following line:

/dev/mmcblk0p2 /media/mmcblk0p2 ext4 defaults 0 2

Save the file and exit nano. Then run mkdir /media/mmcblk0p2.

Run mount -a to verify the /etc/fstab configuration and mount the secondary partition to /media/mmcblk0p2.

Now run setup-alpine like normal, however:

  • When asked to set up your network interface, set it up the same way as before. Same for apk repos setup.
  • When asked to set up disks do the following:
  • No disks available. Try boot media /media/mmcblk0p1? (y/n) [n] n
    Enter where to store configs ('floppy', 'mmcblk0p1', 'mmcblk0p2', 'usb' or 'none') [mmcblk0p2] (enter)
    Enter apk cache directory (or '?' or 'none') [/media/mmcblk0p2/cache] (enter)
    

Lastly run the following 3 commands:

lbu commit
apk cache download
reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment