Archive for category centos

Linux Important System Files

File Purpose Where to Find More Information
User and Security Files
/etc/group User group information group, chmod
/etc/npasswd npasswd configuration file npasswd
/etc/shadow shadow password file password, npasswd
/etc/passwd User account information password, chmod
Networking Files
/etc/bootptab Internet Bootstrap Protocol server database bootptab
/etc/exports Directories to export to NFS clients exports
/etc/gateways List of gateways routed
/etc/hosts Hostname to IP address mapping file route
/etc/hosts.equiv Lists of trusted hosts and remote users hosts.equiv
/etc/inetd.conf inetd configuration file inetd
/etc/named.conf named default initialization file named
/etc/networks Known networks route
/usr/lib/named or/etc/named.d named configuration files named
/etc/smb.conf or /etc/samba/smb.conf SAMBA configuration file smb.conf
/etc/snmpd.conf SNMP daemon configuration file snmpd.conf
/etc/ftpaccess FTP configuration file ftpaccess
/etc/httpd/access.conf HTTP access configuration file
/etc/httpd/httpd.conf HTTP daemon configuration file
/etc/httpd/srm.conf HTTP server resource management configuration file
/etc/services Network services list services(5)
X-Windows Files
/etc/XF86Config or /etc/X11/XF86Config X-Server configuration file XF86Config, xf86config
/etc/X11/xinit/xinitrc xinit configuration file xinit
$HOME/.xinitrc User-specific xinit configuration file xinit
$HOME/.fvwmrc fvwm configuration file fvwm, X
/usr/lib/X11/system.fvwmrc System default MWM configuration file fvwm, X
/usr/lib/X11/app-defaults Application-specific defaults X
$HOME/.Xdefaults-hostname Host-specific defaults X
System Start-Up Files
/etc/inittab init configuration file inittab
/etc/lilo.conf Lilo configuration file lilo.conf, lilo
/etc/rc* System start-up scripts init, initscript
System Log Files
/etc/syslog.conf System login configuration file syslog.conf
/var/log/message General system log file syslogd
Miscellaneous Files
/etc/profile
/etc/bashrc
/etc/cshrc
Systemwide shell configuration files man-page for respective shell
$HOME/.bashrc
$HOME/.chsrc
$HOME/.kshrc
User-specifc shell configuration files man-page for respective shell
/etc/sysconfig Miscellaneous configuration files

Leave a comment

FTP Bash script for auto file transfer and backup

#!/bin/bash

ftp_site=ftp://yoursite.com
username=roger
passwd=abc123
backupdir=$HOME
filename="backup-$(date '+%F-%H%M').tar.gz"

echo "Creating a backup file $filename of $backupdir."

# Make a tar gzipped backup file
tar -cvzf  "$filename" "$backupdir"

ftp -in <<EOF
open $ftp_site
user $username $passwd
bin
put $filename 
close 
bye
EOF

Leave a comment

configure Kdump in centos (to recover data)

