Thursday 9 February 2012


Multiblock allocation

When Ext3 needs to write new data to the disk, there's a block allocator that decides which free blocks will be used to write the data. But the Ext3 block allocator only allocates one block (4KB) at a time. That means that if the system needs to write the 100 MB data mentioned in the previous point, it will need to call the block allocator 25600 times (and it was just 100 MB!). Not only this is inefficient, it doesn't allow the block allocator to optimize the allocation policy because it doesn't knows how many total data is being allocated, it only knows about a single block. Ext4 uses a "multiblock allocator" (mballoc) which allocates many blocks in a single call, instead of a single block per call, avoiding a lot of overhead. This improves the performance, and it's particularly useful with delayed allocation and extents. This feature doesn't affect the disk format. Also, note that the Ext4 block/inode allocator has other improvements, described in detail in this paper.

Delayed allocation

Delayed allocation is a performance feature (it doesn't change the disk format) found in a few modern filesystems such as XFS, ZFS, btrfs or Reiser 4, and it consists in delaying the allocation of blocks as much as possible, contrary to what traditionally filesystems (such as Ext3, reiser3, etc) do: allocate the blocks as soon as possible. For example, if a process write()s, the filesystem code will allocate immediately the blocks where the data will be placed - even if the data is not being written right now to the disk and it's going to be kept in the cache for some time. This approach has disadvantages. For example when a process is writing continually to a file that grows, successive write()s allocate blocks for the data, but they don't know if the file will keep growing. Delayed allocation, on the other hand, does not allocate the blocks immediately when the process write()s, rather, it delays the allocation of the blocks while the file is kept in cache, until it is really going to be written to the disk. This gives the block allocator the opportunity to optimize the allocation in situations where the old system couldn't. Delayed allocation plays very nicely with the two previous features mentioned, extents and multiblock allocation, because in many workloads when the file is written finally to the disk it will be allocated in extents whose block allocation is done with the mballoc allocator. The performance is much better, and the fragmentation is much improved in some workloads.

Journal checksumming

The journal is the most used part of the disk, making the blocks that form part of it more prone to hardware failure. And recovering from a corrupted journal can lead to massive corruption. Ext4 checksums the journal data to know if the journal blocks are failing or corrupted. But journal checksumming has a bonus: it allows one to convert the two-phase commit system of Ext3's journaling to a single phase, speeding the filesystem operation up to 20% in some cases - so reliability and performance are improved at the same time.

Online defragmentation

While delayed allocation, extents and multiblock allocation help to reduce the fragmentation, with usage filesystems can still fragment. For example: You write three files in a directory and continually on the disk. Some day you need to update the file of the middle, but the updated file has grown a bit, so there's not enough room for it. You have no option but fragment the excess of data to another place of the disk, which will cause a seek, or allocate the updated file continually in another place, far from the other two files, resulting in seeks if an application needs to read all the files on a directory (say, a file manager doing thumbnails on a directory full of images). Besides, the filesystem can only care about certain types of fragmentation, it can't know, for example, that it must keep all the boot-related files contiguous, because it doesn't know which files are boot-related. To solve this issue, Ext4 will support online fragmentation, and there's a e4defrag tool which can defragment individual files or the whole filesystem.

Persistent preallocation

This feature, available in Ext3 in the latest kernel versions, and emulated by glibc in the filesystems that don't support it, allows applications to preallocate disk space: Applications tell the filesystem to preallocate the space, and the filesystem preallocates the necessary blocks and data structures, but there's no data on it until the application really needs to write the data in the future. This is what P2P applications do in their own when they "preallocate" the necessary space for a download that will last hours or days, but implemented much more efficiently by the filesystem and with a generic API. This has several uses: first, to avoid applications (like P2P apps) doing it themselves inefficiently by filling a file with zeros. Second, to improve fragmentation, since the blocks will be allocated at one time, as contiguously as possible. Third, to ensure that applications always have the space they know they will need, which is important for RT-ish applications, since without preallocation the filesystem could get full in the middle of an important operation. The feature is available via the libc posix_fallocate() interface.

ext2 ext3 ext4 in Linux

ext2, ext3 and ext4 are all filesystems created for Linux.

  • Ext2 stands for second extended file system.It was introduced with the 1.0 kernel in 1993. Developed by Rémy Card.
  • This was developed to overcome the limitation of the original ext file system.
  • Ext2 does not have journaling feature.
  • On flash drives, usb drives, ext2 is recommended, as it doesn’t need to do the over head of journaling.
  • Maximum individual file size can be from 16 GB to 2 TB.
  • Overall ext2 file system size can be from 2 TB to 32 TB.
It has sparse super blocks feature which increase file system performance.In case any user processes fill up a file system ext2 normally reserves about 5% of disk blocks for exclusive use by root so that root can easily recover from that situation.

Creating an ext2 file system:

mke2fs /dev/sda1


A journaling filesystem is a filesystem that maintains a special file called a journal that is used to repair any inconsistencies that occur as the result of an improper shutdown of a computer.

Journaling filesystems that added to the Linux kernel are,


  • Ext3 stands for third extended file system.
  • It was introduced in 2001. Developed by Stephen Tweedie.
  • Starting from Linux Kernel 2.4.15 ext3 was available.
  • The main benefit of ext3 is that it allows journaling.
  • Maximum individual file size can be from 16 GB to 2 TB.
  • Overall ext3 file system size can be from 2 TB to 32 TB.
There are three types of journaling available in ext3 file system.
  1.     Journal – Metadata and content are saved in the journal.
  2.     Ordered – Only metadata is saved in the journal. Metadata are journaled only after writing the content to disk. This is the default.
  3.     Writeback – Only metadata is saved in the journal. Metadata might be journaled either before or after the content is written to the disk.

You can convert a ext2 file system to ext3 file system directly (without backup/restore).

Creating an ext3 file system:
mkfs.ext3 /dev/sda1


mke2fs –j /dev/sda1

How to  convert  ext2 to ext3 :-
# umount /dev/sda2
# tune2fs -j /dev/sda2
# mount /dev/sda2  /var

  •     Ext4 stands for fourth extended file system.
  •     It was introduced in 2008.
  •     Starting from Linux Kernel 2.6.19 ext4 was available.
  •     Supports huge individual file size and overall file system size.
  •     Maximum individual file size can be from 16 GB to 16 TB.
  •     Overall maximum ext4 file system size is 1 EB (exabyte). 1 EB = 1024 PB (petabyte). 1 PB =       1024 TB (terabyte).
  •     Directory can contain a maximum of 64,000 subdirectories (as opposed to 32,000 in ext3).
  •     You can also mount an existing ext3 fs as ext4 fs (without having to upgrade it).
  •     Several other new features are introduced in ext4: multiblock allocation, delayed allocation, journal checksum. fast fsck, etc. All you need to know is that these new features have improved the performance and reliability of the filesystem when compared to ext3.
  •     In ext4, you also have the option of turning the journaling feature “off”.

Features of Ext4 file system :
1. Compatibility
2. Bigger filesystem/file sizes
3. Subdirectory scalability
4. Extents
5. Multiblock allocation
6. Delayed allocation
7. Fast fsck
8. Journal checksumming
9. Online defragmentation
10. Inode-related features
11. Persistent preallocation
12. Barriers on by default

Creating an ext4 file system:

mkfs.ext4 /dev/sda1


mke2fs -t ext4 /dev/sda1

Converting ext3 to ext4
( Warning :- Never try this live or production servers )
# umount /dev/sda2
# tune2fs -O extents,uninit_bg,dir_index  /dev/sda2
# e2fsck -pf /dev/sda2
# mount /dev/sda2 /var

Linux Boot Process

The six stages of linux boot process

1. BIOS          Basic Input/Output System executes MBR
2. MBR           Master Boot Record executes GRUB
3. GRUB        Grand Unified Bootloader executes Kernel
4. Kernel         Kernel executes /sbin/init
5. Init              Init executes runlevel programs
6. Runlevel      Runlevel programs are executed from  /etc/rc.d/rc*.d/

1. BIOS 

           When the PC is powered up, the BIOS is the first program that runs which is stored in flash memory on the motherboard. The BIOS contains the following parts:

POST (Power On Self Test): The principal duties of the main BIOS during POST are as follows:
Verify CPU registers, verify the integrity of the BIOS code itself, verify some basic components like DMA, timer, interrupt controller, find, size, and verify system main memory, initialize BIOS, discover, initialize, and catalog all system buses and devices, pass control to other specialized BIOSes (if and when required), provide a user interface for system's configuration, identify, organize, and select which devices are available for booting construct whatever system environment that is required by the target operating system.

The Setup Menu: That lets you set some parameters and lets you adjust the real time clock. Most modern BIOS versions let you set the boot order, the devices that BIOS checks for booting. These can be A (the first floppy disk), C (the first hard disk), CD-ROM and possibly other disks as well. The first device in the list will be tried first.

The boot sector loader: This loads the first 512-byte sector from the boot disk into RAM and jumps   to it.

The BIOS interrupts: These are simple device drivers that programs can use to access the screen, the keyboard and disks. Boot loaders rely on them, most operating systems do not (the Linux kernel does not use BIOS interrupts once it has been started). MSDOS does use BIOS interrupts.

2. MBR

           When a computer boots, the BIOS transfers control to the first boot device, which is hard disk.The first sector on a hard disk is called the Master Boot Record. The primary boot loader that resides in the MBR is a 512 byte image containing both program code and a small partition table. The first 446 bytes are the primary boot loader, which contains both executable code and error message text. The next 64 bytes are the partition table, which contains a record for each of four partitions (sixteen bytes each). The MBR ends with two bytes that are defined as the magic number (0xAA55). The magic number serves as a validation check of the MBR.

          The job of the primary boot loader is to find and load the secondary boot loader. It does this by looking through the partition table for an active partition. When it finds an active partition, it scans the remaining partitions in the table to ensure that they're all inactive. When this is verified, the active partition's boot record is read from the device into RAM and executed.

           By default, MBR code looks for the partition marked as active and once such a partition is found, it loads its boot sector into memory and passes control to it.


           GNU GRUB is a bootloader capable of loading a variety of free and proprietary operating systems. GRUB will work well with Linux, DOS, Windows, or BSD.

           GRUB is dynamically configurable. This means that the user can make changes during the boot time, which include altering existing boot entries, adding new, custom entries, selecting different kernels, or modifying initrd. GRUB also supports Logical Block Address mode. This means that if your computer has a fairly modern BIOS that can access more than 8GB (first 1024 cylinders) of hard disk space, GRUB will automatically be able to access all of it.

           GRUB can be run from or be installed to any device (floppy disk, hard disk, CD-ROM, USB drive, network drive) and can load operating systems from just as many locations, including network drives. It can also decompress operating system images before booting them.

LILO (Linux bootloader)

LILO is another Linux bootloader.

Advantage of GRUB over LILO

   LILO supports only up to 16 different boot selections; GRUB supports an unlimited number of boot entries.  
   LILO cannot boot from network; GRUB can.
   LILO must be written again every time you change the configuration file; GRUB does not.
   LILO does not have an interactive command interface.
GRUB replaces the default MBR with its own code.

Furthermore, GRUB works in stages.

Stage 1 is located in the MBR and mainly points to Stage 2, since the MBR is too small to contain all of the needed data.Stage 1 can do little more than load the next stage of GRUB by loading a few disk sectors from a fixed location near the start of the disk (within 1024 cylinders).

Stage 2 points to its configuration file, which contains all of the complex user interface and options we are normally familiar with when talking about GRUB. Stage 2 can be located anywhere on the disk. If Stage 2 cannot find its configuration table, GRUB will cease the boot sequence and present the user with a command line for manual configuration.

Stage 1.5 also exists and might be used if the boot information is small enough to fit in the area immediately after MBR. Stage1.5 is located in the first 30 kilobytes of hard disk immediately following the MBR and before the first partition. If this space is not available (Unusual partition table, special disk drivers, GPT or LVM disk) the install of Stage 1.5 will fail. The stage 1.5 image contains filesystem specific drivers. This enables stage 1.5 to directly load stage 2 from a known location in the filesystem, for example from /boot/grub. Stage 2 will then load the default configuration file and any other modules needed

             The Stage architecture allows GRUB to be large (~20-30K) and therefore fairly complex and highly configurable, compared to most bootloaders, which are sparse and simple to fit within the limitations of the Partition Table.

After loading GRUB, but before the operating system starts

            Once GRUB has loaded, it presents an interface where the user can select which operating system to boot. This normally takes the form of a graphical menu. If this is not available, or the user wishes direct control, GRUB has its own command prompt. The user can then manually specify the boot parameters. GRUB can be set to automatically load a specified kernel after a user defined timeout.

Perhaps the most important commands that GRUB accepts in the operating system selection (kernel selection) menu are the following two commands.

            By pressing 'e', it is possible to edit parameters for the selected operating system before the operating system is started. Typically, this is used for changing kernel parameters for a Linux system. The reason for doing this in GRUB (i.e. not editing the parameters in an already booted system) can be an emergency case: the system has failed to boot. Using the kernel parameters line it is possible, among other things, to specify a module to be disabled (blacklisted) for the kernel. This could be needed, if the specific kernel module is broken and thus prevents boot-up.

            By pressing 'c', the user enters the GRUB command line. This is not a regular Linux shell. It accepts certain GRUB-specific commands.

           Once boot options have been selected, GRUB loads the selected kernel into memory and passes control to the kernel. Alternatively, GRUB can pass control of the boot process to another loader, using chain loading. This is the method used to load operating systems such as Windows, that do not support the Multiboot standard or are not supported directly by GRUB. In this case, copies of the other system's boot programs have been saved by GRUB. Instead of a kernel, the other system is loaded as though it had been started from the MBR. This could be another boot manager, such as the Microsoft boot menu, allowing further selection of non-Multiboot operating systems.

            With the second-stage boot loader in memory, the file system is consulted, and the default kernel image and initrd image are loaded into memory. With the images ready, the stage 2 boot loader invokes the kernel image.

4. Kernel

           With the kernel image in memory and control given from the stage 2 boot loader, the kernel stage begins. The kernel image isn't so much an executable kernel, but a compressed kernel image. Typically this is a zImage (compressed image, less than 512KB) or a bzImage (big compressed image, greater than 512KB), that has been previously compressed with zlib. At the head of this kernel image is a routine that does some minimal amount of hardware setup and then decompresses the kernel contained within the kernel image and places it into high memory. If an initial RAM disk image is present, this routine moves it into memory and notes it for later use. The routine then calls the kernel and the kernel boot begins.

5. Init

           After the kernel is booted and initialized, the kernel starts the first user-space application. This is the first program invoked that is compiled with the standard C library. Prior to this point in the process, no standard C applications have been executed.

6. Runlevel

           The term runlevel refers to a mode of operation in one of the computer operating systems.Conventionally, seven runlevels exist, numbered from zero to six.The exact setup of these configurations will vary from OS to OS, and from one Linux distribution to another.

 Some important files and definitions.

1. /etc/rc.d/rc.sysinit - script to initialize the system(includes mounting local filesystems)

2. /etc/inittab - file containing default runlevel

3. /etc/init/start-ttys.conf - starts 5 or 6 text based virtual consoles

4. /etc/init/rc.conf - init job responsible for starting System V based services

5. /boot/grub/grub.conf - contains bootloader configuration instructions

6. /etc/init/ - directory containing init jobs

7. /etc/rc.d/rc5.d/ - contains links to System V services scripts to be started or stopped when entering runlevel5

8. /etc/init/prefdm.conf - starts graphical loging prompt

9. /etc/init/rc.S.conf - init job to run system initialization script and spawn job to start System V services.

Tuesday 7 February 2012

The Linux w Command

The w command is used to find out who is logged on and what they are doing, w command displays information about the users currently on the machine, and their processes.

The header shows, in this order, the current time, how long the system has been running, how many users are currently logged on, and the system load averages for the past 1, 5, and 15 minutes.

The following entries are displayed for each user: login name, the tty name, the remote host, login time, idle time, JCPU, PCPU, and the command line of their current process.

The JCPU time is the time used by all processes attached to the tty. It does not include past background jobs, but does include currently running background jobs.

The PCPU time is the time used by the current process, named in the "what" field.

Command-line options

-h     Don't print the header.
-u     Ignores the username while figuring out the current process and cpu times.
-s     Use the short format. Don't print the login time, JCPU or PCPU times.
-f     Toggle printing the from (remote hostname) field.
-V     Display version information.
user  Show information about the specified user only.

The Linux vmstat Command

vmstat  stands for system activity, hardware and system information, The command vmstat reports virtual memory information about processes, memory, paging, block IO, traps, and cpu activity.

Syntax    : vmstat [-V] [-n] [delay [count]]

-V      Print version information.
-n       causes the headers not to be reprinted regularly.
-a       print inactive/active page stats.
-d       prints disk statistics
-D      prints disk table
-p       prints disk partition statistics
-s       prints vm table
-m      prints slabinfo
-S      unit size(unit size k:1000 K:1024 m:1000000 M:1048576 (default is K))
delay    delay between updates in seconds.
count     number of updates.

Field Description


r    The number of processes waiting for run time. 
b   The number of processes in uninterruptable sleep.
w  The number of processes swapped out but otherwise runnable. 


swpd    the amount of virtual memory used (kB).
free      the amount of idle memory (kB).
buff      the amount of memory used as buffers (kB).
cache   the amount of memory used as cache (kB).
inact     the amount of inactive memory. (-a option)
active   the amount of active memory. (-a option)


si     Amount of memory swapped in from disk (kB/s).
so    Amount of memory swapped to disk (kB/s).


bi    Blocks sent to a block device (blocks/s).
bo   Blocks received from a block device (blocks/s).


in    The number of interrupts per second, including the clock.
cs   The number of context switches per second.

These are percentages of total CPU time.

us   user time
sy   system time
id    idle time
wa  time spent waiting for IO. included n idle time.
st    time stolen from a virtual machine.

The Linux top Command

top command is known as Process activity command, The top program provides a dynamic real-time view of a running system, In top first 5 lines are the following,

top: present time, uptime, logged in users, load average of cpu in last 1min,5min,15min.

Tasks(in number): total process, running process, sleeping process, stopped process, zombie process.

CPU(s)(usage in %): user related process, system related process,nice related process, ideal process, wait process, hardware IRQ, software IRQ, System still. Suppose you have more than one cpu then press '1' to see the details, to hide the second cpu press '1' again.

mom(usage in kilo bytes): total RAM, used, free, buffers.
swap(usage in kilo bytes): total swap memory, used, free, cached.

m    - displays memory information off and on.
t      - cpu and process information off and on.
l      - load average information off and on.

The 6th line is for entering command such as,

r     - to renice (give PID and new nice value)
k    - to kill a process (give PID of the process)

The 7th line can be explained as,

PID                    lists process identification number(for cpu communication)
USER                lists user of that particular process
NI                      shows priority value of each process (-20 to 19)
VIRT                 shows virtual memory used for each process
RES                  shows residance memory
SHR                  shows shared memory
S                      shows status of the process(s-sleeping, R-running, z-zombie)
%CPU              % of cpu used for each process
%MEM             % of memory used for each process
TIME+               prints how long the particular process is running in background
COMMAND        prints which command used to run the process

Hot keys of top

R     - to sort PID number off and on
u      - to fileter in username (give username then press enter key, no username for show all)
P      - to sort according to cpu
M    - to sort according to memory
c     - to get command information
A     - it sorts by top consumers of various system resources off and on.
f      - provides an interactive configuration screen for top. Helpful for setting up top for a specific task.
o     - to enable interactively select the ordering within top.
n     - the maximum task to be displayed(0 for display all)
d     - to change delay in updation (in sec)
z     - to turn on or off color/mono
w    - write to save
q    - quit or Crl+C
h    - show all threads

The Linux System Monitoring Tools

The commands discussed below are some of the most basic commands when it comes to system analysis and debugging server issues such as:

Finding out bottlenecks.
Disk (storage) bottlenecks.
CPU and memory bottlenecks.
Network bottlenecks.

1. top  : Process activity command, provides a dynamic real-time view of a running system.

2. vmstat  : System Activity, Hardware and System Information, reports virtual memory information about processes, memory, paging, block IO, traps, and cpu activity.

3. w  : Find out who is logged on and what they are doing.

4. uptime  : Tell how long the system has been running. 

5. ps  : Displays the processes.

6. free  : Memory usage.

7. iostat  : Average CPU load, Disk activity, report CPU statistics and input/output statistics for devices, partitions and network filesystems (NFS).

8. sar  : Used to collect, report, and save system activity information. 

9. mpstat  : Displays activities for each available processor, processor 0 being the first one. 

10. pmap  : Reports memory map of a process.

11. netstat  : Displays network connections, routing tables, interface statistics, masquerade connections, and multicast memberships.
12. ss    : Is used to dump socket statistics.

13. iptraf   : Real-time Network Statistics, generates various network statistics including TCP info, UDP counts, ICMP and OSPF information, Ethernet load info, node stats, IP checksum errors, and others. 

14. tcpdump  : Detailed network traffic analysis, need good understanding of TCP/IP protocol to utilize this tool.

15. strace  : Trace system calls and signalsl

16. /Proc file system  : Provides detailed information about various hardware devices and other Linux kernel information.

 cat /proc/cpuinfo
 cat /proc/meminfo
 cat /proc/zoneinfo
 cat /proc/mounts

17. Nagios  : Server and network monitoring, Nagios is a popular open source computer system and network monitoring application software. You can easily monitor all your hosts, network equipment and services.

18. Cacti  : Web-based monitoring tool, Cacti is a complete network graphing solution designed to harness the power of RRDTool's data storage and graphing functionality. 

19. KDE System Guard  : Real-time systems reporting and graphing.

20. Gnome System Monitor : Real-time systems reporting and graphing.

The System Monitor application enables you to display basic system information and monitor system processes, usage of system resources, and file systems.

    Displays various basic information about the computer's hardware and software.
    Linux Kernel version
    GNOME version
    Installed memory
    Processors and speeds
    System Status
    Currently available disk space
    Memory and swap space
    Network usage
    File Systems
    Lists all mounted filesystems along with basic information about each.

21. lsof  : list open files, network connections and much more.

22. mtr  : mtr combines the functionality of the traceroute and ping programs in a single network diagnostic tool.

23. ulimit  : User limits, limit the use of system-wide resources.

24. lsmod  : list of installed modules.

25. watch  : Automated refresh of any code every specified seconds.

26. stat  : Setails of any file or file system status.

27. getconf   : To get configuration values.

28. runlevel  : Redhat run level.

29. ldd   : Print shared library dependencies.

30. rsync  : A fast, versatile, remote (and local) file-copying tool.

Thursday 2 February 2012

Yum Server in RHEL 6

                                   Yum is a yellow dog update manager it is a new package manager introduced by redhat with RHEL5 in year 2007 but now in RHEL6 they also have this facility to manage the packages. By using YUM we can manage the packages in many ways. YUM is always working in Server/Client.

Features of yum over rpm.
  • Multiple Repositories
  • Simple config file
  • Correct dependency calculation and fast operation
  • rpm consistent behavior
  • Simple interface

# install the package
yum install packagename
# delete the old and install the new package            
yum update packagename  
# erase/delete the package        
yum erase packagename 
# remove the package           
yum remove packagename        

Yum Server in RHEL 6

Using FTP method

Go to RHEL6 - settings - Hardware - add - cd/dvd - use physical drive/use ISO image - finish

    #  if not mount reboot the machine
    mount -a                                                      
    cd /media/RHEL 6.0\ i386\ Disc\ 1/

    # make sure that all rpm are available

    cd Packages

    # make sure ftp server is running                                              
    rpm -ivh vsftpd*                                          
    rpm -ivh *ftp*

    rpm -ivh createrepo.rpm
    rpm -ivh deltarpm*
    rpm -ivh python*
   Copy all DVD content in one location /var/ftp/pub/rhel6

    #  rpm collection location
    cd /var/ftp/pub/rhel6 
    #   creating repository                                   
    createrepo .                                                 

    # make an entry in server side
    vim /etc/yum.repos.d/server.repo                 

                 # to enable yum server
                 # for group policy check
    # make an entry in client side
    vim /etc/yum.repos.d/server.repo                    

    yum install gcc (client side example)

Runlevels in Linux

                     The Linux services are organized by runlevels. There are seven runlevels and each runlevel executes a specified set of scripts. All scripts are collectively stored in /etc/rc.d/init.d directory and all runlevels also have their own directory which contains some start and stop scripts. The scripts associated with each runlevel can be found in /etc/rc.d directory:


Runlevel and description of each runlevel is given below:

Runlevel                 Description

   init 0                    Halt (Do not set initdefault to this)

   init 1                    Single-user mode, for maintenance, repairs,backups and restores.

   init 2                    Multiuser with some networking services ( for system performance)

   init 3                    Multiuser with networking

   init 4                    Unused (customized to use)

   init 5                    X11 console, Defaults to a GUI desktop with networking

   init 6                    Reboot (Do not set initdefault to this)

To list all runlevels

cat /etc/inittab

To switch particular runlevel

init x    (eg. init 6 - to reboot)

To list all service settings run the following command:

/sbin/chkconfig --list

To list the entry for the sshd daemon, execute the following command:

/sbin/chkconfig --list | grep sshd

To know which services get started for runlevel 3:

/sbin/chkconfig --list | grep '3:on'

The httpd service to start up at runlevel 5 we would issue the following command:

/sbin/chkconfig --level 5 httpd on

To see graphical tool that allows you to view which services will start for each runlevel


Otherwise go to System - Administration - Services

The graphical tool also allows you to start, stop, restart, enable, disable each services and to customize the services for particular runlevels.


Wednesday 1 February 2012

File System Administration in RHEL 6

ext4 is the default file system of Red Hat Enterprise Linux 6.


  •  Improves performance
  •  Reduces metadata overhead for large files
  •  Labels unallocated block groups and inode tables
Allocation schemes:
  •  Persistent pre-allocation
  •  Delayed allocation
  •  Multi-block allocation
  •  Stripe-aware allocation
Command Method

1. Go to RHEL6 - Settings - Add - virtual - HDD - Create a new virtual HDD - SCSI - 5GB (Store virtual disk as a single file)-give the disk file name and click finish then reboot.

Primary Partitioning

#for partitioning the virtul HDD go terminal and give fdisk
fdisk /dev/sdb
m -for help
n -new partition (give p for primary partition, the partition number and size, maximum can create 4 primary partitions and should create before creating extented partition.)
p -show partition table
w-write and quit

#for updating the partition table.

#formating the partition table
mkfs.ext4 /dev/sdb1 (listen to 3 times done)

#create mount point
mkdir /primary

#edit fstab
vim /etc/fstab
   /dev/sdb1    /primary    ext4    defaults    0 0

mount -a
mount                  (shows all mount points)
cd /primary
ls                        (and confirm with the precentece of lost+found file
fdisk -l                (shows all partitions)

Extented partitioning

#for creating extented partitioning
fdisk /dev/sdb
m-for help
n-new partition (give e for extented partition, partition number and size will be the remaining)
p-show partition table
w-write and quit (do't format and mount the extented patition)

Logical Partitioning

#for creating extented partitioning
fdisk /dev/sdb
m-for help
n-new partition (give l for logical partitioning and also give size, it will take partion number starting from 5 onwards by default)
p-show partition table
w-write and quit

#for updating the partition table.

#formating the partition table
mkfs.ext4 /dev/sdb5    ( and listen to 3 times 'done')

#create mount point
mkdir /logical

#edit fstab
vim /etc/fstab
   /dev/sdb5    /logical    ext4    defaults    0 0

mount -a
mount                 (shows all mount points)
cd /primary
ls                        (and confirm with the precentece of lost+found file)
fdisk -l                (shows all partitions)

deleting a partition

#remove fstab
vim /etc/fstab   - do delete the particular entry
mount -a
umount /logical
fdisk /dev/sdb
d - to delete give the approptiate partition number
w-write and quit

Graphical Method

palimpsest  - for opening the Disk Utility method from the command mode

Otherwise go to Applications - System Tools - Disk Utility

Create Partition - to create a partition
Format Drive - to format the drive
Format Volume - for formatting a particular volume
Mount Volume - to mounting a volume
Unmount Volume - for a unmounted volume
Delete Partition - to deleting a partition

Note:- Logical partitioning is not available in graphical method.

Benchmark :- shows how data is written in HDD.

1. Start Read-Only Benchmark - Mesure read rate and access time
2. Start Read/Write Benchmark - Mesure read rate, write rate and access time