LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-21-2016, 09:16 AM   #1
fred2014
Member
 
Registered: Mar 2015
Posts: 70

Rep: Reputation: Disabled
How can I boot a hard drive into my own non-os software?


When I say non-os I really mean just some executable code
of my own.

My scenario is:
x86_64 processor, standard hard drive.
I want to create a blank partition and boot into my executable on it.
I'm thinking to use grub as a boot loader but not sure what to
do with my code to make that executable -

Can anyone talk me through how to configure my code so grub
can find and run it? Must I use a header such as ELF - if so what is the minimum I must do - or can I do it as a simple executable without that?

also can I get grub onto a drive before there is any other OS on it?
Or can I get a simpler solution than grub in the first place?

Last edited by fred2014; 10-21-2016 at 09:18 AM.
 
Old 10-21-2016, 11:29 AM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,703

Rep: Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896
Yes, however without an OS you can not use standard libraries or functions etc. In 16 bit real mode you can use the built in BIOS functions for keyboard and writing to the screen. I would guess you do not have enough programming experience to be able to do this so tell us what are you trying to accomplish so we can offer you some different ideas.

http://www.codeproject.com/Articles/...bly-and-C-Part
 
Old 10-24-2016, 05:17 PM   #3
fred2014
Member
 
Registered: Mar 2015
Posts: 70

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
Yes, however without an OS you can not use standard libraries or functions etc. In 16 bit real mode you can use the built in BIOS functions for keyboard and writing to the screen. I would guess you do not have enough programming experience to be able to do this so tell us what are you trying to accomplish so we can offer you some different ideas.

http://www.codeproject.com/Articles/...bly-and-C-Part

Thanks michael

All I was trying to do was exactly as described.

I've been around the block a few times. This is just something I've never done.
It turns out reading the grub docs had persuaded me this was a lot more complicated
than it is but thanks again for the suggestions anyway.
 
Old 10-25-2016, 03:27 AM   #4
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
You just need to have executable code which matches the arch of the machine. The first bits of bootloader code are an example of that.
 
Old 10-25-2016, 03:56 AM   #5
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,453

Rep: Reputation: 447Reputation: 447Reputation: 447Reputation: 447Reputation: 447
Here is a library where you can make a C++ program that runs without any OS. And you can use standard library functions:


http://www.includeos.org/
 
Old 10-25-2016, 06:18 AM   #6
fred2014
Member
 
Registered: Mar 2015
Posts: 70

Original Poster
Rep: Reputation: Disabled
[QUOTE=Guttorm;5622619]Here is a library where you can make a C++ program that runs without any OS. And you can use standard library functions:


That web page has the word "cloud" on it. At which point I stop reading.

Again thanks - but I'm all sorted now anyway.
A dozen lines of fasm and it's done.
 
Old 10-25-2016, 02:32 PM   #7
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
Personally, what I would do is to strip Linux to its very-bare minimum, customized for exactly your hardware, and use it as the underlayment of your application.

There are also various non-Linux OSes that are specifically targeted at device-control applications . . .

In short, if it were me, I would not "blur the line" between "your application" and "the system-control program, whatever it may be." I would not merge this concern into "your application."

If you wish it to be, the Linux kernel can be "pretty damned small."

Last edited by sundialsvcs; 10-25-2016 at 02:33 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
I want to copy my hard drive to a larger hard drive and boot from the new drive. lpmorgan1 Ubuntu 8 09-07-2009 11:26 PM
Formated hard drive, runing ubuntu cd cant install, get fedora 11 to boot from hard d IanHarper Linux - Desktop 9 08-10-2009 10:09 PM
Ubuntu: Installed to external hard drive; boot to primary hard drive gives error 22 dcorb62 Linux - General 7 09-04-2007 11:28 PM
Installed GRUB on 3rd hard drive, how do I boot 1st drive? jesusphreak Linux - Newbie 4 04-06-2005 09:34 AM
boot from floppy drive then insall linux redhat9 from HARD DRIVE Shiraz Ahmed Linux - Software 0 08-23-2004 05:11 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:08 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration