Create a raid1 NAS without losing data

I’m currently using one 3TB hd in the NAS perk and I want to add a second 3TB hd, possibly in a raid1 array, to increase its reliability.

Can I follow these instructions to set up the array without losing the data already stored on the first 3TB hd? And if not, is there some other way to do it?

In these same instructions, where exactly do you specify you want a raid0 or raid1 array?

If I bought a 4TB hd, I understand I’d get a 6TB array but what would happen to the unused 1TB? Is it possible to still use it, as a partition or something?

Thanks for the help

AFAIK, you can not convert a normally formatted harddisk to a part of a raid without losing data.

In the instructions, there is a command

mdadm --create --verbose /dev/md0 --level=mirror --raid-devices=2 /dev/sda /dev/sdb

and there, the –level= parameter sets the level.

See mdadm man page.

But when I read the instructions, I wondered why they use the whole disks (/dev/sda, /dev/sdb) instead of partitions (/dev/sda1, /dev/sdb1) as you normally do. Only partitions can have a “type” attribute, but whole disks can’t. And the partition type makes it easier for mdraid to find the raid components at boot.

Using partitions has another advantage: It makes the remaining part of the larger disk usable: You need to create two partitions on the bigger dis, one as big as the smaller disk and one for the rest. Then you create the raid with the two same-sized partitions, and format the remaining partition normally. Without using partitions, you can not use the remaining part of the bigger disk.

You can create array with this command
mdadm --create --verbose /dev/md0 --level=mirror --raid-devices=2 /dev/sdb missing
With command
cat /proc/mdstat
you can view existing array

# cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid5] [raid4] [raid6] [raid10]
md0 : active raid1 sdb[0]
      24418688 blocks [2/1] [U_]

unused devices: <none>

This create array with one disk (degraded). Then you copy existing data to array /dev/md0.
When data is copied you can attach second disk /dev/sda to existing array.
mdadm --manage /dev/md0 --add /dev/sda
After that array will rebuild and you can see progess with command
cat /proc/mdstat
you see this output

# cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid5] [raid4] [raid6] [raid10]
md0 : active raid1 sda[0] sdb[1]
      24418688 blocks [2/1] [U_]
      [=>...................]  recovery =  9.9% (2423168/24418688) finish=2.8min speed=127535K/sec

unused devices: <none>

and finally when the synchronization is finished, the output will look like this:

# cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid5] [raid4] [raid6] [raid10]
md0 : active raid1 sda[0] sdb[1]
      24418688 blocks [2/2] [UU]

unused devices: <none>

That’s it

PS. when you create mirror array with full disk you can use only disk with the same size