# RootPrompt.org   Nothing but Unix.[Home] [Features] [Programming] [Mac OS X] [Search]


 Feature: Linux Install / Reinstall Philosophy

hopeless case has written a short article that talks about their Linux install / reinstall philosophy.

"In my home directory, I make a directory called "sys-config", with a subdir called "conf_files." In conf_files, I copy all of the system wide config files like /etc/HOSTNAME, /etc/hosts, /etc/rc.d/rc.inet1, /etc/rc.d/rc.modules, ... that I typically modify in configuring my machine. In "sys-config" I have a script called install.sh, that copies the files in conf_files to their proper locations and does other stuff to configure my machine. I have appended the install.sh I use on my workstation at work so you can see what it looks like."

 (Submitted by hopeless case Mon Mar 25, 2002 )

   I have recently reinstalled slackware 8.0 on my workstation, my home PC and my laptop. I also have 2 production and 2 test PCs I work with that all run slackware.

I have had some curious hard disk problems, which have resulted in my having to reinstall slackware several times on 1 of the machines.

So, to put it mildly, I've had a lot of practice installing slackware linux recently. As a result, I've worked out a new install philosophy I'd like to run by everyone.

I set up the following partitions:

1. 4 GB root

2. 128 MB swap (or however much memory the machine has)

3. remainder of hard disk

I mount 3 at /mnt/drive2. I also do a "mkdir chris", add the user account chris, and then do a "usermod -d /mnt/drive2/chris chris" to make that my home directory.

In my home directory, I make a directory called "sys-config", with a subdir called "conf_files." In conf_files, I copy all of the system wide config files like /etc/HOSTNAME, /etc/hosts, /etc/rc.d/rc.inet1, /etc/rc.d/rc.modules, ... that I typically modify in configuring my machine. In "sys-config" I have a script called install.sh, that copies the files in conf_files to their proper locations and does other stuff to configure my machine. I have appended the install.sh I use on my workstation at work so you can see what it looks like.

Now, whenever I have problems with my root partition (files get corrupted, someone manages to crack me, whatever), I reformat the bastard, adduser chris, "usermod -d" it over to /mnt/drive2, go to chris/sys-config and run install.sh, reboot, and I'm back where I was.

The thing about the root partition is that there are so many files that need to be there and I only understand the architecture of small parts of it. My home directory and all of the other directories of files I assemble, however, I know much more about, obviously.

Since the root partition is so conceptually large, it is easy for a cracker to hide his hooks there and it would take so much effort to find them. Arranging to automate the process of completely wiping it strikes me as a great way to foil hackers and other problems. I might even do a weekly re-install of linux just for kicks and as an added security measure.

I have also done the same thing for all of the additional software packages I typically install. I usually store the tar.gz files in /usr/src/packages, and untar them in /usr/src. Some of them, like R, or kernel 2.4.16, can take a long time to compile. So what I have done is tar/gzip the compiled source directories and stuck the tarballs on a CDROM, along with a script that can be run from the cdrom to untar them, go into the resulting directories, and execute "make install", which copies all of the programs and libraries into the root partition where they have to go along with whatever else needs to be done. I have also appended the compiled CD install script so you guys can see it.

With the slackware install CD and my compiled packages CD, I can recreate the root partition of any of my various machines in an hour, fully configured with all of the software and files I use.

After the slackware install, I only have to run install.sh from 2 different directories and reboot.

Whadda think?

