0

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.

3
  • 1
    Linux 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 Hood
    Commented 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 Commented 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 Commented Sep 28, 2014 at 23:05

2 Answers 2

1

Have you tried using LSF?, you can have a set of packages that you may to use or not: http://www.linuxfromscratch.org/lfs/

1
  • 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
1

Assuming a BIOS (not EFI) x86 system. Some architectures like ARM require platform data or device tree info.

  1. Build a kernel.
  2. Make a single boot filesystem, and mark as bootable.
  3. Install the kernel into the boot filesystem.
  4. Install a bootloader.
  5. Configure the bootloader to boot your kernel, no arguments necessary, no init{ramfs,rd}.
  6. Boot.
  7. 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.
  8. Build busybox, with at least a shell configured.
  9. 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.
  10. Expand to your fancy, either with LFS, or other.
  11. Read boot(7) if you want an overview of the traditional (likely not what you're using in many modern distros) Linux boot process.
3
  • 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.
    – pilona
    Commented 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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .