Slashdot is powered by your submissions, so send in your scoop

 



Forgot your password?
typodupeerror
×
Data Storage Software Linux

Automatically Installing Linux from Bootable CD? 85

phorm asks: "While there are newer many distributions of linux that come bootable from CD, I've found that some are a bit difficult to customize and wonder how hard it would be to create my own. Currently we are looking at replacing some of our Windows desktops at work with Linux test-machines - and it would be nice to make the installation process as simple as possible. How hard would it be to create a bootable CD that would automagically install Linux onto the first detected hard-drive? How would you go about 'imaging' an existing machine to use as the base? I suppose that in many cases a tar-gzip of the entire OS would work, provided you could partition the drive correctly, recreate some important handles as in /proc, and run lilo/grub to install a boot loader. Does anyone here have experience with this? I know morphix/knoppix make nice bootable distros but what I really want is a basic Linux bootCD which installs a preconfigured version of the OS of my choice."
This discussion has been archived. No new comments can be posted.

Automatically Installing Linux from Bootable CD?

Comments Filter:
  • Knoppix (Score:4, Informative)

    by lortho ( 700090 ) on Friday January 09, 2004 @02:21AM (#7925546)
    The Knoppix [knoppix.org] live CD distro comes with a script for installing to the hard drive that works pretty well, just go to a root console after booting off the cd and type 'knx-hdinstall'. It probably wouldn't be too hard to customize the disk so that it does this automatically.
  • Ghost (Score:3, Informative)

    by Webmoth ( 75878 ) on Friday January 09, 2004 @02:21AM (#7925550) Homepage
    Symantec/Norton Ghost works very well for mirroring drives.

    However, you may have issues when it comes to differing hardare in different machines, and all your boxes will have the same hostname and IP address.
  • Gentoo can do it (Score:4, Informative)

    by Apreche ( 239272 ) on Friday January 09, 2004 @02:25AM (#7925573) Homepage Journal
    The gentoo livecd is high quality. And on any gentoo system you can emerge the tools used to create the livecds. Create your own custom livecd and go at it. Of course knoppix and such can do it, but the knoppix installer is very primitive and set in stone. By making a custom gentoo livecd you can actually make the system the way you want it to be.
  • by MrResistor ( 120588 ) <.peterahoff. .at. .gmail.com.> on Friday January 09, 2004 @02:25AM (#7925575) Homepage
    I found this [suse.com] with a simple search of Suse's support database. I just skimmed it, but it seems to lay out the whole procedure. I'm sure your distro of choice has a similar page. While I haven't tried this myself, I know people have been doing it with Red Hat and Mandrake for years.

  • Kickstart (Score:5, Informative)

    by baywulf ( 214371 ) on Friday January 09, 2004 @02:26AM (#7925576)
    You can do this with Redhat Linux (or Fedora.) It is basically a utility called kickstart that creates a configuration file that you can place onto the cd or a floppy. Then when the install takes place, it will automatically make choices based on the configuration file.
  • Don't use CDs (Score:5, Informative)

    by hbackert ( 45117 ) on Friday January 09, 2004 @02:45AM (#7925687) Homepage

    If possible, use the network. If those PCs have PXE to boot from, that is by far the easiest and customizeable way to install lots of Linux machines. Using RedHat's kickstart, I can install a basic server in about 5 minutes, plus 5 minutes to configure everything for that machine. It's thus faster than CD and easier and easy to customize. No need to burn a new CD.

  • by dougmc ( 70836 ) <dougmc+slashdot@frenzied.us> on Friday January 09, 2004 @02:53AM (#7925733) Homepage
    Install a system, configure it the way you want it. Don't install too much stuff, because it needs to fit on a CD.

    Once done, boot into single user mode.

    tar everything up to *another* disk (mounted here under /mnt) --

    cd /
    tar --one-file-system --sparse -zcvvvf /mnt/disk.tar.gz /

    If that file doesn't fit on a CD with at least 10 MB to spare, remove some stuff and try again. export GZIP=9 might help a bit too.

    Get a bootable linux floppy disk image. It doesn't really matter which one, but it does need to have a real filesystem on it (not just a kernel.) Your typical rescue disk will probably work well.

    Make a script to install. It'll be something like this --

    #!/bin/sh -e
    # zero the partition table
    dd if=/dev/zero of=/dev/hda bs=1024 count=10
    sync
    sleep 3
    sync
    # create a 1024mb / partition
    printf "n\np\n1\n+1024m\nw\n" | fdisk /dev/hda
    # create the filesystem
    mke2fs -j /dev/hda1
    # mount it
    mkdir /m /n
    mount /dev/scd0 /cd
    mount /dev/hda /m
    # dump your tar.gz file to the new fs
    cd /m
    tar --totals --preserve --sparse -zxvf /cd/disk.tar.gz
    cd /
    # (re)install the bootloader
    echo "/sbin/grub-install /dev/hda" | chroot /m /bin/sh
    # clean up
    umount /m
    umount /cd
    echo "Ok. Time to reboot!"
    and then this script will replace /sbin/init on your boot floppy. Of course, if your floppy starts something other than /sbin/init, you'll need to replace that.

    Then you'll burn a cd that contains that floppy image as the el Torito boot image, and has that file.tar.gz in the root of the file system.

    This is really rough, and will only work properly with rather specific hardware, but it may get you started. Making a proper distribution is a lot more work than this -- I only spent a few minutes typing this out.

    I have not tested any of this. In particular, the command to do the fdisking probably has issues -- for example, most boot floppies don't have printf by default (you'll need to add it, or a script to just print all the fdisk commands), and I probably got the order of some stuff in the printf statement wrong (it's a string of commands for fdisk.) And of course it'll happily trash whatever is on your disk with no warning. (Installing lilo rather than grub can be done with a similar procedure if needed.)

    But if you're looking for a really quick and dirty way to install lots of identical machines, this may get you started. This is NOT a procedure for anybody who doesn't really understand what all this stuff does and the possible problems -- I just provided it as a first stab at a possible solution under some limited conditions. Note that the general idea can apply to other OSs as well -- I even remember once making a setup that installed OS/2 (off a network share) just like this -- long before Ghost was a gleam in Norton's (or whomever's) eye.

    In any event, I'd suggest seeing what Knoppix has to offer -- if, like another poster suggested, they have a script to just install to a disk, that would probably be far better than this hack.

  • by dougmc ( 70836 ) <dougmc+slashdot@frenzied.us> on Friday January 09, 2004 @02:58AM (#7925764) Homepage
    Already, one typo --
    mount /dev/hda /m
    That would need to mount /dev/hda1 /m, of course. There's probably more typos.

    No, I don't really expect anybody to actually do this -- there's already much better stuff out there. But several years ago, before all those smart people solved the problem elegantly for you, this was one way that people would solve problems like this -- with a nasty `one off'.

  • Try systemimager (Score:4, Informative)

    by chriskenrick ( 89693 ) on Friday January 09, 2004 @02:59AM (#7925770)
    If you're looking for a "Ghost" like solution, try SystemImager [systemimager.org]. Should work well if your hardware is fairly standardised.
  • Use Kickstart. (Score:4, Informative)

    by Thalin ( 130318 ) on Friday January 09, 2004 @02:59AM (#7925773) Homepage
    As a couple other people have said, Kickstart is probably your best option. I work at NCSU and we have a bunch of linux machines. When we need to upgrade or reinstall, we just take a boot cd, pop it in, and let it go. It grabs all the configuration and install files off our kickstart server and goes to town. When it's done, the system reboots and sits at a login screen, no other config required. It's a beautiful thing.

  • Catalyst (Score:4, Informative)

    by Shwag ( 20142 ) on Friday January 09, 2004 @03:19AM (#7925856)
    The new gentoo image creation program, called catalyst [gentoo.org], does exactly what you are looking for.
  • by severett ( 38602 ) on Friday January 09, 2004 @03:31AM (#7925908) Homepage
    Slackware's simple package and configuration setup made this fairly painless.

    What I did was modify the initrd ram disk to change the custom setup files. I created my own which partitioned the drive, formatted, and started installing packages.

    I modified a couple packages to use defaults the way I liked them, reburned the CD and voila. Perfectly installed systems every time.

    Slackware uses shell scripts exclusively so it's quite easy to figure out what happens when.
  • by ComputerSlicer23 ( 516509 ) on Friday January 09, 2004 @03:36AM (#7925929)
    I've built a RedHat kickstart CD that loads the kickstart file via HTTP of a web server. You can write a pre-install script to massage the disks (using either python or shell, probably anything you want, but python and shell are the only to utilities I know are there, in shell you are limited to mostly busy box utilities).

    You can use the redhat-config-kickstart to help you build a default install package set (and to build the kickstart file).

    Then you can run a post install script (also specified in the kickstart script). Generally, I always make my pre/post scripts wget the script I really want them to run. This gives me a bit more flexibility. (Actually I've never written a pre-install script, only posts).

    In the post install scripts, I've used wget to download the set of scripts/config files I wanted to replace (I recommend using a tarfile that you unpack from the filesystem, use diff to apply patches to all of the config files, or use sed to edit the config files).

    From there, it's relatively simple matter of deciding what you want changed and how you want it to work. I generally make sure to install AutoRPM, and the autorpm config files that point to my local package repository. Thus anything I can make into an RPM, I can get deployed onto remote machines in mass. I create one extra AutoRPM package pool for each class of machine, so I can put custom packages by machine type onto each machine.

    Either use PXE boot, or boot from CD. The CD image to do a kickstart style install is on the first RedHat CD. Look for the isolinux directory and create your own ISO (if you edit the files to put ks=http://kickstart.server.com/kickstart/file, then it's completely unattended). Or you can use the prebuilt images in /images, but then you have to fiddle with the command line a bit from CD. I've never done a PXE boot for installation of a machine (used it for building X-terminals, but not for this).

    Kirby

  • Re:Ghost (Score:3, Informative)

    by jsse ( 254124 ) on Friday January 09, 2004 @04:17AM (#7926072) Homepage Journal
    How about a Linux solution? Mondo [mondorescue.org]
  • Morphix = modular (Score:2, Informative)

    by Louis Guerin ( 728805 ) <guerin.gmx@net> on Friday January 09, 2004 @04:27AM (#7926109)
    Knoppix and Mepis are both good, but Morphix seems like it's best suited to this sort of thing. It is designed to be modular, meaning you can *very* easily build an iso to custom requirements. It has solid hardware detection, and has the built-in capacity to execute a script once it's finished booting, so you could write an installer script to install, configure and reboot the box without intervention. Hell, you could even have it apt-get update && apt-get -y upgrade if you wanted.

    MHO.

    L
  • Cool hack :) (Score:3, Informative)

    by korpiq ( 8532 ) <-,&korpiq,iki,fi> on Friday January 09, 2004 @07:35AM (#7926716) Homepage
    You really make it sound simple. Sure there'll be problems like really getting the image to boot, but a few trials-and-errors should get those right. And a plain approach such as this spells out total control, a pair of words every root should love.

    As for the partitioning (printf) problem, I'd save a partition table with sfdisk -d /dev/hda >partitions.txt, and restore it with sfdisk /dev/hda <partitions.txt. If you have clients with different-sized disks, leave a partition (say, /home or /scratch) out, and after running sfdisk do something like

    fdisk /dev/hda <<EOT
    n
    l
    <newline>
    <newline>
    w
    EOT


    (notice the two empty lines to use defaults for partition start and end - will use the rest of the disk.)

    Also notice that tar --one-file-system already creates the directories (/proc, /usr, ...) to use as mount points for subsequent filesystems, no need to handle them specially. Of course if the original file system consists of several partitions (like a separate /usr or /var) you'll need to run one tar --one-file-system for each of them - spanning several file systems with one tar command will force you to explicitly exclude sources like /proc, /home, /tmp that should not be copied. Whatever suits you best.

    Also note that even while files under /var/log and /var/run should not be copied, subdirectories therein should be.

    If you choose this 'roll your own dirty solution' I'd like to hear about your experiences.
  • Kick Start (Score:3, Informative)

    by floydman ( 179924 ) <floydman@gmail.com> on Friday January 09, 2004 @08:43AM (#7926945)
    At work we have something around 500 Linux desktops, and almost 1K cluster nodes, all of them are installed using Kisck start(well almost all of them). Very neat and good effort, should try it out.

  • Try systemrescuecd (Score:2, Informative)

    by anomaly ( 15035 ) <[moc.liamg] [ta] [3repooc.mot]> on Friday January 09, 2004 @12:15PM (#7928786)
    I've been working on this for work, and have been pleased with the systemrescue cd [systemrescuecd.org]

    I've got a primary system from which to create my "gold disk." I have installed/configured the OS and third-party applications in a meaningful way.

    The process that I've followed is to create an image of the pristine system using partimage (on the rescue CD) and a copy of the boot sector using sfdisk (on the rescue CD) then create installation scripts that rewrite the partition table and dump the image to the hard disk. Finally I created a "gold CD."

    One advantage I have is that I can count on pretty consistent hardware.

    YMMV.


    Regards,
    Anomaly

    BTW - God loves you and longs for relationship with you. If you want to know more, please email me.
  • Re:Ghost (Score:1, Informative)

    by Anonymous Coward on Friday January 09, 2004 @01:15PM (#7929591)
    remaster a small version of knoppix called damnsmalllinux

    partimage from d*mnsmalllinux with a big partimage master image copied on the cdr/dvdr+-whatever.

    you could tweak a bash script like below to setup your various partitions and restore them. MBR can be set also in partimage. though you need similar hardware

    #!/bin/bash
    # get hard disk size
    hd=`sfdisk -s /dev/hda`
    #need the hd's MB
    mbs=`expr $hd / 1024`
    # remove all partitions
    dd if=/dev/zero of=/dev/hda bs=512 count=1
    # make a label for the disk
    parted -s /dev/hda mklabel msdos
    # repartition the drive

    parted -s /dev/hda mkpart primary 0 $mbs

    ####################TWEAK HERE for MBR AND PARTITIONS

    # set boot flag on
    parted -s /dev/hda set 1 boot on
    # make an xxxxx container for Partimage

    # mount cd to get image file zart from your CD
    mount -t iso9660 /dev/sr0 /mnt/cdrom
    # run Partimage master is the image file
    partimage -b -f3 restore /dev/hda1 /mnt/cdrom/zart.000

    # cp reboot from cd
    cp /sbin/shutdown /tmp
    # Eject the CD
    cdrecord -eject dev=0,0,0
    # reboot /tmp/shutdown -nr now

    I use something similar to restore Windows boxen.
  • Sisuite (Score:2, Informative)

    by prefect42 ( 141309 ) on Friday January 09, 2004 @01:19PM (#7929648)
    Sisuite [sisuite.org] Nuff said. It'll do network or CD based installs.

Those who can, do; those who can't, write. Those who can't write work for the Bell Labs Record.

Working...