RPI4 debian server

RPI4 4GB
muSD


Install image on muSD and ssd

flash it on ssd and muSD with https://www.balena.io/etcher/
warning both disks will have same partitions uuids

Do not forget to create an empty ssh file (via touch) boot partition to boot headless and get ssh server running on the rpi4.

Upgrade boot eeprom

Boot from USB

fdisk /dev/sda
p
x
i
r
0xd34db33f
r
w

fdisk -l 
Disk /dev/sda: 232.9 GiB, 250059350016 bytes, 488397168 sectors
Disk model: JMS583
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0xd34db33f

Device     Boot  Start     End Sectors  Size Id Type
/dev/sda1         8192  532479  524288  256M  c W95 FAT32 (LBA)
/dev/sda2       532480 4390911 3858432  1.9G 83 Linux

blkid
vi /boot/cmdline.txt
change root=PARTUUID=6c586e13-02 by root=PARTUUID=d34db33f-02 in /boot/cmdline.txt

mkdir /mnt/rootfs
mount /dev/sda2 /mnt/rootfs
vi /mnt/rootfs/etc/fstab
change only rootfs
PARTUUID=6c586e13-02  /               ext4    defaults,noatime  0       1
PARTUUID=6c586e13-02  /               ext4    defaults,noatime  0       1d34db33f-02

check that it boots

Resize partitions
fdisk /dev/sda

fdisk -l
Disk /dev/sda: 232.9 GiB, 250059350016 bytes, 488397168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 33553920 bytes
Disklabel type: gpt
Disk identifier: D3B3EDDF-DC19-473E-A358-D1BDA74FE6D1

Device         Start       End   Sectors   Size Type
/dev/sda1       8192    532479    524288   256M Microsoft basic data
/dev/sda2     532480 480583167 480050688 228.9G Linux filesystem
/dev/sda3  480583168 488397134   7813967   3.7G Linux swap


apt install rpi-eeprom
vi /etc/default/rpi-eeprom-update
FIRMWARE_RELEASE_STATUS="beta"
rpi-eeprom-update -a

apt update
apt upgrade
apt install git
rpi-clone sda
resizefs
d
n
blah

edit fstab for /boot on mmc
proc            /proc           proc    defaults          0       0
PARTUUID=6c586e13-01  /boot           vfat    defaults          0       2
PARTUUID=d34db33f-02  /               ext4    defaults,noatime  0       1
# a swapfile is not a swap partition, no line here
#   use  dphys-swapfile swap[on|off]  for that

/boot/cmdline.txt
console=serial0,115200 console=tty1 root=PARTUUID=d34db33f-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait


MYHOSTNAME=hyperion
localectl set-locale LANG=fr_FR.UTF-8
timedatectl set-timezone Europe/Paris
hostnamectl set-hostname $MYHOSTNAME

hostname $MYHOSTNAME
vi /etc/hostname
mark32
EOF
vi /etc/hosts
127.0.0.1 localhost hyperion

Configure the right locales:

apt install locales
locale-gen en_US en_US.UTF-8 en_US.ISO-8859-1 en_US.ISO-8859-15 fr_FR fr_FR.UTF-8 fr_FR.ISO-8859-15 fr_FR.ISO-8859-1
dpkg-reconfigure locales
Generating locales (this might take a while)...
  en_US.ISO-8859-1... done
  en_US.ISO-8859-15... done
  en_US.UTF-8... done
  fr_FR.UTF-8... done
  fr_FR.UTF-8... done
  fr_FR.ISO-8859-15@euro... done

Reconfigure your time zone to get proper time:
dpkg-reconfigure tzdata

apt install mosh 

mutt irssi

apt install sudo screen mutt irssi vim subversion-tools rsync mosh less tig git openssh-server build-essential python python-setuptools python-pip convmv sqlite urlview w3m par metastore curl most ispell ifrench mtp-tools apg dnsutils retext obconf apt-file octave maxima locate tmux nmap catdoc wv elinks links lynx pmount mpc ncmpc epstool gnupg pinentry-tty pinentry-curses silversearcher-ag

apt install apache2
cp /media/nfs/ds414/debian/etc/apache2/sites-available/0080-main.conf /media/nfs/ds414/debian/etc/apache2/sites-available
/0443-main.conf .

Autofs between rpi4 and synology nas

apt install autofs
cat /etc/auto.master
/media/nfs /etc/auto.nfs --ghost
#EOF
cat /etc/auto.nfs
ds414   192.168.0.2:/volume1
#EOF

map synology domain users to debian one:

adduser --system --no-create-home --uid 1026 media
addgroup --gid 65536 mediagroup

apt install rsnapshot

apt install apache2 libapache2-mod-svn

a2dissite 000-default
cd /etc/apache2/sites-available/
cp /media/nfs/ds414/debian/etc/apache2/sites-available/0080-main.conf /media/nfs/ds414/debian/etc/apache2/sites-available/0443-main.conf /etc/apache2/sites-available
a2ensite 0080-main
a2ensite 0443-main
a2enmod ssl
vi /etc/apache2/ports.conf
Listen 8080
<IfModule ssl_module>
        Listen 443
</IfModule>
<IfModule mod_gnutls.c>
        Listen 443
</IfModule>
#EOF
service apache2 reload

cd /etc/ssl
cat openssl.cnf | grep _default                                                                                                              |
countryName_default             = FR
stateOrProvinceName_default     = IDF
localityName_default            = Paris
0.organizationName_default      = Courville.org
organizationalUnitName_default  = Software
commonName_default              = courville.org
emailAddress_default            = software@courville.org

htpasswd -c /etc/apache2/htpasswd username 

Comments