1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
#!/bin/bash
set -e
. "$(dirname "$0")"/_common
disk_size=$((512*1024576))
row_A_file=$0.row_A
row_B_file=$0.row_B
OFFSET=1048576
ptlfs=$(_ptlname "extfs")
_check_root
echo -e "partclone offset option test"
echo -e "===========================\n"
echo -e "\ncreate tw row file and setup as loop device\n"
dd if=/dev/zero of=$row_A_file count=1 bs=$disk_size
dd if=/dev/zero of=$row_B_file count=1 bs=$(($disk_size+$OFFSET))
part_loop_device=$(losetup -f)
losetup $part_loop_device $row_A_file
offset_loop_device=$(losetup -f)
losetup $offset_loop_device $row_B_file
sleep 2
echo -e "\nformet loop device $part_loop_device\n"
mkfs.ext3 $part_loop_device
_ptlbreak
echo -e "\n clone $part_loop_device to $offset_loop_device with offset option\n"
echo -e " $ptlfs -d -b -s $part_loop_device -o $offset_loop_device --offset=$OFFSET\n"
$ptlfs -d -b -s $part_loop_device -o $offset_loop_device --offset=$OFFSET
_check_return_code
echo -e "\nmount $offset_loop_device with offset option and check return code\n"
set +e
echo -e " mount -o offset=$OFFSET $offset_loop_device /mnt\n"
mount -o offset=$OFFSET $offset_loop_device /mnt
_check_return_code
mount
umount /mnt
mount | grep loop
losetup -d $part_loop_device
losetup -d $offset_loop_device
set -e
echo -e "\nremove row file\n"
rm -f $row_A_file $row_B_file
echo -e "\noffset test ok\n"
|