[Bug 2023605] [NEW] swap is not discovered for nvme devices

cleary 2023605 at bugs.launchpad.net
Tue Jun 13 01:03:36 UTC 2023


Public bug reported:

scripts/casper-bottom/13swap only looks for swap on
/dev/[hsv]d[a-z][0-9]* devices, missing any /dev/nvme* devices (which
are common now).

I've got a patch that rejigs the logic slightly so that if /dev/[hsv]d[a-z][0-9]* (or /dev/nvme*) is missing completely, it doesn't try and use that regex as the device string.
It also makes it a little more robust so we don't have to loop twice, or consider variable scoping for the $devices variable, by removing it's usage after the first for loop.

---

diff --git a/scripts/casper-bottom/13swap b/scripts/casper-bottom/13swap
index 2ca15d0..e71d1a3 100755
--- a/scripts/casper-bottom/13swap
+++ b/scripts/casper-bottom/13swap
@@ -26,8 +26,9 @@ esac
 
 log_begin_msg "$DESCRIPTION"
 
-devices=""
-for device in /dev/[hsv]d[a-z][0-9]*; do
+devices=$(find /dev -iname "[hsv]d[a-z][0-9]*" -o -iname "nvme[0-9]n[0-9]p[0-9]*")
+
+for device in $devices; do
     if ! [ -b "$device" ]; then
         continue
     fi
@@ -37,13 +38,8 @@ for device in /dev/[hsv]d[a-z][0-9]*; do
     magic=$(/bin/dd if="$device" bs=4086 skip=1 count=1 2>/dev/null | /bin/dd bs=10 count=1 2>/dev/null) || continue
     
     if [ "$magic" = "SWAPSPACE2" -o "$magic" = "SWAP-SPACE" ]; then
-#        log "Found $device"
-        devices="$devices $device"
-        fi
-done
-
-for device in $devices; do
-    swapon $device || true
+        swapon $device || true
+    fi
 done
 
 log_end_msg

** Affects: casper (Ubuntu)
     Importance: Undecided
         Status: New

** Patch added: "enable nvme swap discovery/usage, make the discovery logic/execution more robust"
   https://bugs.launchpad.net/bugs/2023605/+attachment/5679379/+files/nvme_swap.patch

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to casper in Ubuntu.
https://bugs.launchpad.net/bugs/2023605

Title:
  swap is not discovered for nvme devices

Status in casper package in Ubuntu:
  New

Bug description:
  scripts/casper-bottom/13swap only looks for swap on
  /dev/[hsv]d[a-z][0-9]* devices, missing any /dev/nvme* devices (which
  are common now).

  I've got a patch that rejigs the logic slightly so that if /dev/[hsv]d[a-z][0-9]* (or /dev/nvme*) is missing completely, it doesn't try and use that regex as the device string.
  It also makes it a little more robust so we don't have to loop twice, or consider variable scoping for the $devices variable, by removing it's usage after the first for loop.

  ---

  diff --git a/scripts/casper-bottom/13swap b/scripts/casper-bottom/13swap
  index 2ca15d0..e71d1a3 100755
  --- a/scripts/casper-bottom/13swap
  +++ b/scripts/casper-bottom/13swap
  @@ -26,8 +26,9 @@ esac
   
   log_begin_msg "$DESCRIPTION"
   
  -devices=""
  -for device in /dev/[hsv]d[a-z][0-9]*; do
  +devices=$(find /dev -iname "[hsv]d[a-z][0-9]*" -o -iname "nvme[0-9]n[0-9]p[0-9]*")
  +
  +for device in $devices; do
       if ! [ -b "$device" ]; then
           continue
       fi
  @@ -37,13 +38,8 @@ for device in /dev/[hsv]d[a-z][0-9]*; do
       magic=$(/bin/dd if="$device" bs=4086 skip=1 count=1 2>/dev/null | /bin/dd bs=10 count=1 2>/dev/null) || continue
       
       if [ "$magic" = "SWAPSPACE2" -o "$magic" = "SWAP-SPACE" ]; then
  -#        log "Found $device"
  -        devices="$devices $device"
  -        fi
  -done
  -
  -for device in $devices; do
  -    swapon $device || true
  +        swapon $device || true
  +    fi
   done
   
   log_end_msg

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/casper/+bug/2023605/+subscriptions




More information about the foundations-bugs mailing list