1	================================================================
2	Documentation for Kdump - The kexec-based Crash Dumping Solution
3	================================================================
4	
5	This document includes overview, setup and installation, and analysis
6	information.
7	
8	Overview
9	========
10	
11	Kdump uses kexec to quickly boot to a dump-capture kernel whenever a
12	dump of the system kernel's memory needs to be taken (for example, when
13	the system panics). The system kernel's memory image is preserved across
14	the reboot and is accessible to the dump-capture kernel.
15	
16	You can use common commands, such as cp and scp, to copy the
17	memory image to a dump file on the local disk, or across the network to
18	a remote system.
19	
20	Kdump and kexec are currently supported on the x86, x86_64, ppc64, ia64,
21	and s390x architectures.
22	
23	When the system kernel boots, it reserves a small section of memory for
24	the dump-capture kernel. This ensures that ongoing Direct Memory Access
25	(DMA) from the system kernel does not corrupt the dump-capture kernel.
26	The kexec -p command loads the dump-capture kernel into this reserved
27	memory.
28	
29	On x86 machines, the first 640 KB of physical memory is needed to boot,
30	regardless of where the kernel loads. Therefore, kexec backs up this
31	region just before rebooting into the dump-capture kernel.
32	
33	Similarly on PPC64 machines first 32KB of physical memory is needed for
34	booting regardless of where the kernel is loaded and to support 64K page
35	size kexec backs up the first 64KB memory.
36	
37	For s390x, when kdump is triggered, the crashkernel region is exchanged
38	with the region [0, crashkernel region size] and then the kdump kernel
39	runs in [0, crashkernel region size]. Therefore no relocatable kernel is
40	needed for s390x.
41	
42	All of the necessary information about the system kernel's core image is
43	encoded in the ELF format, and stored in a reserved area of memory
44	before a crash. The physical address of the start of the ELF header is
45	passed to the dump-capture kernel through the elfcorehdr= boot
46	parameter. Optionally the size of the ELF header can also be passed
47	when using the elfcorehdr=[size[KMG]@]offset[KMG] syntax.
48	
49	
50	With the dump-capture kernel, you can access the memory image, or "old
51	memory," in two ways:
52	
53	- Through a /dev/oldmem device interface. A capture utility can read the
54	  device file and write out the memory in raw format. This is a raw dump
55	  of memory. Analysis and capture tools must be intelligent enough to
56	  determine where to look for the right information.
57	
58	- Through /proc/vmcore. This exports the dump as an ELF-format file that
59	  you can write out using file copy commands such as cp or scp. Further,
60	  you can use analysis tools such as the GNU Debugger (GDB) and the Crash
61	  tool to debug the dump file. This method ensures that the dump pages are
62	  correctly ordered.
63	
64	
65	Setup and Installation
66	======================
67	
68	Install kexec-tools
69	-------------------
70	
71	1) Login as the root user.
72	
73	2) Download the kexec-tools user-space package from the following URL:
74	
75	http://kernel.org/pub/linux/utils/kernel/kexec/kexec-tools.tar.gz
76	
77	This is a symlink to the latest version.
78	
79	The latest kexec-tools git tree is available at:
80	
81	git://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git
82	and
83	http://www.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git
84	
85	There is also a gitweb interface available at
86	http://www.kernel.org/git/?p=utils/kernel/kexec/kexec-tools.git
87	
88	More information about kexec-tools can be found at
89	http://www.kernel.org/pub/linux/utils/kernel/kexec/README.html
90	
91	3) Unpack the tarball with the tar command, as follows:
92	
93	   tar xvpzf kexec-tools.tar.gz
94	
95	4) Change to the kexec-tools directory, as follows:
96	
97	   cd kexec-tools-VERSION
98	
99	5) Configure the package, as follows:
100	
101	   ./configure
102	
103	6) Compile the package, as follows:
104	
105	   make
106	
107	7) Install the package, as follows:
108	
109	   make install
110	
111	
112	Build the system and dump-capture kernels
113	-----------------------------------------
114	There are two possible methods of using Kdump.
115	
116	1) Build a separate custom dump-capture kernel for capturing the
117	   kernel core dump.
118	
119	2) Or use the system kernel binary itself as dump-capture kernel and there is
120	   no need to build a separate dump-capture kernel. This is possible
121	   only with the architectures which support a relocatable kernel. As
122	   of today, i386, x86_64, ppc64 and ia64 architectures support relocatable
123	   kernel.
124	
125	Building a relocatable kernel is advantageous from the point of view that
126	one does not have to build a second kernel for capturing the dump. But
127	at the same time one might want to build a custom dump capture kernel
128	suitable to his needs.
129	
130	Following are the configuration setting required for system and
131	dump-capture kernels for enabling kdump support.
132	
133	System kernel config options
134	----------------------------
135	
136	1) Enable "kexec system call" in "Processor type and features."
137	
138	   CONFIG_KEXEC=y
139	
140	2) Enable "sysfs file system support" in "Filesystem" -> "Pseudo
141	   filesystems." This is usually enabled by default.
142	
143	   CONFIG_SYSFS=y
144	
145	   Note that "sysfs file system support" might not appear in the "Pseudo
146	   filesystems" menu if "Configure standard kernel features (for small
147	   systems)" is not enabled in "General Setup." In this case, check the
148	   .config file itself to ensure that sysfs is turned on, as follows:
149	
150	   grep 'CONFIG_SYSFS' .config
151	
152	3) Enable "Compile the kernel with debug info" in "Kernel hacking."
153	
154	   CONFIG_DEBUG_INFO=Y
155	
156	   This causes the kernel to be built with debug symbols. The dump
157	   analysis tools require a vmlinux with debug symbols in order to read
158	   and analyze a dump file.
159	
160	Dump-capture kernel config options (Arch Independent)
161	-----------------------------------------------------
162	
163	1) Enable "kernel crash dumps" support under "Processor type and
164	   features":
165	
166	   CONFIG_CRASH_DUMP=y
167	
168	2) Enable "/proc/vmcore support" under "Filesystems" -> "Pseudo filesystems".
169	
170	   CONFIG_PROC_VMCORE=y
171	   (CONFIG_PROC_VMCORE is set by default when CONFIG_CRASH_DUMP is selected.)
172	
173	Dump-capture kernel config options (Arch Dependent, i386 and x86_64)
174	--------------------------------------------------------------------
175	
176	1) On i386, enable high memory support under "Processor type and
177	   features":
178	
179	   CONFIG_HIGHMEM64G=y
180	   or
181	   CONFIG_HIGHMEM4G
182	
183	2) On i386 and x86_64, disable symmetric multi-processing support
184	   under "Processor type and features":
185	
186	   CONFIG_SMP=n
187	
188	   (If CONFIG_SMP=y, then specify maxcpus=1 on the kernel command line
189	   when loading the dump-capture kernel, see section "Load the Dump-capture
190	   Kernel".)
191	
192	3) If one wants to build and use a relocatable kernel,
193	   Enable "Build a relocatable kernel" support under "Processor type and
194	   features"
195	
196	   CONFIG_RELOCATABLE=y
197	
198	4) Use a suitable value for "Physical address where the kernel is
199	   loaded" (under "Processor type and features"). This only appears when
200	   "kernel crash dumps" is enabled. A suitable value depends upon
201	   whether kernel is relocatable or not.
202	
203	   If you are using a relocatable kernel use CONFIG_PHYSICAL_START=0x100000
204	   This will compile the kernel for physical address 1MB, but given the fact
205	   kernel is relocatable, it can be run from any physical address hence
206	   kexec boot loader will load it in memory region reserved for dump-capture
207	   kernel.
208	
209	   Otherwise it should be the start of memory region reserved for
210	   second kernel using boot parameter "crashkernel=Y@X". Here X is
211	   start of memory region reserved for dump-capture kernel.
212	   Generally X is 16MB (0x1000000). So you can set
213	   CONFIG_PHYSICAL_START=0x1000000
214	
215	5) Make and install the kernel and its modules. DO NOT add this kernel
216	   to the boot loader configuration files.
217	
218	Dump-capture kernel config options (Arch Dependent, ppc64)
219	----------------------------------------------------------
220	
221	1) Enable "Build a kdump crash kernel" support under "Kernel" options:
222	
223	   CONFIG_CRASH_DUMP=y
224	
225	2)   Enable "Build a relocatable kernel" support
226	
227	   CONFIG_RELOCATABLE=y
228	
229	   Make and install the kernel and its modules.
230	
231	Dump-capture kernel config options (Arch Dependent, ia64)
232	----------------------------------------------------------
233	
234	- No specific options are required to create a dump-capture kernel
235	  for ia64, other than those specified in the arch independent section
236	  above. This means that it is possible to use the system kernel
237	  as a dump-capture kernel if desired.
238	
239	  The crashkernel region can be automatically placed by the system
240	  kernel at run time. This is done by specifying the base address as 0,
241	  or omitting it all together.
242	
243	  crashkernel=256M@0
244	  or
245	  crashkernel=256M
246	
247	  If the start address is specified, note that the start address of the
248	  kernel will be aligned to 64Mb, so if the start address is not then
249	  any space below the alignment point will be wasted.
250	
251	
252	Extended crashkernel syntax
253	===========================
254	
255	While the "crashkernel=size[@offset]" syntax is sufficient for most
256	configurations, sometimes it's handy to have the reserved memory dependent
257	on the value of System RAM -- that's mostly for distributors that pre-setup
258	the kernel command line to avoid a unbootable system after some memory has
259	been removed from the machine.
260	
261	The syntax is:
262	
263	    crashkernel=<range1>:<size1>[,<range2>:<size2>,...][@offset]
264	    range=start-[end]
265	
266	    'start' is inclusive and 'end' is exclusive.
267	
268	For example:
269	
270	    crashkernel=512M-2G:64M,2G-:128M
271	
272	This would mean:
273	
274	    1) if the RAM is smaller than 512M, then don't reserve anything
275	       (this is the "rescue" case)
276	    2) if the RAM size is between 512M and 2G (exclusive), then reserve 64M
277	    3) if the RAM size is larger than 2G, then reserve 128M
278	
279	
280	
281	Boot into System Kernel
282	=======================
283	
284	1) Update the boot loader (such as grub, yaboot, or lilo) configuration
285	   files as necessary.
286	
287	2) Boot the system kernel with the boot parameter "crashkernel=Y@X",
288	   where Y specifies how much memory to reserve for the dump-capture kernel
289	   and X specifies the beginning of this reserved memory. For example,
290	   "crashkernel=64M@16M" tells the system kernel to reserve 64 MB of memory
291	   starting at physical address 0x01000000 (16MB) for the dump-capture kernel.
292	
293	   On x86 and x86_64, use "crashkernel=64M@16M".
294	
295	   On ppc64, use "crashkernel=128M@32M".
296	
297	   On ia64, 256M@256M is a generous value that typically works.
298	   The region may be automatically placed on ia64, see the
299	   dump-capture kernel config option notes above.
300	
301	   On s390x, typically use "crashkernel=xxM". The value of xx is dependent
302	   on the memory consumption of the kdump system. In general this is not
303	   dependent on the memory size of the production system.
304	
305	Load the Dump-capture Kernel
306	============================
307	
308	After booting to the system kernel, dump-capture kernel needs to be
309	loaded.
310	
311	Based on the architecture and type of image (relocatable or not), one
312	can choose to load the uncompressed vmlinux or compressed bzImage/vmlinuz
313	of dump-capture kernel. Following is the summary.
314	
315	For i386 and x86_64:
316		- Use vmlinux if kernel is not relocatable.
317		- Use bzImage/vmlinuz if kernel is relocatable.
318	For ppc64:
319		- Use vmlinux
320	For ia64:
321		- Use vmlinux or vmlinuz.gz
322	For s390x:
323		- Use image or bzImage
324	
325	
326	If you are using a uncompressed vmlinux image then use following command
327	to load dump-capture kernel.
328	
329	   kexec -p <dump-capture-kernel-vmlinux-image> \
330	   --initrd=<initrd-for-dump-capture-kernel> --args-linux \
331	   --append="root=<root-dev> <arch-specific-options>"
332	
333	If you are using a compressed bzImage/vmlinuz, then use following command
334	to load dump-capture kernel.
335	
336	   kexec -p <dump-capture-kernel-bzImage> \
337	   --initrd=<initrd-for-dump-capture-kernel> \
338	   --append="root=<root-dev> <arch-specific-options>"
339	
340	Please note, that --args-linux does not need to be specified for ia64.
341	It is planned to make this a no-op on that architecture, but for now
342	it should be omitted
343	
344	Following are the arch specific command line options to be used while
345	loading dump-capture kernel.
346	
347	For i386, x86_64 and ia64:
348		"1 irqpoll maxcpus=1 reset_devices"
349	
350	For ppc64:
351		"1 maxcpus=1 noirqdistrib reset_devices"
352	
353	For s390x:
354		"1 maxcpus=1 cgroup_disable=memory"
355	
356	Notes on loading the dump-capture kernel:
357	
358	* By default, the ELF headers are stored in ELF64 format to support
359	  systems with more than 4GB memory. On i386, kexec automatically checks if
360	  the physical RAM size exceeds the 4 GB limit and if not, uses ELF32.
361	  So, on non-PAE systems, ELF32 is always used.
362	
363	  The --elf32-core-headers option can be used to force the generation of ELF32
364	  headers. This is necessary because GDB currently cannot open vmcore files
365	  with ELF64 headers on 32-bit systems.
366	
367	* The "irqpoll" boot parameter reduces driver initialization failures
368	  due to shared interrupts in the dump-capture kernel.
369	
370	* You must specify <root-dev> in the format corresponding to the root
371	  device name in the output of mount command.
372	
373	* Boot parameter "1" boots the dump-capture kernel into single-user
374	  mode without networking. If you want networking, use "3".
375	
376	* We generally don' have to bring up a SMP kernel just to capture the
377	  dump. Hence generally it is useful either to build a UP dump-capture
378	  kernel or specify maxcpus=1 option while loading dump-capture kernel.
379	
380	* For s390x there are two kdump modes: If a ELF header is specified with
381	  the elfcorehdr= kernel parameter, it is used by the kdump kernel as it
382	  is done on all other architectures. If no elfcorehdr= kernel parameter is
383	  specified, the s390x kdump kernel dynamically creates the header. The
384	  second mode has the advantage that for CPU and memory hotplug, kdump has
385	  not to be reloaded with kexec_load().
386	
387	* For s390x systems with many attached devices the "cio_ignore" kernel
388	  parameter should be used for the kdump kernel in order to prevent allocation
389	  of kernel memory for devices that are not relevant for kdump. The same
390	  applies to systems that use SCSI/FCP devices. In that case the
391	  "allow_lun_scan" zfcp module parameter should be set to zero before
392	  setting FCP devices online.
393	
394	Kernel Panic
395	============
396	
397	After successfully loading the dump-capture kernel as previously
398	described, the system will reboot into the dump-capture kernel if a
399	system crash is triggered.  Trigger points are located in panic(),
400	die(), die_nmi() and in the sysrq handler (ALT-SysRq-c).
401	
402	The following conditions will execute a crash trigger point:
403	
404	If a hard lockup is detected and "NMI watchdog" is configured, the system
405	will boot into the dump-capture kernel ( die_nmi() ).
406	
407	If die() is called, and it happens to be a thread with pid 0 or 1, or die()
408	is called inside interrupt context or die() is called and panic_on_oops is set,
409	the system will boot into the dump-capture kernel.
410	
411	On powerpc systems when a soft-reset is generated, die() is called by all cpus
412	and the system will boot into the dump-capture kernel.
413	
414	For testing purposes, you can trigger a crash by using "ALT-SysRq-c",
415	"echo c > /proc/sysrq-trigger" or write a module to force the panic.
416	
417	Write Out the Dump File
418	=======================
419	
420	After the dump-capture kernel is booted, write out the dump file with
421	the following command:
422	
423	   cp /proc/vmcore <dump-file>
424	
425	You can also access dumped memory as a /dev/oldmem device for a linear
426	and raw view. To create the device, use the following command:
427	
428	    mknod /dev/oldmem c 1 12
429	
430	Use the dd command with suitable options for count, bs, and skip to
431	access specific portions of the dump.
432	
433	To see the entire memory, use the following command:
434	
435	   dd if=/dev/oldmem of=oldmem.001
436	
437	
438	Analysis
439	========
440	
441	Before analyzing the dump image, you should reboot into a stable kernel.
442	
443	You can do limited analysis using GDB on the dump file copied out of
444	/proc/vmcore. Use the debug vmlinux built with -g and run the following
445	command:
446	
447	   gdb vmlinux <dump-file>
448	
449	Stack trace for the task on processor 0, register display, and memory
450	display work fine.
451	
452	Note: GDB cannot analyze core files generated in ELF64 format for x86.
453	On systems with a maximum of 4GB of memory, you can generate
454	ELF32-format headers using the --elf32-core-headers kernel option on the
455	dump kernel.
456	
457	You can also use the Crash utility to analyze dump files in Kdump
458	format. Crash is available on Dave Anderson's site at the following URL:
459	
460	   http://people.redhat.com/~anderson/
461	
462	
463	To Do
464	=====
465	
466	1) Provide relocatable kernels for all architectures to help in maintaining
467	   multiple kernels for crash_dump, and the same kernel as the system kernel
468	   can be used to capture the dump.

