Skip to content

Commit a01c4c9

Browse files
author
Yolanda Robla
committed
Create partition at max msdos limit for disks > 2TB
Currently there is a problem on partition creation for MBR case. If disk exceeds 2TB, partition creation fails because we are hitting max msdos limit. Detect total disk size, and if it exceeds that limit, create the partition at the end of legal limits. Fixes-Bug: #1517077 Change-Id: I11dd3f11eaa6af764151b442768d10289ced6d3f
1 parent 0ca90d8 commit a01c4c9

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

ironic_python_agent/shell/copy_configdrive_to_disk.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ usage() {
3636
}
3737

3838
MAX_DISK_PARTITIONS=128
39+
MAX_MBR_SIZE_MB=2097152
3940

4041
CONFIGDRIVE="$1"
4142
DEVICE="$2"
@@ -86,9 +87,20 @@ else
8687
else
8788
log "Working on MBR only device $DEVICE"
8889

89-
# Create small partition at the end of the device
90+
# get total disk size, to detect if that exceeds 2TB msdos limit
91+
disksize_bytes=$(blockdev --getsize64 $DEVICE)
92+
disksize_mb=$(( ${disksize_bytes%% *} / 1024 / 1024))
93+
94+
startlimit=-64MiB
95+
endlimit=-0
96+
if [ "$disksize_mb" -gt "$MAX_MBR_SIZE_MB" ]; then
97+
# Create small partition at 2TB limit
98+
startlimit=$(($MAX_MBR_SIZE_MB - 65))
99+
endlimit=$(($MAX_MBR_SIZE_MB - 1))
100+
fi
101+
90102
log "Adding configdrive partition to $DEVICE"
91-
parted -a optimal -s -- $DEVICE mkpart primary ext2 -64MiB -0 || fail "creating configdrive on ${DEVICE}"
103+
parted -a optimal -s -- $DEVICE mkpart primary ext2 $startlimit $endlimit || fail "creating configdrive on ${DEVICE}"
92104

93105
# Find partition we just created
94106
# Dump all partitions, ignore empty ones, then get the last partition ID

0 commit comments

Comments
 (0)