X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=scripts%2Fzconfig.sh;h=281166c59ba756f3540b090ce148dc0f43d71c18;hb=e43b290fdb61fc9533af96fab48515dec0333a2f;hp=80f7e45701f04c58911388f23403568968e61c51;hpb=5cbf6db937a304c4d2b60878a2405a1e2900abdf;p=zfs.git diff --git a/scripts/zconfig.sh b/scripts/zconfig.sh index 80f7e45..281166c 100755 --- a/scripts/zconfig.sh +++ b/scripts/zconfig.sh @@ -81,23 +81,6 @@ if [ ${SCSI_DEBUG} -eq 0 ] || [ ${HAVE_LSSCSI} -eq 0 ]; then "module and the ${LSSCSI} utility" fi -zconfig_partition() { - local DEVICE=$1 - local START=$2 - local END=$3 - local TMP_FILE=`mktemp` - - /sbin/sfdisk -q ${DEVICE} << EOF &>${TMP_FILE} || fail 4 -${START},${END} -; -; -; -EOF - - rm ${TMP_FILE} - udev_trigger -} - # Validate persistent zpool.cache configuration. test_1() { local POOL_NAME=test1 @@ -209,7 +192,10 @@ test_3() { ${ZFS_SH} zfs="spa_config_path=${TMP_CACHE}" || fail 1 ${ZPOOL_CREATE_SH} -p ${POOL_NAME} -c lo-raidz2 || fail 2 ${ZFS} create -V 100M ${FULL_ZVOL_NAME} || fail 3 - zconfig_partition /dev/zvol/${FULL_ZVOL_NAME} 0 64 || fail 4 + ${ZFS} set snapdev=visible ${FULL_ZVOL_NAME} || fail 3 + label /dev/zvol/${FULL_ZVOL_NAME} msdos || fail 4 + partition /dev/zvol/${FULL_ZVOL_NAME} primary 1% 50% || fail 4 + partition /dev/zvol/${FULL_ZVOL_NAME} primary 51% -1 || fail 4 ${ZFS} snapshot ${FULL_SNAP_NAME} || fail 5 ${ZFS} clone ${FULL_SNAP_NAME} ${FULL_CLONE_NAME} || fail 6 @@ -260,7 +246,10 @@ test_4() { ${ZFS_SH} zfs="spa_config_path=${TMP_CACHE}" || fail 1 ${ZPOOL_CREATE_SH} -p ${POOL_NAME} -c lo-raidz2 || fail 2 ${ZFS} create -V 100M ${FULL_ZVOL_NAME} || fail 3 - zconfig_partition /dev/zvol/${FULL_ZVOL_NAME} 0 64 || fail 4 + ${ZFS} set snapdev=visible ${FULL_ZVOL_NAME} || fail 3 + label /dev/zvol/${FULL_ZVOL_NAME} msdos || fail 4 + partition /dev/zvol/${FULL_ZVOL_NAME} primary 1% 50% || fail 4 + partition /dev/zvol/${FULL_ZVOL_NAME} primary 51% -1 || fail 4 ${ZFS} snapshot ${FULL_SNAP_NAME} || fail 5 ${ZFS} clone ${FULL_SNAP_NAME} ${FULL_CLONE_NAME} || fail 6 @@ -275,8 +264,9 @@ test_4() { zconfig_zvol_device_stat 0 ${POOL_NAME} ${FULL_ZVOL_NAME} \ ${FULL_SNAP_NAME} ${FULL_CLONE_NAME} || fail 9 - # Load the modules, wait 1 second for udev + # Load the modules, list the pools to ensure they are opened ${ZFS_SH} zfs="spa_config_path=${TMP_CACHE}" || fail 10 + ${ZPOOL} list &>/dev/null # Verify the devices were created zconfig_zvol_device_stat 10 ${POOL_NAME} ${FULL_ZVOL_NAME} \ @@ -301,33 +291,28 @@ test_5() { local POOL_NAME=tank local ZVOL_NAME=fish local FULL_NAME=${POOL_NAME}/${ZVOL_NAME} - local SRC_DIR=/bin/ local TMP_CACHE=`mktemp -p /tmp zpool.cache.XXXXXXXX` # Create a pool and volume. ${ZFS_SH} zfs="spa_config_path=${TMP_CACHE}" || fail 1 ${ZPOOL_CREATE_SH} -p ${POOL_NAME} -c lo-raid0 || fail 2 ${ZFS} create -V 800M ${FULL_NAME} || fail 3 + label /dev/zvol/${FULL_NAME} msdos || fail 4 + partition /dev/zvol/${FULL_NAME} primary 1 -1 || fail 4 + format /dev/zvol/${FULL_NAME}-part1 ext2 || fail 5 - # Partition the volume, for a 800M volume there will be - # 1624 cylinders, 16 heads, and 63 sectors per track. - zconfig_partition /dev/zvol/${FULL_NAME} 0 1624 - - # Format the partition with ext3. - /sbin/mkfs.ext3 -q /dev/zvol/${FULL_NAME}-part1 || fail 5 - - # Mount the ext3 filesystem and copy some data to it. + # Mount the ext2 filesystem and copy some data to it. mkdir -p /tmp/${ZVOL_NAME}-part1 || fail 6 mount /dev/zvol/${FULL_NAME}-part1 /tmp/${ZVOL_NAME}-part1 || fail 7 cp -RL ${SRC_DIR} /tmp/${ZVOL_NAME}-part1 || fail 8 sync # Verify the copied files match the original files. - diff -ur ${SRC_DIR} /tmp/${ZVOL_NAME}-part1${SRC_DIR} \ + diff -ur ${SRC_DIR} /tmp/${ZVOL_NAME}-part1/${SRC_DIR##*/} \ &>/dev/null || fail 9 # Remove the files, umount, destroy the volume and pool. - rm -Rf /tmp/${ZVOL_NAME}-part1${SRC_DIR}* || fail 10 + rm -Rf /tmp/${ZVOL_NAME}-part1/${SRC_DIR##*/} || fail 10 umount /tmp/${ZVOL_NAME}-part1 || fail 11 rmdir /tmp/${ZVOL_NAME}-part1 || fail 12 @@ -338,7 +323,7 @@ test_5() { pass } -run_test 5 "zvol+ext3 volume" +run_test 5 "zvol+ext2 volume" # ZVOL snapshot sanity check test_6() { @@ -347,22 +332,18 @@ test_6() { local SNAP_NAME=pristine local FULL_ZVOL_NAME=${POOL_NAME}/${ZVOL_NAME} local FULL_SNAP_NAME=${POOL_NAME}/${ZVOL_NAME}@${SNAP_NAME} - local SRC_DIR=/bin/ local TMP_CACHE=`mktemp -p /tmp zpool.cache.XXXXXXXX` # Create a pool and volume. ${ZFS_SH} zfs="spa_config_path=${TMP_CACHE}" || fail 1 ${ZPOOL_CREATE_SH} -p ${POOL_NAME} -c lo-raid0 || fail 2 ${ZFS} create -V 800M ${FULL_ZVOL_NAME} || fail 3 + ${ZFS} set snapdev=visible ${FULL_ZVOL_NAME} || fail 3 + label /dev/zvol/${FULL_ZVOL_NAME} msdos || fail 4 + partition /dev/zvol/${FULL_ZVOL_NAME} primary 1 -1 || fail 4 + format /dev/zvol/${FULL_ZVOL_NAME}-part1 ext2 || fail 5 - # Partition the volume, for a 800M volume there will be - # 1624 cylinders, 16 heads, and 63 sectors per track. - zconfig_partition /dev/zvol/${FULL_ZVOL_NAME} 0 1624 - - # Format the partition with ext2 (no journal). - /sbin/mkfs.ext2 -q /dev/zvol/${FULL_ZVOL_NAME}-part1 || fail 5 - - # Mount the ext3 filesystem and copy some data to it. + # Mount the ext2 filesystem and copy some data to it. mkdir -p /tmp/${ZVOL_NAME}-part1 || fail 6 mount /dev/zvol/${FULL_ZVOL_NAME}-part1 /tmp/${ZVOL_NAME}-part1 \ || fail 7 @@ -380,9 +361,9 @@ test_6() { # Verify the copied files match the original files, # and the copied files do NOT appear in the snapshot. - diff -ur ${SRC_DIR} /tmp/${ZVOL_NAME}-part1${SRC_DIR} \ + diff -ur ${SRC_DIR} /tmp/${ZVOL_NAME}-part1/${SRC_DIR##*/} \ &>/dev/null || fail 12 - diff -ur ${SRC_DIR} /tmp/${SNAP_NAME}-part1${SRC_DIR} \ + diff -ur ${SRC_DIR} /tmp/${SNAP_NAME}-part1/${SRC_DIR##*/} \ &>/dev/null && fail 13 # umount, destroy the snapshot, volume, and pool. @@ -411,22 +392,18 @@ test_7() { local FULL_ZVOL_NAME=${POOL_NAME}/${ZVOL_NAME} local FULL_SNAP_NAME=${POOL_NAME}/${ZVOL_NAME}@${SNAP_NAME} local FULL_CLONE_NAME=${POOL_NAME}/${CLONE_NAME} - local SRC_DIR=/bin/ local TMP_CACHE=`mktemp -p /tmp zpool.cache.XXXXXXXX` # Create a pool and volume. ${ZFS_SH} zfs="spa_config_path=${TMP_CACHE}" || fail 1 ${ZPOOL_CREATE_SH} -p ${POOL_NAME} -c lo-raidz2 || fail 2 ${ZFS} create -V 300M ${FULL_ZVOL_NAME} || fail 3 + ${ZFS} set snapdev=visible ${FULL_ZVOL_NAME} || fail 3 + label /dev/zvol/${FULL_ZVOL_NAME} msdos || fail 4 + partition /dev/zvol/${FULL_ZVOL_NAME} primary 1 -1 || fail 4 + format /dev/zvol/${FULL_ZVOL_NAME}-part1 ext2 || fail 5 - # Partition the volume, for a 300M volume there will be - # 609 cylinders, 16 heads, and 63 sectors per track. - zconfig_partition /dev/zvol/${FULL_ZVOL_NAME} 0 609 - - # Format the partition with ext2 (no journal). - /sbin/mkfs.ext2 -q /dev/zvol/${FULL_ZVOL_NAME}-part1 || fail 5 - - # Mount the ext3 filesystem and copy some data to it. + # Mount the ext2 filesystem and copy some data to it. mkdir -p /tmp/${ZVOL_NAME}-part1 || fail 6 mount /dev/zvol/${FULL_ZVOL_NAME}-part1 /tmp/${ZVOL_NAME}-part1 \ || fail 7 @@ -444,9 +421,9 @@ test_7() { # Verify the copied files match the original files, # and the copied files do NOT appear in the snapshot. - diff -ur ${SRC_DIR} /tmp/${ZVOL_NAME}-part1${SRC_DIR} \ + diff -ur ${SRC_DIR} /tmp/${ZVOL_NAME}-part1/${SRC_DIR##*/} \ &>/dev/null || fail 12 - diff -ur ${SRC_DIR} /tmp/${SNAP_NAME}-part1${SRC_DIR} \ + diff -ur ${SRC_DIR} /tmp/${SNAP_NAME}-part1/${SRC_DIR##*/} \ &>/dev/null && fail 13 # Clone from the original pristine snapshot @@ -502,30 +479,26 @@ test_8() { local FULL_ZVOL_NAME2=${POOL_NAME2}/${ZVOL_NAME} local FULL_SNAP_NAME1=${POOL_NAME1}/${ZVOL_NAME}@${SNAP_NAME} local FULL_SNAP_NAME2=${POOL_NAME2}/${ZVOL_NAME}@${SNAP_NAME} - local SRC_DIR=/bin/ local TMP_CACHE=`mktemp -p /tmp zpool.cache.XXXXXXXX` # Create two pools and a volume ${ZFS_SH} zfs="spa_config_path=${TMP_CACHE}" || fail 1 ${ZPOOL_CREATE_SH} -p ${POOL_NAME1} -c lo-raidz2 || fail 2 - ${ZPOOL_CREATE_SH} -p ${POOL_NAME2} -c lo-raidz2 || fail 3 - ${ZFS} create -V 300M ${FULL_ZVOL_NAME1} || fail 4 - - # Partition the volume, for a 300M volume there will be - # 609 cylinders, 16 heads, and 63 sectors per track. - zconfig_partition /dev/zvol/${FULL_ZVOL_NAME1} 0 609 - - # Format the partition with ext2. - /sbin/mkfs.ext2 -q /dev/zvol/${FULL_ZVOL_NAME1}-part1 || fail 5 - - # Mount the ext3 filesystem and copy some data to it. + ${ZPOOL_CREATE_SH} -p ${POOL_NAME2} -c lo-raidz2 || fail 2 + ${ZFS} create -V 300M ${FULL_ZVOL_NAME1} || fail 3 + ${ZFS} set snapdev=visible ${FULL_ZVOL_NAME1} || fail 3 + label /dev/zvol/${FULL_ZVOL_NAME1} msdos || fail 4 + partition /dev/zvol/${FULL_ZVOL_NAME1} primary 1 -1 || fail 4 + format /dev/zvol/${FULL_ZVOL_NAME1}-part1 ext2 || fail 5 + + # Mount the ext2 filesystem and copy some data to it. mkdir -p /tmp/${FULL_ZVOL_NAME1}-part1 || fail 6 mount /dev/zvol/${FULL_ZVOL_NAME1}-part1 \ /tmp/${FULL_ZVOL_NAME1}-part1 || fail 7 cp -RL ${SRC_DIR} /tmp/${FULL_ZVOL_NAME1}-part1 || fail 8 sync || fail 9 - # Snapshot the ext3 filesystem so it may be sent. + # Snapshot the ext2 filesystem so it may be sent. ${ZFS} snapshot ${FULL_SNAP_NAME1} || fail 11 wait_udev /dev/zvol/${FULL_SNAP_NAME1} 30 || fail 11 @@ -534,7 +507,7 @@ test_8() { ${ZFS} receive ${FULL_ZVOL_NAME2}) || fail 12 wait_udev /dev/zvol/${FULL_ZVOL_NAME2}-part1 30 || fail 12 - # Mount the sent ext3 filesystem. + # Mount the sent ext2 filesystem. mkdir -p /tmp/${FULL_ZVOL_NAME2}-part1 || fail 13 mount /dev/zvol/${FULL_ZVOL_NAME2}-part1 \ /tmp/${FULL_ZVOL_NAME2}-part1 || fail 14