NAS

Tout ce qui est relatif su stockage

Probleme de pool sur le nas truenas

A la suite d'un remplacement d'un disque défectueux sur le nas truenas, j'ai du faire quelque chose de pas correct, parce qu'il m'indique toujours un disque du pool en problème alors qu'il n'existe plus...





ada0

1836E15408CD
111.79 GiB
freenas-boot
da0
Z1F2XZ07 2.73 TiB vol1
da1 Z5051B2S 2.73 TiB vol1
da2 Z505GKWH 2.73 TiB vol1
da3 Z5051B5V 2.73 TiB vol1
da4 Z501LWNS 2.73 TiB vol1
da5 W1F4FEA3 2.73 TiB vol1
/mnt/vol1

DEGRADED
RAIDZ2

DEGRADED

da0

ONLINE

da1

ONLINE

da2

ONLINE

da3

ONLINE

da4

OFFLINE

da5

ONLINE

Right click / Online

Resilvering Status

0.11%

Resilvering pool: vol1

Status: SCANNING


Now that this operation is ongoing, I am creating another little nas as a backup to store the data from my nas in case I have to recreate it.

The other nas consist of:

For this one I have started to build a mergerfs/snapraid config. Even if I had great success with it (good speed) when it comes to transfert large amount of files it just fails because mergerfs is more a good fir with files that does not move too often and in my case, the transfert of all my files (videos, backups, etc) cause mergerfs to not catch up with the spread of infos among the other disks. I ended installing the LVM plugin, create a big PV/VG/LV with all the disks.

I have added an rsync service (but not used.. see below).

The transfert of the files is done using a rsync command in a screen session and.. wait.

 

├── Media
│   ├── Downloads << la ou le client torrent telecharge
│   ├── Films << torrent completed pour radarr
│   ├── Games
│   ├── img
│   ├── Iso
│   ├── media-nas
│   ├── media-user
│   ├── Music
│   ├── Musiques
│   ├── Photos
│   ├── Series << la ou medusa place les series
│   ├── tdarr
│   ├── TorrentsFiles
│   └── Videos

Move files and folders from a pool to another one (more complex than I thought)

Ok.

So I have this situation.

I use Freenas with 2 pools.

I use a software I don't recall the name (call it thing*daar) to handle the search and download of the torrent files. It download them using a torrent client (Transmission) and copy them when finish to the pool where the files are.

But that make no real sense since it needs to copy the file so I have it twice and that I cannot use symlinks because NFS does not allow this in 2 separate pools.

As backup of those two pools, I use syncthing that sunc those 2 "folders" into another NAS (based on openmediavault and a RPI4).

So I need to plan the move carefully

I guess that I need to list here the different components/vms and how they access the pools

2023-09-16:

So THIS weekend is THE weekend.

I have decided that this little project should go out of my mind for good :)

Let's start the journey by checking one little thing first: Do we have any space in the POOL_B to copy/move the files? In fact.. do we have enough free space at all??.

Let'S check this:

image.png

Ouch... 1.8T free and the POOL_A is 1.5T.

...

Well, still I can make it!!! Anyway, as soon as the copy/move is done I can recover the space so that's good. 

Now another question is: where I will do the copy command? Like in a screen session on the truenas box? That could make it....

Let's do it!

2023-09-17

Cool! transfet is done and all seems to be ok. Well, I have first to modify the mount options on the truenas server to allow the network/ip from the transmission client to be able to connect to the  server. in my case the client is natted so make sure you put in the server mount's option for the networks/ips allowed the address seen by the server and not the clien'ts ip (if you are natted).

I have modified the fstab entry in the client to point to the correct path (I have allowed the alldirs options on the truenas share side) and then restarted the box. Then the transmission client seems to be ok and all the sharing are green/working.

Nice! One big step done!

2023-09-23

Now there are some seetings that need to be change but on the Rancher side this time. I use Rancher as a K3S/pod management. One of this pod is the application that help me search, organise and download the torrent files. Since it'S a pod (more a less a docker pod) I need to configure the volume mapping.

On the Rancher side, I have configure a NFS Storage configuration that looks like this:

2023-10-21

Arf... I knew it in advance... I was lazy and have not finished this "project" yet... 

Now what is the current situation

Well,

Ok. So, I need fist a little plan:

Now for the cleanup part, to discover any duplicated files, I use the ideas from that site: https://www.baeldung.com/linux/finding-duplicate-files, and specially this piece of code:

awk -F'/' '{
  f = $NF
  a[f] = f in a? a[f] RS $0 : $0
  b[f]++ } 
  END{for(x in b)
        if(b[x]>1)
          printf "Duplicate Filename: %s\n%s\n",x,a[x] }' <(find . -type f -not -links 2)

