Optimize Kernel Configuration for Fedora

sudo nano /etc/sysctl.d/99-custom.conf
vm.swappiness=10
vm.dirty_ratio=15
vm.dirty_background_ratio=5
kernel.sched_migration_cost_ns=5000000
sudo sysctl --system
sudo nano /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash mitigations=off noibrs noibpb nospec_store_bypass_disable nopti zswap.enabled=1 zswap.compressor=lz4 zswap.max_pool_percent=25"
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
sudo systemctl enable --now fstrim.timer
sudo journalctl --vacuum-size=100M

 

Set Permanently ulimit -n open files in Fedora

sudo nano /etc/security/limits.d/99-openfiles.conf
* soft    nofile  65536
* hard    nofile  1048576
sudo nano /etc/systemd/system.conf
[Manager]
# Set soft:hard limits
DefaultLimitNOFILE=65536:1048576
# Or set both soft and hard to the same value
# DefaultLimitNOFILE=65536
sudo nano /etc/systemd/user.conf
[Manager]
# Set soft:hard limits
DefaultLimitNOFILE=65536:1048576
# Or set both soft and hard to the same value
# DefaultLimitNOFILE=65536
sudo systemctl daemon-reexec
sysctl fs.file-max
sudo nano /etc/sysctl.d/99-filemax.conf
fs.file-max = <larger_value>
sudo sysctl -p /etc/sysctl.d/99-filemax.conf
# Or apply all sysctl settings: sudo sysctl -p

 

Increase max_user_watches on Fedora Linux

Check current value:

cat /proc/sys/fs/inotify/max_user_watches

Temporarily change the value:
This change will reset after reboot.

sudo sysctl fs.inotify.max_user_watches=524288

Permanently change the value:
Edit or create the config file:

sudo nano /etc/sysctl.d/99-inotify.conf

Add the following line (or update if it already exists):

fs.inotify.max_user_watches=524288

Apply changes:

sudo sysctl -p /etc/sysctl.d/99-inotify.conf

Verify:

cat /proc/sys/fs/inotify/max_user_watches

 

 

Dual Boot Clock Issues

If you’re using dual-boot Windows alongside a Linux distribution (like Fedora, Ubuntu, etc.), you’ve probably encountered that frustrating issue where the clock shows the wrong time after switching from one OS to the other. It drove me crazy! This post is a quick reminder for my future self (and maybe you!) on why this happens and the best way I found to fix it permanently.

The Root Cause: A Tale of Two Time Standards

The heart of the problem lies in how Windows and Linux, by default, interpret the time stored in your computer’s Hardware Clock (also known as the RTC or CMOS clock). This is the clock that keeps running even when your PC is off, thanks to that little battery on the motherboard.

  • Windows: Assumes the time stored in the Hardware Clock is Local Time – the actual time on the clock in your specific time zone (e.g., Eastern Daylight Time, Pacific Standard Time), including adjustments for Daylight Saving Time (DST).
  • Linux (most distros): Assumes the time stored in the Hardware Clock is Coordinated Universal Time (UTC) – the global time standard that doesn’t change with time zones or DST. Linux then calculates your correct local time based on UTC plus your selected time zone settings.

When you switch operating systems, they read the Hardware Clock based on their own assumption. One OS might then “correct” the Hardware Clock according to its standard, making it wrong for the other OS when you boot into it next. This back-and-forth causes the time drift.

The Fix: Tell Windows the Hardware Clock is UTC

The most robust solution is to make Windows adopt the same standard as Linux: interpreting the Hardware Clock as UTC. This requires a simple change in the Windows Registry.

Why this method is generally preferred:

  • It aligns both operating systems with a universal standard (UTC).
  • UTC doesn’t have ambiguities related to Daylight Saving Time transitions, making it more reliable for the base hardware clock time.