Leave a comment

Open Source Software for linux

Proprietary Software Open Source Alternative
Operating Systems
Microsoft Windows
Mac OS X
Ubuntu Linux
Fedora Linux
Centos (Red Hat Linux without Red Hat’s logos and support.)
openSUSE
Debian Linux
Mandriva Linux
Xandros
K12LTSP K12 Linux Terminal Server Project
VectorLinux
PC-BSD
There are too many others to list, go to Linux Online! for more distros!
Office Productivity Software / Suites
Microsoft Office OpenOffice (cross platform)
LibreOffice (cross platform)
KOffice – Linux
HTML Editors
Adobe Dreamweaver
Microsoft FrontPage
BlueGriffon (cross platform)
Digital Image / Photo Editing / Raster Image Editing Software
Adobe Photoshop GIMP (cross platform)
Image Viewers with RAW Capability
Photo Mechanic (Win and Mac OSX) Xee (Mac OSX only)
Vector Drawing Programs
Adobe Illustrator
Macromedia FreeHand
CorelDraw
Inkscape (cross platform)
2D CAD
(Computer Aided Drawing)
AutoCAD QCad (Linux/UNIX * Mac OS X)
3D CAD
(3D Modeling)
SolidWorks
Pro/ENGINEER
AutoDesk Inventor
Blender (cross platform)
BRL-CAD 3D
Povray 3D
Tulip 3D
Screen Recording
(to capture what you are doing on your computer and save as a video file)
CamStudio (for Windows only)
Desktop Publishing
Adobe Indesign
QuarkExpress
Microsoft Publisher
Scribus (cross platform)
PDF Creation
Adobe Acrobat PDF Creator (Windows only)OpenOffice

