Search code examples
linuximagebashisobootable

Creating a bootable .img file


I have problem with making .img file which I can make it bootable in USB.

I have Folder consist of many RPM files include linux distrobution and some bash script file and etc. the bash script install Linux server and two other software besides set MySQL and PHP. I want to make .img file from this folder so when I just make the .img file bootable to boot from USB, it is supposed to automatically install everything in the computer.

My problem is that I don't know how to make such .img file. is there any specific bash command that should I use? Could you help me to do this? Some clues and documentations to read and understand the process or any software to use, is really perfect. I really appreciate your help. Thank you.


Solution

  • The answer is:

    Don't do it.

    At least not in the way you're proposing.

    You are specifying a solution to a problem without really defining your requirements. How many standard packages? How many/how big are your additions? What are the gating items (e.g. need web server, need sshd)? Do you need just a few standard packages or several hundred?

    Linux distros, such as Redhat, CentOS, Fedora, Canonical/Ubuntu, Debian, expend considerable man-hours to get this right.

    So, you need to know what distro you're using. By mentioning rpms, you're probably using Redhat, CentOS, or Fedora. They have procedures to create "live" CDs (and/or USB sticks) and "full install" DVDs. But, this can be a big job, particularly if you're trying to graft on extra files that they don't know about.

    I highly recommend you use a standard installer for your distro [that has been heavily QA'ed]. Then, after installation and reboot, extract your additional packages from separate media or download from a server you control. The install media for your stuff could consist solely of a bash script that creates /etc/yum.repos.d/mystuff.repo and kicks off a yum install mystuff

    Also, if you were to do a plug-in-and-boot installer, do you want it just erase/repartition the main hard drive without asking (e.g. full automatic)? Or, do you want it to show the existing partitions, etc. like standard installers do?

    Getting back to requirements, why do you need to have a one shot installer?

    How many systems are you going to install this on? 5, 10, 100, 1000? Are they all in a server farm? You might be better off with PXE boot and boot/install from a central server.

    For example, Google has hundreds of thousands of servers [or more]. They have a need for this. But, they also have entire teams of developers devoted to the in-house methodologies that they use.

    How often are you going to have to do this for a given server? After the initial install, what is your plan/method for updates (e.g. yum, etc.)?

    By using the standard install, you're not responsible for QA of the entire system [standard system + your custom stuff], only your custom stuff.

    For example, Fedora discourages any "full install". They now prefer the "live boot" and install from Internet approach.

    One of the reasons is that the full install disk gets created [with lots of QA]. But, it's static. If a package has an update, the full install will install the old, unpatched version.

    I've had cases where I used it, then did yum update after reboot. The full install disk installed some things that became obsolete/incompatible within a week or two after release. They clashed with the update and things became broken. I had to intervene manually. This is much less likely to happen with a live boot install that will download the latest [and presumably most bug fixed] packages.

    On the fedoraproject.org site, you can find documentation on creating live CDs and/or USBs. They can even show you how to add some custom files. Other distro sites will have similar documentation.

    BTW, I have doing OS install kits since 1981, so all of the above comes from experience. I've created them from scratch and hacked up ones from distros.

    Can it be done? Sure. Do you really want to do it or should you want to do it? Well, maybe. Just be aware of what you're taking on in terms of maintenance.