New answers tagged

2 votes

How to programattically determine the device name/basename of the root partition?

All of the previously posted answers are wrong; until less than a year ago none of them would have worked on my system reliably.¹ Fundamentally the problem is you need the stable name of the device ...
Joshua's user avatar
  • 1,864
0 votes

How to programattically determine the device name/basename of the root partition?

Here's a simple way. I have only test this on my own box and your mount command may have a different output. boot_device=( $(mount | grep boot) ) if [[ $(echo "${boot_device[0]}" | grep -c ...
Wastrel's user avatar
  • 151
3 votes

How to programattically determine the device name/basename of the root partition?

Use df / to get the device for /. You can filter by column (--output=source) and row (tail -1), too: % df --output=source / | tail -1 /dev/mapper/sys-root
U. Windl's user avatar
  • 1,377
6 votes

How to programattically determine the device name/basename of the root partition?

Here's a Linux answer that doesn't rely on systemd (requires /sys mounted for lsblk use and also the jq command to parse results). Knowing that lsblk already includes all the logic to figure out the ...
A.B's user avatar
  • 35.4k
11 votes
Accepted

How to programattically determine the device name/basename of the root partition?

Mount point is controlled by systemd. You can list the systemd mount unit files through: systemctl list-units --type=mount --all sample output: -.mount loaded active ...
GAD3R's user avatar
  • 66.3k

Top 50 recent answers are included