Description
The Azure-NVMe-Conversion.ps1 script currently allows conversion of Linux VMs that have Azure Disk Encryption (ADE) enabled. In the script when it checks the fstab entries to make changes, the regular expression doesn't take into account partitions with entries in the format of /dev/disk/azure/scsi1/lun0-part1.
Impact
When there are any entries with that format, it fails to make the changes needed in the fstab.
Steps to reproduce
- Deploy a Linux VM in Azure with a data disk or disks that use the format in fstab of /dev/disk/azure/scsi[0-9]*/lun[0-9]-part[0-9].
- Run the conversion from SCSI to NVMe, https://learn.microsoft.com/en-us/azure/virtual-machines/nvme-linux.
- After the script completes, you can see in the VM the fstab entries with the /dev/disk/azure/scsi..... have not been changed.
Expected Behavior
Script should take into account the partitions for those entries and make the changes needed in fstab.
Proposed Solution
Remove the $ sign in line 796 for the regular expression so it will not discount partitions for those entries.
--From: " elif [[ "$device" =~ ^/dev/disk/azure/scsi[0-9]/lun[0-9]$ ]]"
--To: " elif [[ "$device" =~ ^/dev/disk/azure/scsi[0-9]/lun[0-9] ]]"
elif [[ "$device" =~ ^/dev/disk/azure/scsi[0-9]*/lun[0-9]* ]]; then
uuid=$(blkid "$device" | awk -F\" '/UUID=/ {print $2}')
if [ -n "$uuid" ]; then
newline=$(echo "$line" | sed "s|$device|UUID=$uuid|g")
echo "[INFO] Replaced $device with UUID=$uuid"
echo "$newline" >> /etc/fstab.new
else
echo "[WARNING] Could not find UUID for $device. Skipping."
echo "$line" >> /etc/fstab.new
fi
Reference
https://learn.microsoft.com/en-us/azure/virtual-machines/nvme-linux
Related Pull Request
#140
Description
The Azure-NVMe-Conversion.ps1 script currently allows conversion of Linux VMs that have Azure Disk Encryption (ADE) enabled. In the script when it checks the fstab entries to make changes, the regular expression doesn't take into account partitions with entries in the format of /dev/disk/azure/scsi1/lun0-part1.
Impact
When there are any entries with that format, it fails to make the changes needed in the fstab.
Steps to reproduce
Expected Behavior
Script should take into account the partitions for those entries and make the changes needed in fstab.
Proposed Solution
Remove the $ sign in line 796 for the regular expression so it will not discount partitions for those entries.
--From: " elif [[ "$device" =~ ^/dev/disk/azure/scsi[0-9]/lun[0-9]$ ]]"
--To: " elif [[ "$device" =~ ^/dev/disk/azure/scsi[0-9]/lun[0-9] ]]"
Reference
https://learn.microsoft.com/en-us/azure/virtual-machines/nvme-linux
Related Pull Request
#140