* This capability is built into Mac OS X via the print function.

Text Editors
Notepad jEdit (cross platform)
Notepad++ (for Windows only)
Syn (for Windows only)
Smultron (for Mac OS X only)
Web Servers
Microsoft IIS (Internet Information Services) Apache (cross platform)
Web Browsers
Microsoft Internet Explorer
Safari
Mozilla Firefox (cross platform)
Flock
Email Software
Microsoft Outlook
Microsoft Entourage
QuickMail
Thunderbird (cross platform)
Evolution
Kmail
FTP Clients
(File Transfer Protocol)
Ipswitch WS_FTP Pro
Fetch
Filezilla – FTP and SFTP (cross platform)
Cyberduck – FTP and SFTP (for Mac OS X only)
SFTP Programs
(SSH Secure File Transfer)
Filezilla – FTP and SFTP (cross platform)
Cyberduck – FTP and SFTP (for Mac OS X only)
WinSCP – SFTP and SCP client for Windows
SSH
PuTTY – SFTP and Telnet client for Windows
VNC
Apple Remote Desktop (ARD) TightVNC – VNC server and client for Windows, Linux, and Unix
Chicken of the VNC – VNC client for Mac OS X
OSXvnc – VNC server for Mac OS X
Hard Disk Utilities / Partitioning Tools
Norton PartitionMagic GParted & GParted LiveCD (Gnome Partition Editor) – (cross platform)
Anti-Virus Software
McAfee
Norton Anti-virus
AVG
ClamAV
ClamWin – (for Windows only)
ClamXav – (for Mac OS X only)
Keyboarding / Typing Software
Tux Typing 2
Edutainment / Educational Software
The KDE Edutainment Project
FREEDUC – resource for FOSS educational software
A List of Open Source Software for Education
Gcompris – educational softare for kids ages 2 to 10
Childsplay – various games for ages 1-9
KStars – a simualted planetarium (astronomy)
Kalzium – periodic table
KWord Quiz – flash cards
KTouch – teaches typing
Tux Paint – vector and raster image editing program for young children
KTurtle – Logo programming for young children
Math Programs
Geometer’s Sketchpad or Cabri GeoGebra – joins geometry, algebra and calculus
Dr. Geo – interactive geometry software
TuxMath – math game for kids
Music Composition
Rosegarden – similar to Cubase
Noteedit
Solfege – ear training
Montessori Bells
Sound Editing Programs
Sound Forge Audacity (cross platform)
Video Editing
iMovie KINO
Brainstorming, Mind Mapping, Flowcharting, Planning
Inpsiration FreeMind
Kivio
View Your Mind
Compression Utilities
WinZip 7-Zip
The Unarchiver
Accounting / Personal Finance
Quicken GnuCash
Grisbi – (cross platform)
Course Management Systems (CMS) and Virtual Learning Environments (VLE)
Click here for a full list of non-open source CMS/VLEs
Blackboard
WebCT
Campus Pipeline
ClassCampus
CyberProf
eCollege
Virtuoso
TeleTOP cms
Virtual Campus
Sentient Discover
MindEdge CMS
MyEDUkit
Click here for a full list of Open Source CMS/VLEs
Also click here
Moodle – used in 74 countries in 34 diferent languages!
MyClassroom – in use by several middle schools and high schools in the US and around the world!
interact
OpenCourse
Boddington
.LRN
LogiCampus
ATutor
Wordcircle CMS
Sakai
Manhattan
ILIAS
CourseWork – used by Stanford University
COSE (Creation of Study Environments)
Claroline – used in 62 countries and 28 languages!
WebWork
Eledge
ClassWeb 2.0
ePICE
Whiteboard
Student Information Systems (SIS)
Powerschool
WebEIM
eSIS
SCHOOLMASTER
MMS
Centre
Open Admin for Schools
Emulators
Virtual PC for Mac QEMU
PearPC
Q – cocoa port of QEMU for Mac OS X
bochs
Virtualization
Virtual PC for Windows
VMware
VirtualBox (cross platform)
coLinux

