1#!/bin/bash 2 3TS_TOPDIR="${0%/*}/../.." 4TS_DESC="fix page size" 5 6. $TS_TOPDIR/functions.sh 7ts_init "$*" 8 9ts_check_test_command "$TS_CMD_MKSWAP" 10ts_check_test_command "$TS_CMD_SWAPON" 11ts_check_test_command "$TS_CMD_SWAPOFF" 12 13ts_skip_nonroot 14ts_check_losetup 15 16set -o pipefail 17 18PAGESIZE=$($TS_HELPER_SYSINFO pagesize) 19 20# 21# Create a swap-area with incompatible page size 22# 23[ "$?" == 0 ] || ts_die "Cannot init device" 24 25if [ $(( 64 * 1024 )) -ne $PAGESIZE ]; then 26 BADSIZE=$(( 64 * 1024 )) 27else 28 BADSIZE=4096 29fi 30 31DEVICE=$(ts_device_init) 32 33$TS_CMD_MKSWAP -L MyFooBarLabel --pagesize $BADSIZE $DEVICE > /dev/null &> /dev/null \ 34 || ts_die "Cannot make swap $DEVICE" $DEVICE 35 36ts_device_has "TYPE" "swap" $DEVICE || ts_die "Cannot find swap on $DEVICE" $DEVICE 37 38# 39# Swapon 40# 41$TS_CMD_SWAPON --fixpgsz $DEVICE &> /dev/null 42 43grep -q $DEVICE /proc/swaps || ts_die "Cannot find $DEVICE in /proc/swaps" $DEVICE 44 45$TS_CMD_SWAPOFF $DEVICE 46ts_device_deinit $DEVICE 47 48ts_log "Success" 49ts_finalize 50 51