Jubilamos las Raspberrys ¡Hola miniPC! (Ep.1)

The RPI has officially retired

Pues si, el día ha llegado. He tenido algún que otro problema con las distintas Rpi que tenia en casa y al final he decidido buscarme un miniPC y convertirlo en mi nuevo servidor que controlará la parte domótica, el servidor web de prueba y las descargas torrents.


Aunque mucha parte de la instalación coincide con los distintos artículos que he ido publicando al cabo de estos años, he aprovechado que he encontrado esta guía de Jaime Quiroga, al que quiero agradecerle su trabajo, y junto a la guía oficial de archlinux he actualizado todo el proceso.

A medida que vayan apareciendo, enlazaré a los artículos a medida que vaya los vaya ejecutándolos en la nueva instalación.

Empezamos presentando el hardware. Se trata de un miniPC BMAX, Intel Celeron N4120 1.10GHz, 8GB de RAM, con 1 SSD principal NVMe de 250GB y otro de 180GB. Según las especificaciones, se puede conectar un SSD de 2,5" pero una vez leídas las instrucciones, haría falta un cable no incluido y que además no es estándar. Si fuese necesario, ya localizaría el cable. De momento, utilizare el de más capacidad para el sistema operativo y el segundo para almacenar las descargas.

Preparar la imagen

Muy brevemente, descargamos de la página oficial la última imagen y la grabamos en una memoria USB mediante:

sudo dd bs=4M if=archlinux-20XX.XX.XX-x86_64.iso of=/dev/sdX status=progress oflag=sync

Al terminar, la desconectamos del equipo y la conectamos a un puerto USB libre del miniPC. Si fuese necesario, modificaremos en la BIOS el orden de arranque. En mi nuevo equipo esto se consigue pulsando la tecla ESC. Una vez efectuado el cambio, arrancamos con la memoria conectada.

Archlinux con soporte UEFI

loadkeys es
timedatectl set-ntp-true
timedatectl set-timezone Europe/Madrid
timedatectl status

Crearemos 4 particiones:

gdisk /dev/nvme0n1

La primera, atención al tipo de partición EF00 para la partición boot:

GPT fdisk (gdisk) version 1.0.9

Partition table scan:
  MBR: not present
  BSD: not present
  APM: not present
  GPT: not present

Creating new GPT entries in memory.

Command (? for help): n
Partition number (1-128, default 1): 
First sector (34-488397134, default = 2048) or {+-}size{KMGTP}: 
Last sector (2048-488397134, default = 488396799) or {+-}size{KMGTP}: +512M
Current type is 8300 (Linux filesystem)
Hex code or GUID (L to show codes, Enter = 8300): EF00
Changed type of partition to 'EFI system partition'

La segunda será para la partición de intercambio swap y debe ser del tipo 8200:

Command (? for help): n
Partition number (2-128, default 2): 
First sector (34-488397134, default = 1050624) or {+-}size{KMGTP}: 
Last sector (1050624-488397134, default = 488396799) or {+-}size{KMGTP}: +2G
Current type is 8300 (Linux filesystem)
Hex code or GUID (L to show codes, Enter = 8300): 8200
Changed type of partition to 'Linux swap'

La tercera partición es la dedicada a root y debe ser 8304:

Command (? for help): n
Partition number (3-128, default 3): 
First sector (34-488397134, default = 5244928) or {+-}size{KMGTP}: 
Last sector (5244928-488397134, default = 488396799) or {+-}size{KMGTP}: +20G
Current type is 8300 (Linux filesystem)
Hex code or GUID (L to show codes, Enter = 8300): 8304
Changed type of partition to 'Linux x86-64 root (/)'

Y por último, la cuarta, utilizaremos el tipo 8302 para /home:

Command (? for help): n
Partition number (4-128, default 4): 
First sector (34-488397134, default = 47187968) or {+-}size{KMGTP}: 
Last sector (47187968-488397134, default = 488396799) or {+-}size{KMGTP}: 
Current type is 8300 (Linux filesystem)
Hex code or GUID (L to show codes, Enter = 8300): 8302
Changed type of partition to 'Linux /home'

Finalizamos la partición con el comando w:

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/nvme0n1.
The operation has completed successfully.

Comprobamos el resultado:

lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
nvme0n1     259:0    0 232.9G  0 disk 
├─nvme0n1p1 259:1    0   512M  0 part 
├─nvme0n1p2 259:4    0     2G  0 part 
├─nvme0n1p3 259:5    0    20G  0 part 
└─nvme0n1p4 259:8    0 210.4G  0 part 

Formatearemos cada partición con el tipo adecuado:

La partición nvme0n1p1, es la de arranque y la formatearemos con FAT32:

mkfs.fat -F32 /dev/nvme0n1p1
mkfs.fat 4.2 (2021-01-31)

La partición nvme0n1p2, es la de intercambio:

mkswap /dev/nvme0n1p2
Setting up swapspace version 1, size = 2 GiB (2147479552 bytes)
no label, UUID=dbfd60d5-2c3c-4fb5-9101-2b31d9288a01

Activamos está última:

swapon /dev/nvme0n1p2

La partición nvme0n1p3, es la raíz y la formatearemos con ext4:

mkfs.ext4 /dev/nvme0n1p3
mke2fs 1.46.5 (30-Dec-2021)
Discarding device blocks: done                            
Creating filesystem with 5242880 4k blocks and 1310720 inodes
Filesystem UUID: ee8dc5f5-663d-41c6-ad93-1d21309e7801
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
	4096000

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done   

Y la última partición nvme0n1p4, es la /home también con ext4:

