Hi,
Is there a way for my kernel to know which device (HDD/CD/floppy) it's booting from? I'm using GRUB as my kernel's bootloader by the way.
How to know which device my kernel is booting from?
How to know which device my kernel is booting from?
Just a procrastinating uni student doing stupid things (or not doing them at all)...
SysX: https://github.com/itsmevjnk/sysx.git
SysX: https://github.com/itsmevjnk/sysx.git
Re: How to know which device my kernel is booting from?
"boot_device" in the multiboot information structure.
https://www.gnu.org/software/grub/manua ... cification
https://www.gnu.org/software/grub/manua ... cification
Re: How to know which device my kernel is booting from?
"But what about custom bootloader?"?
At start BIOS gives you boot drive ID in DL register. This ID may be used in int 13 (AH = 48h) to get PCI path of drive (http://www.ctyme.com/intr/rb-0715.htm).
At start BIOS gives you boot drive ID in DL register. This ID may be used in int 13 (AH = 48h) to get PCI path of drive (http://www.ctyme.com/intr/rb-0715.htm).
- lkurusa
- Member
- Posts: 42
- Joined: Wed Aug 08, 2012 6:39 am
- Libera.chat IRC: Levex
- Location: New York, NY
- Contact:
Re: How to know which device my kernel is booting from?
I think an important question here, is why do you care?
Cheers,
Lev
Lev
Re: How to know which device my kernel is booting from?
That is a good question. Let me give you a few.lkurusa wrote:I think an important question here, is why do you care?
1) How do you know which partition to make as the active partition?
2) What if you have more than one partition with similar bootable Operating Systems?
3) If you boot to a TUI prompt, what partition do you place in the prompt? (i.e.: A DOS like would be C:\>)
4) What partition do you use to continue loading kernel and driver files from?
Here is an example. Let's say that you have multiple partitions / multiple drives with multiple partitions each. How do you know which one of the partitions you booted from so that you know which partition to continue loading the kernel files from? This is an issue with lots of scenarios.
What if I have two drives with similar operating systems. How do I know which drive I booted from so that I load the files from the correct operating system?
I put a signature in the boot sector of the partition and then my kernel, during partition enumeration, checks for this signature, along with a few other checks, then "marks" a partition as the booted from partition. Other operating systems do this as well.
Ben
- http://www.fysnet.net/osdesign_book_series.htm
- lkurusa
- Member
- Posts: 42
- Joined: Wed Aug 08, 2012 6:39 am
- Libera.chat IRC: Levex
- Location: New York, NY
- Contact:
Re: How to know which device my kernel is booting from?
Normally, this information is stored when the OS is formally "installed". It can be in /etc/fstab, in the boot configuration, or somewhere else.BenLunt wrote:That is a good question. Let me give you a few.lkurusa wrote:I think an important question here, is why do you care?
1) How do you know which partition to make as the active partition?
An option would what Linux does, root= kernel command line argument that uniquely identifies the root partition (via UUID or slot#). Now, of course this gives the task of determining the root partition to the root user or the bootloader. Your bootloader could then ask the firmware and just pass that on to the kernel.
I think my answer above answers all these, too.BenLunt wrote: 2) What if you have more than one partition with similar bootable Operating Systems?
3) If you boot to a TUI prompt, what partition do you place in the prompt? (i.e.: A DOS like would be C:\>)
4) What partition do you use to continue loading kernel and driver files from?
Here is an example. Let's say that you have multiple partitions / multiple drives with multiple partitions each. How do you know which one of the partitions you booted from so that you know which partition to continue loading the kernel files from? This is an issue with lots of scenarios.
What if I have two drives with similar operating systems. How do I know which drive I booted from so that I load the files from the correct operating system?
I put a signature in the boot sector of the partition and then my kernel, during partition enumeration, checks for this signature, along with a few other checks, then "marks" a partition as the booted from partition. Other operating systems do this as well.
Cheers,
Lev
Lev