Classic install or sys mode on Raspberry Pi: Difference between revisions

From Alpine Linux
(Corrected link to mount-point of first partition)
(Amended bare link and mentioned links for sha256 and GPG; amended styles; added See also section; added Category: Installation.)
Line 1: Line 1:
Howto for classic installation or "sys mode"
A howto for classic installation, or "sys mode".


This method works with a desktop PC under Ubuntu and other linuxes
This method works with a desktop PC under Ubuntu and other Linuxes.


== PREPARATION ==
= Preparation =


Download archive of Alpinelinux for Rasperry Pi :
Download the archive from the '''Rasperry Pi armhf''' link  [https://alpinelinux.org/downloads/ here].
'''Sha256''' and '''GPG''' links appear next to the link to check the download.


http://dl-cdn.alpinelinux.org/alpine/v3.6/releases/armhf/alpine-rpi-3.6.2-armhf.tar.gz
On a class 10 sd-card with a size of 8Go or more, create two partitions:-
* First in '''fat16''' with size of 128Mo. Check <code>boot</code> and <code>lba</code> flags
* Second in '''ext4''' with the remaining place


On a class 10 sd-card with size of 8Go or more, create 2 partitions :
Eject and insert your SD card in order to recognize all the partitions.
* First in fat16 with size of 128Mo. Check boot and lba flags
* Second in ext4 with the remaining place


Eject and insert your SD-card to recognize all the partitions
Now go into the first partition ('''fat16''').


Now go inside the first partition (fat16).
Untar the archive with {{pkg|tar}}:
tar zxvf ~/Download/alpine-rpi-*-armhf.tar.gz


Untar the archive with tar:
Due to a bug, it is recommended to add a file named <code>usercfg.txt</code> into the partition.  The file should contain the following single line:
tar zxvf ~/Download/alpine-rpi-3.6.2-armhf.tar.gz


Because a bug, it's recommended to add in the partition a file named '''usercfg.txt''' with the unique line :
  enable_uart=1


enable_uart=1
Eject the SD card properly, insert it into the Raspberry Pi, plug a usb keyboard in plus the HDMI and network cables, and power on.


Eject properly the sd card, insert it in the Raspberry Pi, plug a usb keyboard, an HDMI and a network cables, and power on.
When a prompt displays, connect as root without a password.
As a prompt is displaying, connect as root without password.


== INSTALLATION ==
= Installation =


So, execute the following commands :
Execute the following commands.
* setup-alpine (''set the mapping keyboard, the timezone, how to connect to the network (dhcp is the best method), say "no" at "save config" and cache'')
* apk update
* apk add chrony (''Raspberry Pi has no battery for his hardware clock. So, synchronize with a ntp server'')
* service chronyd restart
* apk add e2fsprogs
* mount /dev/mmcblk0p2 /mnt (''The second partition in ext4 format where Alpinuxlinux is installing in sys mode'')
* setup-disk -m sys /mnt
* mount -o remount,rw /dev/mmcblk0p1 (''An update in the first partition is required for the next reboot'')
* rm -f /media/mmcblk0p1/boot/* (''clean up the boot folder in the first partition to drop unused files'')
* cd /mnt (''We are in the second partition'')
* rm boot/boot (''Drop the unused symbolink link'')
* mv boot/* /media/mmcblk0p1/boot/ (''Move the image and init ram for AlpineLinux at the right place'')
* rm -Rf boot
* mkdir media/mmcblk0p1 (''It's the mount point for the first partition on the next reboot'')
* ln -s media/mmcblk0p1/boot boot (''Don't worry about the error'')
* echo "/dev/mmcblk0p1 /media/mmcblk0p1 vfat defaults 0 0" >> etc/fstab (''Update /etc/fstab'')
* sed -i '/cdrom/d' etc/fstab (''Of course, you don't have any cdrom or floppy on the Raspberry Pi'')
* sed -i '/floppy/d' etc/fstab
* sed -i '/edge/s/^#//' etc/apk/repositories (''Enable the repository for the community if you want vim, mc, php, apache, nginx, ...'')
* cd /media/mmcblk0p1
* sed -i 's/^/root=\/dev\/mmcblk0p2 /' cmdline.txt (''Tell for the next boot that the root filesystem is on the second partition'')
* reboot


That works on Raspberry Pi 3B and 1B. But if you have the 1B version, let's be very, very patient (several tens of minutes)
setup-alpine


If a hard disk is connected via usb, you can replace above /dev/mmcblk0p2 by /dev/sda1, for example.
Set the mapping keyboard, the timezone, how to connect to the network ('''dhcp''' is the best method), say '''no''' at <code>save config</code> and <code>save cache</code>.


If you don't like sed and regular expressions, you can use nano editor after executing the following command :
apk update


apk add nano
Raspberry Pi has no battery for his hardware clock, so synchronize with an ntp server:


== POST-INSTALLATION ==
apk add chrony 
service chronyd restart
apk add e2fsprogs
mount /dev/mmcblk0p2 /mnt  # The second partition, in ext4 format, where Alpine Linux is installing in sys mode
setup-disk -m sys /mnt
mount -o remount,rw /dev/mmcblk0p1  # An update in the first partition is required for the next reboot.


The Raspberry Pi (RPI) has no battery to keep the time updated. So, we need to enable the right service to synchronize with a ntp server:
Clean up the boot folder in the first partition to drop unused files:


* rc-update del hwclock boot
rm -f /media/mmcblk0p1/boot/*
* rc-update add swclock boot
cd /mnt      # We are in the second partition
* service hwclock stop
rm boot/boot  # Drop the unused symbolink link
* service swclock start


Update and upgrade the system :
Move the image and <code>init ram</code> for Alpine Linux into the right place:


* apk update
mv boot/* /media/mmcblk0p1/boot/ 
* apk upgrade
rm -Rf boot
mkdir media/mmcblk0p1  # It's the mount point for the first partition on the next reboot


If you want a cool editor (''vim''), a files manager (''mc''), which tasks are running (''htop''), which services are starting on  the boot process, add the right packages :
Don't worry about the error with the following:


* apk add vim mc htop
ln -s media/mmcblk0p1/boot boot
* htop
* rc-update


The RPI 3B has wifi on board for networking. So, start service for the encrypted key on wpa2 protocol :
Update <code>/etc/fstab</code>:


* apk add wpa_supplicant
echo "/dev/mmcblk0p1 /media/mmcblk0p1 vfat defaults 0 0" >> etc/fstab
* rc-update add wpa_supplicant boot
sed -i '/cdrom/d' etc/fstab  # Of course, you don't have any cdrom or floppy on the Raspberry Pi
* service wpa_supplicant start
sed -i '/floppy/d' etc/fstab
* setup-interface (''replace IP address by dhcp for all the interfaces if necessary, select the SSID network for wifi and add password'')
sed -i '/edge/s/^#//' etc/apk/repositories  # But enable the repository for community if you want vim, mc, php, apache, nginx, etc.
* ip addr (''to know the IP address for all interfaces'')
cd /media/mmcblk0p1


If you want to connect on your remote RPI via ssh, an additional user (''foo'') and sudo package are required because it's forbidden to conect as root :
For the next boot, indicate that the root filesystem is on the second partition:


* apk add sudo
sed -i 's/^/root=\/dev\/mmcblk0p2 /' cmdline.txt 
* adduser foo
reboot
* adduser foo wheel
 
* visudo (''uncomment line #82 with "wheel ALL=(ALL) ALL". If vim is installed, save the changes by typing "Esc :x"'')
That works on '''Raspberry Pi 3B''' and '''1B''', but if you have the '''1B''' version, let's be very, very patient (several tens of minutes).
 
If a hard disk is connected via '''usb''', you can replace the <code>/dev/mmcblk0p2</code> above with <code>/dev/sda1</code>, for example.
 
If you don't like the '''sed''' above and its expressions, you can use a nano editor instead after executing the following command:
 
apk add nano
 
= Post-installation =
 
The '''Raspberry Pi (RPI)''' has no battery to keep the time updated. Therefore, we need to enable the right service to synchronize with an ntp server:
 
rc-update del hwclock boot
rc-update add swclock boot
service hwclock stop
service swclock start
 
Update and upgrade the system:
 
apk update
apk upgrade
 
If you want a cool editor ({{Pkg|vim}}), a file manager ({{Pkg|mc}}), and to determine which tasks are running and which services are starting on boot ({{Pkg|htop}}), add the right packages:
 
apk add vim mc htop
htop
rc-update
 
The '''RPI 3B''' has wifi on board for networking, so start the service for the encrypted key on wpa2 protocol:
 
apk add wpa_supplicant
rc-update add wpa_supplicant boot
service wpa_supplicant start
setup-interface
Replace the IP address by dhcp for all the interfaces if necessary;  select the SSID network for wifi;  and add password.
ip addr    # to know the IP address for all interfaces
 
If you want to connect on your remote RPI via <code>ssh</code>, an additional user (''foo'') and the {{Pkg|sudo}} package are required because it's forbidden to connect as root:
 
apk add sudo
adduser foo
adduser foo wheel
visudo  
 
Uncomment line #82 with <code>wheel ALL=(ALL) ALL</code>. If {{Pkg|vim}} is installed, save the changes by typing '''Esc :x'''
 
 
= See also =
 
* [[Raspberry Pi]]
* [[Raspberry Pi 3 - Setting Up Bluetooth]]
* [[Raspberry Pi 3 - Configuring it as wireless access point -AP Mode]]
* [[Linux Router with VPN on a Raspberry Pi]]
 
[[Category:Installation]]

Revision as of 06:31, 25 January 2018

A howto for classic installation, or "sys mode".

This method works with a desktop PC under Ubuntu and other Linuxes.

Preparation

Download the archive from the Rasperry Pi armhf link here. Sha256 and GPG links appear next to the link to check the download.

On a class 10 sd-card with a size of 8Go or more, create two partitions:-

  • First in fat16 with size of 128Mo. Check boot and lba flags
  • Second in ext4 with the remaining place

Eject and insert your SD card in order to recognize all the partitions.

Now go into the first partition (fat16).

Untar the archive with tar:

tar zxvf ~/Download/alpine-rpi-*-armhf.tar.gz

Due to a bug, it is recommended to add a file named usercfg.txt into the partition. The file should contain the following single line:

enable_uart=1

Eject the SD card properly, insert it into the Raspberry Pi, plug a usb keyboard in plus the HDMI and network cables, and power on.

When a prompt displays, connect as root without a password.

Installation

Execute the following commands.

setup-alpine 

Set the mapping keyboard, the timezone, how to connect to the network (dhcp is the best method), say no at save config and save cache.

apk update

Raspberry Pi has no battery for his hardware clock, so synchronize with an ntp server:

apk add chrony   
service chronyd restart
apk add e2fsprogs
mount /dev/mmcblk0p2 /mnt  # The second partition, in ext4 format, where Alpine Linux is installing in sys mode
setup-disk -m sys /mnt
mount -o remount,rw /dev/mmcblk0p1  # An update in the first partition is required for the next reboot.

Clean up the boot folder in the first partition to drop unused files:

rm -f /media/mmcblk0p1/boot/*  
cd /mnt       # We are in the second partition 
rm boot/boot  # Drop the unused symbolink link

Move the image and init ram for Alpine Linux into the right place:

mv boot/* /media/mmcblk0p1/boot/  
rm -Rf boot
mkdir media/mmcblk0p1   # It's the mount point for the first partition on the next reboot

Don't worry about the error with the following:

ln -s media/mmcblk0p1/boot boot

Update /etc/fstab:

echo "/dev/mmcblk0p1 /media/mmcblk0p1 vfat defaults 0 0" >> etc/fstab
sed -i '/cdrom/d' etc/fstab   # Of course, you don't have any cdrom or floppy on the Raspberry Pi
sed -i '/floppy/d' etc/fstab
sed -i '/edge/s/^#//' etc/apk/repositories   # But enable the repository for community if you want vim, mc, php, apache, nginx, etc.
cd /media/mmcblk0p1

For the next boot, indicate that the root filesystem is on the second partition:

sed -i 's/^/root=\/dev\/mmcblk0p2 /' cmdline.txt  
reboot 

That works on Raspberry Pi 3B and 1B, but if you have the 1B version, let's be very, very patient (several tens of minutes).

If a hard disk is connected via usb, you can replace the /dev/mmcblk0p2 above with /dev/sda1, for example.

If you don't like the sed above and its expressions, you can use a nano editor instead after executing the following command:

apk add nano

Post-installation

The Raspberry Pi (RPI) has no battery to keep the time updated. Therefore, we need to enable the right service to synchronize with an ntp server:

rc-update del hwclock boot
rc-update add swclock boot
service hwclock stop
service swclock start

Update and upgrade the system:

apk update
apk upgrade

If you want a cool editor (vim), a file manager (mc), and to determine which tasks are running and which services are starting on boot (htop), add the right packages:

apk add vim mc htop
htop
rc-update

The RPI 3B has wifi on board for networking, so start the service for the encrypted key on wpa2 protocol:

apk add wpa_supplicant
rc-update add wpa_supplicant boot
service wpa_supplicant start
setup-interface 

Replace the IP address by dhcp for all the interfaces if necessary; select the SSID network for wifi; and add password.

ip addr    # to know the IP address for all interfaces

If you want to connect on your remote RPI via ssh, an additional user (foo) and the sudo package are required because it's forbidden to connect as root:

apk add sudo
adduser foo
adduser foo wheel
visudo 

Uncomment line #82 with wheel ALL=(ALL) ALL. If vim is installed, save the changes by typing Esc :x


See also