swap is not discovered for nvme devices

Bug #2023605 reported by cleary
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
casper (Ubuntu)
Confirmed
Undecided
Unassigned

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

Tags: patch
Revision history for this message
cleary (bernard-gray) wrote :
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "enable nvme swap discovery/usage, make the discovery logic/execution more robust" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in casper (Ubuntu):
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.