Skip to content

Commit

Permalink
Looking for the SSD disk currently used by the SONiC.
Browse files Browse the repository at this point in the history
  • Loading branch information
roger530-ho authored and PJHsieh committed Sep 18, 2024
1 parent de62523 commit e96e5d7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion show/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,14 @@ def psustatus(index, json, verbose):
def ssdhealth(device, verbose, vendor):
"""Show SSD Health information"""
if not device:
device = os.popen("lsblk -o NAME,TYPE -p | grep disk").readline().strip().split()[0]
# Looking for the SSD disk currently used by the SONiC.

base_device = os.popen("lsblk -l -o NAME,TYPE,MOUNTPOINT -p | grep -w '/host'").readline().strip().split()[0]

# Extract the base device name, handling both 'p' and non-'p' partitioning schemes
# Example : /dev/sda1 => /dev/sda
# /dev/nvme0n1p2 => /dev/nvme0n1
device = base_device.rstrip("0123456789").split("p")[0]
cmd = ['sudo', 'ssdutil', '-d', str(device)]
options = ["-v"] if verbose else []
options += ["-e"] if vendor else []
Expand Down

0 comments on commit e96e5d7

Please sign in to comment.