Skip to content

Commit e96e5d7

Browse files
roger530-hoPJHsieh
authored andcommitted
Looking for the SSD disk currently used by the SONiC.
1 parent de62523 commit e96e5d7

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

show/platform.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,14 @@ def psustatus(index, json, verbose):
104104
def ssdhealth(device, verbose, vendor):
105105
"""Show SSD Health information"""
106106
if not device:
107-
device = os.popen("lsblk -o NAME,TYPE -p | grep disk").readline().strip().split()[0]
107+
# Looking for the SSD disk currently used by the SONiC.
108+
109+
base_device = os.popen("lsblk -l -o NAME,TYPE,MOUNTPOINT -p | grep -w '/host'").readline().strip().split()[0]
110+
111+
# Extract the base device name, handling both 'p' and non-'p' partitioning schemes
112+
# Example : /dev/sda1 => /dev/sda
113+
# /dev/nvme0n1p2 => /dev/nvme0n1
114+
device = base_device.rstrip("0123456789").split("p")[0]
108115
cmd = ['sudo', 'ssdutil', '-d', str(device)]
109116
options = ["-v"] if verbose else []
110117
options += ["-e"] if vendor else []

0 commit comments

Comments
 (0)