CasaOS icon indicating copy to clipboard operation
CasaOS copied to clipboard

[Bug] Random new drive found message displayed

Open riclucio opened this issue 5 months ago • 9 comments

Describe the bug

My CasaOS dashboard started to show the message "Found a new drive" randomly, with a "NaN / NaN undefined" message in the size. Clicking "Storage Manager" only shows storage dialog after multiple clicks, and the dialog doesn't show any new storage. The X button to dismiss also doesn't work.

Screenshots Image

Desktop (please complete the following information):

 - OS (Desktop): MacOS, (Server): Ubuntu 24.04.2 LTS aarch64
 - Browser: Brave
 - Version: 1.80.113
 - Server Host: Orange Pi 5 Max
 - Kernel: 6.1.0-1025-rockchip
 - CasaOS version: v0.4.15

System Time

ubuntu@homelab:~$ timedatectl
               Local time: Mon 2025-06-30 16:14:16 UTC
           Universal time: Mon 2025-06-30 16:14:16 UTC
                 RTC time: Mon 2025-06-30 16:14:17
                Time zone: Etc/UTC (UTC, +0000)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

**Logs**

> Run following command to collect corresponding logs:

```bash
sudo journalctl -xef -u casaos-gateway
sudo journalctl -xef -u casaos-user-service
sudo journalctl -xef -u casaos-local-storage
sudo journalctl -xef -u casaos-app-management

[casaos-user-service.log](https://github.com/user-attachments/files/20983921/casaos-user-service.log)
[casaos-service.log](https://github.com/user-attachments/files/20983920/casaos-service.log)
[casaos-local-storage.log](https://github.com/user-attachments/files/20983922/casaos-local-storage.log)
[casaos-gateway.log](https://github.com/user-attachments/files/20983923/casaos-gateway.log)
[casaos-app-management.log](https://github.com/user-attachments/files/20983924/casaos-app-management.log)

riclucio avatar Jun 30 '25 16:06 riclucio

Just to say that the same happened here and I haven't added drives or even rebooted the device for a long time. Why is this happening to several people now?

blindmanonacid avatar Jul 07 '25 15:07 blindmanonacid

I am on proxmox, and something happened to me, but it might just be the boot drive for me

Crazygiscool avatar Jul 11 '25 19:07 Crazygiscool

Check

ls /mnt

If there are any folders there that should not be, delete it. The notification will go away.

forkymcforkface avatar Sep 17 '25 23:09 forkymcforkface

Check

ls /mnt

If there are any folders there that should not be, delete it. The notification will go away.

I kinda resetted it, but I’m sure that would’ve worked, thanks

Crazygiscool avatar Sep 18 '25 01:09 Crazygiscool

I found that it was a SWAP issue, and with the lsblk command I found that the size of zram0 is exactly the same as the size mentioned in the message "Found a new drive".

Image

But I don't know how to change it to prevent casaos from reading zram0's information. So I asked the AI, and they said that you can manually configure udev rules to block zram events, but I tried it and it didn't work.

# Create a rule file:
sudo nano /etc/udev/rules.d/99-ignore-zram.rules
Write the following:
# Ignore the add event for zram0 devices (to prevent misidentification by CasaOS)
KERNEL=="zram0", ACTION=="add", ENV{UDISKS_IGNORE}="1", ENV{ID_MM_DEVICE_IGNORE}="1"
# Can be extended to ignore all zram:
KERNEL=="zram[0-9]*", ACTION=="add", ENV{UDISKS_IGNORE}="1", ENV{ID_MM_DEVICE_IGNORE}="1"
# After saving, reload the udev rules:
sudo udevadm control --reload-rules
sudo udevadm trigger
# Then restart CasaOS:
sudo systemctl restart casaos

songmaker avatar Sep 21 '25 13:09 songmaker

I found that it was a SWAP issue, and with the lsblk command I found that the size of zram0 is exactly the same as the size mentioned in the message "Found a new drive".

Image But I don't know how to change it to prevent casaos from reading zram0's information. So I asked the AI, and they said that you can manually configure udev rules to block zram events, but I tried it and it didn't work.
# Create a rule file:
sudo nano /etc/udev/rules.d/99-ignore-zram.rules
Write the following:
# Ignore the add event for zram0 devices (to prevent misidentification by CasaOS)
KERNEL=="zram0", ACTION=="add", ENV{UDISKS_IGNORE}="1", ENV{ID_MM_DEVICE_IGNORE}="1"
# Can be extended to ignore all zram:
KERNEL=="zram[0-9]*", ACTION=="add", ENV{UDISKS_IGNORE}="1", ENV{ID_MM_DEVICE_IGNORE}="1"
# After saving, reload the udev rules:
sudo udevadm control --reload-rules
sudo udevadm trigger
# Then restart CasaOS:
sudo systemctl restart casaos

This script should fix the issue. lmk

#!/bin/bash
#
# CasaOS Ghost Cleaner
#
# SAFETY NOTICE:
# ----------------------------------------------------
# This script does NOT unmount, touch, or delete any
# user data or mounted drives.
#
# It ONLY:
#   1. Cleans leftover phantom "loop" or zero-size
#      notifications from CasaOS user.db (events table).
#   2. Removes truly empty folders left in /mnt.
#   3. Detaches orphaned loop devices whose backing
#      files no longer exist.
#
# No partitions, mounts, or actual data are modified.
# ----------------------------------------------------

DB="/var/lib/casaos/db/user.db"

# Ensure sqlite3 is available
if ! command -v sqlite3 >/dev/null 2>&1; then
    echo "sqlite3 not found, installing..."
    apt-get update -qq
    apt-get install -y sqlite3
fi

if [ ! -f "$DB" ]; then
    echo "CasaOS user.db not found at $DB"
    exit 1
fi

# --- 1. Detach orphan loops ---
while IFS= read -r line; do
    loopdev=$(echo "$line" | cut -d: -f1)
    file=$(echo "$line" | sed -n 's/.*(\(.*\)).*/\1/p')
    if [ "$file" = "(deleted)" ] || [ ! -e "$file" ]; then
        echo "Detaching orphan loop: $loopdev"
        losetup -d "$loopdev"
    fi
done < <(losetup -a)

# --- 2. Clean phantom loop events from CasaOS DB ---
ACTIVE_LOOPS=$(losetup -a | cut -d: -f1)
SQL="DELETE FROM events WHERE name LIKE 'local-storage:disk:added' AND properties LIKE '%/dev/loop%'"

for loop in $ACTIVE_LOOPS; do
    dev=$(basename "$loop")
    SQL+=" AND properties NOT LIKE '%/$dev%'"
done

sqlite3 "$DB" "$SQL"
sqlite3 "$DB" "DELETE FROM events WHERE properties LIKE '%\"size\":\"0\"%';"

# --- 3. Remove empty /mnt folders ---
for d in /mnt/*; do
    [ -d "$d" ] || continue
    if [ -z "$(ls -A "$d")" ]; then
        echo "Removing empty folder: $d"
        rm -rf "$d"
    fi
done

# Restart CasaOS user service so UI reflects changes
systemctl restart casaos-user-service

forkymcforkface avatar Sep 23 '25 16:09 forkymcforkface

I submitted this PR #256

forkymcforkface avatar Sep 23 '25 18:09 forkymcforkface

I submitted this   我提交了这个PR #256

@forkymcforkface Hello! I found out that the PR #256 you submitted has been merged into mainline and released, so I used the command "curl -fsSL https://get.casaos.io/update | sudo bash" updated the UI of casaos. The UI did update, but the message "Found a new drive" was still there. Although it can be turned off, it still exists after refreshing.

Maybe your changes didn't work? Maybe you can also update the UI to see if it fixes the problem.

songmaker avatar Sep 29 '25 11:09 songmaker

The X button to dismiss also doesn't work.

@riclucio @blindmanonacid Hello! Try using the command "curl -fsSL https://get.casaos.io/update | sudo bash" updated the UI of casaos. The X button is working fine, but the message "Found a new drive" still appears after refreshing on my machine.

I would like to know how your UI is doing after the update.

songmaker avatar Sep 29 '25 11:09 songmaker