Archive for category Server
In addition to installing directly from the physical CentOS 6 installation media (in the form of a DVD) it is also possible to perform a network based CentOS installation whereby the installation image is installed on a remote server and downloaded in packages to the destination computer system during installation. CentOS 6 currently supports network installation via HTTP, FTP and NFS. For the purposes of this tutorial we will focus on the use of HTTP (in other words the installation image is available via a web server on a remote host) though the concepts are largely the same for the other network installation options.
CentOS 6 Network Installation Requirements
Before a network installation of CentOS 6 can be performed a number of items are required. Firstly, the CentOS 6 installation image must be loaded onto the remote server and mounted. If the installation media is in the form of DVD then the image can be read from that media into a disk based ISO image file using the dd command as follows:
dd if=/dev/media of=/path/to/iso/file/rhel6-image.iso
Note that in the above example, /dev/media would be replaced by the path to the DVD device and /path/to/iso/file/ represents the path to a suitable location on the file system to create the image file. Also keep in mind that the installation media may comprise multiple disk images, each of which may need to be imported into the server.
Having created the ISO image file from the installation media, it now needs to be mounted in a location that is accessible to the web server, ftp server or NFS mount point so that it is accessible to the target system. This is achieved using the mount loopback interface:
mount -o loop rhel6_image.iso /path/to/mount/point
In this case, /path/to/mount/point is replaced by the full path to the location where the RHEL 6 installation image is to be mounted such that it can be accessed via the chosen network installation method. For example, in the case of an HTTP based installation, the chosen mount point might be /var/www/html/rhel6. Note that the specified mount point directory must already exist before executing this command.
Obtaining a Network Boot Image
Once the remote server is configured with a copy of the RHEL 6 installation image, the next step is to plan how the installation process will be initiated on the target system. Clearly we will still need to be able to boot from something locally to start the installation. The best option is to download the Network Install image from a CentOS mirror server at:
The file name containing this image is usually adopts the following format:
For example, the 32-bit installation image for CentOS 6.2 is named CentOS-6.2-i386-netinstall.iso.
This image is approximately 170 Mb in size and may be burned to a CDROM, DVD or USB flash drive.
Writing the Boot Image to a USB Flash Drive
Once the network installation ISO image has been downloaded from the CentOS web site, it may optionally be burned onto a USB flash drive and then used to boot the system on which the network installation is to be performed. This task is best performed on another Linux system using the dd command to directly write the ISO image to the flash drive.
Begin by inserting the USB flash drive into an appropriate port on the Linux system and wait for the system to detect the device and mount it. Identify the device name assigned to the drive using the mount command in a terminal window and then unmount the media. Assuming, for the sake of an example, that the mount command indicated the USB drive was assigned to device file /dev/sdb, the following command would be used to write the ISO image to the drive:
dd if=/path/to/iso/image of=/dev/sdb
Once the image has been written to the drive, take it to the target system, modify the BIOS boot settings to ensure that the system will boot from a USB device prior to any other storage devices and reboot the system.
Configuring the Network Installation
When the network installer image has booted press the Esc key on the boot menu screen, enter the following command at the boot: prompt and press the enter key:
A sequence of screens will subsequently appear providing the opportunity to select a language and keyboard type. Once these settings have been defined, a screen will appear requesting the location of the installation media:
Depending on the method by which the installation images are being served by the remote system select either NFS Directory or, in the case of an FTP or HTTP based server, URL. For the purposes of this tutorial we will be assuming the use of HTTP.
Once the installation method has been selected, click OK to proceed to the TCP/IP configuration screen. If the computer has multiple network adaptors, select the one to be used during the installation. On the next screen, configure the required IPv4 and IPv6 settings for the network to which the computer is attached:
The next item of information that the installer needs is the URL of server containing the installation images and the path to the directory where the first installation image media was mounted. Enter this information either as a hostname or IP address before clicking OK to proceed:
In the above figure, the installation media is identified via an HTTP URL to the location on the remote web server where the installation image is located. Proxy and user and password information may also be specified if required for access to the server.
Starting the CentOS 6 Network Installation
Once the network configuration settings are complete, select the OK button to begin the installation process. The network installation process will now connect to the remote server and download the first installation image file (this is typically /install.img):
The duration of this download will vary subject to the speed of the connection between the local system and the remote server hosting the installation image. Once the image has downloaded the installation will proceed as outlined in the previous chapter, with the inevitable exception that it may proceed more slowly than a comparable installation from a local media unless the remote server and client are connected via a high speed network connection such as that provided by a fiber channel.
entOS 6, in common with most Linux distributions, will happily co-exist on a hard disk drive with just about any version of Windows up to and including Windows 7 and Windows Server 2008 R2. This is a concept known as dual-booting. Essentially, when you power up the system, you will be presented with a menu providing the option to boot either your CentOS 6 installation or Windows. Obviously you can only run one operating system at a time in such a configuration, but it is worth noting that the files on the Windows partition of your disk drive will be available to you from CentOS 6 regardless of whether your Windows partition was formatted using Microsoft’s NTFS, FAT16 or FAT32 file system formats.
This installation method involves shrinking the size of the existing Windows partition to accommodate the installation of CentOS 6. How you go about doing this will depend on the version of Windows currently installed on the disk.
- 1 Partition Resizing
- 2 Shrinking the Windows Partition from within Linux
- 3 Choosing an Operating System at Boot Time
- 4 Editing the CentOS 6 Boot Menu
- 5 Accessing the Windows Partition from CentOS 6
In order to accommodate CentOS 6 on a disk drive that already contains a Windows installation the first step involves shrinking the Windows partition to make some room. If you are running Windows Vista, Windows 7, Windows Server 2008 or later, the recommended course of action is to use the Windows Disk Management interface to reduce the size of the partition prior to attempting to install CentOS 6. You can generally access this by right clicking on the Computer icon and selecting Manage from the popup menu. Within the Computer Management interface, select Disk Management to display a graphical representation of the disk drives in your system:
Right click on the partition you wish to reduce and select Shrink Volume. The tool will calculate the maximum amount by which the volume may be reduced without data loss (a process that can take several minutes depending on the overall size of the partition). Once this analysis is complete, a dialog similar to the one in the following figure will appear:
Enter into the Total size after shrink in MB field the new target size for the partition and click on Shrink to proceed. Once the resizing operation is complete, reboot using the CentOS 6 installation media (as outlined in Installing CentOS 6 on a Clean Disk Drive) and proceed with the installation. When prompted to decide on where CentOS 6 is to be installed be sure to select the Use Free Space option.
Shrinking the Windows Partition from within Linux
Whilst it is possible to shrink existing Windows partitions using the Windows Disk Management tool on recent versions of Windows, this is not possible from within Windows XP or earlier Windows releases. If you need to shrink a Windows XP partition in order to install CentOS 6, one option is to use one of the commercially available partitioning tools such as PartitionMagic. If you would prefer not to buy a partitioning tool, the repartitioning may also be performed from within the CentOS 6 Live CD distribution using the fdisk and ntfsresize utilities. As outlined in the chapter entitled Installing CentOS 6 on a Clean Disk Drive, a Live CD is a CDROM from which a Linux distribution can be booted and run without the necessity to install the operating system on a disk drive.
Before attempting this resizing technique it is vital that you back up all essential data from your Windows system. In this section we will be performing some low level disk partitioning activities using command line tools. Whilst following these steps is an invaluable method for learning about the structure of disk partitions, it is important that you understand that errors in performing the following steps may result in loss of data. With that warning out of the way we can proceed.
The CentOS Live CD image can be downloaded from the mirror sites listed on the CentOS web site at:
Once you have loaded this page into your browser, select either the i386 or x86_64 link depending on whether the target system is a 32-bit or 64-bit platform. Within the next screen, select a mirror from the list and look for a link to download the Live CD image. This will typically be named as follows:
Once you have downloaded the image, burn it to a CD, then make sure your BIOS is configured to boot from the CDROM/DVD drive before the hard disk and then boot from the CD. The system will boot CentOS and you will have a fully functional CentOS environment to use during the repartitioning process.
Once CentOS has loaded, log in and open a terminal window (right click anywhere on the desktop and select Open in Terminal). In the terminal window, gain root privileges by executing the following command:
The fdisk tool is installed by default but the ntfsresize tool is not part of the standard CentOS distribution or installation repositories. Instead, we need to install from a different source. To enable access to the required repository, one of the following commands must be run depending on whether you are running a 32-bit or 64-bit version of CentOS:
For 32-bit systems:
rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
For 64-bit systems:
rpm -Uhv http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm
Next, we need to install the package that contains the ntfsresize utility:
yum install ntfsprogs
Now that we have installed the tools we need, the next step is to identify the disk drive on which the Windows partition resides. This is achieved by running the fdisk command as follows:
[root@livecd ~]# fdisk -l Disk /dev/sda: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x86008600 Device Boot Start End Blocks Id System /dev/sda1 * 1 2609 20956761 7 HPFS/NTFS
As we can see, in the case of the above example, we have a single disk drive (/dev/sda) which contains a single partition (/dev/sda1) that is formatted as NTFS (a sure sign that is a Windows partition). Since the Boot column for /dev/sda1 contains an asterisk we also know this is currently the hard disk’s boot partition. Depending on your system configuration you may see different results (for example if you have multiple disk drives or the disk drive contains more than one partition).
Having identified the disk and partition, we now need to find out how much unused space is available within the partition for us to free up. To obtain this information we use the ntfsresize tool as follows:
[root@livecd ~]# ntfsresize -i /dev/sda1 ntfsresize v1.13.1 (libntfs 9:0:0) Device name : /dev/sda1 NTFS volume version: 3.1 Cluster size : 4096 bytes Current volume size: 21459722752 bytes (21460 MB) Current device size: 21459723264 bytes (21460 MB) Checking filesystem consistency ... 100.00 percent completed Accounting clusters ... Space in use : 2139 MB (10.0%) Collecting resizing constraints ... You might resize at 3232075776 bytes or 3233 MB (freeing 18227 MB). Please make a test run using both the -n and -s options before real resizing!
The output from ntfsresize for our example tells us that we can safely free up 18227MB of disk space by shrinking the specified Windows partition. In practice, however, you will want to leave space on your Windows system for storing future data, so it is recommended that you do not shrink the partition to the full extent available. For the purposes of this example, therefore, we will shrink the partition to 10000MB. Before performing the live resize, it is best to run through a simulation in order to identify any potential problems before permanent changes are made. To do this, run ntfsresize with the –no-action option:
[root@livecd ~]# ntfsresize --no-action -b --size 10000M /dev/sda1 ntfsresize v1.13.1 (libntfs 9:0:0) Device name : /dev/sda1 NTFS volume version: 3.1 Cluster size : 4096 bytes Current volume size: 21459722752 bytes (21460 MB) Current device size: 21459723264 bytes (21460 MB) New volume size : 9999995392 bytes (10000 MB) Checking filesystem consistency ... 100.00 percent completed Accounting clusters ... Space in use : 2945 MB (13.7%) Collecting resizing constraints ... Needed relocations : 45 (1 MB) Schedule chkdsk for NTFS consistency check at Windows boot time ... Resetting $LogFile ... (this might take a while) Relocating needed data ... 100.00 percent completed Updating $BadClust file ... Updating $Bitmap file ... Updating Boot record ... The read-only test run ended successfully.
Assuming the read-only test runs successfully, the actual resize can be performed by running the same command, but this time without the –no-action option:
[root@livecd ~]# ntfsresize -b --size 10000M /dev/sda1 ntfsresize v1.13.1 (libntfs 9:0:0) Device name : /dev/sda1 NTFS volume version: 3.1 Cluster size : 4096 bytes Current volume size: 21459722752 bytes (21460 MB) Current device size: 21459723264 bytes (21460 MB) New volume size : 9999995392 bytes (10000 MB) Checking filesystem consistency ... 100.00 percent completed Accounting clusters ... Space in use : 2945 MB (13.7%) Collecting resizing constraints ... Needed relocations : 45 (1 MB) WARNING: Every sanity check passed and only the dangerous operations left. Make sure that important data has been backed up! Power outage or computer crash may result major data loss! Are you sure you want to proceed (y/[n])? y Schedule chkdsk for NTFS consistency check at Windows boot time ... Resetting $LogFile ... (this might take a while) Relocating needed data ... 100.00 percent completed Updating $BadClust file ... Updating $Bitmap file ... Updating Boot record ... Syncing device ... Successfully resized NTFS on device '/dev/sda1'. You can go on to shrink the device for example with Linux fdisk. IMPORTANT: When recreating the partition, make sure that you 1) create it at the same disk sector (use sector as the unit!) 2) create it with the same partition type (usually 7, HPFS/NTFS) 3) do not make it smaller than the new NTFS filesystem size 4) set the bootable flag for the partition if it existed before Otherwise you won't be able to access NTFS or can't boot from the disk! If you make a mistake and don't have a partition table backup then you can recover the partition table by TestDisk or Parted's rescue mode.
At this point we have reduced the size of the NTFS partition but the partition does not yet know we have done so. If, for example, we use fdisk to tell us about the partition, the partition table information still indicates the original size:
[root@livecd ~]# fdisk -l Disk /dev/sda: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x8f6a8f6a Device Boot Start End Blocks Id System /dev/sda1 * 1 2609 20956761 7 HPFS/NTFS
In order to address this we will have to delete the partition information and then recreate it with the new size information. Before doing so, make a note of the Start and Id values for the partition provided by the above fdisk command (since yours will almost certainly differ from the example and we will need these when we recreate the partition). Begin by starting fdisk with the name of the disk drive on which we are going to modify the partition table information:
[root@livecd ~]# fdisk /dev/sda
At the command prompt, delete the partition (for the example this is partition 1 but may be different on your system):
Command (m for help): d Selected partition 1
Next, we need to recreate the partition with the new size information (keeping in mind that we reduced the partition to 10000MB):
Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-2610, default 1): 1 Last cylinder or +size or +sizeM or +sizeK (1-2610, default 2610): +10000M
Next, the Id of the partition needs to set to the original value as indicated by the fdisk –l command (in this case 7 to indicate the partition uses the Windows NTFS format):
Command (m for help): t Selected partition 1 Hex code (type L to list codes): 7 Changed system type of partition 1 to 7 (HPFS/NTFS)
Finally, we need to make sure the partition is still bootable:
Command (m for help): p Disk /dev/sda: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x86008600 Device Boot Start End Blocks Id System /dev/sda1 1 1276 10249438+ 7 HPFS/NTFS
If the Boot column does not contain an asterisk (*) then we need to make the partition bootable before we write the new configuration disk:
Command (m for help): a Partition number (1-4): 1
Once again, it is prudent to check the settings before proceeding:
Command (m for help): p Disk /dev/sda: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x86008600 Device Boot Start End Blocks Id System /dev/sda1 * 1 1276 10249438+ 7 HPFS/NTFS
At this point none of the changes have been written to disk. In the event that the partition settings do not meet your expectations simply exit from fdisk without comitting the changes. If all is well, however, simply write the new partition information to disk as follows:
Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table.
The resize is now complete and you can reboot the system. If you check the disk volumes in the Windows XP disk manager (right click on My Computer, select Manage and choose Disk Management from the Computer Management tool). The newly freed space will be displayed as Unallocated.
Having resized the partition, reboot using the CentOS 6 installation media (as outlined in Installing CentOS 6 on a Clean Disk Drive) and proceed with the installation. When prompted to decide on where CentOS 6 is to be installed be sure to select the Use Free Space option.
Choosing an Operating System at Boot Time
Once the installation completes, the system will display the standard boot countdown screen. Pressing any key on the keyboard at this point will display the boot menu screen as illustrated in the following figure:
This menu provides the option of booting either “CentOS” or “Other”. In this instance, selecting “Other” will boot your original Windows installation. In the next section we will cover the steps to modify this menu to change the boot default and rename the “Other” menu option to something more descriptive.
Editing the CentOS 6 Boot Menu
Once you have logged into the system, completed the tasks presented by the setup agent and the desktop is visible the next step is to configure the boot menu so that it lists the alternate operating system as Windows instead of Other. The boot menu configuration settings are stored in the /boot/grub/menu.lst file. This file may be edited in a terminal window as follows:
su - gedit /boot/grub/menu.lst
When prompted by the su command to enter a password be sure to enter the root password created during the installation process, not the password you created for your user account during the setup agent configuration steps.
The contents of a typical menu.lst file is listed below:
# grub.conf generated by anaconda # # Note that you do not have to rerun grub after making changes to this file # NOTICE: You have a /boot partition. This means that # all kernel and initrd paths are relative to /boot/, eg. # root (hd0,1) # kernel /vmlinuz-version ro root=/dev/mapper/vg_centos62-lv_root # initrd /initrd-[generic-]version.img #boot=/dev/sda default=0 timeout=5 splashimage=(hd0,1)/grub/splash.xpm.gz hiddenmenu title CentOS (2.6.32-220.el6.i686) root (hd0,1) kernel /vmlinuz-2.6.32-220.el6.i686 ro root=/dev/mapper/vg_centos62-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vg_centos62/lv_swap rd_LVM_LV=vg_centos62/lv_root rd_NO_MD quiet SYSFONT=latarcyrheb-sun16 rhgb crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM initrd /initramfs-2.6.32-220.el6.i686.img title Other rootnoverify (hd0,0) chainloader +1
The above menu.lst file contains options to boot for two operating systems. The CentOS section of the configuration typically reads as follows:
title CentOS (2.6.32-220.el6.i686) root (hd0,1) kernel /vmlinuz-2.6.32-220.el6.i686 ro root=/dev/mapper/vg_centos62-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_LVM_LV=vg_centos62/ lv_swap rd_LVM_LV=vg_centos62/lv_root rd_NO_MD quiet SYSFONT=latarcyrheb-sun16 rhgb crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM initrd /initramfs-2.6.32-220.el6.i686.img
The Windows section of the configuration is likely to be similar to the following:
title Other rootnoverify (hd0,0) chainloader +1
The default=0 line indicates that the first entry in the file is to be the default operating system (in other words, the operating system that will boot by default if the user does not intervene during the boot phase). The timeout=5 directive specifies the number of seconds the boot screen is displayed before the default operating system is automatically booted.
To configure the system to boot Windows by default simply change this line so that it reads as follows:
To increase or decrease the timeout before the default operating system boots, change the timeout value (in this case to 20 seconds):
The final task in our dual boot configuration process is to rename the Windows boot option to something more descriptive than “Other”. To achieve this, simply change the “Other” line as follows:
Note that the title value can be anything you choose.
The next time the system is rebooted, the boot screen will wait 20 seconds before auto-booting. If no keys are pressed the system will now boot Windows by default, instead of CentOS 6. If the user does intervene and display the boot menu, the Windows option is now titled “Windows” and not “Other”.
Accessing the Windows Partition from CentOS 6
When running CentOS 6 in a dual boot configuration it is still possible to access files located on the Windows partition. This can be achieved by manually mounting the partition from the command-line. Before doing so, however, some additional packages need to be installed on the system. To do so, run the following commands inside a terminal window:
su - yum install fuse
Next, we need to set up access to the Dag RPMForge repositories:
For 32-bit systems:
rpm -Uhv http://apt.sw.be/redhat/el6/en/i386/rpmforge/RPMS/rpmforge-release-0.5.2-2.el6.rf.i686.rpm
For 64-bit systems:
rpm –Uhv http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.2-1.el6.rf.x86_64.rpm
Next, install the NTFS driver:
yum install fuse-ntfs-3g
Once the requisite packages are installed, the next step is to create a directory to use as the mount point for our Windows partition. In this example we will create a directory called /windows:
When prompted for a password by the su command, enter the root password specified during the CentOS 6 installation process. In order to identify the device name that has been assigned to the Windows partition, use the fdisk command as follows:
[root@localhost ~]# fdisk -l Disk /dev/sda: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x86008600 Device Boot Start End Blocks Id System /dev/sda1 * 1 1276 10249438+ 7 HPFS/NTFS /dev/sda2 1277 1340 512000 83 Linux /dev/sda3 1340 2611 10209280 8e Linux LVM
In the above output, the main Windows partition containing the files we need access to is /dev/sda1.
Next, we need to run the mount command (still with root privileges and assuming the Windows partition is /dev/sda1 and NTFS format – this may be different on your system):
mount –t ntfs-3g /dev/sda1 /windows
Under some circumstances you may get a message that the Windows partition needs to be checked. If so, either reboot into Windows again and manually run chkdsk (if it does not run automatically during the boot process), or force the mount with the –o option:
mount /dev/sda2 /windows -o force
To automate the mount each time the system is booted, simply add the mount line to the /etc/fstab file:
/dev/sda1 /windows ntfs defaults 0 0
To unmount the Windows file system at any time:
The Live CD image can be downloaded from the mirror sites listed on the CentOS web site at:
Once you have loaded this page into your browser, select either the i386 or x86_64 link depending on whether the target system is a 32-bit or 64-bit platform. Within the next screen select a mirror from the list to view the available downloads and look for a link to download the Live CD image. This will typically be named as follows:
CentOS-<version>-<architecture>-LiveCD.iso nce you have downloaded the image, burn it to a CD, then make sure your BIOS is configured to boot from the CDROM/DVD drive before the hard disk and then boot from the CD. The system will boot CentOS and you will have a fully functional CentOS environment to explore.
A couple of points should be noted about the Live CD. Firstly, in addition to providing a live, bootable environment in which to try out CentOS 6, the Live CD also provides the ability to install the operating system onto a hard disk drive. Once the live system is running, simply look for the Install to Hard Drive icon on the desktop. Installation from a Live CD involves a preconfigured operating system image being written directly to the disk drive with no control over which packages get installed. Whilst packages may be added and removed post-installation, if detailed control over package selection during installation is required it is necessary to perform the installation using the CentOS 6 installation DVD images.
Secondly, because the Live CD system runs on a virtual disk drive in memory, as soon as you shut down or reboot the system any files you have created will be lost.
Finally, the performance of running an operating system from a CDROM is going to be orders of magnitude slower than running from a disk drive, so don’t be put off by the sluggishness of the system while you are trying it out. This is entirely indicative of the slow speed of CDROM drives, not a reflection of the performance of the operating system.
The Live CD is a good way to quickly get a copy of CentOS 6 up and running without wiping or repartitioning disk drives, but to really appreciate the power of the CentOS 6, you need to install it to a disk drive.
After you decide to install CentOS 6 onto a hard disk drive it is worth keeping the Live CD in a safe place. It is an ideal tool for performing system rescue and maintenance tasks in the event of problems with the installed system.
Obtaining the CentOS 6 Installation Media
An alternative to running the Live CD is to install directly onto a hard disk drive using the CentOS 6 installation media. In addition to installing from within the Live CD, it is also possible to download and install directly from the CentOS 6 installation media. Once again, go to the following URL and select either the 32-bit or 64-bit link to view available download mirrors:
The installation distribution is downloaded in the form of two ISO format DVD images. The DVD images are named using the following convention:
Alternatively, the image may be downloaded using BitTorrent by selecting the corresponding .torrent file.
Having downloaded the DVD images, either burn them to disk or configure your virtualization environment to treat them as virtual DVD drives.
Installing CentOS 6
Insert the first CentOS 6 DVD into the appropriate drive and power on the system. If the system tries to boot from the hard disk drive you will need to enter the BIOS setup menu for your computer and change the boot order so that it boots from the DVD drive first. Once the system has booted you will be presented with the following screen:
To install using the graphical installer, simply select the first installation option and press the <Enter> key. If you encounter problems with the display when the graphical installer begins, reboot and try again with the basic video driver option. Note also that if the host system has insufficient memory or a graphics card is not detected, the installer will run in text mode. To force the installation to take place in text mode, press the Esc key when the above menu screen is displayed and enter linux text at the resulting boot prompt followed by Enter.
Options are also available to boot from the current operating system on the local drive (if one is installed), test the system memory, or rescue an installed CentOS 6 system. The last option alone is reason enough to keep the installation DVD in a safe place in case you need to perform a rescue at some future date.
The CentOS 6 installer will then provide the option to test the installation media for errors. Use the arrow keys to navigate between the options and make a selection with the <Enter> key. After a short delay the first screen of the graphical installer will appear. Navigate through the next few pages to configure your preferred language, keyboard type and storage devices (unless you plan to use a Storage Area Network device, the Basic option is recommended). If the installer detects that the target disk needs to be initialized, a dialog will appear seeking confirmation.
When prompted, enter a suitable host name for the CentOS 6 installation. This is the name by which the system will be identified on the network to which it is attached. Additional network configuration options may be modified by clicking on the Configure Network button, selecting a network interface and clicking on the Edit… button.
Timezone and the Root Password
Subsequent screens will request information about Timezone and the root password of the system.
On the Timezone screen, make a selection corresponding to your geographical location. The option is also provided to use UTC which automatically adjusts the time to account for daylight savings time. If the computer on which CentOS 6 is being installed also runs another operating system which already uses UTC (such as Windows), leave this option unselected.
On the next screen, enter a password for the root account on the system. The root, or super-user account, is a special user that has administrative privileges on the system. Whilst you will generally use your own account to log into the system, you will need to gain root privileges in order to configure the system and to perform other administrative tasks.
The installer will subsequently move on to the disk partitioning screen.
Partitioning a Disk for CentOS 6
When you reach the disk partitioning phase of the installation, the installer will present a screen similar to the one illustrated in the following figure:
A number of options are provided for allocating space for the installation of CentOS 6:
- Use All Space – The entire disk drive will be assigned to the CentOS 6 operating system installation. Any pre-existing partitions, together with any existing operating systems and associated data files contained therein will be deleted to make room for CentOS. This option should only be used if you are absolutely sure you no longer need anything that is currently stored on that disk, or have already backed up all user files.
- Replace existing Linux System(s) – If the drive was previously configured to support a Windows/Linux dual boot environment or was devoted entirely to another Linux installation, this option may be selected to instruct the installer to delete the pre-existing Linux partition and replace it with CentOS 6. Once again, it is important to backup any user data that may still be needed.
- Shrink Current system – Allows an existing partition to be reduced in size to make room on the drive for the CentOS 6 installation. More details on this option are provided in a later chapter entitled Installing CentOS 6 with Windows in Dual Boot Environment.
- Use Free Space – If the current partitions on the drive do not take up the entire disk space available, any unallocated space may be assigned to the CentOS 6 installation using this option.
- Create Custom Layout – When selected, this option displays the disk partitioning tool allowing each partition on the disk to be manually configured. Unless you have experience with low level disk partitioning this option is not recommended.
we are assuming the entire disk is available to accommodate the CentOS 6 installation so select the Use All Space option.
Beneath the partition menu is the option to encrypt the system. The choice of whether to use encryption will depend on the purpose for which the system is being used, its physical location and type of data it is going to store. Keep in mind that as with any form of encryption there are performance overheads associated with selecting this option.
Having made the partitioning selection, click Next to begin the partitioning process.
Linux is a modular operating system in that it provides a basic operating system kernel and infrastructure upon which a range of different packages may be installed depending on your specific requirements for the system. If, for example, you plan on using the system as a web server you would need to install the Apache web server package.
At this point in the installation the installer needs us to decide which packages should be installed along with the base operating system and displays the screen shown in the following figure:
This screen allows you to make general choices about the type of functions you need the system to perform. Ideally, you should select the option that most closely resembles the intended purpose of the system.
To view or modify the specific package selections, make sure that the Customize now option is selected before proceeding. You will then be provided a complete overview of which packages are selected for installation and which are not together with the ability to make changes to these selections. Don’t worry too much about getting this exactly right at this stage. Packages can be added and removed at any time after the installation is complete by selecting the desktop System -> Administration -> Add/Remove Software menu option. In the interests of security and efficiency it is generally recommended that the minimum number of packages be installed initially and then other packages added on as needed basis once the operating system is up and running.
The Physical Installation
Having made the appropriate package selections, clicking Next will initiate the installation process. During the installation process, the installer will provide a running commentary of the selected packages as they are installed together a progress bar. If you are using the DVD the installation will complete without further interaction. Once the installation process is complete a screen will appear containing a button to reboot the system. Remove the installation media and click the button.
Final Configuration Steps
After the system has started for the first time, the CentOS 6 Setup Agent will appear with a welcome message. Click on the Forward button to display licensing terms and conditions and select the option to accept the terms of the agreement (assuming of course that you do agree to them).
Work through the remaining screens to create a user account for yourself and verify the date and time. If you would like the date and time of your CentOS 6 system to be synchronized with an external Network Time Protocol server, select the Synchronize date and time over network option before proceeding. Finally, choose whether or not to enable Kdump support.
Having worked through all the set up pages, click Finish to exit the setup agent and log in using your newly created account credentials.
As with most operating systems today, the each particular release of CentOS 6 distribution continues to evolve after it has been released to the public. This generally takes the form of bug fixes and security updates and, occasionally, new features that may be downloaded over the internet and installed on your system.
Best practices dictate that the first step after installing CentOS 6 is to make sure any available updates are applied to the system. This can be achieved either through the desktop environment or via the command-line prompt in a Terminal window. The CentOS 6 desktop environment places an indicator in the top desktop panel to notify the user that updates are available to be applied to the system. This indicator takes the form of orange star with a bug crawling on it. Moving the mouse pointer over this icon will display a message indicating the number of updates that are currently available for the system as illustrated in the following figure:
To identify and apply updates using the graphical software update tool, either click on the toolbar icon or select the System -> Administration -> Software Update desktop menu option. The resulting dialog will download a list of available updates and provide the option for those updates to be applied to the system:
Clicking the Install Updates button will begin the update process which consists of resolving package dependencies, downloading and installation of the updates. The duration of the update process will depend on the number and size of updates available combined with the speed of the internet connection to which the CentOS system is connected.
The latest updates may also be applied from within a terminal window (Applications -> System Tools -> Terminal) using the yum command:
su – yum update
Upon execution, the yum tool will provide a list of packages that are available for update and prompt to perform the update. Once the update is complete the installation is essentially finished and CentOS 6 is ready for use.
Along with acting as a web server, email is one of the primary uses of a CentOS 6 based system, particularly in business environments. Given both the importance and popularity of email it is surprising to some people to find out how complex the email structure is on a Linux system and this complexity can often be a little overwhelming to the CentOS newcomer.
The good news is that much of the complexity is there to allow experienced email administrators to achieve complicated configurations for large scale enterprise installations. The fact is that for most Linux users it is relatively straight forward to set up a basic email system so that they can send and receive electronic mail.
In this chapter of CentOS 6 Essentials, we will explain the basics of Linux based email configuration and step through configuring a basic email environment. In the interests of providing the essentials, we will leave the complexities of the email system for more advanced books on the subject.
The structure of the Email System
There are a number of components that make up a complete email system. Below is a brief description of each one:
Mail User Agent
This is the part of the system that the typical user is likely to be most familiar with. The Mail User Agent (MUA), or mail client, is the application that is used to write, send and read email messages. Anyone who has written and sent a message on any computer has used a Mail User Agent of one type or another.
Typical Graphical MUA’s on Linux are Evolution, Thunderbird and KMail. For those who prefer a text based mail client, there are also the more traditional pine and mail tools.
Mail Transfer Agent
The Mail Transfer Agent (MTA) is the part of the email system that does much of the work of transferring the email messages from one computer to another (either on the same local network or over the internet to a remote system). Once configured correctly, most users will not have any direct interaction with their chosen MTA unless they wish to re-configure it for any reason. There are many choices of MTA available for Linux including sendmail, Postfix, Fetchmail, Qmail and Exim.
Mail Delivery Agent
Another part of the infrastructure that is typically hidden from the user, the Mail Delivery Agent (MDA) sits in the background and performs filtering on the email messages between the Mail Transfer Agent and the mail client (MUA). The most popular form of MDA is a spam filter to remove all the unwanted email messages from the system before they reach the inbox of the user’s mail client (MUA). Popular MDAs are Spamassassin and Procmail. It is important to note that some Mail User Agent applications (such as Evolution, Thunderbird and KMail) include their own MDA filtering. Others, such as Pine and Basla, do not. This can be a source of confusion to the Linux beginner.
SMTP is an acronym for Simple Mail Transport Protocol. This is the protocol used by the email systems to transfer mail messages from one server to another. This protocol is essentially the communications language that the MTAs use to talk to each other and transfer messages back and forth.
Configuring a CentOS 6 Email System
Many systems use the Sendmail MTA to transfer email messages and on many Linux distributions this is the default Mail Transfer Agent. Sendmail is, however, a complex system that can be difficult for beginner and experienced user alike to understand and configure. It is also falling from favor because it is considered to be slower at processing email messages than many of the more recent MTAs available.
Many system administrators are now using Postfix or Qmail to handle email. Both are faster and easier to configure than Sendmail.
For the purposes of this chapter, therefore, we will look at Postfix as an MTA because of its simplicity and popularity. If you would prefer to use Sendmail there are many books that specialize in the subject and that will do the subject much more justice than we can in this chapter.
Postfix Pre-Installation Steps
The first step before installing Postfix is to make sure that Sendmail is not already running on your system. You can check for this using the following command:
/sbin/service sendmail status
If sendmail is not installed, the tool will display a message similar to the following:
sendmail: unrecognized service
If sendmail is installed, but not running the following output will be displayed:
sendmail is stopped
If sendmail is running you will see the following:
sendmail (pid 2138) is running
If sendmail is running on your system it is necessary to stop it before installing and configuring Postfix. To stop sendmail run the following command as super user:
/sbin/service sendmail stop
The next step is to ensure that sendmail does not get restarted automatically when the system is rebooted. The first step is to find out which run levels will automatically start sendmail. To do this we can use the chkconfig command-line tool as follows:
/sbin/chkconfig --list | grep sendmail
The above command will typically result in output similar to:
sendmail 0:off 1:off 2:on 3:on 4:on 5:on 6:off
This means that if the system boots into runlevels 2, 3, 4 or 5 then the sendmail service will automatically start. To turn off sendmail we can once again use the chkconfig command as follows:
/sbin/chkconfig sendmail off
The chkconfig tool defaults to changing the settings for runlevels 2, 3, 4 and 5. You can configure for specific runlevels using the –levels command line option if necessary.
To verify the settings run chkconfig one more time as follows:
/sbin/chkconfig --list | grep sendmail
And check that the output is as follows:
sendmail 0:off 1:off 2:off 3:off 4:off 5:off 6:off
Sendmail is now switched off and configured so that it does not auto start when the system is booted. We can now move on to installing Postfix.
Installing Postfix on CentOS 6
By default, the CentOS 6 installation process installs Postfix for most configurations. To verify if Postfix is already installed, use the following rpm command in a Terminal window:
rpm -q postfix
If rpm reports that postfix is not installed, it may be installed as follows:
su - yum install postfix
The yum tool will download and install postfix, and configure a special postfix user in the /etc/passwd file.
The main configuration settings for Postfix are located in the /etc/postfix/main.cf file. There are many resources on the internet that provide detailed information on Postfix so this section will focus on the basic options required to get email up and running.
The key options in the main.cf file are:
myhostname = mta1.domain.com mydomain = domain.com myorigin = $myhostname inet_interfaces = $myhostname
Other settings will have either been set up for you by the installation process or are not needed unless you are feeling adventurous and want to configure a more sophisticated email system.
The format of myhostname is host.domain.extension. For example if your Linux system is called MyLinuxHost and your internet domain is MyDomain.com you would set the myhostname option as:
myhostname = mylinuxhost.mydomain.com The mydomain setting is just the domain part of the above setting. For example: mydomain = mydomain.com
The myorigin and inet_interfaces options use the settings we have just created so do not need to be changed (although the inet_interfaces may be commented out by default so you should remove the # at the beginning of this particular line in the main.cf file).
Starting Postfix on a CentOS 6 System
Once the /etc/postfix/main.cf file is configured with the correct settings it is now time to start up postfix. This can be achieved from the command line as follows:
The postfix process should now start up. The best way to check that everything is working is to check your mail log. This is typically in /var/log/maillog and should now contain an entry that looks like:
Nov 21 13:05:46 mylinuxhost postfix/postfix-script: starting the Postfix mail system Nov 21 13:05:46 mylinuxhost postfix/master: daemon started -- version 2.2.5, configuration /etc/postfix
As long as you don’t see any error messages you have successfully installed and started Postfix and you are ready to set up a mail client and start communicating with the outside world.
To configure Postfix to start automatically at system startup, run the following command in a Terminal window:
/sbin/chkconfig --level 345 postfix on
Amongst the many packages that make up the CentOS 6 operating system is the Apache web server. In fact the scalability and resilience of CentOS 6 makes it an ideal platform for hosting even the most heavily trafficked web sites.
In this chapter we will explain how to configure a CentOS 6 system using Apache to act as a web server.
- 1 Requirements for Configuring a CentOS 6 Web Server
- 2 Installing the Apache Web Server on CentOS 6
- 3 Starting the Apache Web Server
- 4 Testing the Web Server
- 5 Configuring the Apache Web Server for Your Domain
- 6 Web Server and Firewall Issues
Requirements for Configuring a CentOS 6 Web Server
To set up your own web site you need a computer, an operating system, a web server, a domain name, a name server and an IP address.
The computer can be any system capable of running Linux. In terms of an operating system, we will, of course, assume you are using CentOS 6. As previously mentioned CentOS supports the Apache web server which can easily be installed once the operating system is up and running. A domain name can be registered with any domain name registration service.
If your ISP provides static IP addresses then you will need to associate your domain with your static IP address. This is achieved using a name server. Most domain registration services will provide this service for you.
If you do not have a static IP address (i.e. your ISP provides you with a dynamic address which changes frequently) then you can use one of a number of free services which map your dynamic IP address to your domain name. One such service is provided by http://www.dnsExit.com.
Once you have your domain name and your name server configured the next step is install and configure your web server.
Installing the Apache Web Server on CentOS 6
The current release of CentOS typically does not install the Apache web server by default. To check whether the server is already installed, open a Terminal window (Applications -> System Tools -> Terminal) and run the following command:
rpm -q httpd
If rpm generates output similar to the following, the apache server is already installed:
Alternatively, if rpm generates a “package httpd is not installed” message then the next step, obviously, is to install it. This can be performed either from the command-line or using the Add/Remove Software tool. To use this tool, open the System -> Administration desktop menu and select Add/Remove Software. Enter your root password if prompted to do so. Select the Search tab and search for httpd. After the search completes the Apache HTTP Server should be listed in the search results. Click on the toggle next to the httpd server. Finally, click on the Apply button to begin the installation.
To install Apache from the command-line start a terminal window (Applications -> System Tools -> Terminal) and run the following commands at the command prompt:
su - yum install httpd
Starting the Apache Web Server
Once the Apache server is installed, the next step is to verify that the server is running and, if it is not yet running, to start it.
The status of the server can be verified from the command-line or via the GUI Service Configuration tool. To check the status of the Apache httpd service from the command-line, enter the following command in a Terminal window:
/sbin/service httpd status
If the above command indicates that the httpd service is not running, it can be launched from the command-line as follows:
su - /sbin/service httpd start
If you would like the Apache httpd service to start automatically when the system boots (for example when booting to runlevel 3), this can be achieved by running the following command:
/sbin/chkconfig --level 3 httpd on
For more information on runlevels refer to the chapter entitled Configuring CentOS 6 Runlevels and Services.
To configure the Apache service using the Service Configuration tool, select the System -> Administration -> Services menu option and scroll down the list of services until you find httpd. Select the item in the list and click on the Start button.
Testing the Web Server
Once the installation is complete the next step is to verify the web server is up and running. To do this fire up the web browser by clicking on the web browser icon in the top desktop panel and enter 127.0.0.1 in the address bar (127.0.0.1 is the loop-back network address which tells the system to connect to the local machine). The browser should load the CentOS Test Page:
Congratulations, you have now installed the web server and served up what will hopefully be the first of many web pages.
Configuring the Apache Web Server for Your Domain
The next step in setting up your web server is to configure it for your domain name. This is performed in the /etc/httpd directory. To configure the web server open a terminal window and change directory to /etc/httpd. In this directory you will find a number of sub-directories. Change directory into the conf sub-directory where you will find an httpd.conf file which contains the configuration settings for the Apache server.
Edit the httpd.conf’ file using your favorite editor using the su command to ensure you have write permission to the file. Once loaded, there are a number of settings that need to be changed to match your environment.
The ServerAdmin directive defines an administrative email address for people wishing to contact the webmaster for your site. Change this to an appropriate email address where you can be contacted:
Next the ServerName and ServerAlias directives need to be defined so that the web server knows which virtual host this configuration file refers to:
Next, we need to define where the web site files are going to be located using the DocumentRoot directive. The tradition is to use /var/www/domain-name:
Next, create the /var/www/myexample.com directory and place an index.html file in it. For example:
<html> <title>Sample Web Page</title> <body> Welcome to MyExample.com </body> </html>
The last step is to restart the apache web server to make sure it picks up our new settings:
su - /sbin/service httpd restart
Web Server and Firewall Issues
If your CentOS 6 system is configured to use a firewall, you will need to ensure that HTTP traffic on port 80 is permitted in order for external systems to be able to access your web server. Refer to Basic CentOS 6 Firewall Configuration for details on configuring a CentOS Firewall.
If the CentOS 6 system hosting your web server sits on a network protected by a firewall (either another computer running a firewall, or a router or wireless base station containing built in firewall protection) you will need to configure the firewall to forward port 80 to your web server system. The mechanism for performing this differs between firewalls and devices so check your documentation to find out how to configure port forwarding.
Once everything is configured it should be possible to enter the domain name of your web site into a browser anywhere in the world and access your web server.
First of all u have to get an static IP-Address.
Need a a static ip-address for ur FTP Server.Necessity for getting this static ip-address is ur not suppose to use ur own IP-Address.The main reason is u dont want to show ur IP-Address to everyone , there are many other reasons too but leave them aside..
1) Goto no-ip & create urself a free account.
2) Now ur account been created & ll receive ur account password via mail to ur email address.
3) After getting ur password login to ur account of no-ip.com
4.After getting logged in, click upon add a HOST its on the left menu.
5) Type any hostname u want (eg:-abc) & select any domain from da given list (eg:-ftpserve.com) Click on Submit.
6) Now u have owned ur own static address (example: abc.serveftp.com)
7) Now click downloads button which is present above on the page & click on which operating system ur using & den download DNS update client or u can download it from here directly, this is for microsoft window users..
8) After getting downloaded, u have to install this software & login here with ur email addresss & p/w wen asked for it.
9) At last tick on da check box present at the static address.
10) U have ur own static web address.
Installation & setting of the FTP-Server
1) You have to install Serv-U 4.1.03 , download this software from here
2) Run Serv-U & use da wizard to setup ur FTP.
3) Click on next until u have been asked for IP-Address, leave it as it is & click upon next.
4) Enter ur domain name u have registered (example: abc.serveftp.com) it above in da domain field & click upon next.
5) U ll be asked for anonymous access, select No & click upon next.
6) Next u ll be asked for creating a named account, select yes & click upon next.
7) Choose any user name u wish (eg:-xyz) & clcik upon next.
8) Enter password for dis account (eg:-adc341) for security purpose choose difficult password.
9) U ll be asked for da home directory for the account which u have created above.Select directory & click upon next.
10) Click on yes for locking dis account to da home directory, doing dis da user cannot further move up into home directory, click upon next.
11) At last ur account has been created click finish.
Configuring the user accounts which u have been created.
1) On the left tree-menu, select da account which u have been created above & den click upon General Tab.
2) Goto Hide ‘Hidden’ Files.
3) Check Allow only and enter the number one in the box.
4) Set da maximum downloading speed upto wat extent u want.As this is an account so many ll be using so set it low(eg:-10-20) to save ur bandwidth.Don’t leave it blank as uers can download with full bandwidth.
5) choose how many users u want to login at on time.It depends on ur connection speed try these (56 – 1, ISDN – 3, ADSL or cable – 5-6 users.)
6) Click upon Dir Access Tab.
7) Now u can c home folder here.Highlight it & make ur permission.
8) If u want only users to download check only these Read,List & Inherit.
9) If u want ur users to upload into ur server & bu tto only 1 particular folder but not to downlaod, click upon dat add button & then select dat folder, Now u have to highlight dat folder & set these permissions on dat folder.Check,Write,Appened,List,Create & Inherit after setting these permissions click on the arrow which is present at the bottom right-hand corner.U want dis upload folder 2 be list first, before da home folder.
10) If der is any folder which u dont want anyone to access it, & it is present in the home folder, den click da add button & den select da folder.Now u have to highlight dat folder & see dat no all da checkboxes are left.After doing this click upon upper arrow which is present at bottom right hand corner.
11) There are many things u can do, These are only the basics….
12) Your server is now ready to be connected..
13) Login with your username & password…