How to Set Inotify Limit PERMANENTLY on a Synology Diskstation

Go to Control Panel -> Task Scheduler. Create a New Task -> Triggered Task -> User-defined script.

In General Settings tab: give it a name (e.g. “Syncthing Sysctl Inotify Fix”) and Event = Boot-up.

In the Task Settings tab: enter this in the Run Command box:

sh -c '(sleep 90 && echo 204800 > /proc/sys/fs/inotify/max_user_watches)&'

The sleep is to delay the setting to (hopefully) skip past any initialization that Synology does at boot time.

Click OK to close the task dialog, then enable the task and hit the Save button.

Reference

https://forum.syncthing.net/t/setting-inotify-limit-permanently-on-synology-diskstation/12221/3

How To Resize a Cloud Server File System

This guide explains how to expand the file system on a Vultr cloud server instance. If you have upgraded your cloud server to a plan with a larger disk or need to expand a partition while preserving data, follow these steps. A cloud server instance is sometimes called a Virtual Private Server or VPS.

This guide uses Ubuntu 20.04 as an example but applies to any Linux distribution with the fdisk and resize2fs tools. The example server has a 10 GB virtual disk with two partitions:

The virtual disk vda is 10 GB.

The first partition vda1 is 6 GB.

The second partition vda2 is 4 GB.

# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 252:0 0 10G 0 disk
├─vda1 252:1 0 6G 0 part /
└─vda2 252:2 0 4G 0 part

As an example, this guide will remove the second partition (vda2), then expand the first partition (vda1) to fill the virtual disk. This will preserve all data on vda1 and delete all data on vda2.
Use this example as a general guide for your particular situation. Continue reading

How to Install Nextcloud on a Synology the Easy Way

Begin by installing a package called “Container Manager”. This should have created a new folder in your drive volume called ‘docker’. Create a new folder within this folder called “nextcloud”. Then create 3 new folders inside the nextcloud folder called “config”, “db-config”, and “data”. Now open up the “Container Manager” package and click on “Project”. Name it “nextcloud” and select “/docker/nextcloud” for the project path. Choose “Create docker-compose.yml” for source and add the following:

---
services:
  nextcloud:
    image: lscr.io/linuxserver/nextcloud:28.0.3
    container_name: nextcloud
    environment:
      - PUID=1026
      - PGID=100
      - TZ=America/Los_Angeles
    volumes:
      - ./config:/config
      - ./data:/data
    ports:
      - 9333:443
    restart: unless-stopped
  mariadb:
    image: lscr.io/linuxserver/mariadb:latest
    container_name: nextcloud-mariadb
    environment:
      - PUID=1026
      - PGID=100
      - TZ=America/Los_Angeles
      - MYSQL_ROOT_PASSWORD=[PASSWORD]
      - MYSQL_DATABASE=nextcloud #optional
      - MYSQL_USER=nextcloud #optional
      - MYSQL_PASSWORD=[PASSWORD] #optional
    volumes:
      - ./db-config:/config
    ports:
      - 9444:3306
    restart: unless-stopped

Replace [PASSWORD] with unique strong passwords. Continue to build the project. Once completed, you should be able to access the Nextcloud UI by typing “https://[SYNOLOGY_IP]:9333” in your web browser. Go ahead and create an admin user and set it up to use MariaDB with the credentials you entered above. Once installed, you will be logged in. If you are using LDAP you can enable the “LDAP user and group backend” app and configure it with uid=root,cn=users,dc=[SUBDOMAIN],dc=[DOMAIN],dc=[DOMAINSUFFIX] for the User DN. Now we just need to create a reverse proxy so that we don’t have to access Nextcloud with an IP address and port number. This can be done by going to Control Panel -> Login Portal -> Advanced in your Synology and clicking on the “Reverse Proxy” button. Enter your domain name for source and the IP address of your Synology for the destination. Be sure to specify port 9333 for the destination. Last, you will need to add your domain name to Nextcloud’s trusted domains which is located in /docker/nextcloud/config/www/nextcloud/config/config.php. That’s it! Now you should be able to access Nextcloud with your domain name.

How to create a 3-in-1 bootable usb drive on Linux

A usb drive with only 1 partition to load grub2 on usb-bootable machines with Legacy BIOS, 64bit UEFI or 32bit UEFI.

Note: due to the maximum size of a file inside an EFI system partition, files (such as ISO disk images) of 4 GiB or larger must be placed on another partition. That second partition can be of type ext4, for instance.

Partition the drive and install grub2

Warning: the usb drive will be formatted, save your data before proceeding!

First of all, on you current installation, check if the folder /usr/lib/grub/ exists and is not empty. If it is empty or does not exist, make sure the package grub-common (or equivalent for your distribution) version 2 or higher is installed. Depending on the system, /usr/lib/grub/ will contain one or more of the following folders: x86_64-efi, x86_64-efi-signed, i386-pc, i386-efi, …

The x86_64-efi, i386-pc and i386-efi folders need to be present in order to install the corresponding bootloader on the usb drive. Continue reading

Raspberry Pi PXE Boot – Network booting a Pi 4 without an SD card

