DietPi Broken

Hi all, I’ve just removed my SD card to make an image backup and upon restarting my setup, I get this error.

-bash: /DietPi/dietpi/func/dietpi-globals: No such file or directory
grep: /DietPi/dietpi.txt: No such file or directory
-bash: /DietPi/dietpi/dietpi-login: No such file or directory

I’m running an Odroid C2, with DietPi base and Home Assistant installed.

Hoping someone can help me with this, as I made quite a few changes since my last backup (only 3 days ago) :cry:

thekevinkalis
Sorry for the late reply, especially since your critical issue.

Is this still an issue?

DietPi-RAMdisk obviously failed to start. Ways to debug:

journalctl -u dietpi-ramdisk
cat /var/tmp/dietpi/logs/dietpi-ramdisk.log

Hi, this is what I’m getting and really dont know how to fix it. I appreciate the help:

   -- Logs begin at Wed 2019-10-16 10:28:41 CEST, end at Wed 2019-10-16 10:32:53 CEST. --
Oct 16 10:28:45 DietPi systemd[1]: Starting DietPi-RAMdisk...
Oct 16 10:28:45 DietPi dash[221]: /bin/dash: 1: /boot/dietpi/func/dietpi-ramdisk: Exec format error
Oct 16 10:28:45 DietPi systemd[1]: diet
pi-ramdisk.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Oct 16 10:28:45 DietPi systemd[1]: diet
pi-ramdisk.service: Failed with result 'exit-code'.
Oct 16 10:28:45 DietPi systemd[1]: Fail
ed to start DietPi-RAMdisk.

Seferi
“Exec format error”, a wrong dash binary or broken script?

Please try dash -c ‘echo success’ from console? If it fails as well, please try:
apt install --reinstall dash

If dash works well without reinstall, then try to redownload the script and execute it:

wget https://raw.githubusercontent.com/MichaIng/DietPi/master/dietpi/func/dietpi-ramdisk -O /boot/dietpi/func/dietpi-ramdisk
chmod +x /boot/dietpi/func/dietpi-ramdisk
/boot/dietpi/func/dietpi-ramdisk 0

If this works well now, please try to start the service: systemctl start dietpi-ramdisk
Verify via tail -1 /var/tmp/dietpi/logs/dietpi-ramdisk.log.
If this works as well, please reboot.

Thanks for replying mate. Dash gives success. I downloaded the script.

/boot/dietpi/func/dietpi-ramdisk 0

Gives:

Wed Oct 16 14:01:11 CEST 2019 | DietPi-RAMdisk: Copying DietPi to RAM...
Wed Oct 16 14:01:11 CEST 2019 | DietPi-RAMdisk: DietPi is already in RAM. Aborting...



sudo tail -1 /var/tmp/dietpi/logs/dietpi-ramdisk.log

Gives:

Wed 16 Oct 13:47:31 CEST 2019 | DietPi-RAMdisk: Copied DietPi to RAM.

After reboot I’m getting:

-bash: .: /DietPi/dietpi/func/dietpi-globals: cannot execute binary file
[FAILED] DietPi-Login | Failed to load DietPi-Globals. Skipping DietPi login scripts...

Seferi
Very strange, could you paste: ls -Al /boot/dietpi /DietPi/dietpi

  /DietPi/dietpi:
total 1024
-rwxr-xr-x 1 root root     21 Oct 16 13:47 .dietpi-led_control
-rwxr-xr-x 1 root root    578 Oct 16 13:47 .dietpi-services_include_exclude
-rwxr-xr-x 1 root root    194 Oct 16 13:47 .hw_model
-rwxr-xr-x 1 root root      2 Oct 16 13:47 .install_stage
-rwxr-xr-x 1 root root   5735 Oct 16 13:47 .installed
-rwxr-xr-x 1 root root     57 Oct 16 13:47 .network
-rwxr-xr-x 1 root root     16 Oct 16 13:47 .prep_info
-rwxr-xr-x 1 root root    125 Oct 16 13:47 .version
-rwxr-xr-x 1 root root   5275 Oct 16 13:47 boot
-rwxr-xr-x 1 root root   8676 Oct 16 13:47 dietpi-autostart
-rwxr-xr-x 1 root root  18772 Oct 16 13:47 dietpi-backup
-rwxr-xr-x 1 root root   6938 Oct 16 13:47 dietpi-bugreport
-rwxr-xr-x 1 root root  15393 Oct 16 13:47 dietpi-cleaner
-rwxr-xr-x 1 root root  44859 Oct 16 13:47 dietpi-cloudshell
-rwxr-xr-x 1 root root 135880 Oct 16 13:47 dietpi-config
-rwxr-xr-x 1 root root   5256 Oct 16 13:47 dietpi-cpuinfo
-rwxr-xr-x 1 root root   8030 Oct 16 13:47 dietpi-cron
-rwxr-xr-x 1 root root  64663 Oct 16 13:47 dietpi-drive_manager-rwxr-xr-x 1 root root   7874 Oct 16 13:47 dietpi-explorer
-rwxr-xr-x 1 root root   4121 Oct 16 13:47 dietpi-launcher
-rwxr-xr-x 1 root root  21362 Oct 16 13:47 dietpi-letsencrypt
-rwxr-xr-x 1 root root   7988 Oct 16 13:47 dietpi-login
-rwxr-xr-x 1 root root   7672 Oct 16 13:47 dietpi-morsecode
-rwxr-xr-x 1 root root  37483 Oct 16 13:47 dietpi-services
-rwxr-xr-x 1 root root 520984 Oct 16 13:47 dietpi-software
-rwxr-xr-x 1 root root   6779 Oct 16 13:47 dietpi-survey
-rwxr-xr-x 1 root root  16939 Oct 16 13:47 dietpi-sync
-rwxr-xr-x 1 root root  16703 Oct 16 13:47 dietpi-update
drwxr-xr-x 2 root root    420 Oct 16 13:47 func
drwxr-xr-x 2 root root    120 Oct 16 13:47 misc
-rwxr-xr-x 1 root root   1675 Oct 16 13:47 postboot
-rwxr-xr-x 1 root root   1454 Oct 16 13:47 preboot

/boot/dietpi:
total 961
-rwxr-xr-x 1 root root     21 Oct 15 10:39 .dietpi-led_control
-rwxr-xr-x 1 root root    578 Oct 15 10:39 .dietpi-services_include_exclude
-rwxr-xr-x 1 root root    194 Oct 15 10:39 .hw_model
-rwxr-xr-x 1 root root      2 Oct 15 10:39 .install_stage
-rwxr-xr-x 1 root root   5735 Oct 15 10:39 .installed
-rwxr-xr-x 1 root root     57 Oct 15 10:39 .network
-rwxr-xr-x 1 root root     16 Oct 15 10:39 .prep_info
-rwxr-xr-x 1 root root    125 Oct 15 10:39 .version
-rwxr-xr-x 1 root root   5275 Oct 15 10:39 boot
-rwxr-xr-x 1 root root   8676 Oct 15 10:39 dietpi-autostart
-rwxr-xr-x 1 root root  18772 Oct 15 10:39 dietpi-backup
-rwxr-xr-x 1 root root   6938 Oct 15 10:39 dietpi-bugreport
-rwxr-xr-x 1 root root  15393 Oct 15 10:39 dietpi-cleaner
-rwxr-xr-x 1 root root  44859 Oct 15 10:39 dietpi-cloudshell
-rwxr-xr-x 1 root root 135880 Oct 15 10:39 dietpi-config
-rwxr-xr-x 1 root root   5256 Oct 15 10:39 dietpi-cpuinfo
-rwxr-xr-x 1 root root   8030 Oct 15 10:39 dietpi-cron
-rwxr-xr-x 1 root root  64663 Oct 15 10:39 dietpi-drive_manager-rwxr-xr-x 1 root root   7874 Oct 15 10:39 dietpi-explorer
-rwxr-xr-x 1 root root   4121 Oct 15 10:39 dietpi-launcher
-rwxr-xr-x 1 root root  21362 Oct 15 10:39 dietpi-letsencrypt
-rwxr-xr-x 1 root root   7988 Oct 15 10:39 dietpi-login
-rwxr-xr-x 1 root root   7672 Oct 15 10:39 dietpi-morsecode
-rwxr-xr-x 1 root root  37483 Oct 15 10:39 dietpi-services
-rwxr-xr-x 1 root root 520984 Oct 15 10:39 dietpi-software
-rwxr-xr-x 1 root root   6779 Oct 15 10:39 dietpi-survey
-rwxr-xr-x 1 root root  16939 Oct 15 10:39 dietpi-sync
-rwxr-xr-x 1 root root  16703 Oct 15 10:39 dietpi-update
drwxr-xr-x 2 root root   2048 Jul 14 17:34 func
drwxr-xr-x 2 root root    512 Jul 14 17:34 misc
-rwxr-xr-x 1 root root   1675 Oct 15 10:39 postboot
-rwxr-xr-x 1 root root   1454 Oct 15 10:39 preboot

Should I install dietpi and pihole again from scratch?

Seferi
Not required so far, although it looks like some data corruption if bash sees our globals script as binary… It is a plain text bash script.
However RAMdisk HAS indeed been loaded and at least the main script meta data look fine.