Leave a comment

Allocating a Windows Disk Partition to CentOS 6

Deleting the Windows Partition from the Disk

The first step in freeing up the Windows partition for use by CentOS 6 is to delete that partition. Before doing so, however, it is imperative that any data you need to keep is backed up from both the Windows and CentOS 6 partitions. Having done that, it is safe to proceed with this chapter.

In order to remove the Windows partition we first need to identify it using the fdisk tool:

[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 example output the system contains one physical disk drive referenced by device name /dev/sda. On that disk drive are three partitions accessed via the device names /dev/sda1 through /dev/sda3 respectively. Based on the values in the System column, there is one NTFS partition. This NTFS partition is the one containing the Windows operating system and user data that we plan to remove. Note that a FAT partition also indicates the presence of a Windows installation.

To remove the partition, start the fdisk tool using the device name of the disk containing the partition (/dev/sda in this instance) and follow the instructions to switch out from DOS mode and to display sectors:

# su -
# fdisk /dev/sda

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): c
DOS Compatibility flag is not set

Command (m for help): u
Changing display/entry units to sectors

Command (m for help):

Next, display the partition table information for the disk drive using the p command:

Command (m for help): p

Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 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   *          63    20498939    10249438+   7  HPFS/NTFS
/dev/sda2        20500480    21524479      512000   83  Linux
/dev/sda3        21524480    41943039    10209280   8e  Linux LVM

Make a note of the end sector of the partition we will be deleting (/dev/sda1 in this instance).

At the command prompt, delete the Windows partition (which is partition 1 on our example system):

Command (m for help): d
Partition number (1-5): 1

Command (m for help):

Now that we have deleted the Windows partition we now need to create the new Linux partition in the vacated disk space. The partition number must match the number of the partition removed (in this case 1) and is going to be a primary partition. It will also be necessary to enter the Start and End sectors of the partition. In the case of the start sector accept the default value offered by fdisk. Enter the end sector exactly as reported for the old partition (fdisk will typically offer the correct values by default, though it is wise to double check):

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First sector (2048-41943039, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-20500479, default 20500479):  20498939

Having made these changes the next step is to check that the settings are correct:

Command (m for help): p

Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 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            2048    20498939    10248446   83  Linux
/dev/sda2        20500480    21524479      512000   83  Linux
/dev/sda3        21524480    41943039    10209280   8e  Linux LVM

To commit the changes we now need to write the new partition information to disk and quit from the fdisk tool:

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

If you see a warning similar to the one indicated in the above output you will need to reboot your CentOS 6 system to be sure the new partition table information is picked up by the system kernel before proceeding.

Formatting the Unallocated Disk Partition

In order to make the new partition suitable for use by CentOS 6, it needs to have a file system created on it. The default file system type for the current release of CentOS 6 is ext4. Creation of the file system is performed using the mkfs command as follows:

