Decided to migrate my Ugreen NAS off of FreeBSD to NetBSD. Luckily my old nas still had
some space on it, and i had no changes basicly since last backup i had done between the old nas
and the ugreen nas.
So if things did not go as planned, there were nothing to worry about.
This was not as much of a smooth sailing as i'd hoped.
Started of by reading the man page for
raidctl
Then i read this, because why is it disk sometimes and disc sometimes
When is the
right usage of c/k
I did not manage to get the disks to use the space they had,
and it taking about 8h between raid initializing, was frustrating...
Did some more searching which led me to this wiki
Using large disks
A few more attempts, and a few more 8h waits.
Still this did not work as expected. Then later, after
alot more Duckduckgo searching, i found out that:
Disklabel does not support disks larger than 2TB. Ohhh!
GPT / GUID Partition Table is the way to go.
A few more attempts, a few more initializations...
Think i wrote 5ish attempts on Mastodon, but i dont think it is enough. Probably double that...
Finally, i scrolled further down on that Using large disks wiki
and found the Raidframe portion. Followed that, and voila!
Copying files as i write this!
First i installed NetBSD as a usual installation on the ssd disk on the nas.
Checked dmesg to find the the disks, which for me was wd0, wd1, wd2 and wd3
Clear the disks:
$ doas dd if=/dev/zero of=/dev/wd0 bs=1024k count=1
$ doas dd if=/dev/zero of=/dev/wd1 bs=1024k count=1
$ doas dd if=/dev/zero of=/dev/wd2 bs=1024k count=1
$ doas dd if=/dev/zero of=/dev/wd3 bs=1024k count=1
Find the number of sectors and size of one disk:
$ dmesg|grep wd0
wd0: 7452 GB, 15504021 cyl, 16 head, 63 sec, 512 bytes/sect x 15628053168 <--
Create filesystem on the disks. You need -O2 to use ffsv2
force -F and set the size using -s, since disk is bigger than 2TB:
$ doas newfs -O2 -s 7452g -F /dev/rwd0
$ doas newfs -O2 -s 7452g -F /dev/rwd1
$ doas newfs -O2 -s 7452g -F /dev/rwd2
$ doas newfs -O2 -s 7452g -F /dev/rwd3
If things go wrong, start over:
$ doas raidctl -u raid5
After the gpt create, do dmsg|grep wd0 and you will find 15628053168
use that - 2048 and change as size for each drive.
Setting the type to raid (-t raid), is important aswell:
$ doas gpt destroy wd0
$ doas gpt create -Af wd0
$ doas gpt add -t raid -l raid5@wd0 -b $(( 2048 )) -s 15628050000 wd0
$ doas gpt destroy wd1
$ doas gpt create -Af wd1
$ doas gpt add -t raid -l raid5@wd1 -b $(( 2048 )) -s 15628050000 wd1
$ doas gpt destroy wd2
$ doas gpt create -Af wd2
$ doas gpt add -t raid -l raid5@wd2 -b $(( 2048 )) -s 15628050000 wd2
$ doas gpt destroy wd3
$ doas gpt create -Af wd3
$ doas gpt add -t raid -l raid5@wd3 -b $(( 2048 )) -s 15628050000 wd3
Now we start to create the raid. I chose
raid 5 since that was what i had setup before.
Another learning, when you see errors like this, it means you have added the disks in the wrong order to the raid.
Column out of alignment for: /dev/dk5
You create a raid, I called it raid5, then add a serialnumber, which needs to be unique for this raid.
Then you initialize it... which took +8h for me...
Literally
$ doas raidctl raid5 create 5 /dev/dk3 /dev/dk4 /dev/dk6 /dev/dk5 (mine was out of order)
$ doas raidctl -I 133773311 raid5
$ doas raidctl -iv raid5 (can take fuckin forever)
Check status with: raidctl -s raid5 or if you want to monitor it, raidctl -S raid5...
You wake up the next morning, and it is 100% done. \o/
Then you create a gpt label for the raid, and create a partition on it with a label.
I chose island for my label.
If you want, you can create a wedge on it aswell, i did not.
$ doas gpt create -Af raid5
$ doas gpt add -a 1024 -t ffs -l island raid5
/dev/rraid5: Partition 1 added: aaaaaaaa-bbbb-cccc-dddd-ffffffffffff 34 46884149692
(optional) $ doas dkctl raid5 addwedge island 34 46884149692 ffs
# values between label and ffs found in command above
Create a filesystem for the raid, then mount it (check dk value from dmesg or shown from newfs)
$ doas newfs -O2 NAME=island
$ doas mount /dev/dk7 /mnt
If that works, add this to /etc/fstab to mount when starting
NAME=island /mnt ffs rw 1 1
Warning, when you want to shutdown or reboot your NAS. Always use: doas shutdown -r now
If you use doas reboot, it will cause dirty disks! Reboot does not use the same scripts as Shutdown
Create a raid5.conf file in /etc to have the raid start at boot. Mine looks like this:
/etc/raid5.conf
START array
# numRow numCol numSpare
1 4 0
START discs
/dev/dk3
/dev/dk4
/dev/dk6
/dev/dk5
START layout
# sectPerSU SUsPerParityUnit SUsPerReconUnit RAID_level_5
128 1 1 5
START queue
fifo 100
Shut it down, and start it up to see that the raid starts and mounts as expected...
Then start copying files
If the disks go dirty, fsck em'
$ doas fsck -t ffs -f /dev/wd0
$ doas fsck -t ffs -f /dev/wd1
$ doas fsck -t ffs -f /dev/wd2
$ doas fsck -t ffs -f /dev/wd3
This is a very barebones setup, i use SFTP to copy files to it,
That is why i chose FFSv2 instead of something like VFAT
When copying is done, i will feel safe again...