@@ -348,10 +348,28 @@ function initiate_upgrade {
348
348
locale-gen
349
349
350
350
if [ -z " $IS_CI " ] && [ -z " $IS_LOCAL_UPGRADE " ]; then
351
- # awk NF==3 prints lines with exactly 3 fields, which are the block devices currently not mounted anywhere
352
- # excluding nvme0 since it is the root disk
351
+ # DATABASE_UPGRADE_DATA_MIGRATION_DEVICE_NAME = '/dev/xvdp' can be derived from the worker mount
353
352
echo " 5. Determining block device to mount"
354
- BLOCK_DEVICE=$( lsblk -dprno name,size,mountpoint,type | grep " disk" | grep -v " nvme0" | awk ' NF==3 { print $1; }' )
353
+ if command -v ebsnvme-id > /dev/null 2>&1 && dpkg -l | grep -q amazon-ec2-utils; then
354
+ for nvme_dev in $( lsblk -dprno name,size,mountpoint,type | grep disk | awk ' {print $1}' ) ; do
355
+ if [ -b " $nvme_dev " ]; then
356
+ mapping=$( ebsnvme-id -b " $nvme_dev " 2> /dev/null)
357
+ if [[ " $mapping " == " xvdp" || $mapping == " /dev/xvdp" ]]; then
358
+ BLOCK_DEVICE=" $nvme_dev "
359
+ break
360
+ fi
361
+ fi
362
+ done
363
+ fi
364
+
365
+ # Fallback to lsblk if ebsnvme-id is not available or no mapping found, pre ubuntu 20.04
366
+ if [ -z " $BLOCK_DEVICE " ]; then
367
+ echo " No block device found using ebsnvme-id, falling back to lsblk"
368
+ # awk NF==3 prints lines with exactly 3 fields, which are the block devices currently not mounted anywhere
369
+ # excluding nvme0 since it is the root disk
370
+ BLOCK_DEVICE=$( lsblk -dprno name,size,mountpoint,type | grep " disk" | grep -v " nvme0" | awk ' NF==3 { print $1; exit }' ) # exit ensures we grab the first only
371
+ fi
372
+
355
373
echo " Block device found: $BLOCK_DEVICE "
356
374
357
375
mkdir -p " $MOUNT_POINT "
0 commit comments