"""
Return the dev node of the root disk.
"""
- with open("/etc/mtab", "r") as f:
- dev, mountpoint, fs, rest = f.readline().split(" ", 3)
- if mountpoint == "/" and not fs == "rootfs":
- # Cut off /dev
- dev = dev[5:]
+ with open("/proc/mounts", "r") as f:
+ for line in f.readlines():
+ # Skip empty lines
+ if not line:
+ continue
+
+ dev, mountpoint, fs, rest = line.split(" ", 3)
+ if mountpoint == "/" and not fs == "rootfs":
+ # Cut off /dev
+ dev = dev[5:]
- # Handle raids and MMC cards like (mmcblk0p3).
- if dev[-2] == "p":
- return dev[:-2]
+ # Handle raids and MMC cards like (mmcblk0p3).
+ if dev[-2] == "p":
+ return dev[:-2]
- # Otherwise cut off all digits at end of string
- while dev[-1] in string.digits:
- dev = dev[:-1]
+ # Otherwise cut off all digits at end of string
+ while dev[-1] in string.digits:
+ dev = dev[:-1]
- return dev
+ return dev
@property
def root_size(self):