rootdev vs. rootdev -s

44 views
Skip to first unread message

Luigi Semenzato

unread,
Jun 7, 2023, 2:33:29 PM6/7/23
to ChromiumOS Development
Why does rootdev return /dev/sda when booting from USB, but /dev/dm-0 when booting from the internal SDD?

Nicholas Bishop

unread,
Jun 7, 2023, 4:40:16 PM6/7/23
to Luigi Semenzato, ChromiumOS Development
/dev/dm-0 is a virtual device used when rootfs verification is
enabled. In that case, `rootdev -s` will show the path of the
underlying block device, e.g. `/dev/sda3` or similar.

On Wed, Jun 7, 2023 at 2:33 PM 'Luigi Semenzato' via ChromiumOS
Development <chromiu...@chromium.org> wrote:
>
> Why does rootdev return /dev/sda when booting from USB, but /dev/dm-0 when booting from the internal SDD?
>
> --
> --
> Chromium OS Developers mailing list: chromiu...@chromium.org
> View archives, change email options, or unsubscribe:
> https://groups.google.com/a/chromium.org/group/chromium-os-dev
> ---
> To unsubscribe from this group and stop receiving emails from it, send an email to chromium-os-d...@chromium.org.

Luigi Semenzato

unread,
Jun 7, 2023, 5:20:29 PM6/7/23
to Nicholas Bishop, ChromiumOS Development
But, as I said, plain "rootdev" returns dm-0 when booting from nvme0n1, but sda3 when booting from sda.  Why doesn't it return nvme0n1p3 in the first case?

This is in developer mode and without rootfs verification.

I am guessing that when booting from USB, the entire rootfs verification is bypassed, but when booting from internal disk, the virtual device is set up, but then the verification code runs a different path, which just passes the blocks through.
 

Sarthak Kukreti

unread,
Jun 7, 2023, 5:49:39 PM6/7/23
to Luigi Semenzato, Nicholas Bishop, ChromiumOS Development
Rootdev isn't super complicated, it does two things:
1) Look at the device '/' resides on.
2) If '-s' is supplied, iterate through the underlying devices till
you reach a storage device that's not loop/dm.

For the cases you mentioned:
1) USB boot: if the image has rootfs verification disabled, then the
root filesystem is directly mounted from the USB disk without a
dm-verity layer. Therefore, `rootdev` and `rootdev -s` will both give
you /dev/sda3 (Another way to validate this is to look at the output
of `mount` to see what is mounted at '/')
2) Internal Storage Boot: From the looks of it, rootfs verification
isn't disabled on the NVMe device you are booting from (try out
'/usr/share/vboot/bin/make_dev_ssd.sh --remove_rootfs_verification to
see something similar to above). In this case, rootdev reports that
dm-0 is mounted at '/' and `rootdev -s` iterates to the underlying
partition and reports that (/dev/sda3).

Best
Sarthak

Ref: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/third_party/rootdev/rootdev.c
for the gory details.

On Wed, Jun 7, 2023 at 2:20 PM 'Luigi Semenzato' via ChromiumOS

Luigi Semenzato

unread,
Jun 7, 2023, 5:57:06 PM6/7/23
to Sarthak Kukreti, Nicholas Bishop, ChromiumOS Development
Indeed that explains the difference.  Thank you!
Reply all
Reply to author
Forward
0 new messages