How to re-create RAID1 really properly
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
System:
Laptop with Linux Mint 17.3, 1x SSD for system and 2x HDD intended for RAID1 using mdadm
.
Situation:
Without knowing how to create RAID1 properly, I created it badly.
GParted showed a warning that a primary
gpt
partition table is not there, and that it is using the backup one, I think it showed this twiceGParted showed the partition on both HDDs contained
ext4
filesystem, instead oflinux-raid
filesystemGParted did not show the
raid
flag on neither HDDsReboot caused the array not to work, I mean not only it did not mount automatically, it could not be mounted without stopping the array and re-assembling it
There were probably other things I did not notice like I don't know if the array, I mean the mirroring, even worked properly
linux-mint partition mdadm software-raid gpt
add a comment |
up vote
0
down vote
favorite
System:
Laptop with Linux Mint 17.3, 1x SSD for system and 2x HDD intended for RAID1 using mdadm
.
Situation:
Without knowing how to create RAID1 properly, I created it badly.
GParted showed a warning that a primary
gpt
partition table is not there, and that it is using the backup one, I think it showed this twiceGParted showed the partition on both HDDs contained
ext4
filesystem, instead oflinux-raid
filesystemGParted did not show the
raid
flag on neither HDDsReboot caused the array not to work, I mean not only it did not mount automatically, it could not be mounted without stopping the array and re-assembling it
There were probably other things I did not notice like I don't know if the array, I mean the mirroring, even worked properly
linux-mint partition mdadm software-raid gpt
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
System:
Laptop with Linux Mint 17.3, 1x SSD for system and 2x HDD intended for RAID1 using mdadm
.
Situation:
Without knowing how to create RAID1 properly, I created it badly.
GParted showed a warning that a primary
gpt
partition table is not there, and that it is using the backup one, I think it showed this twiceGParted showed the partition on both HDDs contained
ext4
filesystem, instead oflinux-raid
filesystemGParted did not show the
raid
flag on neither HDDsReboot caused the array not to work, I mean not only it did not mount automatically, it could not be mounted without stopping the array and re-assembling it
There were probably other things I did not notice like I don't know if the array, I mean the mirroring, even worked properly
linux-mint partition mdadm software-raid gpt
System:
Laptop with Linux Mint 17.3, 1x SSD for system and 2x HDD intended for RAID1 using mdadm
.
Situation:
Without knowing how to create RAID1 properly, I created it badly.
GParted showed a warning that a primary
gpt
partition table is not there, and that it is using the backup one, I think it showed this twiceGParted showed the partition on both HDDs contained
ext4
filesystem, instead oflinux-raid
filesystemGParted did not show the
raid
flag on neither HDDsReboot caused the array not to work, I mean not only it did not mount automatically, it could not be mounted without stopping the array and re-assembling it
There were probably other things I did not notice like I don't know if the array, I mean the mirroring, even worked properly
linux-mint partition mdadm software-raid gpt
linux-mint partition mdadm software-raid gpt
edited May 30 at 8:40
asked Jun 10 '16 at 11:57
Vlastimil
7,2021153129
7,2021153129
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
2
down vote
accepted
In this answer, let it be clear that all of your data will be destroyed on both of the array members (drives), so back it up first!
Open terminal and become root
(su
); if you have sudo
enabled, you may also do for example sudo -i
; see man sudo
for all options):
sudo -i
Check what number (mdX
) the array has:
cat /proc/mdstat
Suppose it is md0
and it is mounted on /mnt/raid1
, first we have to unmount and stop the array:
umount /mnt/raid1
mdadm --stop /dev/md0
We need to erase the super-block on both drives, suppose sda
and sdb
:
mdadm --zero-superblock /dev/sda1
mdadm --zero-superblock /dev/sdb1
Let's get to work; we should erase the drives, if there were any data and filesystems before, that is. Suppose we have 2 members: sda
, sdb
:
pv < /dev/zero > /dev/sda
pv < /dev/zero > /dev/sdb
If you were to skip the previous step for your reasons, you need to wipe all filesystems on both of the drives. Then check if there is nothing left behind, you may peek with GParted on both of the drives, and if there is any filesystem other than unknown
, wipe it.
First, we wipe all existing partitions, suppose sda
contains 3 partitions, then:
wipefs --all /dev/sda3
wipefs --all /dev/sda2
wipefs --all /dev/sda1
Use this on both of the drives and do all partitions there are.
Then, we wipe the partition scheme with:
wipefs --all /dev/sda
wipefs --all /dev/sdb
Then, we initialize both drives with GUID partition table (GPT):
gdisk /dev/sda
gdisk /dev/sdb
In both cases use the following:
o
Enter for new empty GUID partition table (GPT)y
Enter to confirm your decisionw
Enter to write changesy
Enter to confirm your decision
Now, we need to partition both of the drives, but don't do this with GParted, because it would create a filesystem in the process, which we don't want, use gdisk
again:
gdisk /dev/sda
gdisk /dev/sdb
In both cases use the following:n
Enter for new partition
Enter for first partition
Enter for default of the first sector
Enter for default of the last sectorfd00
Enter for Linux RAID typew
Enter to write changesy
Enter to confirm your decision
To triple-check if there is nothing left behind, you may peek with GParted on both of the newly created partitions, and if they contain any filesystem other than unknown
, wipe it:
wipefs --all /dev/sda1
wipefs --all /dev/sdb1
You can examine the drives now:
mdadm --examine /dev/sda /dev/sdb
It should say:
(type ee)
If it does, we now examine the partitions:
mdadm --examine /dev/sda1 /dev/sdb1
It should say:
No md superblock detected
If it does, we can create the RAID1 array:
mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1
We shall wait until the array is fully created, this process we may watch with:
watch -n 1 cat /proc/mdstat
After creation of the array, we should look at its detail:
mdadm --detail /dev/md0
It should say:
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
Now we create filesystem on the array, if you use ext4
, this is better to be avoided, because of ext4lazyinit
would take noticeable amount of time, hence the name, "lazyinit", therefore I recommend you to avoid this one:
mkfs.ext4 /dev/md0
Instead, you should force a full instant initialization with:
mkfs.ext4 -E lazy_itable_init=0,lazy_journal_init=0 /dev/md0
By specifying these options, the inodes and the journal will be initialized immediately during creation, useful for larger arrays.
If you chose to take a shortcut and created the ext4
filesystem with the "better avoided command", note that ext4lazyinit
will take noticeable amount of time to initialize all of the inodes, you may watch it until it is done, e.g. with:
iotop
Either way you choose to make the file system initialization, you should mount it after it has finished its initialization.
We now create some directory for this RAID1 array:
mkdir --parents /mnt/raid1
And simply mount it:
mount /dev/md0 /mnt/raid1
Since we are essentially done, we may use GParted again to quickly check if it shows linux-raid
filesystem, together with the raid
flag on both of the drives.
If it does, we properly created the RAID1 array with GPT partitions and can now copy files on it.
See what UUID the md0
filesystem has:
blkid /dev/md0
Copy the UUID to clipboard.
Now we need to edit fstab
, with your favorite text editor:
nano /etc/fstab
And add add an entry to it:
UUID=<the UUID you have in the clipboard> /mnt/raid1 ext4 defaults 0 0
You may check if it is correct, after you save the changes:
mount --all --verbose | grep raid1
It should say:
already mounted
If it does, we save the array configuration; in case you don't have any md
device yet created, you can simply do:
mdadm --detail --scan >> /etc/mdadm/mdadm.conf
In case there are arrays already existent, just run the previous command without redirection to the conf file:
mdadm --detail --scan
and add the new array to the mdadm.conf
file manually.
In the end, don't forget to update your initramfs:
update-initramfs -u
Check if you did everything according to plan, and if so, you may restart:
reboot --reboot
add a comment |
up vote
0
down vote
Perfect and exactly what I needed!
Thanks!
New contributor
Thank you for feedback.
– Vlastimil
1 hour ago
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
In this answer, let it be clear that all of your data will be destroyed on both of the array members (drives), so back it up first!
Open terminal and become root
(su
); if you have sudo
enabled, you may also do for example sudo -i
; see man sudo
for all options):
sudo -i
Check what number (mdX
) the array has:
cat /proc/mdstat
Suppose it is md0
and it is mounted on /mnt/raid1
, first we have to unmount and stop the array:
umount /mnt/raid1
mdadm --stop /dev/md0
We need to erase the super-block on both drives, suppose sda
and sdb
:
mdadm --zero-superblock /dev/sda1
mdadm --zero-superblock /dev/sdb1
Let's get to work; we should erase the drives, if there were any data and filesystems before, that is. Suppose we have 2 members: sda
, sdb
:
pv < /dev/zero > /dev/sda
pv < /dev/zero > /dev/sdb
If you were to skip the previous step for your reasons, you need to wipe all filesystems on both of the drives. Then check if there is nothing left behind, you may peek with GParted on both of the drives, and if there is any filesystem other than unknown
, wipe it.
First, we wipe all existing partitions, suppose sda
contains 3 partitions, then:
wipefs --all /dev/sda3
wipefs --all /dev/sda2
wipefs --all /dev/sda1
Use this on both of the drives and do all partitions there are.
Then, we wipe the partition scheme with:
wipefs --all /dev/sda
wipefs --all /dev/sdb
Then, we initialize both drives with GUID partition table (GPT):
gdisk /dev/sda
gdisk /dev/sdb
In both cases use the following:
o
Enter for new empty GUID partition table (GPT)y
Enter to confirm your decisionw
Enter to write changesy
Enter to confirm your decision
Now, we need to partition both of the drives, but don't do this with GParted, because it would create a filesystem in the process, which we don't want, use gdisk
again:
gdisk /dev/sda
gdisk /dev/sdb
In both cases use the following:n
Enter for new partition
Enter for first partition
Enter for default of the first sector
Enter for default of the last sectorfd00
Enter for Linux RAID typew
Enter to write changesy
Enter to confirm your decision
To triple-check if there is nothing left behind, you may peek with GParted on both of the newly created partitions, and if they contain any filesystem other than unknown
, wipe it:
wipefs --all /dev/sda1
wipefs --all /dev/sdb1
You can examine the drives now:
mdadm --examine /dev/sda /dev/sdb
It should say:
(type ee)
If it does, we now examine the partitions:
mdadm --examine /dev/sda1 /dev/sdb1
It should say:
No md superblock detected
If it does, we can create the RAID1 array:
mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1
We shall wait until the array is fully created, this process we may watch with:
watch -n 1 cat /proc/mdstat
After creation of the array, we should look at its detail:
mdadm --detail /dev/md0
It should say:
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
Now we create filesystem on the array, if you use ext4
, this is better to be avoided, because of ext4lazyinit
would take noticeable amount of time, hence the name, "lazyinit", therefore I recommend you to avoid this one:
mkfs.ext4 /dev/md0
Instead, you should force a full instant initialization with:
mkfs.ext4 -E lazy_itable_init=0,lazy_journal_init=0 /dev/md0
By specifying these options, the inodes and the journal will be initialized immediately during creation, useful for larger arrays.
If you chose to take a shortcut and created the ext4
filesystem with the "better avoided command", note that ext4lazyinit
will take noticeable amount of time to initialize all of the inodes, you may watch it until it is done, e.g. with:
iotop
Either way you choose to make the file system initialization, you should mount it after it has finished its initialization.
We now create some directory for this RAID1 array:
mkdir --parents /mnt/raid1
And simply mount it:
mount /dev/md0 /mnt/raid1
Since we are essentially done, we may use GParted again to quickly check if it shows linux-raid
filesystem, together with the raid
flag on both of the drives.
If it does, we properly created the RAID1 array with GPT partitions and can now copy files on it.
See what UUID the md0
filesystem has:
blkid /dev/md0
Copy the UUID to clipboard.
Now we need to edit fstab
, with your favorite text editor:
nano /etc/fstab
And add add an entry to it:
UUID=<the UUID you have in the clipboard> /mnt/raid1 ext4 defaults 0 0
You may check if it is correct, after you save the changes:
mount --all --verbose | grep raid1
It should say:
already mounted
If it does, we save the array configuration; in case you don't have any md
device yet created, you can simply do:
mdadm --detail --scan >> /etc/mdadm/mdadm.conf
In case there are arrays already existent, just run the previous command without redirection to the conf file:
mdadm --detail --scan
and add the new array to the mdadm.conf
file manually.
In the end, don't forget to update your initramfs:
update-initramfs -u
Check if you did everything according to plan, and if so, you may restart:
reboot --reboot
add a comment |
up vote
2
down vote
accepted
In this answer, let it be clear that all of your data will be destroyed on both of the array members (drives), so back it up first!
Open terminal and become root
(su
); if you have sudo
enabled, you may also do for example sudo -i
; see man sudo
for all options):
sudo -i
Check what number (mdX
) the array has:
cat /proc/mdstat
Suppose it is md0
and it is mounted on /mnt/raid1
, first we have to unmount and stop the array:
umount /mnt/raid1
mdadm --stop /dev/md0
We need to erase the super-block on both drives, suppose sda
and sdb
:
mdadm --zero-superblock /dev/sda1
mdadm --zero-superblock /dev/sdb1
Let's get to work; we should erase the drives, if there were any data and filesystems before, that is. Suppose we have 2 members: sda
, sdb
:
pv < /dev/zero > /dev/sda
pv < /dev/zero > /dev/sdb
If you were to skip the previous step for your reasons, you need to wipe all filesystems on both of the drives. Then check if there is nothing left behind, you may peek with GParted on both of the drives, and if there is any filesystem other than unknown
, wipe it.
First, we wipe all existing partitions, suppose sda
contains 3 partitions, then:
wipefs --all /dev/sda3
wipefs --all /dev/sda2
wipefs --all /dev/sda1
Use this on both of the drives and do all partitions there are.
Then, we wipe the partition scheme with:
wipefs --all /dev/sda
wipefs --all /dev/sdb
Then, we initialize both drives with GUID partition table (GPT):
gdisk /dev/sda
gdisk /dev/sdb
In both cases use the following:
o
Enter for new empty GUID partition table (GPT)y
Enter to confirm your decisionw
Enter to write changesy
Enter to confirm your decision
Now, we need to partition both of the drives, but don't do this with GParted, because it would create a filesystem in the process, which we don't want, use gdisk
again:
gdisk /dev/sda
gdisk /dev/sdb
In both cases use the following:n
Enter for new partition
Enter for first partition
Enter for default of the first sector
Enter for default of the last sectorfd00
Enter for Linux RAID typew
Enter to write changesy
Enter to confirm your decision
To triple-check if there is nothing left behind, you may peek with GParted on both of the newly created partitions, and if they contain any filesystem other than unknown
, wipe it:
wipefs --all /dev/sda1
wipefs --all /dev/sdb1
You can examine the drives now:
mdadm --examine /dev/sda /dev/sdb
It should say:
(type ee)
If it does, we now examine the partitions:
mdadm --examine /dev/sda1 /dev/sdb1
It should say:
No md superblock detected
If it does, we can create the RAID1 array:
mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1
We shall wait until the array is fully created, this process we may watch with:
watch -n 1 cat /proc/mdstat
After creation of the array, we should look at its detail:
mdadm --detail /dev/md0
It should say:
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
Now we create filesystem on the array, if you use ext4
, this is better to be avoided, because of ext4lazyinit
would take noticeable amount of time, hence the name, "lazyinit", therefore I recommend you to avoid this one:
mkfs.ext4 /dev/md0
Instead, you should force a full instant initialization with:
mkfs.ext4 -E lazy_itable_init=0,lazy_journal_init=0 /dev/md0
By specifying these options, the inodes and the journal will be initialized immediately during creation, useful for larger arrays.
If you chose to take a shortcut and created the ext4
filesystem with the "better avoided command", note that ext4lazyinit
will take noticeable amount of time to initialize all of the inodes, you may watch it until it is done, e.g. with:
iotop
Either way you choose to make the file system initialization, you should mount it after it has finished its initialization.
We now create some directory for this RAID1 array:
mkdir --parents /mnt/raid1
And simply mount it:
mount /dev/md0 /mnt/raid1
Since we are essentially done, we may use GParted again to quickly check if it shows linux-raid
filesystem, together with the raid
flag on both of the drives.
If it does, we properly created the RAID1 array with GPT partitions and can now copy files on it.
See what UUID the md0
filesystem has:
blkid /dev/md0
Copy the UUID to clipboard.
Now we need to edit fstab
, with your favorite text editor:
nano /etc/fstab
And add add an entry to it:
UUID=<the UUID you have in the clipboard> /mnt/raid1 ext4 defaults 0 0
You may check if it is correct, after you save the changes:
mount --all --verbose | grep raid1
It should say:
already mounted
If it does, we save the array configuration; in case you don't have any md
device yet created, you can simply do:
mdadm --detail --scan >> /etc/mdadm/mdadm.conf
In case there are arrays already existent, just run the previous command without redirection to the conf file:
mdadm --detail --scan
and add the new array to the mdadm.conf
file manually.
In the end, don't forget to update your initramfs:
update-initramfs -u
Check if you did everything according to plan, and if so, you may restart:
reboot --reboot
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
In this answer, let it be clear that all of your data will be destroyed on both of the array members (drives), so back it up first!
Open terminal and become root
(su
); if you have sudo
enabled, you may also do for example sudo -i
; see man sudo
for all options):
sudo -i
Check what number (mdX
) the array has:
cat /proc/mdstat
Suppose it is md0
and it is mounted on /mnt/raid1
, first we have to unmount and stop the array:
umount /mnt/raid1
mdadm --stop /dev/md0
We need to erase the super-block on both drives, suppose sda
and sdb
:
mdadm --zero-superblock /dev/sda1
mdadm --zero-superblock /dev/sdb1
Let's get to work; we should erase the drives, if there were any data and filesystems before, that is. Suppose we have 2 members: sda
, sdb
:
pv < /dev/zero > /dev/sda
pv < /dev/zero > /dev/sdb
If you were to skip the previous step for your reasons, you need to wipe all filesystems on both of the drives. Then check if there is nothing left behind, you may peek with GParted on both of the drives, and if there is any filesystem other than unknown
, wipe it.
First, we wipe all existing partitions, suppose sda
contains 3 partitions, then:
wipefs --all /dev/sda3
wipefs --all /dev/sda2
wipefs --all /dev/sda1
Use this on both of the drives and do all partitions there are.
Then, we wipe the partition scheme with:
wipefs --all /dev/sda
wipefs --all /dev/sdb
Then, we initialize both drives with GUID partition table (GPT):
gdisk /dev/sda
gdisk /dev/sdb
In both cases use the following:
o
Enter for new empty GUID partition table (GPT)y
Enter to confirm your decisionw
Enter to write changesy
Enter to confirm your decision
Now, we need to partition both of the drives, but don't do this with GParted, because it would create a filesystem in the process, which we don't want, use gdisk
again:
gdisk /dev/sda
gdisk /dev/sdb
In both cases use the following:n
Enter for new partition
Enter for first partition
Enter for default of the first sector
Enter for default of the last sectorfd00
Enter for Linux RAID typew
Enter to write changesy
Enter to confirm your decision
To triple-check if there is nothing left behind, you may peek with GParted on both of the newly created partitions, and if they contain any filesystem other than unknown
, wipe it:
wipefs --all /dev/sda1
wipefs --all /dev/sdb1
You can examine the drives now:
mdadm --examine /dev/sda /dev/sdb
It should say:
(type ee)
If it does, we now examine the partitions:
mdadm --examine /dev/sda1 /dev/sdb1
It should say:
No md superblock detected
If it does, we can create the RAID1 array:
mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1
We shall wait until the array is fully created, this process we may watch with:
watch -n 1 cat /proc/mdstat
After creation of the array, we should look at its detail:
mdadm --detail /dev/md0
It should say:
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
Now we create filesystem on the array, if you use ext4
, this is better to be avoided, because of ext4lazyinit
would take noticeable amount of time, hence the name, "lazyinit", therefore I recommend you to avoid this one:
mkfs.ext4 /dev/md0
Instead, you should force a full instant initialization with:
mkfs.ext4 -E lazy_itable_init=0,lazy_journal_init=0 /dev/md0
By specifying these options, the inodes and the journal will be initialized immediately during creation, useful for larger arrays.
If you chose to take a shortcut and created the ext4
filesystem with the "better avoided command", note that ext4lazyinit
will take noticeable amount of time to initialize all of the inodes, you may watch it until it is done, e.g. with:
iotop
Either way you choose to make the file system initialization, you should mount it after it has finished its initialization.
We now create some directory for this RAID1 array:
mkdir --parents /mnt/raid1
And simply mount it:
mount /dev/md0 /mnt/raid1
Since we are essentially done, we may use GParted again to quickly check if it shows linux-raid
filesystem, together with the raid
flag on both of the drives.
If it does, we properly created the RAID1 array with GPT partitions and can now copy files on it.
See what UUID the md0
filesystem has:
blkid /dev/md0
Copy the UUID to clipboard.
Now we need to edit fstab
, with your favorite text editor:
nano /etc/fstab
And add add an entry to it:
UUID=<the UUID you have in the clipboard> /mnt/raid1 ext4 defaults 0 0
You may check if it is correct, after you save the changes:
mount --all --verbose | grep raid1
It should say:
already mounted
If it does, we save the array configuration; in case you don't have any md
device yet created, you can simply do:
mdadm --detail --scan >> /etc/mdadm/mdadm.conf
In case there are arrays already existent, just run the previous command without redirection to the conf file:
mdadm --detail --scan
and add the new array to the mdadm.conf
file manually.
In the end, don't forget to update your initramfs:
update-initramfs -u
Check if you did everything according to plan, and if so, you may restart:
reboot --reboot
In this answer, let it be clear that all of your data will be destroyed on both of the array members (drives), so back it up first!
Open terminal and become root
(su
); if you have sudo
enabled, you may also do for example sudo -i
; see man sudo
for all options):
sudo -i
Check what number (mdX
) the array has:
cat /proc/mdstat
Suppose it is md0
and it is mounted on /mnt/raid1
, first we have to unmount and stop the array:
umount /mnt/raid1
mdadm --stop /dev/md0
We need to erase the super-block on both drives, suppose sda
and sdb
:
mdadm --zero-superblock /dev/sda1
mdadm --zero-superblock /dev/sdb1
Let's get to work; we should erase the drives, if there were any data and filesystems before, that is. Suppose we have 2 members: sda
, sdb
:
pv < /dev/zero > /dev/sda
pv < /dev/zero > /dev/sdb
If you were to skip the previous step for your reasons, you need to wipe all filesystems on both of the drives. Then check if there is nothing left behind, you may peek with GParted on both of the drives, and if there is any filesystem other than unknown
, wipe it.
First, we wipe all existing partitions, suppose sda
contains 3 partitions, then:
wipefs --all /dev/sda3
wipefs --all /dev/sda2
wipefs --all /dev/sda1
Use this on both of the drives and do all partitions there are.
Then, we wipe the partition scheme with:
wipefs --all /dev/sda
wipefs --all /dev/sdb
Then, we initialize both drives with GUID partition table (GPT):
gdisk /dev/sda
gdisk /dev/sdb
In both cases use the following:
o
Enter for new empty GUID partition table (GPT)y
Enter to confirm your decisionw
Enter to write changesy
Enter to confirm your decision
Now, we need to partition both of the drives, but don't do this with GParted, because it would create a filesystem in the process, which we don't want, use gdisk
again:
gdisk /dev/sda
gdisk /dev/sdb
In both cases use the following:n
Enter for new partition
Enter for first partition
Enter for default of the first sector
Enter for default of the last sectorfd00
Enter for Linux RAID typew
Enter to write changesy
Enter to confirm your decision
To triple-check if there is nothing left behind, you may peek with GParted on both of the newly created partitions, and if they contain any filesystem other than unknown
, wipe it:
wipefs --all /dev/sda1
wipefs --all /dev/sdb1
You can examine the drives now:
mdadm --examine /dev/sda /dev/sdb
It should say:
(type ee)
If it does, we now examine the partitions:
mdadm --examine /dev/sda1 /dev/sdb1
It should say:
No md superblock detected
If it does, we can create the RAID1 array:
mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1
We shall wait until the array is fully created, this process we may watch with:
watch -n 1 cat /proc/mdstat
After creation of the array, we should look at its detail:
mdadm --detail /dev/md0
It should say:
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
Now we create filesystem on the array, if you use ext4
, this is better to be avoided, because of ext4lazyinit
would take noticeable amount of time, hence the name, "lazyinit", therefore I recommend you to avoid this one:
mkfs.ext4 /dev/md0
Instead, you should force a full instant initialization with:
mkfs.ext4 -E lazy_itable_init=0,lazy_journal_init=0 /dev/md0
By specifying these options, the inodes and the journal will be initialized immediately during creation, useful for larger arrays.
If you chose to take a shortcut and created the ext4
filesystem with the "better avoided command", note that ext4lazyinit
will take noticeable amount of time to initialize all of the inodes, you may watch it until it is done, e.g. with:
iotop
Either way you choose to make the file system initialization, you should mount it after it has finished its initialization.
We now create some directory for this RAID1 array:
mkdir --parents /mnt/raid1
And simply mount it:
mount /dev/md0 /mnt/raid1
Since we are essentially done, we may use GParted again to quickly check if it shows linux-raid
filesystem, together with the raid
flag on both of the drives.
If it does, we properly created the RAID1 array with GPT partitions and can now copy files on it.
See what UUID the md0
filesystem has:
blkid /dev/md0
Copy the UUID to clipboard.
Now we need to edit fstab
, with your favorite text editor:
nano /etc/fstab
And add add an entry to it:
UUID=<the UUID you have in the clipboard> /mnt/raid1 ext4 defaults 0 0
You may check if it is correct, after you save the changes:
mount --all --verbose | grep raid1
It should say:
already mounted
If it does, we save the array configuration; in case you don't have any md
device yet created, you can simply do:
mdadm --detail --scan >> /etc/mdadm/mdadm.conf
In case there are arrays already existent, just run the previous command without redirection to the conf file:
mdadm --detail --scan
and add the new array to the mdadm.conf
file manually.
In the end, don't forget to update your initramfs:
update-initramfs -u
Check if you did everything according to plan, and if so, you may restart:
reboot --reboot
edited May 30 at 9:51
answered Jun 10 '16 at 11:57
Vlastimil
7,2021153129
7,2021153129
add a comment |
add a comment |
up vote
0
down vote
Perfect and exactly what I needed!
Thanks!
New contributor
Thank you for feedback.
– Vlastimil
1 hour ago
add a comment |
up vote
0
down vote
Perfect and exactly what I needed!
Thanks!
New contributor
Thank you for feedback.
– Vlastimil
1 hour ago
add a comment |
up vote
0
down vote
up vote
0
down vote
Perfect and exactly what I needed!
Thanks!
New contributor
Perfect and exactly what I needed!
Thanks!
New contributor
New contributor
answered 1 hour ago
Hardliner
11
11
New contributor
New contributor
Thank you for feedback.
– Vlastimil
1 hour ago
add a comment |
Thank you for feedback.
– Vlastimil
1 hour ago
Thank you for feedback.
– Vlastimil
1 hour ago
Thank you for feedback.
– Vlastimil
1 hour ago
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f288947%2fhow-to-re-create-raid1-really-properly%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password