You can also have virtual machines that are instances of operating
systems running within another operating systems. If you dual boot, each OS
is completely independent of the other; they can't both be active at the
same time. A virtual machine can run one or more operating systems at the
same time (see an example here which has
advantages of course.
If you have the disk space and enough memory, you can both dual boot and
run virtual machines to take full advantage of your hardware and provide the
most possible power and convenience. There's still another major advantage
of a dual boot configuration; creating a portable operating system you can
use to manage and restore another computer.
USB thumbs drives have enough storage capacity for at least one operating
system and all the utilities you might need to troubleshoot problems on
other computers. Since the USB thumb drive simply plugs into a USB (version
2 of course) port and most computers have these ports, a USB thumb drive
with a bootable OS can be used to boot any computer.
The only preparation
is to set the boot drive order in the BIOS to try the USB thumb drive first
and then the computer's hard disk second. Set that correctly, insert the
USB thumb drive and boot up. The machine will boot from the thumb drive and
load whatever OS you installed on it.
If your computer supports booting from a USB thumb drive (and most do), all
you really have to do is insert a Linux install CD/DVD, boot and, when
prompted for you partitioning scheme, chose "Custom", select the thumb drive
(probably the second disk) as the installation target and configure the
grub bootloader (see more detail
here) to display thumb drive as a boot choice.
Now when you re-boot, you'll see the thumb drive in the grub menu list of
operating systems it can boot. Select the thumb drive, hit Enter and grub
will boot to the USB thumb drive just like any other disk-based operating
system. Everything you selected during the installation process (see more on
this here) will be
available and fully functional. You now have a portable Linux installation
you can plug into the USB port of any computer and boot into. This makes
any computer able to dual boot by just inserting the thumb drive.
Very handy stuff. There are other reasons for doing this, however. Suppose
you have a problem with the operating system on another computer, do you
format and re-install the OS, losing everything? No way. If you've included
some useful and powerful utilities in your thumb drive installation, you
can boot from the thumb drive on the broken computer and use those
utilities to fix it. There's even a boot image you can get that's
especially configured for this,
here.
If you need to fix a broken Linux installation, you need to have Linux
installed on the thumb drive as mentioned above. Suppose your Linux
configured on the hard disk is so corrupted that the only solution is to
re-install? You always be prepared for the worst, especially if you're getting
paid to manage someone else's servers. Think of it as disaster avoidance.
Any time you install Redhat or Fedora, the installation will create a
"kickstart" or "anaconda-ks.cfg" file the /root directory (for
much more detail, see this). This
file has everything you selected to install in the original setup. Copy
that file to another disk on, ideally, another machine and give it a name
identifying it. Call the webserver kickstart file something like
webserver.kickstart. That file is then made available for any
subsequent installation making it pretty much automatic. If you're
configuring a thumb drive for server recovery, copy the kickstart file
there.
While using kickstart is hugely convenient, it doesn't help with stuff you
added after the initial operating system installation. During the
installation of Linux to your computer, you need to carefully plan how your
disk partitions are set up (see a detailed explanation, here).
When you re-install over an existing installation you really only need to
install the operating system specific stuff, everything else can be left as is. To
prevent catastrophic loss of data or capability and get the machine back
on-line as fast as possible, you should divide the original installation
over several partitions. These should be:
/boot
/
/usr
/usr/local
/home
/var
and possibly,
/var/mail
During the installation you only have to format the partitions that are
required to fix the problems. These are usually, /boot, /,
/usr and, probably, /var. If the broken machine
was a mail server, you might want to create a separate partition
for /var/mail (the default for Redhat and Fedora) so you
don't overwrite your user's mail during the install. Since /home and
/usr/local have most of the customized stuff and user installed
programs, they're the ones you really want to preserve. Because they are on
their own partitions they don't have to be formatted and they are
preserved, untouched by the installation.
Let's assume that prior to the OS corruption we're trying to correct, you
had everything working and properly configured. All of this took time and
lots of effort so restoring those configurations will likewise be time
consuming. Since we're wanting to get this machine back on-line as soon as
possible, we can't be messing around trying to figure out how to get
everything back.
Once you've gotten a server alive and everything configured, you need to document
everything and the best way to do that is with a shell script. This script
will not only tell us what we've done but also how to put everything back
like was. Here's an example:
echo -ne "
* Run as root *
This script is to create a working environment
after a new install to boot from a thumb drive.
This will copy stuff after a new install
and put it in the right places. Some services
will have to restart but a reboot is better.
* Run as root *
Hit Enter to begin ... \c"
read "ans"
# put the thunderbird mail client back
if [ ! -d /usr/local/thunderbird ]
then
mkdir /usr/local/thunderbird
ln -s /media/usr/local/thunderbird/thunderbird /usr/local/thunderbird
fi
# Notice that a symbolic link is used since we assume that the /media
# filesystem is permantently mounted. If it isn't you need to copy
# it over so try using something like:
# cd /media/usr/local/thunderbird
# find . -depth|cpio -pdv /usr/local/thunderbird
# put the firefox web browser back
if [ ! -d /usr/local/firefox ]
then
mkdir /usr/local/firefox
ln -s /media/usr/local/firefox/firefox /usr/local/firefox
fi
# Add Apache in case I want a local webserver
ln -s /media/usr/local/apache2 /usr/local/apache2
# Get the Broadcom wireless driver restored
if [ ! -d /lib/firmware/b43 ]
then
mkdir /lib/firmware/b43
cp ../wl_apsta-3.130.20.0.o /lib/firmware/b43
fi
cp ../b43/* /lib/firmware/b43
cp ../wl_apsta-3.130.20.0.o /lib/firmware
# Update /etc
cp httpd /etc/rc.d/init.d
cp wicd /etc/rc.d/init.d
cp ifcfg-wlan0 /etc/sysconfig/network-scripts
cp ifup-wireless /etc/sysconfig/network-scripts
cp keys-wlan0 /etc/sysconfig/network-scripts
cp route-wlan0 /etc/sysconfig/network-scripts
cp hosts /etc
cp passwd /etc
cp resolv.conf /etc
cp shadow /etc
cp modprobe.conf /etc
cp selinux_config /etc/selinux/config
# Disable the Synaptics Touchpad:
cp xorg.conf /etc/X11
# Not needed on Fedora 9 installation but
# since the default install puts an underscore (_)
# in front of directory names mounted in /media
# and I find that annoying, mkdir without the
# underscore and mount to them instead.
# cp fstab /etc
# Restore the wicd wireless configuration going
if [ ! -d /etc/wicd ]
then
mkdir /etc/wicd
fi
cd wicd-conf
find . -depth|cpio -pdv /etc/wicd
cd ..
if [ ! -d /etc/wpa_supplicant ]
then
mkdir /etc/wpa_supplicant
fi
cp wpa_supplicant.conf /etc/wpa_supplicant
# make sure only the service I want are restored
chkconfig NetworkManager off
chkconfig bluetooth off
chkconfig cups off
chkconfig dnsmasq off
chkconfig ip6tables off
chkconfig nfs off
chkconfig nfslock off
chkconfig restorecond off
chkconfig sendmail off
chkconfig setroubleshoot off
chkconfig network on
# use wicd for networking:
if [ `chkconfig --list|grep wicd` = "" ]
then
chkconfig --add wicd
fi
# Re-install wicd for wireless
cd wicd-install
python setup.py configure && python setup.py install
cd ..
chkconfig wicd on
# Restore my environment
cp .bash_profile $HOME
cp .bashrc $HOME
cp .exrc $HOME
# make some stuff available in my $HOME directory
cp wlan-config-3.4.tar.bz2 $HOME
cp wl_apsta-3.130.20.0.o $HOME
cp b43-fwcutter-011.tar.bz2 $HOME
cp broadcom-wl-4.80.53.0.tar.bz2 $HOME
cp NetworkManager-0.7.0.tar.gz $HOME
cp ntfs-3g-2009.1.1.tgz $HOME
# Load the Broadcom driver
modprobe b43
# More wireless stuff
if [ ! -d $HOME/wireless ]
then
mkdir $HOME/wireless
cd wireless
find . -depth|cpio -pdv $HOME/wireless
fi
# Restore my firefox configuration
if [ ! -d $HOME/.mozilla ]
then
mkdir
$HOME/.mozilla
fi
find ../.mozilla -depth|grep -v Cache|cpio -pdv $HOME/.mozilla
Restore my email configuration
if [ ! -d $HOME/.thunderbird ]
then
mkdir $HOME/.thunderbird
fi
find ../.thunderbird -depth|grep -v Cache|cpio -pdv $HOME/.thunderbird
# Enable the wireless interface
ifup wlan0
# Enable networking
service network restart
# Try wicd
service wicd start
# Restore all the user configurations and environments
find /media_1/home -depth|cpio -pdv /home
Think of this script as a template. You'll have different requirements, but
this should suggest how to get everything back up as fast as possible.
Notice that I copied the server configuration files here
($HOME/etc). Below is a list of what's in this directory and why:
b43 |
This directory has all the driver files for a Broadcom wireless NIC
|
copy-new |
This is script that puts everything back like it was
|
fstab |
This saves the original file system layout
|
group |
Restores the original /etc/group file
|
hosts |
Restores the original /etc/hosts file
|
httpd |
Restores the original Apache server
|
ifcfg-wlan0 |
Restores the wireless card configuration
|
ifup-wireless |
Restores the wireless setup
|
keys-wlan0 |
Preserves the wireless WPA key
|
modprobe.conf |
Restores the Broadcom driver
|
passwd |
Restores the original /etc/passwd file
|
resolv.conf |
Restores the original /etc/resolv.conf for nameservers
|
route-wlan0 |
Restores routes for wireless network
|
selinux_config |
Restores the selinux configuration
|
shadow |
Restores the original /etc/shadow file
|
wicd |
This directory has all is for the wicd wireless driver
|
wicd-conf |
The wicd wireless configuration file
|
wicd-install |
This directory has the python installation scripts to re-install
wicd
|
wl_apsta-3 |
Another Broadcom driver file
|
wpa_supplicant |
This directory is for the wpa_supplicant configuration
|
wpa_supplicant.conf |
This is the wpa_supplicant configuration files for wireless
|
xorg.conf |
Restores the /etc/X11/xorg.conf file
|
Obviously the first time you set all this up it will be tedious and
error prone, but something like this is a real life saver (could
save your job too). Remember that all this is on the USB thumb
drive you booted from so you can plug the thumb drive into any
computer, boot, run the restore script and get the broken system
back to life quickly.
Consider that a USB thumb drive can have fairly huge capacity
compared to a CD or DVD so it's by far the best choice for this
kind of thing. You can either have different scripts for different
servers or separate thumb drives for each server. Since all the
restoration work was done and tested prior to a computer problem
requiring a re-installation of the OS, full recovery can be
accomplished quickly, probably less than two hours.