mkfs.ext4 /dev/nvme0n1p4
mke2fs 1.46.5 (30-Dec-2021)
Discarding device blocks: done                            
Creating filesystem with 55151104 4k blocks and 13795328 inodes
Filesystem UUID: 9f9ccba5-ac89-4d4a-a65b-8fba2026cd62
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
	4096000, 7962624, 11239424, 20480000, 23887872


Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done     

Crearemos los puntos de montaje necesarios y los montaremos:

mount /dev/nvme0n1p3 /mnt
mkdir -p /mnt/boot
mount /dev/nvme0n1p1 /mnt/boot
mkdir -p /mnt/home
mount /dev/nvme0n1p4 /mnt/home

Al llegar a este punto obtenía error al instalar el sistema base y he necesitado actualizar las claves mediante:

pacman -Sy archlinux-keyring

Una vez terminada la actualización, he conseguido instalar el sistema base sin ningún problema:

pacstrap /mnt base base-devel nano linux linux-firmware intel-ucode dhcpcd openssh
==> Creating install root at /mnt
==> Installing packages to /mnt
:: Synchronizing package databases...
 core                   157.5 KiB  1184 KiB/s 00:00 [##########################] 100%
 extra                 1720.5 KiB  19.3 MiB/s 00:00 [##########################] 100%
 community                6.7 MiB  63.2 MiB/s 00:00 [##########################] 100%

Generaremos el fichero fstab y lo comprobaremos:

genfstab -U /mnt >> /mnt/etc/fstab
cat /mnt/etc/fstab
# Static information about the filesystems.
# See fstab(5) for details.

#      
# /dev/nvme0n1p3
UUID=ee8dc5f5-663d-41c6-ad93-1d21309e7801	/         	ext4      	rw,relatime	0 1

# /dev/nvme0n1p1
UUID=39C6-235A      	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro	0 2

# /dev/nvme0n1p4
UUID=9f9ccba5-ac89-4d4a-a65b-8fba2026cd62	/home     	ext4      	rw,relatime	0 2

# /dev/nvme0n1p2
UUID=dbfd60d5-2c3c-4fb5-9101-2b31d9288a01	none      	swap      	defaults  	0 0

Cambiamos a chroot para modificar y configurar algunos de los ficheros iniciales:

arch-chroot /mnt /bin/bash
nano /etc/locale.gen
#es_EC.UTF-8 UTF-8
#es_EC ISO-8859-1
es_ES.UTF-8 UTF-8
es_ES ISO-8859-1
es_ES@euro ISO-8859-15
#es_GT.UTF-8 UTF-8
#es_GT ISO-8859-1
locale-gen
Generating locales...
  es_ES.UTF-8... done
  es_ES.ISO-8859-1... done
  es_ES.ISO-8859-15@euro... done
Generation complete.
nano /etc/locale.conf
LANG=es_ES.UTF-8
timedatectl set-ntp true
timedatectl set-timezone Europe/Madrid
timedatectl status
               Local time: Fri 2022-07-15 22:06:12 CEST
           Universal time: Fri 2022-07-15 20:06:12 UTC
                 RTC time: Fri 2022-07-15 20:06:12
                Time zone: Europe/Madrid (CEST, +0200)
System clock synchronized: no
              NTP service: inactive
          RTC in local TZ: no
bootctl --path=/boot install
Created "/boot/EFI".
Created "/boot/EFI/systemd".
Created "/boot/EFI/BOOT".
Created "/boot/loader".
Created "/boot/loader/entries".
Created "/boot/EFI/Linux".
Copied "/usr/lib/systemd/boot/efi/systemd-bootx64.efi" to "/boot/EFI/systemd/systemd-bootx64.efi".
Copied "/usr/lib/systemd/boot/efi/systemd-bootx64.efi" to "/boot/EFI/BOOT/BOOTX64.EFI".
Random seed file /boot/loader/random-seed successfully written (32 bytes).
Successfully initialized system token in EFI variable with 32 bytes.
Created EFI boot entry "Linux Boot Manager".
nano /boot/loader/loader.conf
default arch
timeout 0
editor 0
echo $(blkid -s PARTUUID -o value /dev/nvme0n1p3) > /boot/loader/entries/arch.conf
nano /boot/loader/entries/arch.conf

Y completaremos con lo siguiente:

title ArchLinux
linux /vmlinuz-linux
initrd /intel-ucode.img 
initrd /initramfs-linux.img
options root=PARTUUID=14420948-2cea-4de7-b042-40f67c618660 rw
echo myserver > /etc/hostname
nano /etc/vconsole.conf
KEYMAP=es
FONT=Lat2-Terminus16

Modificamos la palabra de paso al usuario root:

passwd

Añadiremos un unuevo usuario con permisos de root, y le cambiaremos tambien la contraseña:

useradd -m -g users -G audio,lp,optical,storage,video,wheel,games,power,scanner -s /bin/bash usernew
passwd usernew
EDITOR=nano visudo
## Uncomment to allow members of group wheel to execute any command
wheel ALL=(ALL:ALL) ALL

En mi caso he reservado una dirección IP para la dirección MAC del miniPC en el router, por lo tanto no voy a configurar un IP fija. Lo que si que haré, será modificar algunos parametros en la configuración de SSH:

nano /etc/ssh/sshd_config
...
#Port 22
Port 6814
...
PermitRootLogin no
AllowUsers usernew

Activaremos dhcpcd y sshd para que arranquen al inicio:

systemctl enable dhcpcd.service
systemctl enable sshd 

Saldremos de chroot, y desmontaremos los puntos de montaje:

exit
umount -R /mnt

Reinicializamos sin olvidearnos de retirar la memoria USB:

reboot

Soy Jaume Ferré, aficionado a los nuevas tecnologias, aunque ya no lo son tanto.
¡Gracias por leerme!

Valora este artículo1 2 3 4 5 (0 votos)

(0 votos)

Categorias del blog

twitter

Últimos tweets