| 1 |
#!/bin/bash |
| 2 |
|
| 3 |
# |
| 4 |
# Copyright (C) 2010 Karel Zak <[email protected]> |
| 5 |
# |
| 6 |
# This file is part of util-linux. |
| 7 |
# |
| 8 |
# This file is free software; you can redistribute it and/or modify |
| 9 |
# it under the terms of the GNU General Public License as published by |
| 10 |
# the Free Software Foundation; either version 2 of the License, or |
| 11 |
# (at your option) any later version. |
| 12 |
# |
| 13 |
# This file is distributed in the hope that it will be useful, |
| 14 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
# GNU General Public License for more details. |
| 17 |
# |
| 18 |
|
| 19 |
TS_TOPDIR="${0%/*}/../.." |
| 20 |
TS_DESC="MD raid1 (last partition)" |
| 21 |
|
| 22 |
. "$TS_TOPDIR"/functions.sh |
| 23 |
ts_init "$*" |
| 24 |
|
| 25 |
ts_check_test_command "$TS_CMD_FDISK" |
| 26 |
ts_check_test_command "$TS_CMD_BLKID" |
| 27 |
|
| 28 |
ts_skip_nonroot |
| 29 |
ts_check_prog "mdadm" |
| 30 |
|
| 31 |
# rhbz#182625: It can't create new raid0 with metadata 0.90 from mdadm-4.1 |
| 32 |
TS_KNOWN_FAIL="yes" |
| 33 |
|
| 34 |
# set global variable TS_DEVICE |
| 35 |
ts_scsi_debug_init dev_size_mb=51 sector_size=512 |
| 36 |
|
| 37 |
ts_log "Create partitions" |
| 38 |
$TS_CMD_FDISK --noauto-pt ${TS_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG <<EOF |
| 39 |
o |
| 40 |
n |
| 41 |
p |
| 42 |
1 |
| 43 |
|
| 44 |
+25M |
| 45 |
n |
| 46 |
p |
| 47 |
2 |
| 48 |
|
| 49 |
|
| 50 |
p |
| 51 |
w |
| 52 |
q |
| 53 |
EOF |
| 54 |
|
| 55 |
# replace generated ID with something stable |
| 56 |
$TS_CMD_FDISK ${TS_DEVICE} &> /dev/null <<EOF |
| 57 |
x |
| 58 |
i |
| 59 |
0x1 |
| 60 |
r |
| 61 |
w |
| 62 |
q |
| 63 |
EOF |
| 64 |
|
| 65 |
udevadm settle |
| 66 |
MD_DEVNAME=md8 |
| 67 |
MD_DEVICE=/dev/${MD_DEVNAME} |
| 68 |
|
| 69 |
ts_lock "md" |
| 70 |
|
| 71 |
ts_log "Create RAID1 device" |
| 72 |
mdadm -q -S ${MD_DEVICE} &> /dev/null |
| 73 |
mdadm -q --create ${MD_DEVICE} --metadata=0.90 --chunk=64 --level=1 \ |
| 74 |
--raid-devices=2 ${TS_DEVICE}1 ${TS_DEVICE}2 >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 75 |
udevadm settle |
| 76 |
|
| 77 |
ts_log "Probe whole-disk" |
| 78 |
$TS_CMD_BLKID --probe --output udev ${TS_DEVICE} 2>> $TS_ERRLOG | sort >> $TS_OUTPUT |
| 79 |
|
| 80 |
ts_log "Probe first RAID member" |
| 81 |
$TS_CMD_BLKID --probe --output udev ${TS_DEVICE}1 2>> $TS_ERRLOG | sort >> $TS_OUTPUT |
| 82 |
|
| 83 |
ts_log "Probe second RAID member" |
| 84 |
$TS_CMD_BLKID --probe --output udev ${TS_DEVICE}2 2>> $TS_ERRLOG | sort >> $TS_OUTPUT |
| 85 |
|
| 86 |
mdadm -q -S ${MD_DEVICE} >> $TS_OUTPUT 2>> $TS_ERRLOG |
| 87 |
|
| 88 |
udevadm settle |
| 89 |
ts_unlock "md" |
| 90 |
|
| 91 |
ts_fdisk_clean $TS_DEVICE |
| 92 |
# substitute UUIDs and major/minor number before comparison |
| 93 |
sed -i \ |
| 94 |
-e 's/^\(ID_FS_UUID\)=.*/\1=__ts_uuid__/' \ |
| 95 |
-e 's/^\(ID_FS_UUID_ENC\)=.*/\1=__ts_uuid_enc__/' \ |
| 96 |
-e 's/^\(ID_PART_ENTRY_DISK\)=.*/\1=__ts_majorminor__/' \ |
| 97 |
$TS_OUTPUT |
| 98 |
|
| 99 |
ts_finalize |