Ubuntu – How to know from which partition I had booted

bootgrub2

I have a machine which has multi-boot partitions. I have Ubuntu 14.04 on one partition, Ubuntu 15.04 on the second and Ubuntu 16.04 on a third one.
Is there a way to know, from the command line, from which partition I had booted, in order to find you on which partition is the /boot/grub/grub.cfg which was used for the boot process? I have /boot/grub/grub.cfg on each of the three partitions.

Best Answer

Once GRUB has handed off booting to the kernel, the kernel has no idea what started it, and /boot might not be the one which that GRUB used. You might check the access times of boot/grub/grub.cfg in each of the partitions to see which one was most recently accessed. That could tell you which partition's configuration file GRUB used.

stat -c %x /boot/grub/grub.cfg

If the access times aren't updated, you'll have to look for any differences in the kernel parameters used by the various GRUB configuration files. If you can change them, for example, add foo=1, foo=2, etc. to GRUB_CMDLINE_LINUX in each of these, run sudo update-grub2 and reboot, then you can check /proc/cmdline to see which of these values were used.

Related Question