diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 13:14:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 13:14:44 +0000 |
commit | 30ff6afe596eddafacf22b1a5b2d1a3d6254ea15 (patch) | |
tree | 9b788335f92174baf7ee18f03ca8330b8c19ce2b /tests/ts/fdisk/mbr-sort | |
parent | Initial commit. (diff) | |
download | util-linux-30ff6afe596eddafacf22b1a5b2d1a3d6254ea15.tar.xz util-linux-30ff6afe596eddafacf22b1a5b2d1a3d6254ea15.zip |
Adding upstream version 2.36.1.upstream/2.36.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-x | tests/ts/fdisk/mbr-sort | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/tests/ts/fdisk/mbr-sort b/tests/ts/fdisk/mbr-sort new file mode 100755 index 0000000..8ae51bf --- /dev/null +++ b/tests/ts/fdisk/mbr-sort @@ -0,0 +1,79 @@ +#!/bin/bash + +# +# This file is part of util-linux. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This file is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="MBR - sort" + +. $TS_TOPDIR/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_FDISK" + +# cmd to changes system id to 0x1 +FDISK_CMD_WRITE_CLOSE="w\nq\n" +FDISK_CMD_CREATE_DOSLABEL="o\n" #create dos label + +FDISK_CMD_CREATE_1PRIMARY="n\np\n1\n4096\n6143\n" +FDISK_CMD_CREATE_2PRIMARY="n\np\n2\n2048\n4095\n" +FDISK_CMD_CREATE_3PRIMARY="n\np\n3\n6144\n8191\n" +FDISK_CMD_CREATE_EXTENDED="n\ne\n\n\n" + +FDISK_CMD_CREATE_1LOGICAL="n\n14336\n16383\n" +FDISK_CMD_CREATE_2LOGICAL="n\n22528\n24575\n" +FDISK_CMD_CREATE_3LOGICAL="n\n18432\n20479\n" +FDISK_CMD_CREATE_4LOGICAL="n\n10240\n12287\n" + +FDISK_CMD_EXPERT_SORT="x\nf\nr\n" + +function print_layout { + echo -ne "\n---layout----------\n" >> $TS_OUTPUT + $TS_CMD_FDISK -l ${TEST_IMAGE_NAME} >> $TS_OUTPUT + echo -ne "-------------------\n\n" >> $TS_OUTPUT +} + +#set -x + +ts_log "Initialize empty image" +TEST_IMAGE_NAME=$(ts_image_init 20) # 20 MiB + +ts_log "Create new DOS partition table" +echo -e "${FDISK_CMD_CREATE_DOSLABEL}${FDISK_CMD_WRITE_CLOSE}" \ + | $TS_CMD_FDISK --noauto-pt ${TEST_IMAGE_NAME} &> /dev/null + +print_layout + +ts_log "Create primary partitions" +echo -e "${FDISK_CMD_CREATE_1PRIMARY}${FDISK_CMD_CREATE_2PRIMARY}${FDISK_CMD_CREATE_3PRIMARY}${FDISK_CMD_CREATE_EXTENDED}${FDISK_CMD_WRITE_CLOSE}" \ + | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null + +print_layout + + +ts_log "Create logical partitions" +echo -e "${FDISK_CMD_CREATE_1LOGICAL}${FDISK_CMD_CREATE_2LOGICAL}${FDISK_CMD_CREATE_3LOGICAL}${FDISK_CMD_CREATE_4LOGICAL}${FDISK_CMD_WRITE_CLOSE}" \ + | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null + +print_layout + + +ts_log "Fix order." +echo -e "${FDISK_CMD_EXPERT_SORT}${FDISK_CMD_WRITE_CLOSE}" \ + | $TS_CMD_FDISK ${TEST_IMAGE_NAME} &> /dev/null + +print_layout + +ts_fdisk_clean ${TEST_IMAGE_NAME} +ts_finalize |