def find_rootfs(conn, disk_root):
rootfs = conn.inspect_os()<EOL>if not rootfs or len(rootfs) > <NUM_LIT:1>:<EOL><INDENT>filesystems = conn.list_filesystems()<EOL>if disk_root in filesystems:<EOL><INDENT>rootfs = [disk_root]<EOL><DEDENT>else:<EOL><INDENT>rootfs = [fs for fs in filesystems.keys() if disk_root in fs]<EOL>if not rootfs:<EOL><INDENT>raise GuestFSError(<EOL>'<STR_LIT>'.format(<EOL>disk_root, str(filesystems)<EOL>)<EOL>)<EOL><DEDENT><DEDENT><DEDENT>return sorted(rootfs)[<NUM_LIT:0>]<EOL>
Find the image's device root filesystem, and return its path.

1. Use :func:`guestfs.GuestFS.inspect_os` method. If it returns more than
    one root filesystem or None, try:
2. Find an exact match of `disk_root` from
    :func:`guestfs.GuestFS.list_filesystems`, if none is found, try:
3. Return the device that has the substring `disk_root` contained in it,
    from the output of :func:`guestfs.GuestFS.list_filesystems`.

Args:
    conn(guestfs.GuestFS): Open GuestFS handle.
    disk_root(str): Root device to search for. Note that by default, if
        guestfs can deduce the filesystem, it will not be used.

Returns:
    str: root device path

Raises:
    :exc:`GuestFSError` if no root filesystem was found