View previous topic :: View next topic |
Author |
Message |
Vieri l33t
Joined: 18 Dec 2005 Posts: 872
|
Posted: Mon Feb 17, 2014 4:42 pm Post subject: [SOLVED] Gentoo linux software raid with mdadm |
|
|
Hi,
I'm installing Gentoo with a custom bash script and the Gentoo handbook in mind and I've run into some trouble with mdadm/Linux Software RAID.
I booted a Gentoo live CD and at some point I wanted to create a RAID1 set with 2 disks and issued commands such as the following:
Code: |
echo "creating BIOS BOOT RAID set"
mdadm --create --verbose ${TARGET_DEVICE_RAID}1 --level=mirror --raid-devices=2 --metadata=0.90 ${TARGET_DEVICE}1 ${TARGET_DEVICE_2}1
echo "creating BOOT RAID set"
mdadm --create --verbose ${TARGET_DEVICE_RAID}2 --level=mirror --raid-devices=2 --metadata=0.90 ${TARGET_DEVICE}2 ${TARGET_DEVICE_2}2
echo "creating ROOT RAID set"
mdadm --create --verbose ${TARGET_DEVICE_RAID}4 --level=mirror --raid-devices=2 --metadata=0.90 ${TARGET_DEVICE}4 ${TARGET_DEVICE_2}4
|
where TARGET_DEVICE_RAID=/dev/md, TARGET_DEVICE=/dev/sda and TARGET_DEVICE_2=/dev/sdb
However, something went wrong with my script and I wanted to wipe everything out and start over (partitioning, building the RAID and formatting).
So I did something like this to clean everything up (is this a correct approach?):
Quote: |
mdlist=( $(fdisk -l 2>&1 3>&1 | grep "^Disk /dev/md" | cut -d ' ' -f2) )
if [ ${#mdlist[@]} -gt 0 ]; then
for mdi in ${mdlist[@]}
do
mdi=${mdi/:/}
mdadm --stop $mdi
mdadm --remove $mdi
done
fi
mdadm --zero-superblock ${TARGET_DEVICE} ${TARGET_DEVICE_2}
dd bs=512 count=63 if=/dev/zero of=${TARGET_DEVICE}
dd bs=512 count=63 if=/dev/zero of=${TARGET_DEVICE_2}
partprobe
parted -a optimal -s ${TARGET_DEVICE} unit MiB print
parted -a optimal -s ${TARGET_DEVICE_2} unit MiB print
|
Despite a few error messages or warnings both disks seem to be "clean" again.
I then wanted to repeat the following mdadm commands BUT with the --name= parameter because I explicitly want to create /dev/md1, /dev/md2 and /dev/md4 (not /dev/md127,126,125...):
Code: |
echo "creating BIOS BOOT RAID set"
mdadm --create --verbose ${TARGET_DEVICE_RAID}1 --name=1 --level=mirror --raid-devices=2 --metadata=0.90 ${TARGET_DEVICE}1 ${TARGET_DEVICE_2}1
echo "creating BOOT RAID set"
mdadm --create --verbose ${TARGET_DEVICE_RAID}2 --name=2 --level=mirror --raid-devices=2 --metadata=0.90 ${TARGET_DEVICE}2 ${TARGET_DEVICE_2}2
echo "creating ROOT RAID set"
mdadm --create --verbose ${TARGET_DEVICE_RAID}4 --name=4 --level=mirror --raid-devices=2 --metadata=0.90 ${TARGET_DEVICE}4 ${TARGET_DEVICE_2}4
|
Before running the above mdadm --create commands I needed to create the partitions as follows:
Code: |
parted -a optimal -s $LOCAL_DEVICE mklabel gpt
parted -a optimal -s $LOCAL_DEVICE unit MiB mkpart primary ${P_START_AT}MiB $((P_START_AT + BIOS_P_SIZE))MiB
parted -a optimal -s $LOCAL_DEVICE set 1 raid on
parted -a optimal -s $LOCAL_DEVICE name 1 grub
parted -a optimal -s $LOCAL_DEVICE set 1 bios_grub on
parted -a optimal -s $LOCAL_DEVICE unit MiB mkpart primary $((P_START_AT + BIOS_P_SIZE))MiB $((P_START_AT + BIOS_P_SIZE + BOOT_P_SIZE))MiB
parted -a optimal -s $LOCAL_DEVICE set 2 raid on
parted -a optimal -s $LOCAL_DEVICE name 2 boot
parted -a optimal -s $LOCAL_DEVICE unit MiB mkpart primary linux-swap $((P_START_AT + BIOS_P_SIZE + BOOT_P_SIZE))MiB $((P_START_AT + BIOS_P_SIZE + BOOT_P_SIZE + SWAP_P_SIZE))MiB
parted -a optimal -s $LOCAL_DEVICE name 3 swap
parted -a optimal -s -- $LOCAL_DEVICE unit MiB mkpart primary $((P_START_AT + BIOS_P_SIZE + BOOT_P_SIZE + SWAP_P_SIZE))MiB -$((P_START_AT + P_RAID_END_AT))
parted -a optimal -s $LOCAL_DEVICE set 4 raid on
parted -a optimal -s $LOCAL_DEVICE name 4 rootfs
partprobe $LOCAL_DEVICE
|
I did this for LOCAL_DEVICE=/dev/sda and LOCAL_DEVICE=/dev/sdb.
Strangely though, right after these parted commands were issued but BEFORE I could run the mdadm --create commands, I did an ls /dev/md* and found /dev/md127,126,125. Why is that?
Also and still BEFORE running my mdadm --create commands and AFTER I ran my parted commands, I issued the following:
Code: |
# mdadm --detail /dev/md127
/dev/md127:
Version : 0.90
Creation Time : Mon Feb 17 09:30:43 2014
Raid Level : raid1
Array Size : 38337408 (36.56 GiB 39.26 GB)
Used Dev Size : 38337408 (36.56 GiB 39.26 GB)
Raid Devices : 2
Total Devices : 1
Preferred Minor : 127
Persistence : Superblock is persistent
Update Time : Mon Feb 17 17:33:16 2014
State : clean, degraded
Active Devices : 1
Working Devices : 1
Failed Devices : 0
Spare Devices : 0
UUID : 9aea519d:571c7563:cb201669:f728008a (local to host livecd)
Events : 0.21
Number Major Minor RaidDevice State
0 8 4 0 active sync /dev/sda4
1 0 0 1 removed
livecd ~ # mdadm --detail /dev/md126
/dev/md126:
Version : 0.90
Creation Time : Mon Feb 17 09:30:04 2014
Raid Level : raid1
Array Size : 1984
Used Dev Size : 1984
Raid Devices : 2
Total Devices : 1
Preferred Minor : 126
Persistence : Superblock is persistent
Update Time : Mon Feb 17 17:32:26 2014
State : clean, degraded
Active Devices : 1
Working Devices : 1
Failed Devices : 0
Spare Devices : 0
UUID : 59499524:0013ba88:cb201669:f728008a (local to host livecd)
Events : 0.29
Number Major Minor RaidDevice State
0 8 1 0 active sync /dev/sda1
1 0 0 1 removed
livecd ~ # mdadm --detail /dev/md125
/dev/md125:
Version : 0.90
Creation Time : Mon Feb 17 09:30:31 2014
Raid Level : raid1
Array Size : 131008 (127.96 MiB 134.15 MB)
Used Dev Size : 131008 (127.96 MiB 134.15 MB)
Raid Devices : 2
Total Devices : 1
Preferred Minor : 125
Persistence : Superblock is persistent
Update Time : Mon Feb 17 17:32:30 2014
State : clean, degraded
Active Devices : 1
Working Devices : 1
Failed Devices : 0
Spare Devices : 0
UUID : f07fecf2:4c4c56ad:cb201669:f728008a (local to host livecd)
Events : 0.31
Number Major Minor RaidDevice State
0 8 2 0 active sync /dev/sda2
1 0 0 1 removed
|
Any ideas? (the main problem is that I want to get rid of /dev/md127,126,125 and use /dev/md1,2,4)
Thanks,
Vieri
Last edited by Vieri on Thu Feb 20, 2014 6:57 pm; edited 1 time in total |
|
Back to top |
|
|
spike88 n00b
Joined: 16 Oct 2012 Posts: 17
|
Posted: Mon Feb 17, 2014 4:55 pm Post subject: |
|
|
have you saved your .conf after you made your first array setup I found that sometimes gets it done _________________ Gentoo Rocks thanks! |
|
Back to top |
|
|
Vieri l33t
Joined: 18 Dec 2005 Posts: 872
|
Posted: Mon Feb 17, 2014 5:37 pm Post subject: |
|
|
spike88 wrote: | have you saved your .conf after you made your first array setup I found that sometimes gets it done |
Are you referring to /etc/mdadm.conf in LiveCD?
I did not touch that file and its content is all commented out (liveCD). |
|
Back to top |
|
|
spike88 n00b
Joined: 16 Oct 2012 Posts: 17
|
Posted: Mon Feb 17, 2014 10:43 pm Post subject: |
|
|
I have made my own and saved it to the filesystem i am installing Gentoo on unless your using the live CD for other purposes then i am not sure how to get it to display /dev/md1 2 3 and so on. _________________ Gentoo Rocks thanks! |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|