Now I can safelly delete some duplicate files (remember that I can use now hardlink so I will keep the copy from the download folder and hardlink to the files folder

I can now create my dowmload_2 folder, reconfigure my rancher pod for the NFS part to point to this folder and then do the rancher cleanup.

Note: I have added "-not -links 2" because I do not want to list the files that are already harlinks in the output (meaning, the files that are set correctly between the download folder and the target folder)

2023-10-22

So let's do the easy part with syncthing. On the nas part (the source of the files)

image.png

image.png

image.png

root@nas[~]# mkdir /mnt/vol1/media/Media/downloads_tvshows
root@nas[~]#

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

2023-11-12

So, what else I need to do?

Well, I still have the cleanup process to complete. Earlier in this pst, I put a script that can detect and list all deplicate filename. It is very handy to get that list because my "automation" trigger just started and I am thinking "since I have this list, I can use it in order to delete the destination file and instead to hard link!". Yep, that smart, I know. But first I need to validate that all the entries from the ouput are correct.

Luckily, the output, if valid, shoud always looks like this:

Duplicate Filename: the-file.txt
./downloads/complete/the-file.txt
./destination_folder/the-file.txt

it should be like this everytime, everything else could be considered as not correct, So I just the script below to validate those entries in the file output (dup5.txt) from the other script.

#!/bin/bash
SAVEIFS=$IFS
IFS=$'\n'
filename="dup5.txt"


function check () {
        myarray=("$@")

        lin1="Duplicate Filename"
        lin2="./downloads"
        lin3a="./destination_folder"
        len_lin1=${#lin1}
        len_lin2=${#lin2}
        len_lin3a=${#lin3a}

        line1="${myarray[0]}"
        line2="${myarray[1]}"
        line3="${myarray[2]}"
        if [ ${line1:0:${len_lin1}} == "$lin1" ]; then echo "ligne 1 ok";else echo "ligne 1 pas ok at index $((idx -2))";exit;fi
        if [ ${line2:0:${len_lin2}} == "$lin2" ]; then echo "ligne 2 ok";else echo "ligne 2 pas ok at index $((idx -1))";exit;fi
        if [ ${line3:0:${len_lin3a}} == "$lin3a" ]; then echo "ligne 3 ok";else echo "ligne 3 pas ok at index $idx";exit;fi
}

readarray -t lines < "$filename"

let s=0
array=()
for ((idx=0; idx<${#lines[@]}; ++idx)); do
    echo "$idx" "${lines[idx]}"
        if ! [ "$s" -eq 3 ]; then
                array+=(${lines[idx]})
                let s++
        fi
        if [ "$s" -eq 3 ];then
                check "${array[@]}" # ici go function to test the array
                let s=0
                array=()
        fi
done

IFS=$SAVEIFS

Now when I run it I can see the lines in the dup5.txt result file that contain some entries that are not correct. Once I did the cleanup on the files (so removing the files themself if needed and/or removing the entries in the dup5.txt file in case the file name is the same but it is ok), then I can use the same script to delete the destination file and use a hardlink instead.

2023-11-22

So, I guess it's time to switch the 3T drives to the 8T ones. How to do this in Truenas?

First, let's take one offline (starting with the one with sector errors)

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

root@nas[~]# zpool status -xv
  pool: vol1
 state: ONLINE
status: One or more devices has experienced an unrecoverable error.  An
        attempt was made to correct the error.  Applications are unaffected.
action: Determine if the device needs to be replaced, and clear the errors
        using 'zpool clear' or replace the device with 'zpool replace'.
   see: https://openzfs.github.io/openzfs-docs/msg/ZFS-8000-9P
  scan: scrub in progress since Sat Nov 25 10:25:13 2023
        13.2T scanned at 162M/s, 12.8T issued at 157M/s, 13.3T total
        330M repaired, 96.53% done, 00:51:14 to go
config:

        NAME                                            STATE     READ WRITE CKSUM
        vol1                                            ONLINE       0     0     0
          raidz2-0                                      ONLINE       0     0     0
            gptid/65c1b0b9-4a60-11ed-863a-6cb3111b4436  ONLINE       0     0     0
            gptid/7d7c80fe-8a65-11ee-bd6f-6cb3111b4436  ONLINE       0     0    14  (repairing)
            gptid/3c6894da-360a-11e8-a468-7085c24f6f21  ONLINE       0     0     0
            gptid/51df798c-8ae1-11ee-bd6f-6cb3111b4436  ONLINE       0     0 10.5K  (repairing)
            gptid/1a44a6d9-893a-11ee-bd6f-6cb3111b4436  ONLINE       0     0     0
            gptid/3e40c4e8-360a-11e8-a468-7085c24f6f21  ONLINE       0     0     0

errors: No known data errors

image.png

image.png

 

image.png

 

image.png

 

image.png

image.png