User Tools

Site Tools


linux:install_centos6

This is an old revision of the document!


This page shows how to install the Linux distribution CentOS 6 64bit. CentOS is a free clone of 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 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

  1. Boot the server from the CentOS 6 x86_64 installed DVD.
  2. From the initial menu, select the default option of “Install or upgrade and existing system”.
  3. Skip the disk test (use the TAB key to change which button you are going to press).
  4. The GUI should appear.
  5. Click 'Next'.
  6. Select 'English (English)'.
  7. Click 'Next'.
  8. Select 'United Kingdom'.
  9. Click 'Next'.
  10. Select 'Basic Storage Devices'.
  11. Click 'Next'.
  12. Click 'Yes, discard any data'.
  13. Set 'Hostname' to 'template.example.com'.
  14. Click 'Next'.
  15. Set 'City' to 'Europe/London'.
  16. Tick 'System clock uses UTC'.
  17. Click 'Next'.
  18. Set the normal administrator password.
  19. Click 'Next'.
  20. Select 'Create Custom Layout'.
  21. Click 'Next'.
  22. Select 'Hard Drives→sda→Free'.
  23. Click 'Create'.
  24. Select 'Standard Partition'.
  25. Click 'Create'.
  26. Set 'Mount Point' as '/boot'.
  27. Set 'File System Type' as 'ext4'.
  28. Untick all sd* drives except for sda in Allowable Drives.
  29. Set 'Size' to 206 MB
  30. In 'Additional Size Options', select 'Fixed size'.
  31. Click 'OK'
  32. Select 'Hard Drives→sdb→Free'.
  33. Click 'Create'.
  34. Select 'Standard Partition'.
  35. Click 'Create'.
  36. Set 'File System Type' as 'swap'.
  37. Untick all sd* drives except for sdb in Allowable Drives.
  38. Set 'Additional Size Options' to 'Fill to maximum allowable size'.
  39. Click 'OK'
  40. Select 'Hard Drives→sda→Free'.
  41. Click 'Create'.
  42. Select 'LVM Physical Volume'.
  43. Click 'Create'.
  44. Untick all sd* drives except for sda in Allowable Drives.
  45. Set 'Additional Size Options' to 'Fill to maximum allowable size'.
  46. Click 'OK'.
  47. Click 'Create'.
  48. Select 'LVM Volume Group'.
  49. Click 'Create'.
  50. Set 'Volume Group Name' to 'basevg'.
  51. Click 'Add'.
  52. 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'.<br>
  53. Click 'Next'.
  54. Click 'Format'.
  55. Click 'Write changes to disk'.
  56. Ensure 'Install boot loader on /dev/sda' is ticked.
  57. Click 'Next'.
  58. Select 'Minimal Desktop'.
  59. Click 'Next'.
  60. Wait while the installation takes place. Me patient, this may take 5-10 minutes.
  61. Click 'Reboot '.
  62. 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

  1. Click 'Forward'.
  2. Select 'Yes, I agree to the License Agreement'.
  3. Click 'Forward'.
  4. Click 'Forward' (WITHOUT putting any usernames in. We do this later.)
  5. Click 'Yes' in the popup window. You are sure you want to continue.
  6. Select 'Synchronize data and time over the network'.
  7. Click 'Forward'.
  8. 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.
  9. Click 'Finish'.
  10. 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

  1. After the initial, first boot configuration configuration, you should be presented with the GUI logon page. Log into the machine as the user 'root'.
  2. Tick the 'Do not show me this again' on the warning window and close the window.
  3. 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.
  4. Click 'Places→Home Folder'
  5. Click 'System→Preferences'
  6. Select the 'Behaviour' tab
  7. Tick 'Always open in browser windows' (improves the file browser interface)
  8. Click 'Close'.
  9. Click 'Applications→System Tools' and right click 'Terminal'.
  10. Click 'Add this launcher to panel'.
  11. 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

  1. Install the gedit text editor and GNOME configuration editor gcong-editor.
  2. Install perl as it is a very useful thing to have available on the system.
  3. Install Java 1.7 JRE and JDK.
  4. Install the SElinux manager tool
  5. 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 here.

linux/install_centos6.1590330577.txt.gz · Last modified: (external edit)