Raspberry Pi: Difference between revisions

From Alpine Linux
(Added Post-installation section)
(Added guides for Persistent Storage and X11 -Expecting criticisms and edits)
Line 60: Line 60:


After reboot, make sure that the <code>date</code> command outputs the correct date and time.
After reboot, make sure that the <code>date</code> command outputs the correct date and time.
=== Persistent Storage ===
The install is in disk-less mode and forces everything into memory, if you want additional storage we need to create loop-back storage onto the SD mounted with overlayfs.
First make the sd-card writable again and change fstab to always do so:
{{cmd|mount /media/mmcblk0p1 -o rw,remount
sed -i 's/vfat\ ro,/vfat\ rw,' /etc/fstab}}
Create the loop-back file, this example is 1 GB:
{{cmd|dd if&#61;/dev/zero of&#61;/media/mmcblk0p1/persist.img bs&#61;1024 count&#61;0 seek&#61;1048576}}
Install the ext utilities:
{{cmd|apk add e2fsprogs}}
Format the loop-back file:
{{cmd|mkfs.ext4 /media/mmcblk0p1/persist.img}}
Mount the storage:
{{cmd|echo "/media/mmcblk0p1/persist.img /media/persist ext4 rw,relatime,errors&#61;remount-ro 0 0" >> /etc/fstab
mkdir /media/persist
mount -a}}
Make the overlay folders, we are doing /usr here, but you can do /home or anything else:
{{cmd|mkdir /media/persist/usr
mkdir /media/persist/.work
echo "overlay /usr overlay lowerdir&#61;/usr,upperdir&#61;/media/persist/usr,workdir&#61;/media/persist/.work 0 0" >> /etc/fstab
mount -a}}
Your /etc/fstab should look something like this:
{{Cmd|/dev/cdrom      /media/cdrom    iso9660 noauto,ro 0 0
/dev/usbdisk    /media/usb      vfat    noauto,ro 0 0
/dev/mmcblk0p1 /media/mmcblk0p1 vfat rw,relatime,fmask&#61;0022,dmask&#61;0022,errors&#61;remount-ro 0 0
/media/mmcblk0p1/persist.img /media/persist ext4 rw,relatime,errors&#61;remount-ro 0 0
overlay /usr overlay lowerdir&#61;/usr,upperdir&#61;/media/persist/usr,workdir&#61;/media/persist/.work 0 0}}
Now commit the changes: (optionally remove the e2fsprogs, but it does contain repair tools)
{{cmd|lbu_commit}}
Remember with this setup, if you install things and you have done this overlay for /usr, you must not commit the 'apk add', otherwise while it boots it will try and install it to memory and not to the persist storage.
If you do want to install something small at boot you can use `apk add` and `lbu commit`.
If it is something a bit bigger then you can use `apk add` but then not commit it, it will be persistent (in /user), but do check everything you need is in that directory and not in folders you have not made persistent.
=== X11 Setup ===
Here are what you need if you want to try and run a single X11 application like a browser kiosk or maybe even a desktop: ​{{cmd|setup-xorg-base
​apk add xf86-video-fbdev xf86-input-mouse xf86-input-keyboard dbus ​set​xkbmap
rc-update ​​add dbus}}
Also edit the default X11 module config: /etc/X11/xorg.conf.d/20-modules.conf
{{cmd|Section "Module"
    Load "fbdevhw"
    Load "fb"
    Load "shadow"
    Load "shadowfb"
    Load "dbe"
    Disable "glx"
    Disable "dri"
EndSection}}
Commit your changes:
{{cmd|lbu_commit}}
Now you should be able to run a browser or desktop. (Guides may follow)


== See Also ==
== See Also ==


* [[Create a bootable SDHC from a Mac]]
* [[Create a bootable SDHC from a Mac]]

Revision as of 13:22, 25 January 2016

This tutorial will help you install Alpine Linux on your Raspberry Pi.

Preparation

This section will help you format and partition your SD card:

  1. Download Alpine for Raspberry Pi tarball which is named as alpine-rpi-<version>-armhf.rpi.tar.gz. You will need version 3.2.0 or greater if you have a Raspberry Pi 2.
  2. Mount your SD card to your workstation
  3. Use gnome-disks or fdisk to create a FAT32 partition. If you are using fdisk, the FAT32 partition type is called W95 FAT32 (LBA) and its ID is 0xC.
  4. Mark the newly created partition as bootable and save
  5. Mount the previously created partition
  6. Extract the tarball contents to your FAT32 partition
  7. Unmount the SD Card.

Installation

Alpine Linux will be installed as diskless mode, hence you need to use Alpine Local Backup (lbu) to save your modifications between reboots. Follow these steps to install Alpine Linux:

  1. Insert the SD Card into the Raspberry Pi and turn it on
  2. Login into the Alpine system as root. Leave the password empty.
  3. Type setup-alpine
  4. Once the installation is complete, commit the changes by typing lbu commit

Type reboot to verify that the installation was indeed successful.

Post Installation

Update the System

Upon installation, make sure that your system is up-to-date:

apk update apk upgrade

Don't forget to save the changes:

lbu commit

Clock-related error messages

During the booting time, you might notice errors related to the hardware clock. The Raspberry Pi does not have a hardware clock and therefore you need to disable the hwclock daemon and enable swclock:

rc-update add swclock boot # enable the software clock rc-update del hwclock boot # disable the hardware clock

Since Raspberry Pi does not have a clock, the Alpine Linux needs to know what the time is by using a Network Time Protocol (NTP) daemon. Make sure that you a NTP daemon installed and running. If you are not sure, then you can install NTP client by running the following command:

setup-ntp

Busybox NTP client might be the most lightweight solution. Save the changes and reboot, once the NTP software is installed and running:

lbu commit reboot

After reboot, make sure that the date command outputs the correct date and time.

Persistent Storage

The install is in disk-less mode and forces everything into memory, if you want additional storage we need to create loop-back storage onto the SD mounted with overlayfs.

First make the sd-card writable again and change fstab to always do so:

mount /media/mmcblk0p1 -o rw,remount sed -i 's/vfat\ ro,/vfat\ rw,' /etc/fstab

Create the loop-back file, this example is 1 GB:

dd if=/dev/zero of=/media/mmcblk0p1/persist.img bs=1024 count=0 seek=1048576

Install the ext utilities:

apk add e2fsprogs

Format the loop-back file:

mkfs.ext4 /media/mmcblk0p1/persist.img

Mount the storage:

echo "/media/mmcblk0p1/persist.img /media/persist ext4 rw,relatime,errors=remount-ro 0 0" >> /etc/fstab mkdir /media/persist mount -a

Make the overlay folders, we are doing /usr here, but you can do /home or anything else:

mkdir /media/persist/usr mkdir /media/persist/.work echo "overlay /usr overlay lowerdir=/usr,upperdir=/media/persist/usr,workdir=/media/persist/.work 0 0" >> /etc/fstab mount -a

Your /etc/fstab should look something like this:

/dev/cdrom /media/cdrom iso9660 noauto,ro 0 0 /dev/usbdisk /media/usb vfat noauto,ro 0 0 /dev/mmcblk0p1 /media/mmcblk0p1 vfat rw,relatime,fmask=0022,dmask=0022,errors=remount-ro 0 0 /media/mmcblk0p1/persist.img /media/persist ext4 rw,relatime,errors=remount-ro 0 0 overlay /usr overlay lowerdir=/usr,upperdir=/media/persist/usr,workdir=/media/persist/.work 0 0

Now commit the changes: (optionally remove the e2fsprogs, but it does contain repair tools)

lbu_commit

Remember with this setup, if you install things and you have done this overlay for /usr, you must not commit the 'apk add', otherwise while it boots it will try and install it to memory and not to the persist storage.

If you do want to install something small at boot you can use `apk add` and `lbu commit`.

If it is something a bit bigger then you can use `apk add` but then not commit it, it will be persistent (in /user), but do check everything you need is in that directory and not in folders you have not made persistent.

X11 Setup

Here are what you need if you want to try and run a single X11 application like a browser kiosk or maybe even a desktop: ​

setup-xorg-base ​apk add xf86-video-fbdev xf86-input-mouse xf86-input-keyboard dbus ​set​xkbmap rc-update ​​add dbus

Also edit the default X11 module config: /etc/X11/xorg.conf.d/20-modules.conf

Section "Module" Load "fbdevhw" Load "fb" Load "shadow" Load "shadowfb" Load "dbe" Disable "glx" Disable "dri" EndSection

Commit your changes:

lbu_commit

Now you should be able to run a browser or desktop. (Guides may follow)

See Also