Install Raspbian on an SD card and install needed tools

Let’s start configuring your client system for netboot. This is the Raspberry Pi that will eventually boot without a micro SD card installed.

  • Download PiOS Lite. For this tutorial I used the Bullseye release.
  • Copy the Bullseye image onto an SD card. I suggest using the PiOS Imager. Warning! This will overwrite data on the device specified. Triple check you are writing to the SD card and not your laptop drive!
  • Put the SD card in your client Raspberry Pi 4 and boot it. Using the lite version of raspbian give you a text console only. If you want a graphical console you can use the full version and it should work. I have not tested this workflow with the full version.
  • Log in via the console using the login you created with the Imager.
  • Connect your Raspberry Pi to the internet via an ethernet cable.
  • Update PiOS via apt-get and install the rpi-config program:

Continue reading

How to Backup IMAP Mailboxes and Nextcloud Calendars, Contacts, and Notes

To backup all IMAP mailboxes for a user account, first download Rick Sander’s IMAP tools and save them somewhere on your system. Next, create a cron job and have it execute the following command:

mkdir -p /tmp/IMAP_$(date +%Y-%m-%d) && /path/to/imapdump/imapdump.pl -S example.com:993/user/password -f /tmp/IMAP_$(date +%Y-%m-%d) && cd /tmp/IMAP_$(date +%Y-%m-%d) && zip -r /backup/path/user@example.com_$(date +'%m-%d-%Y').zip user@example.com && chown user:user /backup/path/user@example.com_$(date +'%m-%d-%Y').zip && rm -Rf /tmp/IMAP_$(date +%Y-%m-%d)/user@example.com && find /backup/path -type f -mtime +90 -delete

To backup Nextcloud calendars and contacts, create a cron job running as root and have it execute the following command:

wget --directory-prefix=/tmp/nc-backup --user=ncuser --password=ncpassword --timestamping https://example.com/remote.php/dav/calendars/k4hjd9n3-k3ns-9385-9k2n-l3kjs9fk4b9z/personal-1?export https://example.com/remote.php/dav/addressbooks/users/k4hjd9n3-k3ns-9385-9k2n-l3kjs9fk4b9z/contacts?export && mv /tmp/nc-backup/personal-1?export /backup/path/calendar_$(date +'%m-%d-%Y').ics && mv /tmp/nc-backup/contacts?export /backup/path/contacts_$(date +'%m-%d-%Y').vcf && find /backup/path -type f -mtime +90 -delete

For Notes, do the same thing as above but execute the following instead:

mkdir -p /tmp/nc-backup && cd /nextcloud/path/k4hjd9n3-k3ns-9385-9k2n-l3kjs9fk4b9z/files && zip -r /tmp/nc-backup/notes_$(date +'%m-%d-%Y').zip Notes && chown user:user /tmp/nc-backup/notes_$(date +'%m-%d-%Y').zip && mv /tmp/nc-backup/notes_$(date +'%m-%d-%Y').zip /backup/path

How to solve delete file “Operation not permitted” on Linux

Sometimes it is necessary to prevent all users including root from deleting a file. This is often done by changing the file attributes on a Linux file system. The tool used to change file attributes in Linux and other Unix systems is chattr and the tool used to view the newly set attributes is lsattr.

The format of a symbolic mode is +-=[acdeijstuADST]. The format of a symbolic mode is +-=[acdeijstuADST] and they select the new attributes for
the files.

  • The operator ‘+’ causes the selected attributes to be added
    to the existing attributes of the files
  • ‘-’ causes them to be removed
  • ‘=’ causes them to be the only attributes that the files have.

See explanation of all letters used below:

Continue reading

How to Install Webmin+Nginx+Nextcloud+Syncthing on a Raspberry Pi 4

Flash Pi OS Lite to a micro SD card.

Install Webmin

If you like to install and update Webmin via APT, edit the /etc/apt/sources.list file on your system and add the line:

deb https://download.webmin.com/download/repository sarge contrib

You should also fetch and install the Webmin GPG key with which the repository is signed, with the commands:

wget https://download.webmin.com/jcameron-key.asc
sudo apt-key add jcameron-key.asc

You will now be able to install with the commands:

sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install webmin

All dependencies should be resolved automatically.
Continue reading

How To Install Nextcloud On A Synology NAS

This post should tell you everything you need to know to install Nextcloud instance on your Synology NAS without using Docker.

I previously published a post on how to setup Pi-Hole on a Synology and since then a number of people have asked for a guide on how to install Nextcloud on a Synology. After lots of tinkering, this post is the result.

I’ve talked about Nextcloud vs Synology before, and why I think Synology is the better choice for a home server. However, by using this guide you don’t need to choose – you can install Nextcloud on your Synology NAS!

This is likely to be another long post, so let’s get cracking shall we?

Setup DNS

Once Nextcloud is all setup and working on your Synology NAS, you will probably want to access it via a nice URL, usually a subdomain like nextcloud.example.com. If that’s the case, make sure you log into the DNS provider for your domain (this is usually the registrar you registered the domain with) and configure an A record that points to the public IP address of your Synology NAS. Continue reading