diff options
| author | PMR <pmr@pmr-lander> | 2017-02-21 16:30:46 +0000 |
|---|---|---|
| committer | PMR <pmr@pmr-lander> | 2017-02-21 16:30:46 +0000 |
| commit | 6d190232a1ad63b0065d2de0483547d0675d2d45 (patch) | |
| tree | abae5e5033c939c5d319db881e7d45923f54aba4 | |
| parent | 10465f19b13ff95d2e7c62d798136011d544a688 (diff) | |
| parent | 0564789ff10112d2d8c995a0af0da62ff186b94f (diff) | |
Merge #317286 from ~pierre-equoy/plainbox-provider-checkbox:1660386-mount-drive-before-storage-tests
| -rwxr-xr-x | bin/storage_test | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/bin/storage_test b/bin/storage_test index ef19c5e..40cc3f2 100755 --- a/bin/storage_test +++ b/bin/storage_test @@ -30,6 +30,34 @@ function run_bonnie() { fi } +# Find the largest partition that holds a supported filesystem on $disk_device. +# This code is adapted from a similar function in `disk_stress_ng`. +# Output: +# $largest_part -- Device filename of largest qualifying partition or logical volume +# $largest_size -- Size of largest qualifying partition or logical volume +# $largest_fs -- Filesystem (ext4, etc.) used on largest qualifying partition or logical volume +# $unsupported_fs -- Empty or contains name of unsupported filesystem found on disk +find_largest_partition() { + largest_part="" + largest_size=0 + partitions=$(lsblk -b -l -n -o NAME,SIZE,TYPE,MOUNTPOINT $disk | grep part | tr -s " ") + unsupported_fs="" + for partition in $(echo "$partitions" | cut -d " " -f 1) ; do + part_size=$(echo "$partitions" | grep "$partition " | cut -d " " -f 2) + local blkid_info=$(blkid -s TYPE /dev/$partition | grep -E ext2\|ext3\|ext4\|xfs\|jfs\|btrfs) + if [ "$part_size" -gt "$largest_size" ] && [ -n "$blkid_info" ] ; then + largest_size=$part_size + largest_part="/dev/$partition" + largest_fs=$(blkid -s TYPE "/dev/$partition" | cut -d "=" -f 2) + fi + local blkid_info=$(blkid -s TYPE /dev/$partition | grep -E ntfs\|vfat\|hfs) + if [ -n "$blkid_info" ] ; then + # If there's an NTFS, HFS+, or FAT filesystem on the disk make note of it.... + unsupported_fs=$(blkid -s TYPE "/dev/$partition" | cut -d "=" -f 2) + fi + done +} # find_largest_partition() + disk=/dev/$1 if [ -b $disk ] @@ -62,7 +90,17 @@ then echo "$disk is mounted, proceeding." else echo "$disk is not mounted. It must be mounted before testing." - exit 1 + find_largest_partition + if [ -n "$largest_part" ] + then + dest=/tmp/drive/$partition + echo "Mounting $largest_part into $dest..." + mkdir -p $dest + mount $largest_part $dest + else + echo "$disk has no partition. Please format this drive and re-launch the test." + exit 1 + fi fi |
