On linux, you can’t count on the devices listed under /dev/sd*
or /dev/xvd*
, to have the same names or order. With the UUID (which is how /etc/fstab
usually specifies how to mount the root system device), the /dev
device name can be determined using the blkid
command and some hacky bash.
|
|
However, you might need to do something like start a Docker container with your main system device connected using docker run --device=...
, and so the following also works in this specific case looking for the device mounted at the local machine’s /
.
|
|
In addition to the device names and mount points, lsblk
provides the associated UUIDs as well.
|
|
You can even skip the bash var string slicing thing entirely with cut
:
|
|