Which DietPi version do you use? I guess v6.25?
If so please try the following to have all together updated to v6.26 and hopefully fixed:

wget https://raw.githubusercontent.com/MichaIng/DietPi/2aa9cf03cbf10dfc26d5d6bbde2a1fbaf23d0f28/dietpi/func/dietpi-globals -O /DietPi/dietpi/func/dietpi-globals
. /DietPi/dietpi/func/dietpi-globals
dietpi-update 1

Thanks mate. I updated as you described and after reboot I’m getting:

-bash: /DietPi/dietpi/func/dietpi-globals: No such file or directory
[FAILED] DietPi-Login | Failed to load DietPi-Globals. Skipping DietPi login scripts...

sudo systemctl status dietpi-ramdisk.service

● dietpi-ramdisk.service - DietPi-RAMdisk
   Loaded: loaded (/etc/systemd/system/dietpi-ramdisk.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sat 2019
-10-19 13:00:04 CEST; 38s ago
  Process: 769 ExecStartPre=/bin/mkdir -p /var/tmp/dietpi/logs (code=exited, status=0/SUCCESS)
  Process: 770 ExecStart=/bin/dash -c /boot/dietpi/func/dietpi-ramdisk 0 2>&1 >> /var/tmp/dietpi/logs/dietpi-ramdisk.log
(code=exited, status=2)
 Main PID: 770 (code=exited, status=2)

Oct 19 13:00:04 DietPi systemd[1]: Starting DietPi-RAMdisk...
Oct 19 13:00:04 DietPi dash[770]: /bin/dash: 1: /boot/dietpi/func/dietpi-ramdisk: Exec format error
Oct 19 13:00:04 DietPi systemd[1]: diet
pi-ramdisk.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Oct 19 13:00:04 DietPi systemd[1]: diet
pi-ramdisk.service: Failed with result 'exit-code'.
Oct 19 13:00:04 DietPi systemd[1]: Fail
ed to start DietPi-RAMdisk.

Seferi
I have one idea, could you please try:

sed -i $'s/\r$//' /boot/dietpi/func/dietpi-ramdisk
/boot/dietpi/func/dietpi-ramdisk 0

If that still fails, please paste:

ls -l /boot/dietpi/func/dietpi-ramdisk
head -5 /boot/dietpi/func/dietpi-ramdisk

And since some output confuses me, could you verify /DietPi is correctly mounted as tmpfs:

findmnt /DietPi
Barry@DietPi:~ $ ls -l /boot/dietpi/func/dietpi-ramdisk
-rwxr-xr-x 1 root root 4306 Oct 19 14:09 /boot/dietpi/func/dietpi-ramdisk
Barry@DietPi:~ $ head -5 /boot/dietpi/func/dietpi-ramdisk   
Barry@DietPi:~ $ findmnt /DietPi
TARGET  SOURCE FSTYPE OPTIONS                                
  /DietPi tmpfs  tmpfs  rw,nosuid,nodev,noatime,size=10240k
Barry@DietPi:~ $

Seferi
Wow, head -5 /boot/dietpi/func/dietpi-ramdisk didn’t output anything? I believe your SDcard is somehow damaged then. Strange that the meta data still shows a file size. What happens if you open the file in an editor? nano /boot/dietpi/func/dietpi-ramdisk.

Not sure how to fix best. We could do a last attempt to re-download all matching DietPi scripts to your SDcard and manually sync to RAMdisk, however high likely they will be damaged again after reboot or such. I am just wondering that neither systemd nor kernel (dmesg) reports any related errors :thinking:.
Ah or did you actually already check it: dmesg | tail -10

Here is the dmesg output mate:

[620929.358025] systemd[1]: Detected architecture arm.
[620929.705095] systemd[1]: File /lib/systemd/system/systemd-journald.service:12 configures an IP firewall (IPAddressDeny=any), but the local system does not support BPF/cgroup based firewalling.
[620929.705134] systemd[1]: Proceeding WITHOUT firewalling in effect! (This warning is only shown for the first loaded unit using IP firewalling.)
[620930.254821] systemd[1]: getty@tty1.service: Current command vanished from the unit file, execution of the command list won’t be resumed.
[620930.888029] systemd-journald[104]: Received SIGTERM from PID 1 (systemd).
[620930.896879] systemd[1]: Stopping Journal Service…
[620930.901047] systemd[1]: systemd-journald.service: Succeeded.
[620930.904612] systemd[1]: Stopped Journal Service.
[620930.928448] systemd[1]: Condition check resulted in Journal Audit Socket being skipped.
[620930.940447] systemd[1]: Starting Journal Service…


I’m probably gonna get a new sdcard if you think thats the problem. Sorry for the late reply.