Skip to content

Commit da16486

Browse files
adityageshCopilot
andauthored
Update lisa/tools/fstab.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent ae59029 commit da16486

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

lisa/tools/fstab.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,19 @@ def add_entry(
163163

164164
lsblk = self.node.tools[Lsblk]
165165
try:
166-
disk = lsblk.find_disk_by_mountpoint(mount_point, force_run=True)
167-
device = disk.device_name
166+
# Try to find partition first
167+
partition = lsblk.find_partition_by_mountpoint(mount_point, force_run=True)
168+
device = partition.device_name
168169
except LisaException:
169-
raise LisaException(
170-
f"Could not auto-detect device for mount point {mount_point}. "
171-
"Please provide device parameter."
172-
)
173-
170+
try:
171+
# Fall back to disk if partition not found
172+
disk = lsblk.find_disk_by_mountpoint(mount_point, force_run=True)
173+
device = disk.device_name
174+
except LisaException:
175+
raise LisaException(
176+
f"Could not auto-detect device for mount point {mount_point}. "
177+
"Please provide device parameter."
178+
)
174179
# Convert to UUID if requested
175180
device_str = device
176181
if use_uuid and device.startswith("/dev/"):

0 commit comments

Comments
 (0)