Here are the steps:

  1. Boot into Windows.
  2. Open Registry Editor: Press Win + R, type regedit, and hit Enter. You’ll likely need to approve the User Account Control (UAC) prompt by clicking “Yes”.
    • Standard Warning: Be careful when editing the registry. Incorrect changes can cause system instability. Stick precisely to these instructions.
  3. Navigate to the Key: In the left-hand pane of the Registry Editor, navigate to this specific location:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation
    

    (Expand HKEY_LOCAL_MACHINE, then SYSTEM, CurrentControlSet, Control, and finally click on TimeZoneInformation).

  4. Create the DWORD Value:
    • In the right-hand pane (showing the values within TimeZoneInformation), right-click on an empty space.
    • Select New -> DWORD (32-bit) Value.
    • Crucial: Even if you are using 64-bit Windows, you must select DWORD (32-bit) Value.
    • Name this new value exactly:
      RealTimeIsUniversal
      
  5. Set the Value Data:
    • Double-click the RealTimeIsUniversal value you just created.
    • In the “Value data” box, type 1.
    • Ensure the “Base” is set to Hexadecimal (though it makes no difference for the value 1).
    • Click OK.
  6. Close Registry Editor.
  7. Reboot Your Computer: The change takes effect after a restart.

Use a Self-Signed SSL Certificate for Nginx Server

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/nginx-selfsigned.key -out /etc/ssl/certs/nginx-selfsigned.crt

Modify Your Nginx Server Block:

server {
    listen 443 ssl;
    server_name your_domain.com;

    ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
    ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;

    location / {
        # Your proxy or root configurations
    }
}
sudo nginx -t
sudo systemctl reload nginx

 

Set Battery Charge Limit in Fedora

sudo nano /etc/systemd/system/battery-charge-threshold.service
[Unit]
Description=Set battery charge threshold to 60%
After=multi-user.target

[Service]
Type=oneshot
ExecStart=/bin/bash -c 'echo 60 > /sys/class/power_supply/BAT0/charge_control_end_threshold'
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable --now battery-charge-threshold.service

 

Disable systemd-networkd-wait-online.service in Ubuntu Server

In Ubuntu Server, the systemd-networkd-wait-online.service is responsible for waiting until the network is fully online before allowing the boot process to continue. This service can sometimes cause delays during the boot process if the network configuration takes a long time to initialize.

1. Disable the Service

To completely disable the systemd-networkd-wait-online.service, run the following command:

sudo systemctl disable systemd-networkd-wait-online.service

This will prevent the service from starting at boot time.

2. Mask the Service (Optional)

If you want to ensure that the service cannot be started manually or automatically by any other service, you can mask it:

sudo systemctl mask systemd-networkd-wait-online.service

Masking creates a symbolic link to /dev/null, making it impossible for the service to start unless explicitly unmasked.

Install Syncthing on Ubuntu 24.04

# Add the release PGP keys:
sudo mkdir -p /etc/apt/keyrings
sudo curl -L -o /etc/apt/keyrings/syncthing-archive-keyring.gpg https://syncthing.net/release-key.gpg
# Add the "stable" channel to your APT sources:
echo "deb [signed-by=/etc/apt/keyrings/syncthing-archive-keyring.gpg] https://apt.syncthing.net/ syncthing stable" | sudo tee /etc/apt/sources.list.d/syncthing.list
# Update and install syncthing:
sudo apt-get update
sudo apt-get install syncthing

Syncthing can be run as a service so that it starts automatically on boot.

  1. Enable the Syncthing service : By default, Syncthing installs a systemd service for the user syncthing. You can enable it to start on boot.
    sudo systemctl enable syncthing@<username>.service

    Replace <username> with the username of the user who will run Syncthing. For example, if your username is ubuntu, the command would be:

    sudo systemctl enable [email protected]
  2. Start the Syncthing service : Once enabled, start the Syncthing service.
    sudo systemctl start syncthing@<username>.service

By default, Syncthing runs on localhost and listens on port 8384.

References
https://apt.syncthing.net/