博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
test-definitions/blob/master/auto-test/disk-partitioning/disk-partitioning.sh
阅读量:4214 次
发布时间:2019-05-26

本文共 2407 字,大约阅读时间需要 8 分钟。

#!/bin/sh# shellcheck disable=SC1091#相对路径执行脚本,并给常量赋值. ../../utils/sh-test-libOUTPUT="$(pwd)/output"RESULT_FILE="${OUTPUT}/result.txt"export RESULT_FILEDISKLABEL="gpt"FILESYSTEM="ext4"#定义一个函数说明这个脚本该如何使用usage() {    echo "Usage: $0 [-d ] [-l 
] [-f
] [-s
]" 1>&2 exit 1}#通过while parse 可选参数while getopts "d:l:f:r:s:" o; do case "$o" in # The existing disk label on the device will be destroyed, # and all data on this disk will be lost. d) DEVICE="${OPTARG}" ;; l) DISKLABEL="${OPTARG}" ;; f) FILESYSTEM="${OPTARG}" ;; s) SKIP_INSTALL="${OPTARG}" ;; *) usage ;; esacdonecreate_disklabel() { echo echo "Creating ${DEVICE} disklabel: ${DISKLABEL}" #umount 这个parition umount "${DEVICE}*" > /dev/null 2>&1 # If mklabel fails, skip the following tests. skip_list="create-partition format-partition mount-partition umount-partition" #执行parted 命令 parted -s "${DEVICE}" mklabel "${DISKLABEL}" exit_on_fail "create-disklabel" "${skip_list}" sync sleep 10}create_partition() { echo echo "Creating partition: ${DEVICE}1" skip_list="format-partition mount-partition umount-partition" #通过parted -s 命令来创建新的partition parted -s "${DEVICE}" mkpart primary 0% 100% exit_on_fail "create-partition" "${skip_list}" sync sleep 10}format_partition() { echo echo "Formatting ${DEVICE}1 to ${FILESYSTEM}" skip_list="mount-partition umount-partition" #格式化partition,注意这里fat32的命令的参数和其他不同 if [ "${FILESYSTEM}" = "fat32" ]; then echo "y" | mkfs -t vfat -F 32 "${DEVICE}1" else echo "y" | mkfs -t "${FILESYSTEM}" "${DEVICE}1" fi exit_on_fail "format-partition" "${skip_list}" #sysc 后然后等10s。 sync sleep 10}disk_mount() { echo echo "Running mount/umount tests..." #由于要将device mount到/mnt .所以这里先把mnt umount掉 umount /mnt > /dev/null 2>&1 skip_list="umount-partition" mount "${DEVICE}1" /mnt exit_on_fail "mount-partition" "${skip_list}" umount "${DEVICE}1" check_return "umount-partition"}# Test run.#如果不存在这个块设备的话就是输出错误日志[ -b "${DEVICE}" ] || error_msg "Please specify a block device with '-d'"#检查是否是root用户! check_root && error_msg "You need to be root to run this script."create_out_dir "${OUTPUT}"#使用parted 命令需要安装的包pkgs="parted e2fsprogs dosfstools"install_deps "${pkgs}" "${SKIP_INSTALL}"#分别执行前面的函数测试这个block devicecreate_disklabelcreate_partitionformat_partitiondisk_mount

转载地址:http://vznmi.baihongyu.com/

你可能感兴趣的文章
test-definitions/blob/master/auto-test/blogbench/blogbench.sh
查看>>
test-definitions/blob/master/auto-test/boost/boost.sh
查看>>
Java多态性理解
查看>>
Intellij Idea 工具在java文件中怎么避免 import .*包,以及import包顺序的问题
查看>>
IDEA Properties中文unicode转码问题
查看>>
Oracle中Blob转换成Clob
查看>>
Linux如何查看so中函数名
查看>>
自动管理代码的android.mk
查看>>
cocos2dx 2.2.6编译记录(1)
查看>>
makefile学习网站
查看>>
C 编写lua模块(1)
查看>>
Lua教程:Lua调用C/C++函数(4)
查看>>
win下创建win32控制台工程,执行lua脚本
查看>>
cocos2dx android启动错误
查看>>
eclipse: android rename package name
查看>>
cocos2dx c++调用java思想
查看>>
cocos2dx lua Node节点 私有数据存取
查看>>
lua math.ceil math.ceil
查看>>
cocos2dx CCNode计算node的大小
查看>>
cocos2dx 布局记录(1)
查看>>