https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&user=Anonymous&feedformat=atomAlpine Linux - User contributions [en]2024-03-28T11:47:06ZUser contributionsMediaWiki 1.40.0https://wiki.alpinelinux.org/w/index.php?title=Classic_install_or_sys_mode_on_Raspberry_Pi&diff=16600Classic install or sys mode on Raspberry Pi2019-10-29T14:06:45Z<p>Anonymous: Removed a completed TODO</p>
<hr />
<div>{{TOC right}}<br />
<br />
A howto for classic installation, or "sys mode".<br />
<br />
This method works with a desktop PC under Ubuntu and other Linuxes.<br />
<br />
= Preparation =<br />
<br />
Download the archive from the '''Rasperry Pi armhf''' link [https://alpinelinux.org/downloads/ here].<br />
'''Sha256''' and '''GPG''' links appear next to the link to check the download.<br />
<br />
On a class 10 sd-card with a size of 8Go or more, create two partitions:-<br />
* First in '''fat16''' with size of 256Mo. You may have to check <code>boot</code> and <code>lba</code> flags<br />
* Second in '''ext4''' with the remaining place<br />
<br />
Eject and insert your SD card in order to recognize all the partitions.<br />
<br />
Now go into the first partition ('''fat16''').<br />
<br />
Untar the archive with {{pkg|tar}}:<br />
tar zxvf ~/Download/alpine-rpi-*-armhf.tar.gz<br />
<br />
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:<br />
<br />
enable_uart=1<br />
<br />
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.<br />
<br />
When a prompt displays, connect as root without a password.<br />
<br />
== OSX Preparation: creating a FAT16 partition on microSD ==<br />
<br />
To create a FAT16 partition with OSX, use the diskutil program and a USB microSD card reader (I used an older version of this: https://www.bestbuy.com/site/insignia-usb-3-0-memory-card-reader/5787406.p?skuId=5787406).<br />
<br />
Put the microSD card in reader, the reader in a USB port, and type <code>ls -1 /Volumes</code> in a terminal. Note the name of the microSD volume; for example, VOL1 in the output below:<br />
$ ls -1 /Volumes<br />
Macintosh HD<br />
Preboot<br />
VOL1<br />
$<br />
<br />
Unmount the reader, unplug it and re-run <code>ls -1 /Volumes</code>. Verify the microSD volume name is no longer listed and then re-insert the USB reader.<br />
<br />
Find the mount point of your microSD volume; for example, disk3 in the output below:<br />
$ diskutil list VOL1<br />
/dev/disk3 (external, physical):<br />
#: TYPE NAME SIZE IDENTIFIER<br />
0: FDisk_partition_scheme *31.4 GB disk3<br />
1: DOS_FAT_16 VOL1 256.0 MB disk3s1<br />
2: Linux 30.0 GB disk3s2<br />
3: Linux_Swap 1.2 GB disk3s3<br />
$<br />
<br />
(For help on diskutil command, type <code>diskutil</code> to list all command verbs. For help on a specific verb, add the verb; for example, <code>diskutil partitionDisk</code>)<br />
<br />
Destroy all the existing partitions on the microSD card and create two new ones: <br />
# a 256MB, FAT16, DOS-compatible partition and <br />
# a free space gap for the rest of the card<br />
<br />
$ diskutil partitionDisk disk3 MBR "MS-DOS FAT16" VOL1 256MB "Free Space" VOL2 R<br />
Started partitioning on disk3<br />
Unmounting disk<br />
Creating the partition map<br />
Waiting for partitions to activate<br />
Formatting disk3s1 as MS-DOS (FAT16) with name VOL1<br />
512 bytes per physical sector<br />
/dev/rdisk3s1: 499472 sectors in 62434 FAT16 clusters (4096 bytes/cluster)<br />
bps=512 spc=8 res=1 nft=2 rde=512 mid=0xf8 spf=244 spt=32 hds=32 hid=2 drv=0x80 bsec=500000<br />
Mounting disk<br />
Finished partitioning on disk3<br />
/dev/disk3 (external, physical):<br />
#: TYPE NAME SIZE IDENTIFIER<br />
0: FDisk_partition_scheme *31.4 GB disk3<br />
1: DOS_FAT_16 VOL1 256.0 MB disk3s1<br />
$ <br />
<br />
Change your current working directory to the new FAT16 partition and then pickup with the untar instruction in the parent prep section.<br />
<br />
$ cd /Volumes/VOL1/<br />
<br />
= Installation =<br />
<br />
Execute the following commands. Make sure there is an internet connection available otherwise setting up the apk mirrors will fail.<br />
<br />
setup-alpine <br />
<br />
Set the mapping keyboard, the timezone, how to connect to the network ('''dhcp''' is the best method), say '''none''' at <code>save config</code> and <code>save cache</code>.<br />
<br />
apk update<br />
<br />
If the extra space in the sd card was left empty, a partition must be created now:<br />
<br />
apk add cfdisk # or the tool of your choice<br />
cfdisk /dev/mmcblk0 # create the new partition with the free space<br />
mkfs.ext4 /dev/mmcblk0p2 # create the ext4 filesystem in the new partition<br />
<br />
Raspberry Pi has no battery for his hardware clock, so synchronize with an ntp server:<br />
<br />
apk add chrony <br />
service chronyd restart<br />
apk add e2fsprogs<br />
mount /dev/mmcblk0p2 /mnt # The second partition, in ext4 format, where Alpine Linux is installing in sys mode<br />
setup-disk -m sys /mnt<br />
mount -o remount,rw /media/mmcblk0p1 # An update in the first partition is required for the next reboot.<br />
<br />
Clean up the boot folder in the first partition to drop unused files:<br />
<br />
rm -f /media/mmcblk0p1/boot/* <br />
cd /mnt # We are in the second partition <br />
rm boot/boot # Drop the unused symbolink link<br />
<br />
Move the image and <code>init ram</code> for Alpine Linux into the right place:<br />
<br />
mv boot/* /media/mmcblk0p1/boot/ <br />
rm -Rf boot<br />
mkdir media/mmcblk0p1 # It's the mount point for the first partition on the next reboot<br />
<br />
Don't worry about the error with the following:<br />
<br />
ln -s media/mmcblk0p1/boot boot<br />
<br />
Update <code>/etc/fstab</code>:<br />
<br />
echo "/dev/mmcblk0p1 /media/mmcblk0p1 vfat defaults 0 0" >> etc/fstab<br />
sed -i '/cdrom/d' etc/fstab # Of course, you don't have any cdrom or floppy on the Raspberry Pi<br />
sed -i '/floppy/d' etc/fstab<br />
cd /media/mmcblk0p1<br />
<br />
If you want to active edge repository<br />
sed -i '/edge/s/^#//' etc/apk/repositories # But enable the repository for community if you want vim, mc, php, apache, nginx, etc.<br />
<br />
For the next boot, indicate that the root filesystem is on the second partition. If the cmdline.txt file<br />
contains a line that starts with <code>/root</code>, then use sed:<br />
<br />
sed -i 's/^/root=\/dev\/mmcblk0p2 /' /media/mmcblk0p1/cmdline.txt <br />
reboot<br />
<br />
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).<br />
<br />
If a hard disk is connected via '''usb''', you can replace the <code>/dev/mmcblk0p2</code> above with <code>/dev/sda1</code>, for example.<br />
<br />
If you don't like the '''sed''' above and its expressions, you can use a nano editor instead after executing the following command:<br />
<br />
apk add nano<br />
<br />
= Post-installation =<br />
<br />
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:<br />
<br />
rc-update del hwclock boot<br />
rc-update add swclock boot<br />
service hwclock stop<br />
service swclock start<br />
<br />
Update and upgrade the system:<br />
<br />
apk update<br />
apk upgrade<br />
<br />
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:<br />
<br />
apk add vim mc htop<br />
htop<br />
rc-update<br />
<br />
The '''RPI 3B''' has wifi on board for networking, so start the service for the encrypted key on wpa2 protocol:<br />
<br />
apk add wpa_supplicant<br />
rc-update add wpa_supplicant boot<br />
service wpa_supplicant start<br />
setup-interfaces <br />
Replace the IP address by dhcp for all the interfaces if necessary; select the SSID network for wifi; and add password.<br />
ip addr # to know the IP address for all interfaces<br />
<br />
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:<br />
<br />
apk add sudo<br />
adduser foo<br />
adduser foo wheel<br />
visudo <br />
<br />
Uncomment line #82 with <code>wheel ALL=(ALL) ALL</code>. If {{Pkg|vim}} is installed, save the changes by typing '''Esc :x'''<br />
<br />
<br />
= See also =<br />
<br />
* [[Raspberry Pi]]<br />
* [[Raspberry Pi 3 - Setting Up Bluetooth]]<br />
* [[Raspberry Pi 3 - Configuring it as wireless access point -AP Mode]]<br />
* [[Linux Router with VPN on a Raspberry Pi]]<br />
<br />
[[Category:Installation]]<br />
[[category: Raspberry]]</div>Anonymous