LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux From Scratch (https://www.linuxquestions.org/questions/linux-from-scratch-13/)
-   -   Building Custom Linux ISO from scratch (https://www.linuxquestions.org/questions/linux-from-scratch-13/building-custom-linux-iso-from-scratch-4175684864/)

athithanvijay 11-07-2020 09:15 AM

Building Custom Linux ISO from scratch
 
Hi All,
I have been trying to build ISO using LFS book. I am fine with the book. But I was not successful for after trying multiple attempts on different versions. Each time it fails on due to some error where I couldn't move further.

Just wanted to know is there any approach to build Linux custom ISO for x86_64 arch with my own modules and make it as bootable ISO to load it into VM.

I heard about Yocto and Buildroot. Any suggestions whether buildroot is simpler than LFS approach

Keith Hedger 11-07-2020 10:27 AM

This may not be quite what you want but it is a start:
https://github.com/KeithDHedger/LFSBootCD
Look at the file
Roll your own Linux Rescue or Setup CD.html

athithanvijay 11-07-2020 11:58 PM

Thanks for sharing the scripts. It looks much simpler and has got good documentation. let me go through it.

On the other hand I have come across about people where they talk about Yocto and build root as well. It seems these tools are used heavily in software industry. If learning curve is small I am wondering whether I can also try the same

athithanvijay 11-23-2020 06:35 AM

I have completed LFS 10 chapter 10 on Debian 10 VM successfully. Would appreciate your suggestions towards the next step. I would like to create iso and use that for set up CD so that I can install it in a new VM or PC.

As mentioned by @Keith Hedger,Roll your own Linux Rescue or Setup CD.html at https://github.com/KeithDHedger/LFSBootCD seems to be a solution for that as they achieved the same purpose using lfs. I am not sure whether I need to run both build_iso and build_diskimage files.

I have used instructions from lfs. All went fine. The other thing is I didn't create any partition for lfs as mentioned in the book. Now I have got file system(chapter 8), boot scripts(chapter 9),kernel-config-5.8.3, vmlinuz-5.8.3-lfs-10.0, and System.map-5.8.3(chapter 10) in /home/vijay/lfs directory.

Now I need to create an installer file which would create partitions in the target system and install kernel, file system then call the boot scripts. I also need to create iso file. Not sure which code will create initial ramdisk related code. Anything else is there in the process?

can someone guide me in simple steps on things to be done or providing some more references so that I learn more.

fiajm 11-28-2020 05:51 PM

I think your question is not clear (regardless you said you want for a VM) because an ISO is common term for the installer

Do you want a raw LFS image like a live iso, don't you?

First of all finish having a installed LFS system (functional, booteable, with its own partition) is mandatory. When you finish simply copy the partition with dd and try to put it in the VM.

Otherwise if you are looking for a LFS installer you could make a script that personalize the instalation (copying files and defining user, keyboardlayout, passwd...), you would need to manage the new loader and some firmware specific for the hardware and also the new partitions of the new system (Calamares may help)

I expect this help, if not, specify more concretely your problem.

athithanvijay 11-29-2020 09:27 AM

Thanks for your inputs. I can download Ubuntu ISO or Debian from their website and install it in a VM or PC. Can we do the same with our own distribution?

I try to build a custom Linux distribution with our own modules in an R&D setup. I follow guidelines from LFS 10 to build distribution.

we should be able to install it in a VM, PC or appliance depends on whether we use it for testing purposes, demo purposes or production use. We prefer X86_64 based on arch.

Now we need an installer for that as you mentioned(LFS installer). It seems I lack an understanding of these aspects such as installer, iso creation etc. Currently, I refer http://www.linuxfromscratch.org/hint...ot-cd_easy.txt to understand things that happen in the background.

I have tried to explain what I try to do in more concrete terms.

Let me try to explore further

colorpurple21859 11-29-2020 04:07 PM

If I read it correctly, the op wants to create an installation iso of a built lfs system, so when the iso is booted in a vm, one can run an installation script similar to other distributions install iso.

If, so the question should be broken down in to two parts,
how to create an iso from a pre-built lfs system?
How to create an installation script?


another source to create a live iso from an installed system:
https://www.linux-live.org/
How to create an iso has been answered, to give any additional help on creating iso you have will need to give details on where the making of the iso/booting iso is failing.

athithanvijay 11-29-2020 11:34 PM

You have put things in a perfect manner. I appreciate that clarity. Thanks for that.

As on Aug 2020, we had some old shell scripts that would automatically download sources, build them in LFS way(Linux kernel 3.x), create ISO with installation scripts as well.

Then we wanted higher version of Kernel and other packages, those scripts didn't help and we also didn't know what those scripts are doing in different stages. We know how to write programs but didn't know about underlying things. Hence I started this learning.

I learned the following things from LFS 10 and other sources.
  1. How to create tool chain for X86_64 target system
  2. How to build basic tools using tool chain
  3. how to create file system with directory structure
  4. How to build development packages such Perl,Python etc
  5. How to build application packages
  6. How to build kernel
  7. How to build default init scripts - /etc/rc.d etc
  8. How to update grub

As mentioned earlier I didn't create partition to build LFS system. Remaining things are how to create ISO and installation script. These things I have to try and understand so that in future I don't have to struggle again though we use other Linux distributions as well.

From LFS hints I see following steps
1. What do you need and what is the idea?
2. Configure & compile Kernel, add packages, other tweaks
3. Add bootloader.
4. Move /etc /var /root /home to /fake/needwrite and make symlinks
5. Create boot script which mounts the ramdisk
6. Tweaks for running with CD as root fs.
7. Create initial ramdisk
8. (Optional) compress /usr
9. Create initial ramdisk
9a. Burn the Boot CD
10. Reboot and enjoy

Let me try www.linux-live.org as well and get back.


All times are GMT -5. The time now is 01:33 PM.