Reasonably filtered list of disks (block devices)
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
Iàam trying toàimprove anàinstallation script withàinteractive selection ofàsource andàdestination disks. Itàcurrently gets theàlist ofàentries fromà/sys/block andàfiltersàit through sr[0-9]|sd[a-z]|hd[a-z]|scd[0-5] â effecively excluding other appropriate types ofàdevices. Myàidea was toàremove theàhardcoded mask andàapproach withàmore general method. Asàanàexample ofàsatisfying result, lsblk
works asÃÂ needed byÃÂ default, andÃÂ IÃÂ thought itÃÂ willÃÂ be that simple toÃÂ merely look into its sources toÃÂ copy theÃÂ logic, but that was not theÃÂ case asÃÂ it turnedÃÂ out.
According toÃÂ set_cxt()
function, theÃÂ device is excluded ifÃÂ it has size ofÃÂ zero, orÃÂ is non-SCSI, which inÃÂ turn is checked byÃÂ sysfs_blkdev_scsi_get_hctl()
â theàone Iàcouldànot get totally through: itàis supposed toàinspect something (namely, HCTL â Host, Channel, Target, LUN) inàtheàdevice subtree, which is probably represented byàscsi_device andàscsi_disk directories, however there is noàscsi atàall inàhda subtree ofàaàmemory card device, foràexample, neither thereàis aàdevice subtree inàetherd!e42.0 ofàanàATA-over-Ethernet storage, yet they are included inàlsblk
output byÃÂ default.
What else may one check toÃÂ reliably filterÃÂ out dummy devices like ram15? Those are pre-created inÃÂ big numbers,ÃÂ having sizeÃÂ >ÃÂ 0 andÃÂ roÃÂ =ÃÂ 0, making itÃÂ hard toÃÂ distinguish them fromÃÂ regular disks. InÃÂ simple terms, theÃÂ result should ideally be identical toÃÂ lsblk -d -n -o NAME
â asàaàlast resort Iàwill just parse that output, but Iàjust wanted toàunderstand theàthings better myself.
linux block-device lsblk
add a comment |Â
up vote
0
down vote
favorite
Iàam trying toàimprove anàinstallation script withàinteractive selection ofàsource andàdestination disks. Itàcurrently gets theàlist ofàentries fromà/sys/block andàfiltersàit through sr[0-9]|sd[a-z]|hd[a-z]|scd[0-5] â effecively excluding other appropriate types ofàdevices. Myàidea was toàremove theàhardcoded mask andàapproach withàmore general method. Asàanàexample ofàsatisfying result, lsblk
works asÃÂ needed byÃÂ default, andÃÂ IÃÂ thought itÃÂ willÃÂ be that simple toÃÂ merely look into its sources toÃÂ copy theÃÂ logic, but that was not theÃÂ case asÃÂ it turnedÃÂ out.
According toÃÂ set_cxt()
function, theÃÂ device is excluded ifÃÂ it has size ofÃÂ zero, orÃÂ is non-SCSI, which inÃÂ turn is checked byÃÂ sysfs_blkdev_scsi_get_hctl()
â theàone Iàcouldànot get totally through: itàis supposed toàinspect something (namely, HCTL â Host, Channel, Target, LUN) inàtheàdevice subtree, which is probably represented byàscsi_device andàscsi_disk directories, however there is noàscsi atàall inàhda subtree ofàaàmemory card device, foràexample, neither thereàis aàdevice subtree inàetherd!e42.0 ofàanàATA-over-Ethernet storage, yet they are included inàlsblk
output byÃÂ default.
What else may one check toÃÂ reliably filterÃÂ out dummy devices like ram15? Those are pre-created inÃÂ big numbers,ÃÂ having sizeÃÂ >ÃÂ 0 andÃÂ roÃÂ =ÃÂ 0, making itÃÂ hard toÃÂ distinguish them fromÃÂ regular disks. InÃÂ simple terms, theÃÂ result should ideally be identical toÃÂ lsblk -d -n -o NAME
â asàaàlast resort Iàwill just parse that output, but Iàjust wanted toàunderstand theàthings better myself.
linux block-device lsblk
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Iàam trying toàimprove anàinstallation script withàinteractive selection ofàsource andàdestination disks. Itàcurrently gets theàlist ofàentries fromà/sys/block andàfiltersàit through sr[0-9]|sd[a-z]|hd[a-z]|scd[0-5] â effecively excluding other appropriate types ofàdevices. Myàidea was toàremove theàhardcoded mask andàapproach withàmore general method. Asàanàexample ofàsatisfying result, lsblk
works asÃÂ needed byÃÂ default, andÃÂ IÃÂ thought itÃÂ willÃÂ be that simple toÃÂ merely look into its sources toÃÂ copy theÃÂ logic, but that was not theÃÂ case asÃÂ it turnedÃÂ out.
According toÃÂ set_cxt()
function, theÃÂ device is excluded ifÃÂ it has size ofÃÂ zero, orÃÂ is non-SCSI, which inÃÂ turn is checked byÃÂ sysfs_blkdev_scsi_get_hctl()
â theàone Iàcouldànot get totally through: itàis supposed toàinspect something (namely, HCTL â Host, Channel, Target, LUN) inàtheàdevice subtree, which is probably represented byàscsi_device andàscsi_disk directories, however there is noàscsi atàall inàhda subtree ofàaàmemory card device, foràexample, neither thereàis aàdevice subtree inàetherd!e42.0 ofàanàATA-over-Ethernet storage, yet they are included inàlsblk
output byÃÂ default.
What else may one check toÃÂ reliably filterÃÂ out dummy devices like ram15? Those are pre-created inÃÂ big numbers,ÃÂ having sizeÃÂ >ÃÂ 0 andÃÂ roÃÂ =ÃÂ 0, making itÃÂ hard toÃÂ distinguish them fromÃÂ regular disks. InÃÂ simple terms, theÃÂ result should ideally be identical toÃÂ lsblk -d -n -o NAME
â asàaàlast resort Iàwill just parse that output, but Iàjust wanted toàunderstand theàthings better myself.
linux block-device lsblk
Iàam trying toàimprove anàinstallation script withàinteractive selection ofàsource andàdestination disks. Itàcurrently gets theàlist ofàentries fromà/sys/block andàfiltersàit through sr[0-9]|sd[a-z]|hd[a-z]|scd[0-5] â effecively excluding other appropriate types ofàdevices. Myàidea was toàremove theàhardcoded mask andàapproach withàmore general method. Asàanàexample ofàsatisfying result, lsblk
works asÃÂ needed byÃÂ default, andÃÂ IÃÂ thought itÃÂ willÃÂ be that simple toÃÂ merely look into its sources toÃÂ copy theÃÂ logic, but that was not theÃÂ case asÃÂ it turnedÃÂ out.
According toÃÂ set_cxt()
function, theÃÂ device is excluded ifÃÂ it has size ofÃÂ zero, orÃÂ is non-SCSI, which inÃÂ turn is checked byÃÂ sysfs_blkdev_scsi_get_hctl()
â theàone Iàcouldànot get totally through: itàis supposed toàinspect something (namely, HCTL â Host, Channel, Target, LUN) inàtheàdevice subtree, which is probably represented byàscsi_device andàscsi_disk directories, however there is noàscsi atàall inàhda subtree ofàaàmemory card device, foràexample, neither thereàis aàdevice subtree inàetherd!e42.0 ofàanàATA-over-Ethernet storage, yet they are included inàlsblk
output byÃÂ default.
What else may one check toÃÂ reliably filterÃÂ out dummy devices like ram15? Those are pre-created inÃÂ big numbers,ÃÂ having sizeÃÂ >ÃÂ 0 andÃÂ roÃÂ =ÃÂ 0, making itÃÂ hard toÃÂ distinguish them fromÃÂ regular disks. InÃÂ simple terms, theÃÂ result should ideally be identical toÃÂ lsblk -d -n -o NAME
â asàaàlast resort Iàwill just parse that output, but Iàjust wanted toàunderstand theàthings better myself.
linux block-device lsblk
linux block-device lsblk
asked 15 mins ago
Anton Samsonov
1977
1977
add a comment |Â
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f475151%2freasonably-filtered-list-of-disks-block-devices%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password