I'm building my own Operating system with Linux. I use the kernel and some compoments from GNU.

I compiled the kernel and installed bash with readline and busybox. After it works fine. I wanted to install nano, gcc...

When I run these applications it gives me 'Segmentation failed (core dumped)'. I installed gdb (GNU debugger) to see what is wrong. Also gdb doesn't start and gives me the error:

Segmentation failed (core dumped)

The problem was that I have the /include and /share not copied to /usr And by some libraries more than 1 library version. There was no stacktrace or something like that to paste it here in this question.

Steps that I did:

  1. Download grub and install it with the grub-installer on my usb disk
  2. Download Linux kernel 4.17.1
  3. Configure Linux with make menuconfig
  4. Compiled with make and make modules
  5. Copied bzimage and executable to my usb (/boot)
  6. Also copied bzimage to /tmp, I unpacked it with gzip, dd
  7. Copied the contents from the bzimage of /lib, /usr to my usb
  8. Installed gclib, ncurses, readline and bash 4.4
  9. Installed busybox
  10. Restarted computer with my new operating system, it works fine. I can execute the busy commands (mkdir, rmdir, adduser...)
  11. Installed nano and gcc compiler
  12. Restarted computer, try to run nano and it gives me:

    Segmentation failed (core dumped)
  13. Installed gdb to it and reboot. It gives me also:

    Segmentation failed (core dumped)

How i installed busybox

I downloaded the binary from the busybox site. Then you paste it in /bin Don't forget to do busybox --install when you run your new operatins system to install the commands.

But you can also build it from source with make menuconfig, make and make install

How I installed grub

I downloaded the source from GNU site and compiled it with make and make install. In utils you can see the grub-install. With that you can install grub on your disk. https://www.gnu.org/software/grub/manual/grub/html_node/Installing-GRUB-using-grub_002dinstall.html

How I installed kernel

First you need to config with make menuconfig. Then you need to build with make, make modules and make modules_install If you want to copied the installed bzimage and exe to you current linux destribution you do sudo make install I copied the files to my usb. (bzimage and linux executable)

How i installed gclib

You need to download gclib from gnu and configure it with ./configure --prefix=<usb_directory> Then you need to build it with make and make install Copy the /include and /share to /usr/share and /usr/include

How i installed nano

You need to download nano from gnu and configure it with ./configure --prefix=<usb_directory>/usr Then you need to build it with makeand make install If there is a /usr/etc copy it to /etc

How I installed ncurses

The same as gclib


I found the solution. I copied /include and /share to /usr/include and /usr/share. Make sure that you do not have more than 1 library version.

I can not post my answer, so I paste it here.

@JiggyNaga: No fatal errors.

telecoM: If you unpack initramfs you can see the libraries that you may need. So you don't have to install them.

  • no upx involved? – Rui F Ribeiro Jul 5 '18 at 20:07
  • 1
    What is upx? Can you explain it? Thanks – SmileDeveloper Jul 6 '18 at 9:20
  • 1
    It's highly likely you have a mismatch between the versions of the libraries against which you compiled your programs and the versions of the libraries actually installed. – roaima Jul 6 '18 at 9:23
  • Please add your solution as an Answer. Not as part of the Question. You can then even accept your own answer (and get the points...) – roaima Jul 7 '18 at 16:08
  • Just delete this question. I have the solution. If I must explain how to build a Linux distribution... That are 3 pages of instructions. – SmileDeveloper Jul 8 '18 at 8:09