[Terminal] How do I obtain the sdX for the parity disk?


mgutt

Recommended Posts

I like to know if the Parity Disk is sleeping. The command would be:

smartctl -n standby /dev/sdX

But how do I obtain the sdX of the (first) parity disk?

 

lsblk does not return the correlation between sdX and mdX:

lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
loop0         7:0    0   9.1M  1 loop /lib/modules
loop1         7:1    0   7.1M  1 loop /lib/firmware
loop2         7:2    0    20G  0 loop /var/lib/docker
sda           8:0    0  10.9T  0 disk 
└─sda1        8:1    0  10.9T  0 part 
sdb           8:16   0  10.9T  0 disk 
└─sdb1        8:17   0  10.9T  0 part 
sdc           8:32   1  14.2G  0 disk 
└─sdc1        8:33   1  14.2G  0 part /boot
sdd           8:48   0  10.9T  0 disk 
└─sdd1        8:49   0  10.9T  0 part 
sde           8:64   0  10.9T  0 disk 
└─sde1        8:65   0  10.9T  0 part 
sdf           8:80   0  10.9T  0 disk 
└─sdf1        8:81   0  10.9T  0 part 
sdg           8:96   0  10.9T  0 disk 
└─sdg1        8:97   0  10.9T  0 part 
sdh           8:112  0  10.9T  0 disk 
└─sdh1        8:113  0  10.9T  0 part 
sdi           8:128  0  10.9T  0 disk 
└─sdi1        8:129  0  10.9T  0 part 
sdj           8:144  0  10.9T  0 disk 
└─sdj1        8:145  0  10.9T  0 part 
sdk           8:160  0  10.9T  0 disk 
└─sdk1        8:161  0  10.9T  0 part 
md1           9:1    0  10.9T  0 md   /mnt/disk1
md2           9:2    0  10.9T  0 md   /mnt/disk2
md3           9:3    0  10.9T  0 md   /mnt/disk3
md4           9:4    0  10.9T  0 md   /mnt/disk4
md5           9:5    0  10.9T  0 md   /mnt/disk5
md6           9:6    0  10.9T  0 md   /mnt/disk6
md7           9:7    0  10.9T  0 md   /mnt/disk7
md8           9:8    0  10.9T  0 md   /mnt/disk8
md9           9:9    0  10.9T  0 md   /mnt/disk9
nvme0n1     259:0    0 931.5G  0 disk 
└─nvme0n1p1 259:1    0 931.5G  0 part /mnt/cache

 

Link to comment

Why are you so insistent to find it through the use of the command line?  You could easily grab it from the GUI.  (Just look for it on the Main page..)  Once the assignment is make during boot-up, it will never change. 

 

Point of disclosure:  It has been forty years since I last did much Unix(Linux) command line work and I don't remember enough of it to even begin to start to construct an expression to extract that information from the syslog.  The starting point would probably be the use of grep...

Link to comment
41 minutes ago, mgutt said:

I meant through a command. I mean I could filter the syslog, but is this the only solution?

Why do you even want to use the sdX type name as that is subject to change at any time if you reboot (as the sdX names are assigned dynamically by Linux during the boot process).   Is it possible for your use case to use one of the names that show up under the /dev/disk hierarchy as these should be invariant.

Link to comment
7 minutes ago, itimpi said:

Why do you even want to use the sdX type name

If you are interested:

https://forums.unraid.net/topic/98033-xfs-extended-defragmentation/

 

Solved it as follows:

parity_id=$(mdcmd status | grep rdevName.0 | cut -d = -f 2)
echo "Parity has device id $parity_id"
parity_state=$(smartctl -n standby "/dev/$parity_id")

 

Edited by mgutt
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.