I am programming a OS based on Linux but I want to "re-invent the wheel" in this OS just as an achievement. I have been told that Linux can be installed on a PC without any packages (obviously causing a "Kernel panic") but I couldn't find any tutorial. I just need to know how to start with an empty partition and get it to the point where it can boot (and load the init file which I will provide). I don't want to use any packages since I will be executing a program on boot.
-
1Linux is a kernel. That would be nothing, but a kernel, and a boot-loader. Just install your fav distro, and then delete everything off the partition except vmlinuz file. en.wikipedia.org/wiki/Vmlinux . If you want a basic environment to boot into then keep the intird file tool. en.wikipedia.org/wiki/Initrd . The initrd will likely have busybox installed, so you run some basic commands, but you'll need to edit it boot run busybox instead of performing the handoff– Robin HoodCommented Sep 28, 2014 at 21:29
-
@RobinHood I was thinking of executing a native application that would take over once the kernel has booted. I am going to use my program as init therefore no packages are required– DividedByZeroCommented Sep 28, 2014 at 22:54
-
@RobinHood when you say "delete everything off the partition" do you mean the /boot files too? How will the kernel boot if there are no boot files? Btw I normally have only one partition on my pc and /boot, /sbin and /pretty-much-everything is on the same partition– DividedByZeroCommented Sep 28, 2014 at 23:05
Add a comment
|
2 Answers
Have you tried using LSF?, you can have a set of packages that you may to use or not: http://www.linuxfromscratch.org/lfs/
-
I don't want any packages. I want just the kernel to execute my program. For that I need to provide the kernel with my file as init and obviously the kernel must be able to boot and load init. That's all I want Commented Sep 28, 2014 at 23:00
Assuming a BIOS (not EFI) x86 system. Some architectures like ARM require platform data or device tree info.
- Build a kernel.
- Make a single boot filesystem, and mark as bootable.
- Install the kernel into the boot filesystem.
- Install a bootloader.
- Configure the bootloader to boot your kernel, no arguments necessary, no init{ramfs,rd}.
- Boot.
- Read
Documentation/initrd.txt
for how to construct an initramfs, if you want to do initramfs booting, else create a new partition and format it (root filesystem). Ignore the ramdisk part per se, and use the CPIO image part instead. - Build busybox, with at least a shell configured.
- Install busybox into the initramfs or the root filesystem. For the former, configure the bootloader to use the initramfs/tell the Linux kernel. For the latter, symlink /bin/sh to busybox, and add the init=/bin/sh argument to the kernel command line.
- Expand to your fancy, either with LFS, or other.
- Read
boot(7)
if you want an overview of the traditional (likely not what you're using in many modern distros) Linux boot process.
-
Can you please explain the purpose of busybox. And what do you mean by a "single boot file system"? Also, without booting into the system how can yo uinatall a bootloader Commented Sep 28, 2014 at 22:47
-
busybox is a single binary providing many of the common UNIX utilities. It's easier than trying to use any other coreutils package. By "single boot filesystem", remove the "boot". I just meant to create a single partition on some device, and to format it with some filesystem that your bootloader can understand. As for the bootloader question, aren't you building the system from an existing system? Installing a bootloader here is just writing 440 bytes to the MBR, setting the boot flag on some partition, and moving a few files into the newly created filesystem. There's nothing magical here.– pilonaCommented Sep 29, 2014 at 3:56
-
Okay thanks! It's about time I read about boot loaders :P Commented Sep 29, 2014 at 9:26