This page shows how to install the Linux distribution CentOS 6 64bit. [[http://en.wikipedia.org/wiki/CentOS|CentOS]] is a free clone of [[http://en.wikipedia.org/wiki/Rhel|Red Hat Enterprise Linux]]. For the purposes of this page, we will assume that the machine being setup is called ''template'' and that the IP address is 172.16.1.1. You must change these values as appropriate when setting up your machine. It is standard practice to separate the os installation and application data onto separate disks. For example, if we are installing an Oracle database server, we install CentOS onto one disk and create a second, separate disk to store the Oracle installation and data on. =====Prerequisites===== You will need a computer, either physical or virtual, to install CentOS on. Creating virtual machines is covered in a separate page of this wiki. Whether you are installing CentOS on a physical or a virtual machine, you will need access to the DVD ISO file. This can be downloaded off the internet from on of the links on the [[http://wiki.centos.org/Download|CentOS wiki]]. If you are installing CentOS on a physical machine, burn the ISO to a DVD-R and use that. It is assumed that you know how to get a computer to boot from a DVD. If you are installing CentOS on VirtualBox or VMware, make sure that the ISO file is loading in the virtual DVD drive and is connected to the virtual machine. In this example, we have two disks. The first is ''/dev/sda'' and is 25Gb in size. The second is ''/dev/sdb'' and is 4Gb in size. We will use ''/dev/sda'' to store the OS and ''/dev/sdb'' to store the swap space. =====Install CentOS===== - Boot the server from the CentOS 6 x86_64 installed DVD. - From the initial menu, select the default option of "Install or upgrade and existing system". - Skip the disk test (use the TAB key to change which button you are going to press). - The GUI should appear. - Click 'Next'. - Select 'English (English)'. - Click 'Next'. - Select 'United Kingdom'. - Click 'Next'. - Select 'Basic Storage Devices'. - Click 'Next'. - Click 'Yes, discard any data'. - Set 'Hostname' to 'template.example.com'. - Click 'Next'. - Set 'City' to 'Europe/London'. - Tick 'System clock uses UTC'. - Click 'Next'. - Set the normal administrator password. - Click 'Next'. - Select 'Create Custom Layout'. - Click 'Next'. - Select 'Hard Drives->sda->Free'. - Click 'Create'. - Select 'Standard Partition'. - Click 'Create'. - Set 'Mount Point' as '/boot'. - Set 'File System Type' as 'ext4'. - Untick all sd* drives except for sda in Allowable Drives. - Set 'Size' to 206 MB - In 'Additional Size Options', select 'Fixed size'. - Click 'OK' - Select 'Hard Drives->sdb->Free'. - Click 'Create'. - Select 'Standard Partition'. - Click 'Create'. - Set 'File System Type' as 'swap'. - Untick all sd* drives except for sdb in Allowable Drives. - Set 'Additional Size Options' to 'Fill to maximum allowable size'. - Click 'OK' - Select 'Hard Drives->sda->Free'. - Click 'Create'. - Select 'LVM Physical Volume'. - Click 'Create'. - Untick all sd* drives except for sda in Allowable Drives. - Set 'Additional Size Options' to 'Fill to maximum allowable size'. - Click 'OK'. - Click 'Create'. - Select 'LVM Volume Group'. - Click 'Create'. - Set 'Volume Group Name' to 'basevg'. - Click 'Add'. - Fill in the information using the first row of the 'Partition Layout' table below. When you are done, click 'OK' in the 'Make Logical Volume' window to add the logical volume. Then click 'Add' again and repeat for every row in the table. When you are done, click 'OK' in the 'Make LVM Volume Group' window to close it. Do NOT tick the 'Encrypt' box at any point. For the first partition (swap), don't put anything in the mount point text field. The mount point text field will be automatically greyed out when you set the file system type to 'swap'.
- Click 'Next'. - Click 'Format'. - Click 'Write changes to disk'. - Ensure 'Install boot loader on /dev/sda' is ticked. - Click 'Next'. - Select 'Minimal Desktop'. - Click 'Next'. - Wait while the installation takes place. Me patient, this may take 5-10 minutes. - Click 'Reboot '. - Wait while the machine reboots and ejects the disk. After reboot, an 'initial configuration' wizard should be automatically launched. If the disk is not ejected, manually eject it and reboot. ^ Mount Point^ File System Type^ Logical Volume Name^ Size^ | /| ext4| root| 4120| | /usr| ext4| usr| 4120| | /opt| ext4| opt| 1040| | /var| ext4| var| 1040| | /tmp| ext4| tmp| 2052| | /home| ext4| tmp| 500| =====Initial System Configuration===== - Click 'Forward'. - Select 'Yes, I agree to the License Agreement'. - Click 'Forward'. - Click 'Forward' (WITHOUT putting any usernames in. We do this later.) - Click 'Yes' in the popup window. You are sure you want to continue. - Select 'Synchronize data and time over the network'. - Click 'Forward'. - Untick 'Enable kdump?' if you are able to. If you are not able to, that is probably because it is greyed out and unticked already. This is good. - Click 'Finish'. - If asked further questions about kdump, yes, you are sure you don't want it and if it wants to reboot, that is fine. ^ Mount Point^ File System Type^ Logical Volume Name^ Size^ | /| ext4| root| 4120| | /usr| ext4| usr| 3076| | /opt| ext4| opt| 1040| | /var| ext4| var| 1040| | /tmp| ext4| tmp| 2052| | /home| ext4| tmp| 500| =====Configure CentOS===== - After the initial, first boot configuration configuration, you should be presented with the GUI logon page. Log into the machine as the user 'root'. - Tick the 'Do not show me this again' on the warning window and close the window. - At this point I normally do a tidy up of the GUI and get rid of several bits of junk. However, for this guide, I'll leave it mostly as-is. - Click 'Places->Home Folder' - Click 'System->Preferences' - Select the 'Behaviour' tab - Tick 'Always open in browser windows' (improves the file browser interface) - Click 'Close'. - Click 'Applications->System Tools' and right click 'Terminal'. - Click 'Add this launcher to panel'. - Click the terminal icon to launch the terminal (a.k.a. the console a.k.a. the command line) You can left click the network icon at the top right corner of the screen and select "System eth0" to get a DCHP address. You can then ssh into the box to enable to you paste the following commands into a terminal rather than typing them out manually. Increase the number of commands that are kept in bash history and have the history file formatted so that it timestamps each command. Set the terminal to write to bash history on command completion rather than when the terminal window closes ''cat << EOF >> /etc/bashrc export HISTSIZE=1000000 export HISTTIMEFORMAT='%F %T ' export PROMPT_COMMAND='history -a' EOF'' =====Remove NetworkManager===== The NetworkManager package gets in the way of networking by trying to be clever with IP addresses. As we are setting up a server that just sits there and never changes, we want to get rid of Networkmanager so that it doesn't interfere with the network configuration we set. Once it is removed, we restart the network service. ''yum -y remove *NetworkManager* service network restart'' =====Disable IPv6===== Edit sysctl.conf to disable IPv6. Obviously, you shouldn't do this if you intend to use IPv6. This command also disables TCP timestamps to make the machines a little less vulnerable to attack. ''cat << EOF >> /etc/sysctl.conf - Disables TCP Timestamps net.ipv4.tcp_timestamps = 0 - Disable IPv6 net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 net.ipv6.conf.lo.disable_ipv6 = 1 EOF'' =====Configure Static IP===== As this is a server, you will want to configure a static IP on it rather than leaving it with DHCP. Configure the network settings on the machine. Copy the following section of text into a text editor and change the values of the variables as appropriate to match the values you are using for the machine you are setting up. Open up a terminal as root on the machine and paste in the text. If necessary, access this wiki page from within the machine and copy/paste these commands manually (editing them as needed). IPADDRESS=172.16.1.10 SUBNET=255.255.0.0 GATEWAY=172.16.10.10 DNS1=172.16.1.2 DNS1=172.16.1.3 DOMAIN=example.com HSTNAME="template.$DOMAIN" ADAPTER=eth0 rm -f /etc/udev/rules.d/70-persistent-net.rules TARGETFILE="/etc/sysconfig/network-scripts/ifcfg-$ADAPTER" echo "DEVICE=$ADAPTER" > $TARGETFILE echo 'BOOTPROTO=static' >> $TARGETFILE echo 'NM_CONTROLLED=no' >> $TARGETFILE echo 'ONBOOT=yes' >> $TARGETFILE echo 'TYPE=Ethernet' >> $TARGETFILE echo "IPADDR=$IPADDRESS" >> $TARGETFILE echo "NETMASK=$SUBNET" >> $TARGETFILE TARGETFILE="/etc/sysconfig/network" echo 'NETWORKING=yes' > $TARGETFILE echo "HOSTNAME=$HSTNAME" >> $TARGETFILE echo "GATEWAY=$GATEWAY" >> $TARGETFILE TARGETFILE="/etc/resolv.conf" echo "search $DOMAIN" > $TARGETFILE echo "nameserver $DNS1" >> $TARGETFILE echo "nameserver $DNS2" >> $TARGETFILE service network restart =====Fix Localisations===== You may need to log into Gnome to get the user-dirs.locale generated. sed -i "s/_US/_GB/g" /root/.config/user-dirs.locale sed -i "s/_US/_GB/g" /etc/sysconfig/i18n =====Set Skel===== mkdir /etc/skel/.config cp /root/.config/user-dirs.locale /etc/skel/.config/ cp /root/.config/user-dirs.dirs /etc/skel/.config/ mkdir /etc/skel/Desktop mkdir /etc/skel/Documents mkdir /etc/skel/Downloads mkdir /etc/skel/Music mkdir /etc/skel/Pictures mkdir /etc/skel/Public mkdir /etc/skel/Templates mkdir /etc/skel/Videos =====Add and Remove Software===== CentOS comes with Java 1.6 installed. We don't want this so remove it. yum -y remove java We now need to install lots of software - Install the gedit text editor and GNOME configuration editor gcong-editor. - Install perl as it is a very useful thing to have available on the system. - Install Java 1.7 JRE and JDK. - Install the SElinux manager tool - Install the bits needed to install the Guest Addons for VirtualBox or VMware. These are also very useful to install in general as they are required by many software packages yum -y install \ gedit gconf-editor \ perl \ java-1.7.0-openjdk java-1.7.0-openjdk-devel \ policycoreutils-python \ gcc kernel kernel-devel kernel-headers dkms make bzip2 \ wget unzip openssh-clients cifs-utils Now that Java is installed, set JAVA_HOME so that when and if we install Groovy, it will work properly. echo 'export JAVA_HOME=/usr/lib/jvm/java; export JAVA_HOME' >> /etc/profile Restart the machine by clicking System->Shutdown->Restart or by typing 'init 6' in the root terminal window. =====Install Guest Addons===== Obviously you should skip this section if you are installing CentOS on a physical machine. Instructions can be found [[Setup_Virtual_Machine| here]].