This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Mr. Bateman's profile picture

LuaGRUB2 - An OS Bootloader for CC - Version 3.3

Started by Mr. Bateman, 23 June 2014 - 03:40 PM
Mr. Bateman #1
Posted 23 June 2014 - 05:40 PM
LuaGRUB2 v3.3

Screenshots

Spoiler


Legacy Bootscreen, only for Desktop




Bootmenu




(Outdated, but I will update these in the future sometime)



Created with the blessing of skwerlman with his original project of LuaGRUB (a GRand Unified Bootloader), which I have massacred carved into a finished masterpiece.

This program is a bootloader, which allows you to run multiple operating systems at once. The twist is that it's currently 100% compatible with all current OSes (They even run in a sandbox!). No need for any relative path voodoo. (Well, they should work, unless they do something I haven't predicted.)

New: You can now disable HTTP and Rednet, if you need to sandbox an OS. You can change these settings in the BIOS SETUP.

How to install an OS with LuaGRUB2

Use the "Install an OS via Pastebin" option for the easiest way to to do this. If you're feeling adventurous, manually copy the entire contents of the OS over to a folder you created inside the "/os" folder.

Note to OS devs: If you would like to integrate your OS with LuaGRUB2, but have no idea how to do it, don't be afraid to ask me because I would be glad to help.

How to install LuaGRUB2

If you have already installed an OS, backup or rename the file at "/startup". I cannot stress this enough. LuaGRUB2 requires this file to be able to let you select an OS, so when LuaGRUB2 installs, it will overwrite this file, possibly locking you out of using that operating system for good, requiring you to re-install it.
I'll also (re)address this issue in a later update.

Use this to run the installer (Desktop and Pocket):
pastebin run N3917AaN

Note for people updating from v1.x to v2.x: Run the installer again. The inbuilt updater has lost backwards compatibility to 1.x, so it won't do anything.

Certified OSes
All OSes and installers should be compatible now (Assuming you're using the inbuilt install option), but there's always the chance that it might not. Please report any that don't work.

Credits:
Spoiler

Oeed, for his Drawing.lua API and update framework
ElvishJerricco for his JSON API for the BIOS settings
And most importantly, skwerlman for the original code. Around half of it is his, and the most things I have been doing is patching his code and upgrading features (Infact, the only thing I haven't changed greatly is the bootloader GUI!)

Github: https://github.com/R...r64bit/LuaGRUB2

One final note: I am not liable for anything this program does, such as delete files, set your house on fire etc.

Please, post any suggestions, bug reports or comments!
AssossaGPB #2
Posted 23 June 2014 - 11:52 PM
Nice, I love it! The only feature that would be nice (but impossible as far as I know) is making booting to a disk optional.
I personally don't use oses because they seem restrictive and useless.
Mr. Bateman #3
Posted 24 June 2014 - 02:26 AM
Nice, I love it! The only feature that would be nice (but impossible as far as I know) is making booting to a disk optional.
I personally don't use oses because they seem restrictive and useless.
Done, just make sure that instead of putting their script at "/startup" on the disk, rename it to "/grubstartup".
I've also included an update feature in version 1.2.
AssossaGPB #4
Posted 24 June 2014 - 03:14 AM
Nice, I love it! The only feature that would be nice (but impossible as far as I know) is making booting to a disk optional.
I personally don't use oses because they seem restrictive and useless.
Done, just make sure that instead of putting their script at "/startup" on the disk, rename it to "/grubstartup".
I've also included an update feature in version 1.2.
Good job! Very cool!
Mr. Bateman #5
Posted 24 June 2014 - 06:05 AM
1.3 now has a compatibility fix for all operating systems and their respective installers. Just use the new option to install an OS, and it should work completely.

But this update breaks the previous updater; to fix, just run the update option twice. It's that simple.
oeed #6
Posted 24 June 2014 - 08:58 AM
This looks pretty nice. Also nice to see someone using my drawing API :D/>

One question, many OSs have a /System folder, what happens if I install, for example, OneOS and say this one: https://github.com/FlareHAX0R/deltaOS
Mr. Bateman #7
Posted 24 June 2014 - 09:19 AM
This looks pretty nice. Also nice to see someone using my drawing API :D/>

One question, many OSs have a /System folder, what happens if I install, for example, OneOS and say this one: https://github.com/FlareHAX0R/deltaOS

Right now, that would be the biggest issue, as it would clash, but there's a fix in the works. (The first priority of this program was to make each individual operating system compatible, and multiple would be the second priority) I would just have to use the same patching system I made for the OS installation, but trick the operating system that / is the same as /os/OneOS/.
Speaking of which, that would break backwards compatibility, but it won't break or delete much anyway.

I won't put it as first priority for the next update, but it will be patched soon. :)/>
Mr. Bateman #8
Posted 25 June 2014 - 12:47 AM
Version 2 is well on the way, as I've changed the way things operate. Instead of going straight to the boot menu, it will now default to the BIOS screen, where it will load the default OS with a specified delay which is set in the SETUP screen.This is almost finished, I just need to finish the sandboxing for each OS.


Mr. Bateman #9
Posted 25 June 2014 - 09:40 AM
LuaGRUB2 v2.0 alpha has been released!
Now, instead of going straight to the bulky bootmenu, it will go to a bootscreen which after a specified delay it will automatically boot a specified OS, which is all configurable in the now-implemented BIOS setup screen!

One question, many OSs have a /System folder, what happens if I install, for example, OneOS and say this one: https://github.com/FlareHAX0R/deltaOS
Sandboxing is now implemented, but some pesky files escape to the real root folder. I've only documented one so far, and it's the '/desktop/.desktop.settings' file (That's what I remember off the top of my head), but everything else behaves nicely. Fixing this is for another update.
skwerlman #10
Posted 27 June 2014 - 01:26 AM
This is much better than anything I had planned originally. Great to see my idea in a finished state! Keep up the good work!

EDIT: And now that I've looked through the a2 code, I wonder exactly how I even got mine to run… It's just so much cleaner now! Great work!
Edited on 26 June 2014 - 11:43 PM
Mr. Bateman #11
Posted 27 June 2014 - 06:25 AM
This is much better than anything I had planned originally. Great to see my idea in a finished state! Keep up the good work!

I'm not really sure this is a finished state, since i'm sure it can have more features crammed in somewhere (Not to mention some minor bugs). Is there any other features that you would like to see?
Mr. Bateman #12
Posted 27 June 2014 - 05:15 PM
Version 2.0 is now released (this time the full version) with enough bugs fixed that I feel comfortable calling it stable.
skwerlman #13
Posted 28 June 2014 - 01:56 AM
I'm not really sure this is a finished state, since i'm sure it can have more features crammed in somewhere (Not to mention some minor bugs). Is there any other features that you would like to see?
Perhaps some way to detect and move any OSs already installed on the machine, instead of simply overwriting them… (though that'd be kinda tedious, since each OS is different. Maybe just add a warning and continue prompt if /startup exists to the installer)
Also, maybe add support for downloading OSs from github (i.e. if you want to install a dev version of OneOS)? (The pastebin installer idea is really cool! Wish I'd thought of it, lol)
alexbuzzbee #14
Posted 04 August 2014 - 07:54 PM
Does /disk mount correctly inside the sandbox?
theeboris #15
Posted 04 August 2014 - 10:43 PM
You could add a option that overrides the rednet and modem or http api to enable or disable them.
Mr. Bateman #16
Posted 05 August 2014 - 01:26 AM
Does /disk mount correctly inside the sandbox?
I haven't had the chance to properly check it, so I will once I have the chance since one of the updates most likely broke it.
You could add a option that overrides the rednet and modem or http api to enable or disable them.
Seems neat, but I don't really see the use in that. I'll do it anyway, sounds like fun.
Mc Fow1er #17
Posted 12 August 2014 - 08:29 AM
Would you be as kind as to make the OS boot chooser work on pockets? As I use my pocket as my computer when I'm not at the physical terminal.
!!!!!!!!!!ExclaimationMark #18
Posted 13 August 2014 - 05:09 AM
Quick question: HOW ON EARTH DID YOU SANDBOX?
theeboris #19
Posted 13 August 2014 - 10:32 AM
Quick question: HOW ON EARTH DID YOU SANDBOX?

http://lua-users.org/wiki/SandBoxes

On this site is a nice explanation about sandbox in lua ;)/>
Look it it! :D/>
it's interesting ;)/>
Mr. Bateman #20
Posted 14 August 2014 - 04:43 AM
Thanks guys for all the input, I've updated the program and the OP to include what you've wanted. You can sandbox OSes from HTTP and Rednet now by changing this in the BIOS SETUP (Press 's' when the boot screen displays), and a skeleton version called PocketGRUB is available. More requests for features are more than welcome.

Quick question: HOW ON EARTH DID YOU SANDBOX?
I have overridden the fs functions with my own that prevent accessing anything outside it's own folder. The only other sandbox is HTTP and Rednet, but that is user-changeable.
!!!!!!!!!!ExclaimationMark #21
Posted 14 August 2014 - 07:13 AM
Thanks guys for all the input, I've updated the program and the OP to include what you've wanted. You can sandbox OSes from HTTP and Rednet now by changing this in the BIOS SETUP (Press 's' when the boot screen displays), and a skeleton version called PocketGRUB is available. More requests for features are more than welcome.

Quick question: HOW ON EARTH DID YOU SANDBOX?
I have overridden the fs functions with my own that prevent accessing anything outside it's own folder. The only other sandbox is HTTP and Rednet, but that is user-changeable.
so… you made custom fs apis but how do you overwrite it?

EDIT: PAGECLAIM :D/>
Edited on 14 August 2014 - 05:13 AM
willwac #22
Posted 22 August 2014 - 01:58 AM
What emulator are you using?

KilOS screwes up your boot loader.
This is the pastebin code: sP9WXu8n
Edited on 22 August 2014 - 12:06 AM
Mr. Bateman #23
Posted 22 August 2014 - 06:50 AM
What emulator are you using?

KilOS screwes up your boot loader.
This is the pastebin code: sP9WXu8n
The emulator is CCEmuRedux.
I'll have a look at that OS later and work on a patch.
Mc Fow1er #24
Posted 22 August 2014 - 03:24 PM
Hey could I possibly try to make the booter see weather or not your using a pocket and make it select the appropreate code? I think that it might work, even though I'm not that skilled in lua I have a strong it will still work. With some testing and debugging of course but I'm sure it will work.
Edited on 22 August 2014 - 01:28 PM
Mr. Bateman #25
Posted 23 August 2014 - 12:18 AM
Hey could I possibly try to make the booter see weather or not your using a pocket and make it select the appropreate code? I think that it might work, even though I'm not that skilled in lua I have a strong it will still work. With some testing and debugging of course but I'm sure it will work.
I could do it, but I'd need to increase the size of the program by at least 50%, since the pocket version uses different APIs and most of the code is changed. I'll have a go at it.
Mc Fow1er #26
Posted 23 August 2014 - 08:08 AM
Hey could I possibly try to make the booter see weather or not your using a pocket and make it select the appropreate code? I think that it might work, even though I'm not that skilled in lua I have a strong it will still work. With some testing and debugging of course but I'm sure it will work.
I could do it, but I'd need to increase the size of the program by at least 50%, since the pocket version uses different APIs and most of the code is changed. I'll have a go at it.
Well, by default the maximum amount of space your allowed to have on a computer is exactly 2MB down to the byte, I set mine to 5MB (5242880 bytes). My currently installed OSes only take up about 1.41MB of which OneOS(464KB) and DeltaOS(402KB) take up the most space, lbrub.sys and the startup how ever only take up about 52ish KB so it wouldn't really bother the user size wise. As most advanced programs take up about ~100 - 300 KB
Edited on 23 August 2014 - 06:17 AM
tenshae #27
Posted 28 August 2014 - 09:08 PM
I think this is too advanced looking for a bootloader. Most EFI are just text and "1. bleh, 2. blehbleh," options and stuff. Something simpler looking with the same amount of power would be more realistic.
EDIT: Wow, I really should have tried it out before posting. It's nice! I'm using this as the default bootloader for an OS i'm making. Is that alright? I have my own custom one I can switch back to if you have problems with this.
Edited on 29 August 2014 - 12:09 AM
Mr. Bateman #28
Posted 29 August 2014 - 11:19 PM
I think this is too advanced looking for a bootloader. Most EFI are just text and "1. bleh, 2. blehbleh," options and stuff. Something simpler looking with the same amount of power would be more realistic.
Right now in the update I'm making you get to choose the boot screen you want to appear, so that will basically fix any problems that anyone has like yourself, while allowing people to choose what they want.
EDIT: Wow, I really should have tried it out before posting. It's nice! I'm using this as the default bootloader for an OS i'm making. Is that alright? I have my own custom one I can switch back to if you have problems with this.
Sure, go right ahead. Just make sure they install the bootloader first just to make sure there aren't any issues.
Mr. Bateman #29
Posted 30 August 2014 - 12:16 AM
Version 3.0 changelog:
Merged desktop and pocket versions, added new bootscreen options, improved sandboxing and slight improvements all round.
Pretty much everything that has been suggested has been added.
tenshae #30
Posted 03 September 2014 - 06:04 AM
-snip-
Right now in the update I'm making you get to choose the boot screen you want to appear, so that will basically fix any problems that anyone has like yourself, while allowing people to choose what they want.
-snip-
Sure, go right ahead. Just make sure they install the bootloader first just to make sure there aren't any issues.
I think I've settled on a simpler, sandboxing startup file approach. But thanks for your help!
Mr. Bateman #31
Posted 26 September 2014 - 03:45 AM
What emulator are you using?

KilOS screwes up your boot loader.
This is the pastebin code: sP9WXu8n
I seem to have forgotten this, but I've addressed the issue that causes your installer to override the LUAGrub installation method. But, it breaks the ability to patch HTTP and Rednet, so I won't be releasing it via the stable channel until I fix these issues too. But, if you're still interested, I can link it to you to test it to make sure I haven't broken too many things.
Edited on 26 September 2014 - 01:45 AM
Mr. Bateman #32
Posted 11 October 2014 - 01:39 AM
No screenshots unfortunately, but I've been working on v3.1. I'm releasing a program soon that allows you to set a computer as a database over Rednet, so you can access it on a wired or wireless network. I'm still playing around with protocols and data saving methods, so it's still going to be a while away. It's going to address the issues above, and you will be able to boot using files from another computer, creating a sort of cloud network in CC.
Just a heads up since I haven't made an update for well over a month.
Mr. Bateman #33
Posted 12 October 2014 - 02:08 PM
Version 3.1.1 has been released, which primarily adds working capability to OneOS and KilOS, and also fixes the issue with http/rednet sandboxing.
FTP (cloud) bootloading is on its way.
LDDestroier #34
Posted 07 November 2014 - 02:32 PM
I absolutely love what you're doing! LuaGRUB2 seems to work well, except the operating system "Nova" (link) does not work when using 'install via pastebin'.
Mr. Bateman #35
Posted 09 November 2014 - 07:26 AM
I absolutely love what you're doing! LuaGRUB2 seems to work well, except the operating system "Nova" (link) does not work when using 'install via pastebin'.
We have discovered the error that causes the incompatibility, and a fix is in the works as we speak.

In other news, LuaGRUB2 has been updated to v3.2, which benefits both users and developers. It now handles errors properly, and can display what went wrong. Users can use this feature to report bugs, and developers can use it to help fix the bug, or even help developers of OSes that haven't been released yet to find out issues when the computer restarts too fast to find out what the error was.

This is an example error of Nova when you try to run it (which is incompatible as of writing), instead of just shutting down before it can be read.
Edited on 09 November 2014 - 06:26 AM
Mr. Bateman #36
Posted 10 November 2014 - 12:56 AM
Version 3.3 has been released, support for Nova has been added, and preparation for a developer API is in the works.
LDDestroier #37
Posted 16 March 2015 - 10:45 PM
It appears the nova beta isn't showing up on the menu, despite the '/os/Nova' folder existing. Please fix?
biggest yikes #38
Posted 18 March 2015 - 12:41 AM
It appears the nova beta isn't showing up on the menu, despite the '/os/Nova' folder existing. Please fix?
Chances are the "startup" file doesn't exist in that folder.
If an OS doesn't set itself to boot on startup, the OS won't be detected. (Or rather, detected but ignored)
EDIT: Just tried it, it's because the "Nova" folder is placed in the sandbox folder; so '/os/Nova/Nova'. Just extract the contents from '/os/Nova/Nova' to '/os/Nova' and it should boot.
EDIT 2: Ignore what I said with the first edit, you need the Nova folder, it's just the startup file isn't stored! Yes, you're right, fixing is needed.. Maybe an option to store the main file aswell? That would be nice.

Also, to the author, operating systems with "advanced shell" will crash if you type ".." because it tries to auto-complete the directory.. in which case it crashes because you can't access files outside the sandbox directory. Wonderful.

I also find a glitch where with fs.list and fs.isDir, fs.isDir executes based off the sandboxed directory, and fs.list is based off the main directory. So, when you type "ls" into the shell, it lists the contents of the root directory (it should list the contents of the sandboxed directory), and it lists all the directories (excluding rom, I think that's hardcoded) as files (because with fs.isDir if a file doesn't exist it's reported as a file), returning a wonky result:

Either fs.list should default to the sandboxed directory, or fs.isDir should execute based off the root, preferably the former (considering you can't cd to these directories, which is even wonkier)

Either way, this program is really cool and very well done, a few bugs patched around and I would use it on my main (main-main; I get the image in the screenshot says "Main", that's just Main for my session) computer.
Edited on 18 March 2015 - 12:00 AM
Mr. Bateman #39
Posted 18 March 2015 - 01:18 AM
Also, to the author, operating systems with "advanced shell" will crash if you type ".." because it tries to auto-complete the directory.. in which case it crashes because you can't access files outside the sandbox directory. Wonderful.



Either fs.list should default to the sandboxed directory, or fs.isDir should execute based off the root, preferably the former (considering you can't cd to these directories, which is even wonkier)
It sandboxes the filesystem by adding '/os/[os name]/' in front of paths. If everyone and everything used absolute paths 100% of the time, everything would be working perfectly. But that isn't the case, so we have some wonky mechanics going on here.

I've revised the sandbox enough times to get relative paths to (partially) work, but I think I can explain why '..' causes it to crash.
Simply put, it thinks '..' is a relative path since it doesn't have a '/' at the very start, so it tries to append '..' at the end, and since shell isn't involved to interpret that to go up a level, the sandbox freaks out and I'm not sure what happens after that.

I'll look into those fs.list issues, but I don't believe I'll get a fix out soon since I don't really have much time on me.
biggest yikes #40
Posted 18 March 2015 - 01:34 PM
I'll look into those fs.list issues, but I don't believe I'll get a fix out soon since I don't really have much time on me.
Okay, thanks anyway!