Tiny Core Linux
Tiny Core Base => TCB Q&A Forum => Topic started by: innominate on November 21, 2012, 08:08:46 PM
-
Hi,
I think the way Tiny Core loads a file system into memory is complicating what would otherwise be a simple Linux question:
Is there a simple way to determine the device that Tiny Core booted from? I'm concerned about corner cases such as booting from a USB device and then another one being inserted before this query is run.
Thanks,
Dave
-
Hi innominate
This question has come up at least once before. As I recall, there is no way to tell which device you booted from.
Furthermore, I don't think this is unique to Tinycore. I think all Linuxs load the kernel into RAM and there is no way
to tell where it was loaded from.
-
The bootloader actually loads the kernel and optional initrd into RAM and then jumps to the entry point.
Therefore, there is no way for the linux kernel to know how it was loaded.
-
Before TC i was using SLAX. There inside the very first setup shell script I could identify bootup partition. Do not remember details :(
-
Sure you can identify a partition by label or uuid, but that is no proof that the kernel was loaded from that partition.
You can use a USB drive to boot one version of Linux, and the hard drive can contain a completely different version.
Just because you see a boot partition with a linux kernel in it, it does not mean
that that was the one that was loaded even if it is the same version.
-
In addition to above, I couldn't see any relevance of "device".
The device could possibly be disconnected as soon as the kernel is loaded, also there is no requirement that the kernel would have the capability to recognize it.
In case of optical or floppy disks there is no direct relation between device and medium, while in case of NIC, medium is unrelated to the device.
-
Gents, Thanks for the feedback.
In case you're curious, here's the kludge I arrived at:
Without a closed-form solution, I just used the UUID stashed in /proc/cmdline... basically I look around to see if a device with a partition labeled with that UUID is around and if so, figure that was most likely what I booted from.
Thanks again,
Dave
-
I'm a little late to the thread, but here is how I am determining the boot device...
BOOTDEV=`cat /etc/sysconfig/backup_device | cut -d "/" -f1`
I don't think that the above works if you use the norestore boot code.
Regards.
-
hi fmarinonj,
cat /etc/sysconfig/backup_device | cut -d "/" -f1
reports the backup_device and this needs not to be the boot_device.
in my configuration i boot with /dev/sdb1, but my backup is located on /dev/sdb2.
for that reason i really enjoy to use uuid in my boot-codes, uuid offers so many flexible configurations.
never mind, it stays exiting :)