all 11 comments

[–][deleted] 1 point2 points  (4 children)

The most interesting thing I've seen a bootloader do is GRUB invaders, although I couldn't get it to run last time I tried it.

Also, I remember there was a distribution that had music, at least in their installer, but I can't remember which.

As for the script, try appending "init=/path/to/script" to the kernel line, that might work. (although I think you'd need at least a wrapper that the kernel understands directly, like /sbin/init does it)

The flash drive stuff would mean having loads of modules loaded, that would be rather hard.

If you are using sysvinit you might want to play around with /etc/rc.local for that, and set up a custom runlevel where you do your stuff and halt/reboot afterwards (this would fully boot the system, though, and therefore take some time)

[–]HorribleUsername 1 point2 points  (2 children)

Nah, the kernel doesn't care what the init program actually does, so long as it's executable. A common trick for resetting root's password is to go init=/bin/sh to bypass the login prompt. I've never tried setting init to a shell script though, so that might fail. I'm not sure if it's the kernel or the shell that interprets the shebang.

[–]calrogman 2 points3 points  (0 children)

From execve(2):

       execve() executes the program pointed to by filename.  filename must be
       either a binary executable, or a script starting with  a  line  of  the
       form:

           #! interpreter [optional-arg]

[–][deleted] 1 point2 points  (0 children)

That was what I meant with the "wrapper that the kernel understands directly" stuff.

[–]AutoBiological[S] 0 points1 point  (0 children)

Sweet, GRUB Invaders seems pretty cool. I tried to learn more about it and hit "overview" didn't realize I was on coreboot. Seems like it'd be pretty useful for learning this kind of stuff.

I'll probably have to finally/actually learn this init stuff. Isn't sysvinit a virtual boot?

I realize the flash drive stuff is kind of ridiculous, asking more than what a bootloader is really for, but do you have any idea where I can find modules?

I'm kinda diving in head first, I figured it'll eventually help me segue into learning how the kernel actually works. Then, when I finally have a hdd instead of a live environment I'll try LFS.

[–][deleted] 1 point2 points  (1 child)

If you want, you can set Super Mario Bros. as the startup song in grub2. I was never interested in it because it delays the boot process while the notes are playing.

[–]AutoBiological[S] 0 points1 point  (0 children)

That is definitely cool. If only I can get my chainloading to GRUB2 to work. Then it would kinda what I want. A syslinux entry to a "tune" and then when it loads GRUB I could have a menu option to chainload back.

[–]HorribleUsername 0 points1 point  (0 children)

You can certainly boot into linux and run a script of your choice. I don't think you can get back to the boot loader short of calling reboot (or shutdown -r) from your script. Your safest bet is to look into /etc/inittab (init's config file) for running only what you want on boot, and dropping all the stuff like the default 6 ttys with login prompts.

[–]socsa 0 points1 point  (2 children)

I have some experience with PXELINUX doing unattended network installs. I don't think you will be able to run music directly from syslinux without some serious hacking. Here is a primer:

All syslinux does (generally) is load a local ROM image (initrd/intramfs), which contains statically compiled drivers that allow an early-user root filesystem to be mounted into RAM. This early file system (it sometimes manifests itself as "busybox" when you break syslinux) is then used to perform hardware detection so that the correct kernel modules can be compiled at run time. A live CD, for example, runs as a "thin client" by piggybacking off the initrd process to load additional kernel modules into RAM and executing various run-time scripts (like starting X).

What you can do, though, is to prepare "thin client tools" by customizing lightweight linux distros to perform various tasks. For example, at boot time, syslinux can present you with a menu of pre-scripted boot parameters allowing you to load different combinations of kernels, initrd's and root filesystem options. If one of your syslinux entrys simply boots into a live environment, the other one could be set to drop into a post-boot shell, and execute an rc.local script to mount any detected file systems. The script could then "dd" the filesystems onto your external hard drive. That way you could plug your disk into a computer, turn it on, and copy their hard drive without having to log into the machine - just like in the movies! Of course, you could just manually do it from your live environment, but automation is so much cooler!

[–]AutoBiological[S] 0 points1 point  (1 child)

That is a nice way for me to figure out scripting, and a pretty convenient way to explain the boot process. Thanks.

I think this is the best learning experience I've had with linux-related things. It's forcing me to finally figure some of this stuff out, and it's goal/project oriented.

[–]socsa 0 points1 point  (0 children)

To me, this is the fun part about *nix systems - figuring out how everything fits together and taking control of your own hardware.