Adding two SATA SSD devices to a RAID10 six SATA array.

I needed a bit more space on my NAS’s RAID10 array which was 6 x 2TB drives.To be honest iI’m not sure why I am using RAID10. The array was initially on my main Linux workstation. Then I decided I needed a separate NAS as my existing NAS was way too small, so I moved it across. RAID5/6 would give me more space. But I guess I like the flexibility and the ability to survive failure of two disks even though it does reduce space by 50%!

The server is running Debian and is headless. I know there’s loads of NAS OSs. But I do prefer to do things myself. The boot/root partitions are on a single SATA SSD card and the (now) eight drives are plugged into a Seagate Smart Host bus Adaptor H240.

I found two “consumer” Crucial 2TB SSD disks on Black Friday for £65 which seemed reasonable. I did wonder how well two SSDs would do in a RAIDarray with spinning drives. Let’s find out….! So this is what I did (which I am blogging about so I do not have to remember next time!). Interestingly the last time I blogged about growing a RAID array was quite some time ago. Also that’s the only time I’ve ever got comments on my blog (127 to be exact!). I think growing RAID arrays with MDADM was quite new back then.

The procedure to add new devices and grow the raid array is:

Procedure to grow an array with two new disks

  • physically add new disks
  • Partition
  • add disks to array
  • increase number of active disks in array to grow the array
  • grow filesystem

The new disks are /dev/sda /dev/sdd

Partition

For GPT use sgdisk to copy the partition table from one disk to a new one

Backup first of course!

sgdisk /dev/sdX -R /dev/sdY

sgdisk -G /dev/sdY

“The first command copies the partition table of sdb to sda/d

sgdisk /dev/sdb -R /dev/sda

sgdisk /dev/sdb -R /dev/sdd

Now randomise the GUID of each device:

sgdisk -G /dev/sdd

sgdisk -G /dev/sda

Add new devices

mdadm --add /dev/md1 /dev/sdd1 /dev/sda1

mdadm: added /dev/sdd1

mdadm: added /dev/sda1

These are added as spares as the number of active devices does not change. Let’s check:

# cat /proc/mdstat
Personalities : [raid10] [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4]
md1 : active raid10 sda1[8](S) sdd1[7](S) sdc1[5] sdg1[0] sde1[6] sdh1[3] sdb1[1] sdf1[4]
5860141056 blocks super 1.2 512K chunks 2 near-copies [6/6] [UUUUUU]
bitmap: 4/22 pages [16KB], 131072KB chunk

Increase number of devices to include new ones

mdadm --grow --raid-devices=8 --backup-file=/mnt/USB/grown_md1.bak /dev/md1

The –backup-file creates a backup file in case the power goes. Not essential as I have a UPS. Also the filesystem is still mounted. However, to speed it up I turned off all services except the DNS/DHCP server. The less disk activity the quicker the reshape will finish.

The reshaping took about 20 hours. Much less than I thought.

Now we need to resize the filesystem. Unmounting is not essential for growing a ext4 filesystem (although it is for shrinking), but hey it’s a lot safer so I shut off everything and unmounted it

systemctl stop smbd
systemctl stop docker
umount /mnt/storage

resize2fs /dev/md1

This gave an error that the filesystem needed checking first.

e2fsck -f /dev/md1

resize2fs /dev/md1

This took about 30 minutes.

Finishing off.

Now let’s get it all back up and running.

mount /mnt/storage

systemctl start docker

systemctl start samba

systemctl start smbd

systemctl start docker

systemctl restart docker

The entry for the mdadm device does not need updating. Previous it did but I think that’s when I was using the 0.9 metadata block.

mdadm --detail --scan

cat /etc/mdadm/mdadm.conf

One bizarre issue was that when I restarted all the docker containers they downloaded a new image rather than using existing images. I have no idea why that happened.

Plan9 – what I do after an install

This was written in Markdown using acme on Plan9 with an sshfs mounted folder of my NextCloud setup (via a Linux host). Tidied up in Drafts, then posted on macOS using Marsedit! This post is for me really. ..it will also be a WIP.

initial post install stuff

Create a new user

Everybody seems to use the default user, Glenda (from Plan9 from outer space). This is the equivalent of a root* unix user. Except I do not like that.

*Well almost. There is no root user that is all powerful in plan9

This also shows how you run a lot of command stuff by cat’ing text to the running process. cwfs.cmd is the file server process that runs the CWFS filesystem (it’s different if you run another filesystem). You can do this in one step with the “con” tool. But i prefer to do each step one by one as I remember it better.

echo newuser chris >>/srv/cwfs.cmd

You also need to add the new user to the sys and upas groups.

echo newuser sys +chris >>/srv/cwfs.cmd

echo newuser upas +chris >>/srv/cwfs.cmd

Various how to pages also suggest the “adm” group too. I think this is equivalent to root. I have not yet added my user to it and not found any errors.

term% cat /adm/users
-1:adm:adm:glenda
0:none::
1:tor:tor:
2:glenda:glenda:
3:chris:chris:
10000:sys::glenda,chris
10001:map:map:
10002:doc::
10003:upas:upas:glenda,chris
10004:font::
10005:bootes:bootes:

I’ve no idea what the other groups are for!

Then reboot, login as this user. You will see errors. But run the newuser script to setup your $home folder and profile


/sys/lib/newuser

customise plan9.ini

This requires you to mount the 9fat filesystem which contains a plain text file (hey everything is plain text file!) that configures the boot process.


9fs 9fat
cd /n/9fat


“9fs” is equivalent to mount and “9fat” is the partition.


Nice and simple.


You now need to familiarise yourself with a text editor. Acme is the best. I have found myself having to use “ed” a streaming text editor. It’s Ok, but very basic and quite painful to do anything other than simple emergency edits. Keep backups!

acme plan9.ini

Setup plan9.ini to boot straightway into my user account

Once you have your user then you can bypass which filesystem to boot and which user to boot into.
Remembering that at anytime you are promoted for options in the boot process then you can type “!rc” at a prompt to launch a minimal terminal to fix the issue. ..and booting from the USB install image always allows you to easily mount the 9fat partition and fix things.

change the video driver to IGFX

customise your desktop – rio

Rio is the windowing application.

To customise Rio you need to edit your profile

acme $home/lib/profile

I now configure my profile to load a “$home/bin/rc/riostart”, which autostart a few tools and a few “rc” shells.
Change

rio

to

rio -i riostart

Mine is:

#!/bin/rcwindow 0,0,161,117 stats -lmiscewindow -miny 130
window bar
# run a system shell on the serial console
~ $#console 0 || window -scroll console`

Bar is a cool little tool you will have to compile and install.

Change the font

Change the following line. There are many different fonts in /lib/font:

#font=/lib/font/bit/vga/unicode.font
font=/lib/font/bit/dejavusans/unicode.14.font

keyboard

Add this line just before loading rio:


cat /sys/lib/kbmap/uk > /dev/kbmap

misc

Setup SSH

The instructions are here. However, there is an omission in that first line as “role=client” needs to be added.

auth/rsagen -t 'service=ssh role=client' >$home/lib/sshkey # generate private key
auth/rsa2ssh $home/lib/sshkey >$home/lib/sshkey.pub # generate public key, if you need to share it
cat $home/lib/sshkey >/mnt/factotum/ctl # put the private key in the password manager
echo 'ssh sha256=DDDDDDDDDDDDDDDDDDDDDDDD server=scotgate.pixies' >> /usr/chris/lib/sshthumbs

a few useful tips

Mounting a linux filesystem over SSH

sshfs is useful.

sshfs chris@scotgate.pixies
cd /n/ssh

..will mount your $home folder on the remote host as /n/ssh

Note if you are using Drawterm then /srv/ has your root filesystem of the host already.

Software to install

Treason