Commit 12ee32cf authored by Helen Koike's avatar Helen Koike

wip: raid4

parent 2ef61b5c
......@@ -28,6 +28,60 @@ fill_rootfs()
sudo chmod +x dm-mount/bin/init.sh
}
create_raid4()
{
# Create disk
DISK=$1
PREFIX=$2
DM_DEV=dm-raid4
if [ -f $DISK -a -f ${DISK}.info ]; then
echo "$DISK already exist, not creating it"
return
else
echo "creating $DISK"
fi
dd if=/dev/zero of=$DISK bs=256M count=4
# Partition 1
sudo sgdisk -n 1:0:+200M -t 1:7f01 "$DISK"
# Partition 2
sudo sgdisk -n 2:0:+200M -t 2:7f01 "$DISK"
# Partition 3
sudo sgdisk -n 3:0:+200M -t 3:7f01 "$DISK"
# Partition 4
sudo sgdisk -n 4:0:+200M -t 4:7f01 "$DISK"
LOOP_DEV=$(sudo losetup -fP --show $DISK)
sectors=$(sudo blockdev --getsz "${LOOP_DEV}"p1)
sectors=$(($(sudo blockdev --getsz "${LOOP_DEV}"p2) + $sectors))
sectors=$(($(sudo blockdev --getsz "${LOOP_DEV}"p3) + $sectors))
table="0 $sectors raid raid4 3 64 region_size 1024 4 - ${LOOP_DEV}p1 - ${LOOP_DEV}p2 - ${LOOP_DEV}p3 - ${LOOP_DEV}p4"
echo "$table"
echo "$table" | sudo dmsetup create $DM_DEV
bash -c "cat > ${DISK}.info" <<- EOF
${PREFIX}sectors=${sectors}
EOF
echo "concise table (with loopback device)"
sudo dmsetup table --concise /dev/mapper/$DM_DEV
# Format
sudo mkfs.ext4 -L ROOT-RAID4 /dev/mapper/$DM_DEV
mkdir -p dm-mount
sudo mount /dev/mapper/$DM_DEV dm-mount
fill_rootfs "raid4 disk $DISK"
# Umount disk/dm/loopback
sudo umount dm-mount
rm -r dm-mount
sudo dmsetup remove $DM_DEV
sudo losetup -d $LOOP_DEV
}
create_crypt()
{
# Create disk
......@@ -487,6 +541,24 @@ launch_test \
124
}
# --------------
# Raid
# --------------
raid_tests()
{
launch_test \
"raid4: with minor" \
"-hda ${DR41}" \
/dev/dm-4 \
"dm-crypt,,4,ro,0 $DR41_sectors raid raid4 3 64 region_size 1024 4 - 8:1 - 8:2 - 8:3 - 8:4"
}
DR41=disk-raid4-1.img
create_raid4 $DR41 DR41_
# Load disk info
source ${DR41}.info
DS1=disk-striped-1.img
create_striped $DS1 DS1_
# Load disk info
......@@ -516,3 +588,4 @@ verity_tests
linear_parser_tests
striped_tests
crypt_tests
raid_tests
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment