Меню Рубрики

Linux arch raspberry pi

Arch Linux на Raspberry Pi

После довольно продолжительно использования Raspberry Pi совместно с Raspbian решил попробовать установить Arch Linux ARM. Что из этого получилось рассмотрено в статье.

Так как в месте установки RPi подключать что-либо к разъемам HDMI или RCA Video и LAN мне неудобно, я использую WiFi-подключение к сети и USB-UART для терминального доступа. Поэтому некоторые описанные шаги я отметил как необязательные.

Использованное оборудование: ноутбук с Windows, Raspberry Pi Model B, SD-карта объемом 4GB, WiFi-адаптер, UART-адаптер.

Загружаем и записываем на SD-карту образ операционной системы. В моем случае это был ArchLinuxARM-2014.01-rpi.img, запись выполнялась при помощи Win32DiskImager 0.9.5.

После установки войти в систему можно как root, пароль root. Это можно сделать как через локальный терминал так и через LAN, используя SSH.

Запуск getty на ttyAMA0 (необязательно)

Для вывода на последовательный порт загрузочных сообщений необходимо добавить в файл /boot/cmdline.txt параметр loglevel=5.

Разрешаем работу getty на последовательном порту командой:

Сигналы UART выведены на GPIO разъем Raspberry Pi:

Нужно подключить к ним USB-UART конвертер и указать в терминальной программе следующие параметры подключения: скорость 115200, 8 бит данных, 1 стоп бит, без проверки четности, без управления потоком. Подробнее как использовать PuTTY для работы через последовательный порт здесь.

Настройка беспроводной сети (необязательно)

Копируем и редактируем нужный профиль, указав в нем имя сети и пароль:

Активируем созданный профиль и разрешаем его запуск при включении:

Аппаратный генератор случайных чисел

В ArchLinux для Raspberry Pi есть поддержка аппаратного генератора случайных чисел, но демону rngd нужно указать, как его найти. Для это необходимо отредактировать файл /etc/conf.d/rngd следующим образом:

И перезапустить rngd:

Часовой пояс и синхронизация времени

Удаляем часовой пояс, назначенный по умолчанию и устанавливаем нужный:

Запускаем ntpd и разрешаем его работу при включении:

Обновление системы

Просто запускаем команду:

Расширение корневого раздела

Запускаем fdisk и выводим существующую таблицу разделов:

На SD-карте, как видно, есть основной (mmcblk0p1) и дополнительный (mmcblk0p2) разделы. Дополнительный, в свою очередь, содержит один логический (mmcblk0p5) раздел. Раздел mmcblk0p1 имеет небольшой размер, монтируется как /boot и используется при загрузке. Его модифицировать не нужно. Расширить нужно раздел mmcblk0p5, который монтируется как /.

Удаляем раздел mmcblk0p2 (при этом раздел mmcblk0p5 также удалится):

Теперь нужно создать новый дополнительный раздел, занимающий все доступное свободное пространство:

После этого внутри дополнительного, нужно создать логический раздел, так же занимающий все доступное пространство:

Проверяем, что разделы созданы правильно:

Стартовые блоки созданных разделов должны быть такими же как до внесения изменений, а общее количество блоков увеличиться.

Сохраняем изменения и выполняем перезагрузку:

После перезагрузки нужно увеличить размер файловой системы на созданном логического разделе. Текущий размер:

Имеет смысл для уменьшения количества операций записи на SD-карту установить в файле /etc/fstab параметр noatime для корневого раздела:

Добавление непривилегированного пользователя

Добавляем пользователя и устанавливаем пароль:

Установка и настройка sudo

Открыв с помощью команды visudo конфигурацию раскомментируем следующую строку:

Добавляем созданного ранее пользователя pi в группу wheel:

Это позволит пользователю pi использовать sudo для выполнения команд, требующих повышенных полномочий.

Настройка ssh

Так как SSH-ключи у меня уже были, останавливаться на их создании я не буду. Как их создать можно прочитать здесь.

Копируем публичный ключ на RPi:

Открываем файл конфигурации sshd:

Устанавливаем в нем запрет входить по ssh пользователю root и отключаем аутентификацию по паролю:

Заключение

В результате выполнения перечисленных шагов получаем RPi подключенный к WiFi сети, синхронизирующий время через интернет. На RPi можно зайти через SSH как непривилегированный пользователь имея при этом возможность вызова системных команд через sudo.

Источник

theramiyer / arch-arm-rpi3-b-plus.md

Install Arch Linux (ARM) on Raspberry Pi B+

Created 17 Aug 2018

This is a simple installation that I did on my Raspberry Pi. Of course, this is only one of the many reasons to do it.

Here are my requirements:

First, insert the memory card into your laptop. I use a memory card slot, so my device name would differ from yours if you use a USB memory card reader.

Format the SD card with fdisk

  1. List out all the drives and partitions using lsblk . Note down the name of the SD card. In my case, it is mmcblk0 .
  2. Start fdisk using sudo fdisk /dev/mmcblk0 .
  3. Delete the existing partitions by entering o at the prompt. This clears out all partitions on the card.
  4. Type p to list the partitions; there should be none.
  5. Create a new partition with n , make it primary by entering p , set it as the first partition using 1 .
  6. Press Enter to accept the default first sector. At the prompt, enter +110M to make it a 100 MB partition.
  7. Type t and then c to set the partition type to W95 FAT32 (LBA) .
  8. Now, to create the second partition, type n , then p , make it the second partition by typing 2 , and then, press Enter twice to accept the default first and the last sectors.
  9. Enter w to write this configuration to the card.
  10. Next, format the first partition as VFAT , and the second as EXT4 .

Transfer Arch Linux ARM to the card

The next step is to transfer the OS files onto the partitions.

Insert the SD card into the Pi. Now, connect a keyboard and a mouse. Connect the Pi to a display using the HDMI port. Next, connect the ethernet cable. Finally, plug in the power supply.

As soon as the login prompt arrives, enter root as the username and root as the password. You are now logged into the device.

Connect to WiFi (in case you don’t use Ethernet)

If you would rather connect the device to WiFi:

  1. Navigate to /etc/wpa_supplicant .
  2. Create a new file called anything of your choice.

Arch Linux allows SSH by default. If you would like to connect to the Pi using SSH from your personal computer instead of attaching a keyboard and a mouse and HDMI and everything, by all means, please do.

This setup may be optional. I prefer doing this because I’m used to swap.

    Setup the swapfile.

pacman is the package manager for Arch Linux.

    Add colour to pacman .

Right out of the box, Arch Linux ARM comes with two users: root and alarm . The first thing we would want to do is reset the password for root , and then, either create a new user to replace alarm , or reset the password for alarm . I go with the former approach.

    Change the password for root .

Now that we have most things set up, we will now proceed and install the necessary packages.

  1. First, install a bunch of necessary software.
  1. Install pi-bluetooth from the AUR. You should already have the packages necessary to build packages from the AUR. The package, pi-bluetooth , needs hciattach-rpi3 installed. Run the following.

Update: Looks like hciattach-rpi3 is no more available. Use bluez-utils-compat instead. Thanks to @SleepingNewton.

  1. Enable Bluetooth using sudo systemctl enable bluetooth.service .
  2. Start the Bluetooth service using sudo systemctl start bluetooth.service .
  3. Now, let us install packages necessary for audio.
  1. Enable audio at boot by adding the following line to sudo vim /boot/config.txt .

Increase the life of your SD card.

That should get you going with Arch Linux on Raspberry Pi 3 B+.

This comment has been minimized.

Copy link Quote reply

Maik93 commented Sep 5, 2019

Hi, cool guide!
One question: when, at the beginning, you download the ArchLinux ARM image, you use the command:
wget http://archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz
I’ve checked the official site too, and it’s the same, but we are using a Pi3, so doesn’t we have to change rpi-2 in rpi-3 ? I’ve tried and it resolves in an existing package.

My main concern is that the Pi3 is 64-bit, while the Pi2 is not, so I suppose that anything should not work if exchanged.

This comment has been minimized.

Copy link Quote reply

theramiyer commented Sep 6, 2019

Hey! Thank you! I wrote this guide quite long ago. I think I copied links off of my notes, rather than from the terminal, at the time of writing the guide. Sorry about the glitch; I’ve changed that. Thank you for pointing it out. 👍 🙂

This comment has been minimized.

Copy link Quote reply

0pcom commented Oct 8, 2019

Awesome and very helpful guide!

This comment has been minimized.

Copy link Quote reply

OfficialMuffin commented Oct 9, 2019

I get a few errors when using the command sudo tar -xpf ArchLinuxARM-rpi-latest.tar.gz -C /mnt/root/
I used sudo tar -zxvf ArchLinuxARM-rpi-latest.tar.gz -C /mnt/root/ instead and it unpacks perfeclty without error.

This comment has been minimized.

Copy link Quote reply

theramiyer commented Oct 14, 2019

Oh okay, could you please tell me what error you got if you have the logs? I could add it to the documentation.

This comment has been minimized.

Copy link Quote reply

theramiyer commented Oct 14, 2019

This comment has been minimized.

Copy link Quote reply

blaggacao commented Oct 28, 2019

Little glitch:
change

archlinux-keyring might already have a newer release, so update pacman first.

This comment has been minimized.

Copy link Quote reply

theramiyer commented Nov 10, 2019

Hey, thank you! Changed it.

This comment has been minimized.

Copy link Quote reply

SleepingNewton commented Jan 13, 2020 •

I couldn’t set up Bluetooth with these instructions; the hciattach-rpi3 package is not available anymore.

I installed bluez-utils-compat instead.

This comment has been minimized.

Copy link Quote reply

open-antux commented Jan 19, 2020 •

  1. sync command stuck, I don’t know why but when I do sync it take very long long time to be executed and I think that it crashes instead.
  2. Ok I avoid sync command, continue with the guide and when I boot Archlinux it stuck at: fb0 switching to vc4drmfb from simple .

How can I solve these problems?

Edit: I solved the problem with sync

This comment has been minimized.

Copy link Quote reply

theramiyer commented Jan 23, 2020

Hey, @SleepingNewton and @Superjolly002, thank you for adding your solutions. I’ll update the article. Unfortunately, I don’t have the device with me anymore, so I can’t test anything just yet. Will probably buy a 4 soon. 🙂

This comment has been minimized.

Copy link Quote reply

open-antux commented Jan 23, 2020 •

@theramiyer the bluez-firmware package doesn’t exist anymore
EDIT: I’ve notice you wrong to mention, change «Thanks to @Superjolly002» with «Thanks to @SleepingNewton»

This comment has been minimized.

Copy link Quote reply

luckily82 commented Feb 6, 2020 •

Author, You did not note about setup and sync time and select timezone:

In case if you have not file rc.conf
Для того, чтобы сравнить системное время и UTC:

$ timedatectl status
Для установки системных часов:

timedatectl set-time «2012-10-30 18:17:16»

Изменить Вашу зону и субзону:

timedatectl set-timezone Zone/SubZone

Лист доступных зон:

$ timedatectl list-timezones
Пример установки зон:

timedatectl set-timezone Europe/Moscow

This comment has been minimized.

Copy link Quote reply

mb720 commented Feb 13, 2020

Thanks for your instructions!

The image at http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-3-latest.tar.gz did not work for me. When plugging in USB power, after a short while the green ACT LED started blinking rhythmically: two short blinks separated by a longer pause. I’m not sure what it means, also after reading the flash codes.

I figured out that it works fine with a different image:

It might seem counter-intuitive to use the rpi-2 image, but it worked on my Raspberry Pi 3 B+ as opposed to the rpi-3 image.

The instructions here also use the rpi-2 image.

This comment has been minimized.

Copy link Quote reply

niktob560 commented Apr 11, 2020

wpa_supplicant requires «-c» key before the config file path

Источник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *

  • Mac os загрузка в режиме жесткого диска
  • Mac os загрузка в режиме восстановления
  • Mac os загрузка в безопасном режиме
  • Mac os загружаю информацию установки
  • Mac os загружается только в безопасном режиме