Page 1 of 1

How I mirrored my M.2 SSD without reinstalling (T6-424)

Posted: 06 Nov 2024, 04:31
by efindel
First, for the poor support people - I'm not asking for help! You don't need to read this unless you're interested!

Second, for everyone else - this worked for me on my 6-424 with TOS 6. I make no guarantee that your TNAS will be the same, but I do hope this will be useful to someone else who wants to mirror their M.2 SSD without reinstalling!

I recently bought a TNAS 6-424, which I'm setting up to use for backups and Plex. I was planning to use a WD Blue SN550 I already had in one M.2 slot, coupling it with a new SN580 (because that was half the price, despite being a newer generation!). Those would be the system drives, and Seagate Ironwolf drives the storage drives.

But the SN580 got delayed in transit, so I wound up setting up the TNAS with just one M.2 drive, figuring I could add the other later and turn on mirroring. As it turned out, though, I couldn't find a way to do that in the TOS control panel.

My day job, though, is Unix/Linux sysadmin. I'd already turned on SSH and poked around a bit, discovering that it was using Linux software RAID, so I figured "Hell, I'll try to configure mirroring for it manually. Worst that happens is I have to reinstall, and it looks like I'm going to have to do that anyway to get mirroring if I can't."

So first, I did

df -h
swapon -s

to identify where the root and swap partitions were.

On mine, they were /dev/md9 (root) and /dev/md8 (swap). Next, I looked up the software RAID commands online, because while my job is as a sysadmin, the machines I've worked with in the past either had hardware RAID, or were VMs with storage on a SAN, where our SAN group worried about setting up the RAID. I quickly found that the command I needed to see information about the RAID sets was

cat /proc/mdstat

so I used that to see what devices /dev/md8 and 9 were on. On mine, they were sdzb2 (root)) and sdzb3 (swap), but yours could be different.

Now, from the existing devices being on /dev/sdzb, I guessed that was my M.2 drive, but I wanted to be sure. I tried "hdparm -i /dev/sdzb", but that gave me a message about the device not supporting that ioctl. So, I went down into /sys. Specifically, it turned out to be in

/sys/block/<device>/device/model

So, for mine, it was /sys/block/sdzb/device/model and /sys/block/sdza/device/model. Those confirmed that yes, szdb was the WD Blue SN550 I'd originally installed, and szda was the SN580 I had just added. (I'll note here that I'm not going to keep repeating "yours could be different". I'm giving you the commands I used to find out information, but you'll need to substitute the block devices you find!)

Now, the output from /proc/mdstat also showed me that /dev/sdzb2 and 3 were each already in a RAID set... just ones that only had one device each. So that meant all I needed to do was partition /dev/sdza (my new SSD), then add the partitions to the RAID sets.

Back to searching online to check what the proper commands are. A few searches later, I found them:

First, to copy the partition table from sdzb to sdza:

sfdisk -d /dev/sdzb > part_table
sfdisk /dev/sdza < part_table

To add the new partitions to the RAID sets:

mdadm /dev/md9 --add /dev/sdza2
mdadm /dev/md8 --add /dev/sdza3

Then I did

cat /proc/mdstat

to see the results. There, though, the new devices in the RAID sets were listed with an (S) after them. Another quick Google lookup, and I found out that meant they were spares. Well, RAID 1 with only one device and one spare isn't really helpful. So I looked for the command to turn them into actual *mirrors* instead of spares. That turned out to be:

mdadm /dev/md9 --grow --raid-devices=2
mdadm /dev/md8 --grow --raid-devices=2

With that done, cat /proc/mdstat showed them syncing up! (But you have to be quick about it - those partitions are small, and they're M.2 SSDs, so it literally took under a minute for the larger one to sync).

Using

blkid -o list

showed me the available block devices and some info about them. Using that, I saw that sdza2 and 3 were now listed as "linux_raid_member", so yay.

But I also saw that /dev/szdb1, while not mounted, had a filesystem on it. A VFAT filesystem, in fact. I suspected that was probably a UEFI boot partition, and mounting it on /mnt then doing "ls /mnt" confirmed that. So, I used dd to copy it over to the new disk:

dd if=/dev/szdb1 of=/dev/szda1 bs=1M

I looked at /dev/szdb4 as well (using "strings /dev/szdb4 | more") and found that it just had left-over data from the drive's previous life in my desktop PC. Thus, I didn't bother doing anything to sync that over with /dev/szda4.

The resources I'd found online had recommended doing:

mdadm --detail --scan --verbose >> /etc/mdadm.conf

to store the new configuration. Leery of possibly messing things up if something wasn't right, I sent the output to my home directory on the system instead, then used "diff mdadm.conf /etc/mdadm.conf" to see what the differences were. I noticed that the new version listed the devices in use, the number of devices, and the RAID level, but the old one had none of those things. Some online searching found that while you *can* include that info in mdadm.conf, you don't *have* to -- the software will scan the superblocks of the partitions to find the devices on startup. So I chose not to alter /etc/mdadm.conf.

Then, for my ultimate test, I rebooted. It came back up, I was able to log in, my applications were still there, storage still there, Plex still working, and "cat /proc/mdstat" showed that md8 and 9 had active mirroring. Yay!

Anyway, hope this helps someone else out there who would like to add a mirror to their install drive without having to reinstall!

--Travis

Re: How I mirrored my M.2 SSD without reinstalling (T6-424)

Posted: 06 Nov 2024, 06:30
by Gremlin
I think that may well answer a question I posed earlier if @TMSupport don't come up with an 'easier' option :)

Re: How I mirrored my M.2 SSD without reinstalling (T6-424)

Posted: 06 Nov 2024, 06:38
by efindel
Gremlin wrote: 06 Nov 2024, 06:30 I think that may well answer a question I posed earlier if @TMSupport don't come up with an 'easier' option :)
Cool! Hopefully there's an easy way that I just missed! Good luck with it!

--Travis

Re: How I mirrored my M.2 SSD without reinstalling (T6-424)

Posted: 06 Nov 2024, 19:37
by Gremlin
So, I followed a similar path this morning (since TM remain quiet). Because "my case was different" I had to make a couple of changes :)
My second disk was already partitioned - just not "ACTIVE". at the 'mdadm --add' step I encountered an "in use" situation so chose to use the 'force' option (suggested). I was not worried about failure as I have no data on these drives.
Had I checked, I suspect I would have seen the second drive as 'spare' and saved myself a previous step. As it was I did not need to 'grow' the arrays.
All I have left to do is copy the Vfat partition so that I can be sure of booting from second drive if needed.

For anyone else reading, this was an exercise in fixing a problem caused by my not thinking ahead and also thinking that this situation would not arise. As they say in all the good stories "Don't try this at home" :shock: :lol: :roll: :roll:

Re: How I mirrored my M.2 SSD without reinstalling (T6-424)

Posted: 06 Nov 2024, 19:51
by Gremlin
efindel wrote: 06 Nov 2024, 04:31
Copy of the boot partition was successful. All seems good now. The nice thing about this is that I was able to accomplish everything from within the Tos6 Terminal screen. Many Thanks for your original efforts.

Re: How I mirrored my M.2 SSD without reinstalling (T6-424)

Posted: 06 Nov 2024, 21:30
by efindel
Glad it helped, and congrats!