Skip to content

Commit

Permalink
Exclude loop and network devices
Browse files Browse the repository at this point in the history
  • Loading branch information
lvps committed Oct 23, 2024
1 parent 25f00b2 commit 8206249
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions basilico.py
Original file line number Diff line number Diff line change
Expand Up @@ -1421,10 +1421,10 @@ def find_mounts(el: dict):

def get_disks_linux(path: Optional[str] = None) -> list:
# Name is required, otherwise the tree is flattened
# To filter out ODDs and tape drives: --exclude 9,11
# To filter out loop devices, ODDs, tape drives and network devices: --exclude 7,9,11,43
# See: https://www.kernel.org/doc/Documentation/admin-guide/devices.txt
# Also: https://unix.stackexchange.com/a/610634
output = subprocess.getoutput(f"lsblk --exclude 9,11 -b -o NAME,PATH,VENDOR,MODEL,SERIAL,HOTPLUG,ROTA,MOUNTPOINT,SIZE -J {path if path else ''}")
output = subprocess.getoutput(f"lsblk --exclude 7,9,11,43 -b -o NAME,PATH,VENDOR,MODEL,SERIAL,HOTPLUG,ROTA,MOUNTPOINT,SIZE -J {path if path else ''}")
jsonized = json.loads(output)
if "blockdevices" in jsonized:
result = jsonized["blockdevices"]
Expand Down

0 comments on commit 8206249

Please sign in to comment.