Did you know the operating system of your Synology named DSM is split in a RAID1 on all attached drives? In RAID1 data is read from all drives but what if we can get those jucy short access times from an attached SSD?
Synology structures the system in the following manner:
/dev/md0 – Operating System
/dev/md1 – Swap Space
/dev/mdx – Your Volumes/Storage Pools
To view your current layout you have to logon via SSH and become root (sudo -i). Running ‘cat /proc/mdstat’ shows the following output:
Personalities : [raid1] [raid6] [raid5] [raid4] [raidF1]
md2 : active raid5 sda5[0] sdd5[3] sdc5[4] sdb5[1]
XX blocks super 1.2 level 5, 64k chunk, algorithm 2 [4/4] [UUUU]
md3 : active raid1 sdf5[0]
XX blocks super 1.2 [1/1] [U]
md1 : active raid1 sda2[0] sdf2[4] sdb2[3] sdc2[2] sdd2[1]
XX blocks [5/5] [UUUUU]
md0 : active raid1 sda1[0] sdf1[4] sdb1[3] sdc1[2] sdd1[1]
XX blocks [5/5] [UUUUU]
In my case you can see four raidsets. DSM, Swap, Volume 1 and Volume 2. However one of those drives is a SSD (sdf) and as you can see part of md0 and md1.
mdadm (casual linux software raid) allows you to configure a RAID with the attribute ‘writemostly’.
This is valid for RAID1 only and means that the ‘md’ driver will avoid reading from these devices if at all possible. This can be useful if mirroring over a slow link.
Source: https://linux.die.net/man/8/mdadm
Writemostly means, please only write to this drive and don’t try to read. You can achieve that by flagging all rotational drives on md0 (DSM) and md1 (Swap Space) with ‘writemostly’. In my case sda, sdb, sdc and sdd, as sdf is the SSD. We can achieve that with running the following command for each drive in each raidset:
echo writemostly > /sys/block/md0/md/dev-sda1/state
echo writemostly > /sys/block/md0/md/dev-sdb1/state
echo writemostly > /sys/block/md0/md/dev-sdc1/state
echo writemostly > /sys/block/md0/md/dev-sdd1/state
echo writemostly > /sys/block/md1/md/dev-sda2/state
echo writemostly > /sys/block/md1/md/dev-sdb2/state
echo writemostly > /sys/block/md1/md/dev-sdc2/state
echo writemostly > /sys/block/md1/md/dev-sdd2/state
Why is it sda1 and sda2? sda is the physical drive and sda1 is the first partition, sda2 the second and so on. After you did that you will the the following out put of ‘cat /proc/mdstat’:
Personalities : [raid1] [raid6] [raid5] [raid4] [raidF1]
md2 : active raid5 sda5[0] sdd5[3] sdc5[4] sdb5[1]
XX blocks super 1.2 level 5, 64k chunk, algorithm 2 [4/4] [UUUU]
md3 : active raid1 sdf5[0]
XX blocks super 1.2 [1/1] [U]
md1 : active raid1 sda2[0](W) sdf2[4] sdb2[3](W) sdc2[2](W) sdd2[1](W)
XX blocks [5/5] [UUUUU]
md0 : active raid1 sda1[0](W) sdf1[4] sdb1[3](W) sdc1[2](W) sdd1[1](W)
XX blocks [5/5] [UUUUU]
Saw the (W) after all rotational drives? This shows that mdadm will only try to do write operations on those drives and no reads.
After a restart you can verify your startup times with ‘cat /var/log/synobootup.log’:Startup finished in 13.354s (kernel) + 2min 46.683s (userspace) = 3min 38ms.
You can do additional verification by running ‘mdadm -D /dev/md0’. -D for detail.
/dev/md0:
Version : 0.90
Creation Time : Fri Jul 20 15:51:28 2018
Raid Level : raid1
Array Size : XX (XX GiB XX GB)
Used Dev Size : XX (XX GiB XX GB)
Raid Devices : 5
Total Devices : 5
Preferred Minor : 0
Persistence : Superblock is persistent
Update Time : Sun Jul 7 21:17:33 2024
State : clean
Active Devices : 5
Working Devices : 5
Failed Devices : 0
Spare Devices : 0
UUID xxxxxxxx:xxxxxxxx:xxxxxxxx:xxxxxxxx:xxxxxxxx
Events : 0
Number Major Minor RaidDevice State
0 8 1 0 active sync writemostly /dev/sda1
1 8 49 1 active sync writemostly /dev/sdd1
2 8 33 2 active sync writemostly /dev/sdc1
3 8 17 3 active sync writemostly /dev/sdb1
4 8 81 4 active sync /dev/sdf1
You will see here the ‘writemostly’ flag on all rotational drives. You can always return to the previous state with the following command for each drive:
echo -writemostly > /sys/block/mdX/md/dev-sdX1/state
The result is Synology DSM “mostly” reads from your SSD. “Mostly” because it will start to read from rotational drives again if your SSD(s) fail.
Cheers
Recent Comments