Skip to content

Instantly share code, notes, and snippets.

@guitarpicva
Last active November 24, 2023 20:08
Show Gist options
  • Save guitarpicva/fdde00c1af84d14412b27db3617c2805 to your computer and use it in GitHub Desktop.
Save guitarpicva/fdde00c1af84d14412b27db3617c2805 to your computer and use it in GitHub Desktop.
Suitable for RPi4 or RPi400. Tested with 4GB RAM RPi400 system and 32 GB SD card. 2023-09-12
# THE MACHINE YOU USE TO MAKE THE Alpine Linux SD CARD SHOULD BE BACKED UP FOR
# SAFETY!!!!!!!!!!!!!!!!!!!! YOU HAVE BEEN WARNED.
# Download the Alpine Linux for RPi in the aarch64 flavor. The current stable is a
# good place to start in order to get used to the process. As of 2023-11-17, stable is at:
https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/aarch64/alpine-rpi-3.18.4-aarch64.tar.gz
# If you intend on using ax.25 packages, they are currently (2023-09-12) found in the
# "edge/testing" area, so be sure to get the "edge" version of Alpine and later enable the testing area in
# /etc/apk/repositories. So far, I have yet to figure out WHICH tarball is the correct one for this.
# Upgrading the kernel to the testing level (6.5.2) is not a trivial task for RPi and it is one which
# I have not yet performed or documented.
# Choose an SD card with a size of at least 32 GB. I use a Windows box to get it ready.
# Load the SD card in the Windows machine and then use the Win button or click Start
# button and type 'diskmgmt' <Enter> to start the disk utility.
# Find the removeable drive you just plugged in and ensure the disk size matches up. BE SURE!!
#
# Now left click to select each partition on that disk and then right click and choose
# 'Delete Volume'. Do this for ALL partitions until you have one large unallocated
# space. BE CAREFUL! Sometimes the window will scroll on you and hide the SD card
# volume. BE CAREFUL ! Always triple-check that you are deleting what you think you are
# deleting.
# Now right click on the unallocated space of the drive and create a 'Simple Volume'
# give it 512 MB of size and in the next screen, choose 'FAT32' as the type. All
# of the rest of the choices can be left defaulted. It will take only a second or
# two for diskmgmt to make the little partition. MAKE A NOTE OF THE DRIVE LETTER
# WHICH HAS BEEN ASSIGNED TO THIS SD CARD. (such as E: F: or G:)
# Close the diskmgmt tool.
# The SD card should still be mounted on the Windows machine so if your system has
# the 'tar' tool on it, open a cmd.exe box and use tar to put the alpine....tar.gz
# file contents onto the SD card's newly created partition. Open a cmd.exe box on
# the Windows machine and type 'tar <Enter>' to see if tar is installed. If so, then
# Type <DriveLetter>: <enter> example:
F:<Enter>
tar xfzf c:\path\to\the\tar\alpine<whatever>.tar.gz
# Example:
G:\>tar xvzf c:\users\mitch\Downloads\alpine-rpi-3.18.3-aarch64.tar.gz
# This will extract a bootable installer system onto the SD card.
#### THIS IS NOT THE ONLY WAY TO GET THOSE FILES ONTO THE SD CARD SO IF YOU ARE USED
#### TO USING SOME OTHER WAY, THE ONLY ADVICE IS TO ENSURE THAT THE 512 MB
#### PARTITION IS CREATED AS A FAT32 PARTITION....THEN PROCEED
# Load the SD card into the RPi and power it on to begin the boot process.
# You should be presented with a login prompt. The login to use is "root" with no
# password. This will be set to a valid password in the next step.
# Then start the script named:
setup-alpine
# Answer the questions. They are typical of a Linux installation process.
# DURING THIS PROCESS YOU MUST CREATE A NORMAL USER ACCOUNT ON THE SYSTEM FOR THE
# DESKTOP TO USE LATER. There will be a prompt for this after you change the root
# password.
# When you see "No disks available. Try boot media /media/.....? (y/n) [n]
# ANSWER y
# >>>>>>>>>>> You will perform a "sys" installation <<<<<<<<<<<< THIS IS IMPORTANT, so
# when you are asked which type of install ensure you type 'sys' at the prompt.
# You should now see a list of disks, usually only something like "mmcblk0 (31.7 GB)" or similar
# which represents the inserted SD card. Type in "?" or that disk name and press Enter. You
# will then be led through the erasure and re-building of that disk which is where
# the setup-alpine script installs the system to the SD card.
# NOTES:
# For the United States, the keyboard is "us" then "us" again. Other countries, you
# likely know the drill.
# Time zone defaults to UTC which is what I used on my radio-related system. Do what
# you like here.
# When prompted for the time standard package, choose "chrony" (default) because it will
# most easily allow configuration of time standard from a LAN based gpsd installation
# later if so desired. (details not included here). See note below regarding configuration
# of the ntp time pool server if your system doesn't seem to get the correct time from ntp.
# Reboot as directed once configuration is complete and all is installed for the "sys"
# installation type (typical disk install).
reboot
# when the system comes back up, there is an adjustment to make for RPi video to
# work properly, and since you are logged in as root already, may as well do it now.
# !! Login as root again !! with your newly created root password.
# NOTE: IF YOU DON'T DO THIS STEP, THERE WILL BE NO DESKTOP!!!!!
# create a user addendum to config.txt in a usercfg.txt file
echo 'disable_overscan=1' > /boot/usercfg.txt
echo 'dtoverlay=vc4-kms-v3d' >> /boot/usercfg.txt
echo 'gpu_mem=64' >> /boot/usercfg.txt
# typical desktop can do ok with 64, adjust if necessary later (NOTE: headless use 32)
reboot
# !!! Login as root again !!!
## add some useful packages of your choice
apk add nano bash usbutils pciutils
# Edit the /etc/chrony/chrony.conf file to fix a bad pool server hostname
# I found that the default chrony.conf file uses pool.ntp.org as the ntp server
# and that didn't seem to work for me, so I used 2.debian.pool.ntp.org instead
# I'm sure there are other hostnames also. If this is not fixed, then web pages
# will sometimes fail with certs that are in the future from your system time.
# NOW: to install Plasma/KDE use by running:
setup-desktop
# and choose plasma. This is over 500 packages so takes a while. (You may of
# course choose another desktop environment as well, which means this
# document ends here.)
reboot
# You should get the standard SDDM login screen for your regular user name
# which you SHOULD have created during setup-alpine above.
# !!!!!!!!!!!!!!!! AT THE BOTTOM LEFT OF THE LOGIN SCREEN !!!!!!!!!!!!!!!!!
# look for the words, "Desktop Session: Plasma (Wayland)". Click on this and
# you should see a choice "Plasma (X11)". Choose the X11, then log in.
# FINI!
############# OPTIONAL STEPS ######################################
# I prefer bash shell and I have a lot of bash scripts, so I edit the
# /etc/passwd file and find my regular user login name and change the last token
# to "/bin/bash" instead of "bin/ash". Totally optional.
# If you like to use sudo for making administrative changes, you must install it:
apk add sudo
# AND add yourself to the sudoers file by uncommenting one of the two " %wheel ..." lines
# in the /etc/sudo/sudoers file.
# Also add yourself to the dialout and plugdev groups, which makes using USB and
# serial devices easier with Ham radio programs.
usermod -G dialout myusername
usermod -G plugdev myusername
# I am still working out what qt5 packages to get for dev on Alpine,
# but the following seem to work ok:
## alpine-sdk is the build tools, like build-essential on a Debian or derivative distribution
apk add alpine-sdk qtchooser qt5-qtbase-dev qt5-qtserialport-dev qt5-qtusb-dev qt5-qtx11extras-dev qt5-qtxmlpatterns-dev qt5-qtmultimedia-dev qt5-qtimageformats qt5-qtbase-x11 qt5-qtbase-sqlite qt5-qtbase-postgresql qt5-qtwebsockets-dev qt5-qtwayland-dev qt5-qtsvg-dev
# If you need to build the Qt5 MQTT library get it from github.
## NOTE: this will not install properly unless you have installed the base packages for Qt5 in the step above.
cd
mkdir src
cd src
git clone https://github.com/qt/qtmqtt.git -b 5.15.2
cd qtmqtt
mkdir build
cd build
qmake ../
make -j3
# you are already root so just do make install
make install
# consult the wiki for help on other setup-nnnn scripts
# https://wiki.alpinelinux.org/wiki/Alpine_setup_scripts
# if you need man pages for help
apk add man-db man-pages man-pages-posix
### NOTE: the below probably won't work, so just leaving it here for general reference
### Most likely would need to have installed xfce4 vs plasma for this to function
### as expected.
# lastly, set up tigervncserver if you wish to use the system via VNC on another computer
apk add tigervnc tigervnc-client
cd
vncserver
# that should fail but create ~/.vnc folder
cd .vnc
touch passwd
vncpasswd
# type in password no prompt! hit enter
# repeat the password, hit enter
# answer "NO" to view only password
vncserver :1
# that should now start it up ok and crank up XFCE also.
# use the tigervnc viewer on some other machine or local windows box to connect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment