Основное требование к следующему моему серверу я сформулировал так: "Необходима возможность восстановления".
Ставим Linux Ubuntu 24.04.1 на микрокомпьютер Raspbery Pi 4. Возможность восстановления сервера будет обеспечена наличием копий дистрибутива, копями настроенной системы и еженедельными копиями диска сервера. А так же, этому способствует наличие запасного железа.
Скачиваем дистрибутив Ubuntu 24.04.1 для Raspberry Pi с сайта Ubuntu по ссылке https://cdimage.ubuntu.com/ubuntu-server/noble/daily-preinstalled/current/. Я скачал файл noble-preinstalled-server-arm64+raspi.img.xz.
IMG файл записываю на microSD Flash карту объёмом 8 Gb с помощью программы Raspberry Pi Imager. Выбор файла можно сделать в разделе Операционная система выбрав пункт Use custom.
Рис. 1.
В Raspberry Pi Imager, прежде чем начать запись, делаю некоторые настройки: задаю имя хоста, логин и пароль пользователя и включаю службу SSH для удалённого доступа к серверу.
Рис. 2.
Рис. 3.
Рис. 4.
Теперь Ubuntu Server на Flash карте. Вставляем Flash карту в соответствующий слот компьютера Raspberry Pi.
Кабелем подключаем Raspberry Pi к локальной компьютерной сети.
Подключаем монитор и клавиатуру.
И, наконец, подаём питание на сервер.
Локально, с помощью команды hostname, выясняем IP адрес сервера.
hostname -I
192.168.1.12
Лист. 1.
С удалённого компьютера, по протоколу SSH подключаемся серверу.
ssh 192.168.1.12
Адрес электронной почты защищен от спам-ботов. Для просмотра адреса в вашем браузере должен быть включен Javascript.'s password:
Welcome to Ubuntu 24.04.1 LTS (GNU/Linux 6.8.0-1018-raspi aarch64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/pro
System information as of Mon Feb 3 10:11:58 UTC 2025
System load: 1.03 Temperature: 42.8 C
Usage of /: 14.6% of 14.18GB Processes: 166
Memory usage: 13% Users logged in: 0
Swap usage: 0% IPv4 address for eth0: 192.168.1.12
Expanded Security Maintenance for Applications is not enabled.
36 updates can be applied immediately.
5 of these updates are standard security updates.
To see these additional updates run: apt list --upgradable
Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status
The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
Лист. 2.
Выполняем обновление системы.
sudo apt update
sudo apt upgrade
Лист. 3.
Любопытно, в каких группах я зарегистрирован.
groups
dior adm dialout cdrom sudo audio video plugdev games users netdev render input gpio spi i2c
Лист. 4.
Хорошо.
Настройка поддержки русского языка.
Проверим языки установлены в системе.
locale -a
C
C.utf8
POSIX
Лист. 5.
Приступаем к настройкам.
sudo dpkg-reconfigure locales
┌────────────────────────────────┤ Configuring locales ├─────────────────────────────────┐ │ Locales are a framework to switch between multiple languages and allow users to use │ │ their language, country, characters, collation order, etc. │ │ │ │ Please choose which locales to generate. UTF-8 locales should be chosen by default, │ │ particularly for new installations. Other character sets may be useful for backwards │ │ compatibility with older systems and software. │ │ │ │ Locales to be generated: │ │ │ │ [ ] ro_RO.UTF-8 UTF-8 ↑ │ │ [*] ru_RU.UTF-8 UTF-8 ▮ │ │ [ ] ru_UA.UTF-8 UTF-8 ↓ │ │ │ │ │ │ <Ok> <Cancel> │ │ │ └────────────────────────────────────────────────────────────────────────────────────────┘
┌──────────────────────────────────┤ Configuring locales ├──────────────────────────────────┐ │ Many packages in Debian use locales to display text in the correct language for the │ │ user. You can choose a default locale for the system from the generated locales. │ │ │ │ This will select the default language for the entire system. If this system is a │ │ multi-user system where not all users are able to speak the default language, they will │ │ experience difficulties. │ │ │ │ Default locale for the system environment: │ │ │ │ None │ │ C.UTF-8 │ │ ru_RU.UTF-8 │ │ │ │ │ │ <Ok> <Cancel> │ │ │ └───────────────────────────────────────────────────────────────────────────────────────────┘
sudo dpkg-reconfigure tzdata
┌──────────────────────────────────┤ Configuring tzdata ├───────────────────────────────────┐ │ Please select the geographic area in which you live. Subsequent configuration questions │ │ will narrow this down by presenting a list of cities, representing the time zones in │ │ which they are located. │ │ │ │ Geographic area: │ │ │ │ Atlantic ↑ │ │ Australia ▒ │ │ Europe ▒ │ │ Indian ▮ │ │ Pacific ▒ │ │ Etc ↓ │ │ │ │ │ │ <Ok> <Cancel> │ │ │ └───────────────────────────────────────────────────────────────────────────────────────────┘
┌───────────────────────┤ Configuring tzdata ├───────────────────────┐ │ Please select the city or region corresponding to your time zone. │ │ │ │ Time zone: │ │ │ │ Minsk ↑ │ │ Monaco ▒ │ │ Moscow ▒ │ │ Nicosia ▮ │ │ Oslo ▒ │ │ Paris ▒ │ │ Podgorica ▒ │ │ Prague ↓ │ │ │ │ │ │ <Ok> <Cancel> │ │ │ └────────────────────────────────────────────────────────────────────┘
Current default time zone: 'Europe/Moscow' Local time is now: Sun Feb 2 19:43:36 MSK 2025. Universal Time is now: Sun Feb 2 16:43:36 UTC 2025.
sudo dpkg-reconfigure console-setup
┌────┤ Configuring console-setup ├─────┐ │ │ │ │ │ Encoding to use on the console: │ │ │ │ ISO-8859-7 ↑ │ │ ISO-8859-8 ▒ │ │ ISO-8859-9 ▒ │ │ KOI8-R ▒ │ │ KOI8-U ▒ │ │ TIS-620 ▮ │ │ UTF-8 ▒ │ │ VISCII ↓ │ │ │ │ │ │ <Ok> <Cancel> │ │ │ └──────────────────────────────────────┘
Package configuration────────────┤ Configuring console-setup ├───────────────────────┐ │ Please choose the character set that should be supported by the console │ │ font. │ │ │ │ If you don't use a framebuffer, the choices that start with "." will │ │ reduce the number of available colors on the console. │ │ │ │ Character set to support: │ │ │ │ . Arabic ↑ │ │ # Armenian ▮ │ │ # Cyrillic - KOI8-R and KOI8-U ▒ │ │ # Cyrillic - non-Slavic languages ▒ │ │ . Cyrillic - non-Slavic languages (for blind users) ▒ │ │ # Cyrillic - Slavic languages (also Bosnian and Serbian ... ▒ │ │ . Cyrillic - Slavic languages (for blind users) ↓ │ │ │ │ │ │ <Ok> <Cancel> │ │ │ └───────────────────────────────────────────────────────────────────────────┘
Package configuration────────────┤ Configuring console-setup ├───────────────────────┐ │ "VGA" has a traditional appearance and has medium coverage of │ │ international scripts. "Fixed" has a simplistic appearance and has │ │ better coverage of international scripts. "Terminus" may help to reduce │ │ eye fatigue, though some symbols have a similar aspect which may be a │ │ problem for programmers. │ │ │ │ If you prefer a bold version of the Terminus font, choose either │ │ TerminusBold (if you use a framebuffer) or TerminusBoldVGA (otherwise). │ │ │ │ Font for the console: │ │ │ │ Fixed ↑ │ │ Terminus ▮ │ │ TerminusBold ▒ │ │ TerminusBoldVGA ↓ │ │ │ │ │ │ <Ok> <Cancel> │ │ │ └───────────────────────────────────────────────────────────────────────────┘
┌─────────────────────┤ Configuring console-setup ├──────────────────────┐ │ Please select the size of the font for the console. Some font sizes │ │ require framebuffer. │ │ │ │ Font size: │ │ │ │ 8x13 │ │ 8x14 │ │ 8x15 │ │ 8x16 │ │ 8x18 │ │ │ │ │ │ <Ok> <Cancel> │ │ │ └────────────────────────────────────────────────────────────────────────┘
Лист. 6
Эту команду надо выполнить локально:
sudo dpkg-reconfigure keyboard-configuration
reboot
Лист. 7
Настроим для нашего сервера статический IP адрес
Сначала, посмотрим текущие настройки.
ip -c address show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether dc:a6:32:d1:b8:9b brd ff:ff:ff:ff:ff:ff
inet 192.168.1.12/24 metric 100 brd 192.168.1.255 scope global dynamic eth0
valid_lft 84288sec preferred_lft 84288sec
inet6 fe80::dea6:32ff:fed1:b89b/64 scope link
valid_lft forever preferred_lft forever
Лист.
Откроем в редакторе nano сетевые настройки службы netplan.
sudo nano /etc/netplan/50-cloud-init.yaml
network:
version: 2
ethernets:
eth0:
optional: true
dhcp4: true
Лист.
Внесём в этот yaml файл следующие изменения.
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: false
addresses: [192.168.1.222/24]
nameservers:
addresses: [ 8.8.8.8, 8.8.4.4 ]
routes:
- to: default # could be 0.0.0.0/0 optionally
via: 192.168.1.1
metric: 100
on-link: true
advertised-mss: 1400
Лист.
Проверим настройки.
sudo netplan generate
Лист.
Применим настройки сети.
sudo netplan apply
Лист.
Придётся переподключиться к серверу, теперь у него другой IP адрес.
ssh 192.168.1.222
Адрес электронной почты защищен от спам-ботов. Для просмотра адреса в вашем браузере должен быть включен Javascript.'s password:
Welcome to Ubuntu 24.04.1 LTS (GNU/Linux 6.8.0-1018-raspi aarch64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/pro
System information as of Пн 03 фев 2025 17:15:15 MSK
System load: 0.15 Temperature: 49.7 C
Usage of /: 15.2% of 14.18GB Processes: 150
Memory usage: 11% Users logged in: 0
Swap usage: 0% IPv4 address for eth0: 192.168.1.222
* Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8s
just raised the bar for easy, resilient and secure K8s cluster deployment.
https://ubuntu.com/engage/secure-kubernetes-at-the-edge
Расширенное поддержание безопасности (ESM) для Applications выключено.
Включите ESM Apps для получения дополнительных будущих обновлений безопасности.
Смотрите https://ubuntu.com/esm или выполните: sudo pro status
Лист.
Проверим температуру процессора.
vcgencmd measure_temp
temp=55.0'C
Лист.
Сервер готов к настройке служб. На этом этапе можно сделать архивную копию Flash карты сервера. Работать с Flash картой будем на компьютере.
С помощью графической утилиты gparted уменьшим второй раздел на Flash карте.
Рис.
С помощью графической утилиты gnome-disks создадим образ Flash диска.
Рис.
Рис.
Сожмём файл с образом Flash карты архиватором xz.
xz -zkv Ubuntu24.04.1ip222dior2025-02-03.img
Лист.
Этот файл можно использовать для установки на Flash карту с помощью программы Raspberry Pi Imager.
Рис.
Рис.
Рис.
Обратите внимание, если открыть Flash карту в программе gparted, мы увидим что весь объём Flash карты не используется. Но с этим ничего не надо делать!
Рис.
При первом запуске сервера с восстановленной Flash карты система увеличит второй раздел на Flash карте и займёт всё её пространство. Если вы возьмёте Flash карту большего размера, например 16 Gb система развернётся на всю Flash карту.
Рис.