Nextcloud on Raspberry Pi with disk encryption.

Nextcloud on Raspberry Pi with disk encryption.

Package contents:

  • Raspberry Pi 4 B πŸ–₯
  • USB Flash Kingstom 256G USB3.0

We install the minimum πŸ–₯ debian 12 on the raspberry.
Next, we install πŸ–₯ docker:

apt install docker docker.io docker-compose

We install cryptsetup:

apt install cryptsetup

By default, our entire disk will be marked as the root, but this is not a problem. We create space for the file:

fallocate -l 200G /var/nextcloud

200 GB is enough for me, I don't have that much porn 🀭

Next we encrypt:

cryptsetup luksFormat /var/nextcloud

Enter "YES" and specify the encryption password, you need to remember it!

Next we decrypt our sub-disk:

cryptsetup luksOpen /var/nextcloud nextcloud

Specify the password that you entered for encryption.

Mount:

mkdir /mnt/crypt
mount /dev/mapper/nextcloud /mnt/crypt

Don't forget about the file system:

mkfs.ext4 /dev/mapper/nextcloud

Well, now the place for porn is ready.
Next, we install nextcloud.
Create a docker-compose.yml file and write the following in it:

docker-compose.yml
version: '2'

volumes:
  twnextcloud:
  db:

services:
  db:
    image: mariadb:10.6
    restart: unless-stopped
    command: --transaction-isolation=READ-COMMITTED --log-bin=binlog --binlog-format=ROW
    volumes:
      - /mnt/crypt/nextcloud/mysql:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=PASSWORD
      - MYSQL_PASSWORD=PASSWORD
      - MYSQL_DATABASE=nextcloudtw
      - MYSQL_USER=nextcloudtw

  app:
    image: nextcloud
    restart: unless-stopped
    ports:
      - 8081:80
    links:
      - db
    volumes:
      - /mnt/crypt/nextcloud/data_users:/var/www/html
    environment:
      - MYSQL_PASSWORD=PASSWORD
      - MYSQL_DATABASE=nextcloudtw
      - MYSQL_USER=nextcloudtw
      - MYSQL_HOST=db

Change the passwords to your own if necessary. (need).

Then just execute the commands here:

docker-compose pull
docker-compose up -d

That's it. Now open in the browser: http://YOUR_IP:8081/

We get to the user creation page, create a user and enjoy home, private, encrypted and personal storage.