[root@localhost ~]# mkfs -t ext4 /dev/sda1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
640848 inodes, 2562111 blocks
128105 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2625634304
79 block groups
32768 blocks per group, 32768 fragments per group
8112 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

Editing the Boot Menu

The next step is to modify the boot menu. Since this was originally a dual boot system, the menu is configured to provide the option of booting either Windows or CentOS 6. Now that the Windows partition is gone, we need to remove this boot option. This is achieved by editing the menu.lst as follows:

su - 
gedit /boot/grub/menu.lst

Towards the bottom of the grub.conf file you will see a section similar to:

 
title Windows
        rootnoverify (hd0,0)
        chainloader +1

Delete this section from the file. Also check the default= value to make sure the default is not set to the partition which was just deleted. Save the file once the changes have been made.

Mounting the New Partition

Finally, we need to mount the new partition. In this example we will mount it in a directory named /data. You are free, however, to mount the new partition using any valid mount point you desire or to use it as part of a logical volume (details of which are covered in the chapter entitled Adding a New Disk to a CentOS 6 Volume Group and Logical Volume). First we need to create the directory to act as the mount point:

su - 
mkdir /data

Secondly, we need to edit the mount table so that the partition is automatically mounted each time system starts:

gedit /etc/fstab

At the bottom of the /etc/fstab file, add the following line to mount the new partition (modifying the /dev/sda1 device to match your environment):

