Saturday, 23 May 2020

FreeNAS 0.7.2 - GEOM: adn: the secondary GPT table is corrupt or invalid

On booting FreeNAS 0.72 you may see the message: "the secondary GPT table is corrupt or invalid".

This can be ignored. According to this article:

"This error is caused by a basic flaw in the software used in FreeBSD and XigmaNAS to create and manage RAID arrays. Until FreeBSD version 7x the OS ignored / did not report the error. Now it and XigmaNAS, since it is based on FreeBSD, do report it. In the future, this may be fixed in FreeBSD, until then let's all continue blissfully ignoring it like we did prior to version 7x"

Wednesday, 20 May 2020

Rsync with SystemRescueCD

Using the SystemRescueCD:

mkdir /mnt/usb
mkdir /mnt/Data

Mount the NTFS USB disk
ntfs-3g /dev/sdc1 /mnt/usb

Mount the UFS disk
mount -t ufs -o ufstype=ufs2,ro /dev/sda1 /mnt/Data

then use grsync to copy the data

Source: /mnt/Data
Destination: /mnt/usb
This will copy the Data folder and its subdirectories to the mounted USB drive.

Tuesday, 19 May 2020

Rebuild a RAID 1 in FreeNAS 0.7.2

Determine the disk that has failed: is it ad0 or ad1?

Go to Disks > Software RAID > Tools
Select the failed drive, select Forget and click Send
Insert the new drive
Select the inserted drive, select Insert and click Send
Wait 5 minutes, select the drive and hit Status. You should see a percentage next to the new drive: this is it rebuilding.

Wednesday, 22 April 2020

Saturday, 14 March 2020

crontab doesn't run script

If crontab doesn't run a script and if the output is redirected to a zero length file, it may be because it is missing the #!/bin/bash or #!/bin/sh directive.

Another reason may be that the path is required.
change dotnet to /opt/dotnet/dotnet

Remember that crontab runs under a reduced environment. It may not have the necessary environment variables. For example echo @DOTNET_ROOT is empty when running as crontab. If you run it as su it returns /opt/dotnet

Consider the user you are running the crontab under. Does it need to be su?

In the end another approach was required: execute bash to run the script. This is the full crontab:
# Added dotnet to the path
MAILTO=""
PATH=/usr/bin:/bin:/opt/dotnet:/usr/local/sbin:/usr/local/bin:/usr/sbin:/sbin
SHELL=/bin/bash
# It is necessary to execute bash in order to access the environment variables required for dotnet
* */12 * * * bash -l -c '/home/pi/SmartHome/easy-weatherstation/scripts/publishreadings.sh' > /home/pi/SmartHome/easy-weatherstation/scripts/logs/publishreadings.log 2>&1
*/30 * * * * bash -l -c '/home/pi/SmartHome/easy-weatherstation/scripts/onereading.sh' > /home/pi/SmartHome/easy-weatherstation/scripts/logs/onereading.log 2>&1

Sunday, 1 March 2020

the required library libhostfxr.so could not be found

Problem: Running .net core 3.1 app on a Raspberry Pi returns
"the required library libhostfxr.so could not be found."

check
dotnet --version
echo $DOTNET_ROOT

if the second line is empty then the environment variable needs to be set at startup.

Add a file set_dotnetroot.sh to /etc/profile.d
sudo nano /etc/profile.d/set_dotnet.sh

add
export DOTNET_ROOT="/opt/dotnet"

save and reboot

If you want it to run for su too, especially if running a su crontab,
edit /etc/bash.bashrc and add it there too.