Here's the install.sh script from /mnt/drive2/chris/sys-config:

 


  #!/bin/bash  


 


  chris_home_dir=/mnt/drive2/chris  


 


  # install crontabs  


  crontab conf_files/crontab.root -u root  


 


  # copy system wide configuration files to their proper places  


  (  


     cd conf_files  


 


     # etc files  


     cp HOSTNAME hosts exports fstab lilo.conf printcap syslog.conf ntp.conf  


  /etc  


 


     # X11  


     cp XF86Config /etc/X11  


 


     # ssh  


     cp sshd_config /etc/ssh  


     # alert sshd to use new config file  


     killall -HUP sshd  


 


     # etc/rc.d files  


     cp rc.inet1 rc.modules rc.local /etc/rc.d  


 


     # samba  


     cp smb.conf /etc/samba  


 


     # put new inittab into effect  


  #   kill -HUP 1  


 


     # reconfigure boot sector  


     lilo  


  )  


 


  # make links from /usr/local/bin and /usr/local/sbin  


  ln -s ${chris_home_dir}/bin/* /usr/local/bin  


  ln -s ${chris_home_dir}/sbin/* /usr/local/sbin  


And here's the script from the compiled packages CD I have burned:

 


  #!/bin/bash  


  # a script to copy, unzip/tar, and install the compiled packages I just  


  can't  


  # live without on a newly installed slackware system.  


 


  # packages directory  


  package_dir=$(pwd)  


  sdir=${package_dir}/compiled  


 


  # we install source directories to /usr/src  


  cd /usr/src  


 


  # set up linux-2.4.16.  Lots of special steps here.  


  echo "installing linux 2.4.16"  


  rm linux  


  echo "un(zip/tar)ing"  


  gzip -dc ${sdir}/linux-2.4.16.tgz | tar x  


  ln -s linux-2.4.16 linux  


  (  


     cd linux  


     echo "installing modules"  


     make modules_install  


     echo "copying bzImage to /boot"  


     cp /usr/src/linux/arch/i386/boot/bzImage /boot/vmlinuz-2.4.16  


  )  


 


  # hand compiled source packages requiring a "make install"  


  packages="R-1.3.0 libpcap tcpdump ethereal xwit aumix pcmcia"  


 


  echo "installing hand compiled packages"  


  for pkg in $packages; do  


     file=${sdir}/${pkg}.tgz  


     echo "un zip/tar ing $file"  


     gzip -dc $file | tar x  


 


     # notice the "maxdepth" switch.  This is necessary because sometimes sub  


  dirs of  


     # the main dir have the package name embedded in them and the find  


  command will then  


     # find multiple directories and the "cd" below will fail.  


     pdir=$(find . -maxdepth 1 -type d -name "${pkg}*" -print)  


     (  


        echo "installing $pdir"  


        cd $pdir  


        make install  


     )  


  done  


 


  # and now for all of the slackware tgz packages and misc packages that don't  


  fit the  


  # "./configure, make, make install" pattern  


 


  # straight slackware binary packages:  


  # cvs, xforms, lyx  


  echo "installing cvs"  


  installpkg ${package_dir}/devtools/cvs-1.11.1p1-cvshome.7x.1.i386.tgz  


  installpkg ${package_dir}/office/xforms-0.88.1-1.i386.tgz  


  installpkg ${package_dir}/office/lyx-1.1.5fix2-1.i386.tgz  


 


  # vnc: this one's a real odd-ball.  


  echo "installing vnc"  


  gzip -dc ${package_dir}/network/vnc/vnc-3.3.3r2_x86_linux_2.0.tgz | tar x  


  (  


     cd vnc_x86_linux_2.0  


     cp Xvnc vnc* /usr/local/bin  


  )  


 


  # java:  this one is also pretty odd  


  echo "installing java"  


  cd /usr/local  


  bzip2 -dc ${package_dir}/languages/j2sdk-1.3.0-FCS-linux-i386.tar.bz2 | tar  


  x  


  ln -s /usr/local/j2sdk1.3.0 /usr/local/java  


  # create a file in /etc/profile.d to put java on the path  


  (  


     echo "#!/bin/bash"  


     echo 'export "PATH=${PATH}:/usr/local/java/bin"'  


  ) > /etc/profile.d/java.sh  


  chmod 755 /etc/profile.d/java.sh  



Our content can be syndicated: Main page Mac Page

Copyright 1999-2005 Noel Davis. Noel also runs web sites about sailing and kayaking.
All trademarks are the property of their owners.
All articles are owned by their author