/dev/sda1 /data ext4 defaults 0 0

Finally, we can manually mount the new partition (note that on subsequent reboots this will not be necessary as the partition will automount as a result of the setting we added to the /etc/fstab file above).

mount /data

To check the partition, try running the following command to display the available space:

 
df -h /data

You should see output similar to:

[root@localhost ~]# df -h /data
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1             9.7G  150M  9.0G   2% /data

Leave a comment

CentOS 6 Network Installation

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.

Contents

[hide]

  • 1 CentOS 6 Network Installation Requirements
  • 2 Obtaining a Network Boot Image
  • 3 Writing the Boot Image to a USB Flash Drive
  • 4 Configuring the Network Installation
  • 5 Starting the CentOS 6 Network Installation

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:

http://mirror.centos.org/centos/6/isos/

The file name containing this image is usually adopts the following format:

CentOS-<version>-<architecture>-netinstall.iso

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:

linux askmethod

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:
CentOS 6 imnstallation method screen
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:
CentOS 6 network installation network settings
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:
CentOS 6 network installation URL settings
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):
A CentOS 6 network based installation in progress
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.

Leave a comment

CentOS 6 with Windows in a Dual Boot Environment

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.

Contents

[hide]

Partition Resizing

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:
The Windows Disk Management Tool
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:

Shrinking a Windows NTFS partition

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:

http://mirror.centos.org/centos/6/isos/

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:

CentOS-<version>-<architecture>-LiveCD.iso

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:

su –

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:
Choosing to boot Windows or CentOS 6
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:

default=1

To increase or decrease the timeout before the default operating system boots, change the timeout value (in this case to 20 seconds):

timeout=20

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:

title Windows

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:

mkdir /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:

umount /windows

Leave a comment

CentOS 6 on a Clean Disk Drive

The Live CD image can be downloaded from the mirror sites listed on the CentOS web site at:

http://mirror.centos.org/centos/6/isos/

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:

http://mirror.centos.org/centos/6/isos/

The installation distribution is downloaded in the form of two ISO format DVD images. The DVD images are named using the following convention:

CentOS-<version>-<architecture>-bin-DVD<number>.iso

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:

The CentOS 6 Boot 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:
CentOS 6 Disk Partitioning options
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.

Package Selection

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:
Making CentOS 6 package installation selections
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.

Installing Updates

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:
CentOS 6 Update availability Indicator
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:
CentOS 6 Software Updates tool
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.

Leave a comment

Configuring a CentOS 6 Postfix Email Server

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.

Contents

[hide]

  • 1 The structure of the Email System
    • 1.1 Mail User Agent
    • 1.2 Mail Transfer Agent
    • 1.3 Mail Delivery Agent
    • 1.4 SMTP
  • 2 Configuring a CentOS 6 Email System
  • 3 Postfix Pre-Installation Steps
  • 4 Installing Postfix on CentOS 6
  • 5 Configuring Postfix
  • 6 Starting Postfix on a CentOS 6 System

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

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.

Configuring Postfix

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:

/usr/sbin/postfix start

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[10334]: 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

Leave a comment

Configuring a CentOS 6 Based Web Server

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.

Contents

[hide]

  • 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:

httpd-2.2.15-5.el6.x86_64

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:
The Apache test page on CentOS 6
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:

ServerAdmin webmaster@myexample.com

Next the ServerName and ServerAlias directives need to be defined so that the web server knows which virtual host this configuration file refers to:

ServerName myexample.com

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:

DocumentRoot /var/www/myexample.com

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.

Leave a comment