Commit 43d9c978 authored by Helen Koike's avatar Helen Koike

wip: snapshot

parent 3c8e4daa
......@@ -28,6 +28,42 @@ fill_rootfs()
sudo chmod +x dm-mount/bin/init.sh
}
create_snap()
{
# Create disk
DISK=$1
PREFIX=$2
DM_DEV=dm-snap
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=2
# Partition 1
sudo sgdisk -n 1:0:+200M -t 1:7f01 "$DISK"
# Partition 2
sudo sgdisk -n 2:0:+200M -t 2:7f01 "$DISK"
LOOP_DEV=$(sudo losetup -fP --show $DISK)
sectors=$(sudo blockdev --getsz "${LOOP_DEV}"p1)
bash -c "cat > ${DISK}.info" <<- EOF
${PREFIX}sectors=${sectors}
EOF
sudo mkfs.ext4 -L ROOT-SNAP ${LOOP_DEV}p1
mkdir -p dm-mount
sudo mount ${LOOP_DEV}p1 dm-mount
fill_rootfs "snap disk $DISK"
# Umount disk/dm/loopback
sudo umount dm-mount
rm -r dm-mount
}
create_raid()
{
# Create disk
......@@ -575,6 +611,27 @@ launch_test \
"dm-raid,,,ro,0 $DR61_sectors raid raid6_zr 3 64 region_size 1024 4 - 8:1 - 8:2 - 8:3 - 8:4"
}
snap_tests()
{
launch_test \
"snap: snapshot-origin" \
"-hda ${DSN1}" \
/dev/dm-4 \
"dm-snap-orig,,4,ro,0 ${DSN1_sectors} snapshot-origin 8:1"
launch_test \
"snap: snapshot-origin" \
"-hda ${DSN1}" \
/dev/dm-0 \
"dm-snap,,,ro,0 ${DSN1_sectors} snapshot 8:1 8:2 P 8"
launch_test \
"snap: snapshot-merge" \
"-hda ${DSN1}" \
/dev/dm-0 \
"dm-snap,,,ro,0 ${DSN1_sectors} snapshot-merge 8:1 8:2 P 8"
}
DR41=disk-raid4-1.img
create_raid $DR41 DR41_ raid4
# Load disk info
......@@ -615,8 +672,14 @@ create_crypt $DC1 DC1_
# Load disk info
source ${DC1}.info
DSN1=disk-snap-1.img
create_snap $DSN1 DSN1_
# Load disk info
source ${DSN1}.info
verity_tests
linear_parser_tests
striped_tests
crypt_tests
raid_tests
snap_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