To completely remove the UniFi Controller and all related services from your UniFi Cloud Key Gen2 Plus (which is running Debian 11 underneath), and leave it as a clean Debian 11 system, follow these step-by-step instructions carefully. ⚠️ This process is advanced and may void your Ubiquiti warranty. Also, data will be lost, so make backups if needed.
⚠️ WARNING: Are you sure?
The UniFi Cloud Key Gen2 Plus is not a general-purpose Debian server. It is an embedded appliance made to run UniFi software. While it uses Debian 11 underneath, removing UniFi services and using it like a regular Debian box may break features like:
- OLED screen display
- Cooling/fan management
- Cloud management
- Automatic updates
- HDD usage in Protect
If you’re sure you want to turn it into a plain Debian 11 device:
🧼 Steps to Remove UniFi Software from Cloud Key Gen2+
1. Access the System
SSH into your Cloud Key Gen2 Plus:
ssh root@<cloud-key-ip>
2. Stop All UniFi Services
systemctl stop unifi
systemctl stop unifi-core
systemctl stop mongodb
3. Uninstall UniFi Controller
apt remove --purge unifi unifi-core unifi-video -y
Also uninstall MongoDB (UniFi requires it):
apt remove --purge mongodb-org* -y
4. Remove Leftover Files
rm -rf /usr/lib/unifi
rm -rf /usr/lib/unifi-core
rm -rf /var/lib/unifi
rm -rf /var/lib/mongodb
rm -rf /etc/init.d/unifi
rm -rf /etc/unifi
rm -rf /etc/systemd/system/unifi*
5. Autoclean and Autoremove Unused Packages
apt autoremove --purge -y
apt clean
6. Check Services
systemctl list-units --type=service | grep unifi
Make sure nothing related to UniFi or MongoDB is running.
7. Optional: Clean OLED Display
The front panel OLED might still try to show UniFi status. You can disable its daemon:
systemctl stop cloudkey-oled
systemctl disable cloudkey-oled
Or completely remove it:
apt remove --purge cloudkey-oled -y
✅ Now you have a clean Debian 11 system
You can now install other apps like:
- VitalPBX
- Docker
- Apache/Nginx
- Any other Debian-compatible software
❓ Do You Want to Reclaim HDD Storage?
If you want to use the internal hard drive (for Protect) for general storage:
- Check partitions:
lsblk
- Identify the Protect partition (usually
/dev/sda
), then unmount and reformat:umount /dev/sda1 mkfs.ext4 /dev/sda1 mkdir /mnt/data mount /dev/sda1 /mnt/data
To auto-mount on reboot, add to /etc/fstab
:
/dev/sda1 /mnt/data ext4 defaults 0 2
If you’d like help installing something else (e.g., VitalPBX), let me know and I can guide you step-by-step.
Thanks for sharing the df -h
output. Here’s a quick breakdown of what it shows and what it means in the context of cleaning UniFi from your UniFi Cloud Key Gen2 Plus (UCK-G2-Plus):
🧠 Understanding Your System Layout:
Mount Point | Device | Use |
---|---|---|
/ | overlayfs-root | Your main writable system, overlay over RO FS |
/mnt/.rwfs | /dev/mmcblk0p46 | Read-write lower layer for overlayfs |
/mnt/.rofs | /dev/disk/by-partlabel/rootfs | Read-only root image |
/persistent | /dev/mmcblk0p45 | Holds settings and persistent system config |
/data | /dev/mmcblk0p47 | Data partition (used by UniFi Controller) |
/volume1 | /dev/md3 | Internal HDD, used by UniFi Protect for video |
⚠️ Important Things to Know Before Removing UniFi:
- The root filesystem is read-only (
/mnt/.rofs
) with an overlayfs writable layer. This means:- You cannot directly modify the base OS unless you remove/modify overlay configuration.
- This is intentional by Ubiquiti to prevent corruption during updates.
/data
and/volume1
are the main areas used by the UniFi Controller and UniFi Protect.- UniFi software is installed in
/usr/lib/unifi
, configs in/etc/unifi
, and data in/data
.
✅ What You Can Safely Do:
1. Clear UniFi Data and Configuration
systemctl stop unifi
systemctl stop mongodb
rm -rf /usr/lib/unifi
rm -rf /etc/unifi
rm -rf /data/unifi
rm -rf /persistent/system.cfg
rm -rf /etc/init.d/unifi
Also clear MongoDB and other UniFi apps:
apt remove --purge unifi mongodb-org* -y
2. Optional: Reclaim /volume1
HDD Space (used by UniFi Protect)
If you’re not using UniFi Protect anymore, and want the 900GB+ HDD for your own use:
umount /volume1
mkfs.ext4 /dev/md3
mkdir /mnt/hdd
mount /dev/md3 /mnt/hdd
To mount it automatically:
echo "/dev/md3 /mnt/hdd ext4 defaults 0 2" >> /etc/fstab
3. Disable UniFi Boot Behavior
To prevent the system from booting into UniFi environment again:
systemctl disable unifi
systemctl disable cloudkey-oled
systemctl disable unifi-core
❗ Optional: Remove Ubiquiti Overlay + Convert to True Debian 11
⚠️ This is risky and only for advanced users.
If you want a fully clean Debian 11 system without Ubiquiti overlays:
- Backup everything.
- Boot from another OS (via USB or PXE).
- Wipe
/dev/mmcblk0
partitions. - Install clean Debian 11 (ARM64) using
debootstrap
or another method.
🔚 Summary
You can remove UniFi apps and reclaim the storage, but because UCK-G2-Plus is built with a read-only root + overlay, it’s not meant to be a regular Debian box. If you want to repurpose it long-term, it’s better to wipe and install a custom Debian image — but that’s risky and not officially supported.
Would you like a full script to clean everything up? Or are you planning to install another service like VitalPBX, Docker, or Nextcloud on this box?
To remove Nginx from your UniFi Cloud Key Gen2 Plus (or any Debian 11 system), follow these steps via SSH as root
:
✅ Step-by-Step: Remove Nginx on Debian 11
1. Stop the Nginx Service
systemctl stop nginx
2. Disable Nginx on Boot
systemctl disable nginx
3. Uninstall Nginx Packages
To completely remove Nginx and its dependencies:
apt remove --purge nginx nginx-common nginx-full -y
If you’re unsure which variant is installed (e.g., nginx-light
, nginx-core
), run:
dpkg -l | grep nginx
Then remove any remaining variants, for example:
apt remove --purge nginx-light nginx-core -y
4. Remove Configuration and Leftover Files
rm -rf /etc/nginx
rm -rf /var/www/html
rm -rf /var/log/nginx
5. Clean Up Unused Packages
apt autoremove --purge -y
apt clean
✅ Verify It’s Gone
Check that nothing is listening on port 80 or 443:
ss -tuln | grep ':80\|:443'
If no output appears, Nginx has been successfully removed.
Let me know if you want to replace Nginx with something else (like Apache, Caddy, or a reverse proxy like Traefik).
Thanks! Based on your df -h
output, you’ve done a great job so far — Nginx is likely removed, and it looks like:
- You’ve mounted your HDD at
/mnt/hdd
(formerly used by UniFi Protect). - Your system root (
/
) is still an overlay filesystem, backed by:/mnt/.rofs
(read-only base OS image – full)/mnt/.rwfs
(read-write overlay)
Now, if your goal is to:
- Completely remove all UniFi software ✅
- Free space or reclaim partitions ✅ (seems done)
- Turn Cloud Key Gen2 Plus into a general-purpose Debian system 🔄 (currently not fully done)
Then the next decision is:
❓What Do You Want to Do Next?
Here are your options, based on your current state:
✅ If you just want to keep using it as a Debian system (with existing overlay):
You’re already done, but note:
- The root filesystem (
/
) will always be limited by the 5.9 GB/mnt/.rwfs
. - You can use
/mnt/hdd
(900 GB+) for apps, logs, Docker, databases, etc.
🟢 Tip: If you install anything big (e.g., databases), install them to
/mnt/hdd
and symlink or configure paths to store data there.
Example:
mkdir /mnt/hdd/myapps
ln -s /mnt/hdd/myapps /opt/myapps
🔥 If you want to completely erase Ubiquiti’s OS and turn this into a normal Debian 11 system:
⚠️ WARNING: Risky, advanced, and may brick your Cloud Key if something goes wrong.
Steps (overview):
- Boot into Debian via USB or UART (requires hardware access).
- Use
debootstrap
or similar to install a clean ARM64 Debian system on/dev/mmcblk0
. - Replace Ubiquiti’s bootloader and partitions (dangerous).
- Manually configure kernel/initramfs/network.
Let me know if you’re seriously interested in this path and I’ll guide you step-by-step — but again: not officially supported by Ubiquiti.
💡 Summary
Goal | Status | Notes |
---|---|---|
UniFi & Nginx removed | ✅ Done | System clean |
HDD reclaimed and usable | ✅ Done | Mounted at /mnt/hdd |
Still running Ubiquiti OS overlay | ⚠️ Yes | 5.9 GB limit for root |
Full Debian system (no overlay) | ❌ Not yet | Requires manual install |
Let me know what you’d like to do next:
- Keep it like this and install new software?
- Mount external storage for apps?
- Wipe everything and install clean Debian?
I’m happy to guide any of those paths.
Yes, you can absolutely install Nginx and MySQL (or MariaDB) on your UniFi Cloud Key Gen2 Plus Debian-based system, and you can store large data like MySQL databases on the internal 900 GB HDD (/mnt/hdd
). You just need to manage where things are stored, because:
- The system root (
/
) is limited to 5.9 GB (/mnt/.rwfs
). - The HDD (
/mnt/hdd
, 900 GB) is available for large files, apps, and databases.
✅ Summary of What You Can Do
Task | Possible? | Notes |
---|---|---|
Install Nginx | ✅ Yes | Lightweight, fits in / |
Install MySQL/MariaDB | ✅ Yes | But configure data dir to use /mnt/hdd |
Store website files | ✅ Yes | Store under /mnt/hdd/www and point Nginx there |
Store large DB data | ✅ Yes | Set MySQL to use /mnt/hdd/mysql |
✅ How to Do It Properly (Step-by-Step)
🔧 1. Install Nginx and MySQL (or MariaDB)
apt update
apt install nginx mariadb-server -y
✅ Installs to /usr
, which is inside your limited /
— but they’re small enough.
🗂️ 2. Prepare HDD for Storage
Assuming your HDD is already mounted at /mnt/hdd
:
mkdir -p /mnt/hdd/mysql
mkdir -p /mnt/hdd/www
chown -R mysql:mysql /mnt/hdd/mysql
⚙️ 3. Move MySQL Data Directory to HDD
🔸 Stop MySQL
systemctl stop mariadb
🔸 Copy Existing Data
cp -av /var/lib/mysql/* /mnt/hdd/mysql/
🔸 Backup & Replace Old Folder
mv /var/lib/mysql /var/lib/mysql.bak
ln -s /mnt/hdd/mysql /var/lib/mysql
🔸 Fix Permissions Again
chown -R mysql:mysql /mnt/hdd/mysql
🔁 4. Start MySQL and Verify
systemctl start mariadb
If no error:
mysql -u root
✅ Your MySQL now uses the HDD!
🌐 5. Configure Nginx to Use /mnt/hdd/www
- Set up site directory:
mkdir -p /mnt/hdd/www/myapp
- Edit or create Nginx config:
nano /etc/nginx/sites-available/myapp
server {
listen 80;
server_name localhost;
root /mnt/hdd/www/myapp;
index index.html index.php;
location / {
try_files $uri $uri/ =404;
}
}
- Enable the site:
ln -s /etc/nginx/sites-available/myapp /etc/nginx/sites-enabled/
nginx -t && systemctl reload nginx
✅ Result
You now have:
- Nginx installed ✅
- MySQL installed and using HDD ✅
- Plenty of space for web files and databases ✅
🧠 Pro Tips
- Monitor root space with
df -h
often — keep/
under 80%. - Log files can fill up space; configure MySQL/Nginx logs to write to
/mnt/hdd/logs
if needed. - You can install PHP (
apt install php-fpm
) to support dynamic sites.
Let me know if you want a full script or want to run apps like WordPress, Laravel, or VitalPBX on this system.
Thanks for the update. The 404 Not Found
error from Nginx means:
✅ Nginx is running and serving the domain/path,
❌ But it can’t find the file or directory it was told to serve.
✅ Let’s Fix It Step-by-Step
We’ll verify:
- Your folder exists at the correct path.
- Your Nginx config is correct.
- File permissions are okay.
- The site is enabled and reloaded.
🔍 Step 1: Check the Folder and Test File
Let’s make sure /mnt/hdd/www/myapp/index.html
exists:
mkdir -p /mnt/hdd/www/myapp
echo "<h1>It works!</h1>" > /mnt/hdd/www/myapp/index.html
🔧 Step 2: Confirm Nginx Config
Open your Nginx config:
nano /etc/nginx/sites-available/myapp
Make sure it looks like this:
server {
listen 80;
server_name _;
root /mnt/hdd/www/myapp;
index index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
}
Save and exit.
🔗 Step 3: Enable the Site
If not yet enabled:
ln -sf /etc/nginx/sites-available/myapp /etc/nginx/sites-enabled/myapp
(Optional: remove default site)
rm /etc/nginx/sites-enabled/default
🔄 Step 4: Reload Nginx
nginx -t && systemctl reload nginx
✅ Step 5: Test Again
Go to:
http://<your-ip>/
Or:
http://<your-ip>/index.html
You should see:
It works!
🧠 Extra: Permissions
Ensure Nginx can read the files:
chown -R www-data:www-data /mnt/hdd/www
chmod -R 755 /mnt/hdd/www
Let me know if you’re serving PHP, WordPress, or Laravel — the config will need php-fpm
settings too.
To install PHP on your Debian-based UniFi Cloud Key Gen2 Plus system and use it with Nginx, follow these steps:
✅ Step-by-Step: Install PHP (with PHP-FPM) for Nginx
⚠️ Nginx does not use
mod_php
like Apache. It uses PHP-FPM to process PHP scripts.
🔧 1. Install PHP and PHP-FPM
apt update
apt install php php-fpm -y
Optionally install common modules:
apt install php-mysql php-cli php-curl php-mbstring php-xml php-zip php-gd -y
🔍 2. Verify PHP-FPM Is Running
systemctl status php*-fpm
You should see something like:
Active: active (running)
🧪 3. Create a PHP Test Page
echo "<?php phpinfo(); ?>" > /mnt/hdd/www/myapp/info.php
⚙️ 4. Edit Your Nginx Config to Support PHP
Edit your site’s config:
nano /etc/nginx/sites-available/myapp
Update it to include PHP handling:
server {
listen 80;
server_name _;
root /mnt/hdd/www/myapp;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.4-fpm.sock; # ← Adjust version if needed
}
location ~ /\.ht {
deny all;
}
}
📝 If you installed a different PHP version, check the socket with:
ls /run/php/
Examples:
- PHP 7.4 →
/run/php/php7.4-fpm.sock
- PHP 8.1 →
/run/php/php8.1-fpm.sock
Change the fastcgi_pass
line to match your version.
🔄 5. Restart Nginx
nginx -t && systemctl reload nginx
✅ 6. Test It
Visit:
http://<your-ip>/info.php
You should see the PHP Info page.
🧹 7. (Optional) Delete the Test File After Testing
rm /mnt/hdd/www/myapp/info.php
🧠 Ready for WordPress, Laravel, etc.
You’re now fully ready to:
- Host PHP sites
- Use MySQL (or MariaDB)
- Store large data on
/mnt/hdd
Let me know if you want help setting up WordPress or Laravel next!
As of July 2025, PHP 8.4 is still in pre-release / alpha/beta.
If you want PHP 8.3 (latest stable) or a newer version (like 8.4 for testing), you’ll need to add an external repo, because Debian 11 defaults to PHP 7.4.
⚠️ Summary
Version | Status | Available via |
---|---|---|
PHP 7.4 | ✅ Default | Debian 11 repo |
PHP 8.3 | ✅ Stable | Sury PPA |
PHP 8.4 | ⚠️ Pre-release | Sury testing repo (only for dev use) |
✅ Recommended: Install PHP 8.3 via Sury (Stable)
🔧 1. Remove PHP 7.4
apt remove --purge 'php7.4*' -y
apt autoremove --purge -y
🧱 2. Add SURY PHP Repo (Official for Debian)
apt install apt-transport-https lsb-release ca-certificates curl gnupg -y
curl -fsSL https://packages.sury.org/php/apt.gpg | gpg --dearmor -o /etc/apt/trusted.gpg.d/php.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list
apt update
📦 3. Install PHP 8.3 and FPM
apt install php8.3 php8.3-fpm php8.3-cli php8.3-common php8.3-mysql php8.3-curl php8.3-xml php8.3-mbstring php8.3-zip php8.3-gd -y
🔍 4. Verify Installed Version
php -v
Should output something like:
PHP 8.3.x (cli)
⚙️ 5. Update Nginx Config
Edit Nginx to point to the new PHP-FPM socket:
nano /etc/nginx/sites-available/myapp
Update this line:
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
Then reload:
nginx -t && systemctl reload nginx
🔄 Optional: Use PHP 8.4 (Pre-release)
Only if you’re a developer/testing:
apt install php8.4 php8.4-fpm php8.4-cli ...
And update Nginx to:
fastcgi_pass unix:/run/php/php8.4-fpm.sock;
❗PHP 8.4 is not stable yet. Not recommended for production.
✅ Done!
You now have:
- ❌ Removed PHP 7.4
- ✅ Installed PHP 8.3 (or 8.4)
- ✅ Nginx configured properly
- ✅ Using your HDD for web hosting
Let me know if you want to set up Laravel, WordPress, or run multiple PHP versions side-by-side!