1. Take an output of the currently available disks
# fdisk -l
2. Scan for the new disk
# echo "- - -" > /sys/class/scsi_host/host0/scan
3. List the available disk to find out the name of newly created disk
# fdisk -l
4. View the messages file for confirmation
# tail -f /var/log/messages
Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts
Friday, December 18, 2015
How to do release update on Red Hat Linux ?
Following procedure guides you on how to update a Red Hat Linux server from RHEL 6.3 to 6.4.
1. Mount the file RHEL6.4-Server-20130130.0-x86_64-DVD1.iso on a directory.
# mount -o loop RHEL6.4-Server-20130130.0-x86_64-DVD1.iso /media/rhel6/
2. Copy the repo file from the ISO to local repos.d directory.
# cp /media/rhel6/media.repo /etc/yum.repos.d/rhel6.repo
3. Modify the file /etc/yum.repos.d/rhel6.repo
baseurl=file:///media/rhel6/
4. Update the OS
# yum update
5. Unmount the file system
# umount /media/rhel6
6. Remove the temporary repo file
# rm /etc/yum.repos.d/rhel6.repo
7. Reboot the server
8. Check the OS version.
# cat /etc/redhat-release
1. Mount the file RHEL6.4-Server-20130130.0-x86_64-DVD1.iso on a directory.
# mount -o loop RHEL6.4-Server-20130130.0-x86_64-DVD1.iso /media/rhel6/
2. Copy the repo file from the ISO to local repos.d directory.
# cp /media/rhel6/media.repo /etc/yum.repos.d/rhel6.repo
3. Modify the file /etc/yum.repos.d/rhel6.repo
baseurl=file:///media/rhel6/
4. Update the OS
# yum update
5. Unmount the file system
# umount /media/rhel6
6. Remove the temporary repo file
# rm /etc/yum.repos.d/rhel6.repo
7. Reboot the server
8. Check the OS version.
# cat /etc/redhat-release
Wednesday, August 1, 2012
Access Control List
Access Control List (ACL) is a list of permissions attached to a file or directory.
Pre-Requisite:
To set ACL for any file or directory, the underlying filesystem should be ACL enabled which you have to mention while mounting the filesystem.
To make it permanent, you need to edit /etc/fstab and add "acl" under options field for the specific filesystem.
Ex:
LABEL=/data /data ext3 defaults,acl 1 2
After modifying the /etc/fstab file, you have to remount the filesystem.
# mount -o remount /data
Now we can start setting the ACL on any file or directory located under /data filesystem.
To set full permission for a user on /data,
# setfacl -m u:user1:rwx /data
To set only read/execute permission for a user on /data/file1,
# setfacl -m u:user1:r-x /data/file1
To set full permission for dba group on /data/oracle directory,
# setfacl -m g:dba:rwx /data/oracle
To set full permission to user1 and group1 on /data directory,
# setfacl -m u:user1:rwx,g:group1:rwx /data
To revoke the ACL for a user on /data,
# setfacl -x u:user1 /data
To view the current ACL values on /data,
# getfacl /data
To revoke write access for all users and groups on a file,
# setfacl -m m::rx /data/file1
Above command will set the mask value as "r-x".
To copy the acl of one file to another,
# getfacl file1 | setfacl --set-file=- file2
You can also use the below method to copy the acl rights between files.
$ getfacl /data/file1 > acls.txt
$ setfacl -f acls.txt /data/file2
Pre-Requisite:
To set ACL for any file or directory, the underlying filesystem should be ACL enabled which you have to mention while mounting the filesystem.
To make it permanent, you need to edit /etc/fstab and add "acl" under options field for the specific filesystem.
Ex:
LABEL=/data /data ext3 defaults,acl 1 2
After modifying the /etc/fstab file, you have to remount the filesystem.
# mount -o remount /data
Now we can start setting the ACL on any file or directory located under /data filesystem.
To set full permission for a user on /data,
# setfacl -m u:user1:rwx /data
To set only read/execute permission for a user on /data/file1,
# setfacl -m u:user1:r-x /data/file1
To set full permission for dba group on /data/oracle directory,
# setfacl -m g:dba:rwx /data/oracle
To set full permission to user1 and group1 on /data directory,
# setfacl -m u:user1:rwx,g:group1:rwx /data
To revoke the ACL for a user on /data,
# setfacl -x u:user1 /data
To view the current ACL values on /data,
# getfacl /data
To revoke write access for all users and groups on a file,
# setfacl -m m::rx /data/file1
Above command will set the mask value as "r-x".
To copy the acl of one file to another,
# getfacl file1 | setfacl --set-file=- file2
You can also use the below method to copy the acl rights between files.
$ getfacl /data/file1 > acls.txt
$ setfacl -f acls.txt /data/file2
Friday, July 20, 2012
User and Group Management in Redhat Linux
Here are some configuration files which you should be familiar.
/etc/passwd :
Contains the database of information of all the users.
The format of the file is
username:password:uid:gid:gecos:directory:shell
/etc/shadow :
The actual password of every user is stored in /etc/shadow, indicated by an x in the password field.
As /etc/passwd is readable by all users, storing even encrypted passwords in it makes password guessing easier.
However, /etc/shadow is more secure because it is readable only by programs that run with root privileges, such as login and passwd.
Here is a sample line from /etc/shadow
johny:$1$EmRh1cmZ$gkXY30H43D7NtpQXjm9F01:11589:0:99999:7:::
It contains the following fields,
- The account name
- The account’s encrypted password
- The number of days since 1 January 1970 that the password was last changed
- The number of days permitted before the password can be changed
- The number of days after which the password must be changed
- The number of days before the password expires that the user is warned
- The number of days after the password expires before the account is disabled
- The number of days since 1 January 1970 after which the account is disabled
- Reserved for future use
/etc/group :
Contains the database of information of all the groups.
The format of the file is
groupname:password:gid:userlist
where
groupname is the name of the group
- password is an optional field containing the encrypted group password
- gid is the numeric group ID number
- userlist is a comma-separated list of the user account names that comprise the group
For ex,
finance:x:507:jacob,maylyn,nancy
Now lets see some commands,
Q. To create a user account with default settings,
# useradd jacob
In this case,
the home directory will be /home/jacob,
shell will be bash
uid will be the next unused UID
Q. To show the default values taken while creating a user account,
# useradd -D
Q. To set a password for the newly created user account,
# passwd jacob
Q. To change the gecos(description) of a user account,
# usermod -c "Jacob Oyden" jacob
Q. To delete a user account
# userdel jacob
Q. To delete a user account along with its home directory,
# userdel -r jacob
Q. To create a group for finance department,
# groupadd finance
Q. To create a group in a specific guid,
# groupadd -g 1000 finance
Q. To delete a group,
# groupdel finance
Q. To lock a user account,
# passwd -l jacob
Q. To unlock a user account,
# passwd -u jacob
Q. To change the user name of an existing user account,
# usermod -l joyden jacob
above command change the username from jacob to joyden.
Q. To change the 'uid' of a user account,
# usermod -u 1023 jacob
Above command will also update all files and directories rooted in the user’s home directory automatically to the new UID, but any files outside of the user’s home directory must be altered manually.
Q. To show the user account expiry information,
# chage -l jacob
Q. To change user account expiry information,
# chage jacob
Q. To list all the shells (or you can refer the file /etc/shells for the available shells),
# chsh -l
Q. To change the shell of a user,
# chsh jacob
/etc/passwd :
Contains the database of information of all the users.
The format of the file is
username:password:uid:gid:gecos:directory:shell
/etc/shadow :
The actual password of every user is stored in /etc/shadow, indicated by an x in the password field.
As /etc/passwd is readable by all users, storing even encrypted passwords in it makes password guessing easier.
However, /etc/shadow is more secure because it is readable only by programs that run with root privileges, such as login and passwd.
Here is a sample line from /etc/shadow
johny:$1$EmRh1cmZ$gkXY30H43D7NtpQXjm9F01:11589:0:99999:7:::
It contains the following fields,
- The account name
- The account’s encrypted password
- The number of days since 1 January 1970 that the password was last changed
- The number of days permitted before the password can be changed
- The number of days after which the password must be changed
- The number of days before the password expires that the user is warned
- The number of days after the password expires before the account is disabled
- The number of days since 1 January 1970 after which the account is disabled
- Reserved for future use
/etc/group :
Contains the database of information of all the groups.
The format of the file is
groupname:password:gid:userlist
where
groupname is the name of the group
- password is an optional field containing the encrypted group password
- gid is the numeric group ID number
- userlist is a comma-separated list of the user account names that comprise the group
For ex,
finance:x:507:jacob,maylyn,nancy
Now lets see some commands,
Q. To create a user account with default settings,
# useradd jacob
In this case,
the home directory will be /home/jacob,
shell will be bash
uid will be the next unused UID
Q. To show the default values taken while creating a user account,
# useradd -D
Q. To set a password for the newly created user account,
# passwd jacob
Q. To change the gecos(description) of a user account,
# usermod -c "Jacob Oyden" jacob
Q. To delete a user account
# userdel jacob
Q. To delete a user account along with its home directory,
# userdel -r jacob
Q. To create a group for finance department,
# groupadd finance
Q. To create a group in a specific guid,
# groupadd -g 1000 finance
Q. To delete a group,
# groupdel finance
Q. To lock a user account,
# passwd -l jacob
Q. To unlock a user account,
# passwd -u jacob
Q. To change the user name of an existing user account,
# usermod -l joyden jacob
above command change the username from jacob to joyden.
Q. To change the 'uid' of a user account,
# usermod -u 1023 jacob
Above command will also update all files and directories rooted in the user’s home directory automatically to the new UID, but any files outside of the user’s home directory must be altered manually.
Q. To show the user account expiry information,
# chage -l jacob
Q. To change user account expiry information,
# chage jacob
Q. To list all the shells (or you can refer the file /etc/shells for the available shells),
# chsh -l
Q. To change the shell of a user,
# chsh jacob
Monday, February 21, 2011
Managing HBAs and SAN disks in Redhat Linux 4 & 5
Redhat 5 :
To list the LUNs and their paths :
# multipath -ll
To display pv information on a multipath :
# pvdisplay /dev/mapper/mpath0
To find the server hardware details :
# dmidecode <- hardware info To scan for new LUNs: # ls /sys/class/fc_host host0 host1 # fdisk -l 2>/dev/null | egrep '^Disk' | egrep -v 'dm-' | wc -l
# echo "1" > /sys/class/fc_host/host0/issue_lip
# echo "- - -" > /sys/class/scsi_host/host0/scan
# echo "1" > /sys/class/fc_host/host1/issue_lip
# echo "- - -" > /sys/class/scsi_host/host1/scan
# cat /proc/scsi/scsi | egrep -i 'Host:' | wc -l
# fdisk -l 2>/dev/null | egrep '^Disk' | egrep -v 'dm-' | wc -l
RHEL 4.6 :
To see HBA details like firmware, wwn,etc.. :
# cat /proc/scsi/qla2xxx/0
To list the HBAs along with their HBA :
# adapter_info
To scan for new LUNs:
# hp_rescan -a
To show the WWN of a LUN :
# scsi_info /dev/sdb
To list the configured Qlogic adapters:
# lspci | grep -i qlo
To list the LUNs:
# /opt/hp/hp_fibreutils/lssd
Output will be like
sda H,B,T,L
where
H is the host number of the HBA
B is the bus number (normally 0)
T is the target number
L is the LUN number
is a string which uniquely identifies the storage array.
To remove a lun from OS:
# echo "1" > /sys/block/sd/device/delete
# echo "scsi remove-single-device H B T L" > /proc/scsi/scsi
# echo "1" > /sys/class/scsi_host/host/device/targetH:B:T:L/H:B:T:L/delete
To list the LUNs and their paths :
# multipath -ll
To display pv information on a multipath :
# pvdisplay /dev/mapper/mpath0
To find the server hardware details :
# dmidecode <- hardware info To scan for new LUNs: # ls /sys/class/fc_host host0 host1 # fdisk -l 2>/dev/null | egrep '^Disk' | egrep -v 'dm-' | wc -l
# echo "1" > /sys/class/fc_host/host0/issue_lip
# echo "- - -" > /sys/class/scsi_host/host0/scan
# echo "1" > /sys/class/fc_host/host1/issue_lip
# echo "- - -" > /sys/class/scsi_host/host1/scan
# cat /proc/scsi/scsi | egrep -i 'Host:' | wc -l
# fdisk -l 2>/dev/null | egrep '^Disk' | egrep -v 'dm-' | wc -l
RHEL 4.6 :
To see HBA details like firmware, wwn,etc.. :
# cat /proc/scsi/qla2xxx/0
To list the HBAs along with their HBA :
# adapter_info
To scan for new LUNs:
# hp_rescan -a
To show the WWN of a LUN :
# scsi_info /dev/sdb
To list the configured Qlogic adapters:
# lspci | grep -i qlo
To list the LUNs:
# /opt/hp/hp_fibreutils/lssd
Output will be like
sda H,B,T,L
where
H is the host number of the HBA
B is the bus number (normally 0)
T is the target number
L is the LUN number
To remove a lun from OS:
# echo "1" > /sys/block/sd
# echo "scsi remove-single-device H B T L" > /proc/scsi/scsi
# echo "1" > /sys/class/scsi_host/host
Wednesday, December 1, 2010
Swap Space
1. To setup swap space on a newly created partition :
# mkswap /dev/sdb3
2. To enable the swap partition :
# swapon /dev/sdb3
3. To enable the above swap device at boot time, add the below line to /etc/fstab
/dev/sdb3 swap swap defaults 0 0
4 To create a swap file:
a. Create an empty file
# dd if=/dev/zero of=/swapfile bs=1024 count=65536
b. Create swap space on the file
# mkswap /swap-file
c. Enable the swap file
# swapon /swap-file
d. Add the below line to /etc/fstab
/swap-file swap swap defaults 0 0
5. To remove a swap file
a. Disable swap on the file
# rmswap /swap-file
b. Remove the corresponding entry in /etc/fstab
c. Delete the file
# rm /swap-file
# mkswap /dev/sdb3
2. To enable the swap partition :
# swapon /dev/sdb3
3. To enable the above swap device at boot time, add the below line to /etc/fstab
/dev/sdb3 swap swap defaults 0 0
4 To create a swap file:
a. Create an empty file
# dd if=/dev/zero of=/swapfile bs=1024 count=65536
b. Create swap space on the file
# mkswap /swap-file
c. Enable the swap file
# swapon /swap-file
d. Add the below line to /etc/fstab
/swap-file swap swap defaults 0 0
5. To remove a swap file
a. Disable swap on the file
# rmswap /swap-file
b. Remove the corresponding entry in /etc/fstab
c. Delete the file
# rm /swap-file
Kernel Module
1. To list the currently loaded kernel modules :
# lsmod
2. To load a module :
# modprobe hid
For detailed output:
# modprobe -v hid
3. To unload a module (only the unused and undependent modules) :
# rmmod hid
4. Module files are kept under /lib/modules//kernel/drivers/
5. To display information about a specific module :
# modinfo -d hid
# lsmod
2. To load a module :
# modprobe hid
For detailed output:
# modprobe -v hid
3. To unload a module (only the unused and undependent modules) :
# rmmod hid
4. Module files are kept under /lib/modules/
5. To display information about a specific module :
# modinfo -d hid
Identifying a system using /proc Filesystem
1. To show the OS (Kernel) version:
# cat /proc/version
2. To identify the processor details :
# cat /proc/cpuinfo
3. To identify the memory information :
# cat /etc/meminfo
4. To show the raid devices :
# cat /proc/mdstat
5. File containing the disk partition details :
/proc/partitions
6. File containing the swap details :
/proc/swaps
7. File containing the uptime details :
/proc/uptime
# cat /proc/version
2. To identify the processor details :
# cat /proc/cpuinfo
3. To identify the memory information :
# cat /etc/meminfo
4. To show the raid devices :
# cat /proc/mdstat
5. File containing the disk partition details :
/proc/partitions
6. File containing the swap details :
/proc/swaps
7. File containing the uptime details :
/proc/uptime
Starting and Stopping Services
1. To start http service :
# /etc/rc.d/init.d/httpd start
# service sshd start
2. To stop http service :
# /etc/rc.d/init.d/httpd stop
# service sshd stop
3. To restartp http service :
# /etc/rc.d/init.d/httpd restart
# service sshd restart
4. To show the status of http service :
# /etc/rc.d/init.d/httpd status
# service sshd status
5. To show the status of all the services :
# service --status-all
6. To list the state of a service in different run levels :
# chkconfig --list ypxfrd
7. To list the state of all the services in different run levels :
# chkconfig --list
8. To enable SSH service in run levels 2,3 and 4 :
# chkconfig --level 234 sshd on
9. To disable SSH service in run levels 2,3 and 4 :
# chkconfig --level 234 sshd off
# /etc/rc.d/init.d/httpd start
# service sshd start
2. To stop http service :
# /etc/rc.d/init.d/httpd stop
# service sshd stop
3. To restartp http service :
# /etc/rc.d/init.d/httpd restart
# service sshd restart
4. To show the status of http service :
# /etc/rc.d/init.d/httpd status
# service sshd status
5. To show the status of all the services :
# service --status-all
6. To list the state of a service in different run levels :
# chkconfig --list ypxfrd
7. To list the state of all the services in different run levels :
# chkconfig --list
8. To enable SSH service in run levels 2,3 and 4 :
# chkconfig --level 234 sshd on
9. To disable SSH service in run levels 2,3 and 4 :
# chkconfig --level 234 sshd off
Software Management
1. To install a RPM package :
# rpm -ivh foo-1.0-2.i386.rpm
2. To uninstall a RPM package :
# rpm -e foo
3. To upgrade a RMP package :
# rpm -Uvh foo-1.0-2.i386.rpm
4. To query a RPM package :
# rpm -q foo
# rpm -qa | grep foo
5. To display a RPM package information :
# rpm -qi foo
6. To check the signatue of a RPM package :
# rpm --checksig foo
7. To list files in a RPM package :
# rpm -ql foo
8. To list all the installed RPMs :
# rpm -qa
# rpm -ivh foo-1.0-2.i386.rpm
2. To uninstall a RPM package :
# rpm -e foo
3. To upgrade a RMP package :
# rpm -Uvh foo-1.0-2.i386.rpm
4. To query a RPM package :
# rpm -q foo
# rpm -qa | grep foo
5. To display a RPM package information :
# rpm -qi foo
6. To check the signatue of a RPM package :
# rpm --checksig foo
7. To list files in a RPM package :
# rpm -ql foo
8. To list all the installed RPMs :
# rpm -qa
Hardware Information
1. To show the SCSI HDD/CD/VD drive information
# sdparm -i /dev/sda
2. To show the IDE HDD/CD/VD drive information
# hdparm -i /dev/hda
# sdparm -i /dev/sda
2. To show the IDE HDD/CD/VD drive information
# hdparm -i /dev/hda
Monday, September 7, 2009
System Monitoring
File containing Boot messages:
/var/log/boot.msg
To view the content of current kernel buffer:
# dmesg
Few /proc files containing system info:
/proc/cpuinfo : View processor information
/proc/meminfo : View memory information
/proc/devices : View the devices configured on your linux machine
/pro/ioports : View the I/O ports
/pro/interrupts : View the IRQ assignments
/proc/dma : View the DMA channels
/proc/bus/pci/devices : View the PCI information
/proc/scsi/scsi : View the scsi information
Fiew Commands to view hardware details:
To display the list of hardware(devices) installed in your system:
# hwinfo
To display hard drive info and manage its paramets:
# hdparm
To list the current disk partitions:
# fdisk
To display the CPU and I/O statistics:
# iostat
To display the list of PCI buses and the devices connected to it:
# lspci
To collect the system information in HTML or ASCII format:
# siga
To prepare system information using Perl:
# sitar
To display the current time, system uptime, # of users on the system:
# uptime
To list the network ports and their offered services:
# netstat -patune
To display current kernel version:
# uname -a
To display the cpu, memory, swap usage :
# top
To display the system memory and swap usage:
# free
To display memory, swap, io, system and cpu usage:
# vmstat
To display the kernel type:
# getconf LONG_BIT
/var/log/boot.msg
To view the content of current kernel buffer:
# dmesg
Few /proc files containing system info:
/proc/cpuinfo : View processor information
/proc/meminfo : View memory information
/proc/devices : View the devices configured on your linux machine
/pro/ioports : View the I/O ports
/pro/interrupts : View the IRQ assignments
/proc/dma : View the DMA channels
/proc/bus/pci/devices : View the PCI information
/proc/scsi/scsi : View the scsi information
Fiew Commands to view hardware details:
To display the list of hardware(devices) installed in your system:
# hwinfo
To display hard drive info and manage its paramets:
# hdparm
To list the current disk partitions:
# fdisk
To display the CPU and I/O statistics:
# iostat
To display the list of PCI buses and the devices connected to it:
# lspci
To collect the system information in HTML or ASCII format:
# siga
To prepare system information using Perl:
# sitar
To display the current time, system uptime, # of users on the system:
# uptime
To list the network ports and their offered services:
# netstat -patune
To display current kernel version:
# uname -a
To display the cpu, memory, swap usage :
# top
To display the system memory and swap usage:
# free
To display memory, swap, io, system and cpu usage:
# vmstat
To display the kernel type:
# getconf LONG_BIT
Networking
To start network services:
# /etc/rc.d/init.d/network start
To stop network services:
# /etc/rc.d/init.d/network stop
To restart network services:
# /etc/rc.d/init.d/network restart
To view the network configuraiton:
# ifconfig [or]
# ip addr show
To configure an interface :
# ifconfig eth0 192.168.0.1 netmask 255.255.255.0 up
# Modify the file /etc/sysconfig/network-scripts/ifcfg-eth0
To configure alias on eth0 :
# ifconfig eth0:1 192.168.0.2 netmask 255.255.255.0 up
To list routing table :
# route
To add the default gateway to the routing table:
# route add default gw 192.168.0.15
[or]
# ip route add default via 192.168.0.5
To add a route for a specific host:
# route add -host 11.0.0.2 gw 192.168.0.115
To add a route for a specific network:
# route add -net 11.0.0.0 gw 192.168.0.115
Daemon used for dynamin routing/ Uses RIP: routed
Command to start routed daemon:
# rcrouted start
Configure a network card:
# ip link set mtu 9000 dev eth0
To show the network links:
# ip link show
To view ARP cache:
# arp -n
To remove an ARP entry:
# arp -d 192.168.1.1
To modifiy the host name resolution order, Modify the below file:
# cat /etc/host.conf
order hosts,bind
To modify the DNS server info:
# cat /etc/resolv.conf
search openna.com
nameserver 218.104.16.6
nameserver 218.104.16.12
To configure networking in Linux, modify the below file:
# cat /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=myserver
GATEWAY=192.168.1.1
GATEWAYDEV=eth0
To enable IP Forwarding:
For RHEL 6.2,
a. Add the below lines to /etc/sysctl.conf file
# Enable packet forwarding
net.ipv4.ip_forward = 1
b. Restart network services
# /etc/rc.d/init.d/network restart
For RHEL version lesser than 6.2,
a. Modify /etc/sysconfig/network
b. Restart network services
# /etc/rc.d/init.d/network start
To stop network services:
# /etc/rc.d/init.d/network stop
To restart network services:
# /etc/rc.d/init.d/network restart
To view the network configuraiton:
# ifconfig [or]
# ip addr show
To configure an interface :
# ifconfig eth0 192.168.0.1 netmask 255.255.255.0 up
# Modify the file /etc/sysconfig/network-scripts/ifcfg-eth0
To configure alias on eth0 :
# ifconfig eth0:1 192.168.0.2 netmask 255.255.255.0 up
To list routing table :
# route
To add the default gateway to the routing table:
# route add default gw 192.168.0.15
[or]
# ip route add default via 192.168.0.5
To add a route for a specific host:
# route add -host 11.0.0.2 gw 192.168.0.115
To add a route for a specific network:
# route add -net 11.0.0.0 gw 192.168.0.115
Daemon used for dynamin routing/ Uses RIP: routed
Command to start routed daemon:
# rcrouted start
Configure a network card:
# ip link set mtu 9000 dev eth0
To show the network links:
# ip link show
To view ARP cache:
# arp -n
To remove an ARP entry:
# arp -d 192.168.1.1
To modifiy the host name resolution order, Modify the below file:
# cat /etc/host.conf
order hosts,bind
To modify the DNS server info:
# cat /etc/resolv.conf
search openna.com
nameserver 218.104.16.6
nameserver 218.104.16.12
To configure networking in Linux, modify the below file:
# cat /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=myserver
GATEWAY=192.168.1.1
GATEWAYDEV=eth0
To enable IP Forwarding:
For RHEL 6.2,
a. Add the below lines to /etc/sysctl.conf file
# Enable packet forwarding
net.ipv4.ip_forward = 1
b. Restart network services
# /etc/rc.d/init.d/network restart
For RHEL version lesser than 6.2,
a. Modify /etc/sysconfig/network
b. Restart network services
Disk Partitioning
To list the current partitions:
# fdisk -l
To list the partitions on a disk:
# fdisk -l /dev/sdb
To create partition on a disk:
# fdisk /dev/sdb
-> type n
-> type 'e' for extended or
'p' for primary partition
-> Enter the first cylinder number
-> Enter the last cylinder or size in KB,MB or GB
-> Enter 'p' to verify the partition table
-> Finally save the partition table by entering 'w'
Command used to inform the kernel of partition table changes:
# partprobe
# fdisk -l
To list the partitions on a disk:
# fdisk -l /dev/sdb
To create partition on a disk:
# fdisk /dev/sdb
-> type n
-> type 'e' for extended or
'p' for primary partition
-> Enter the first cylinder number
-> Enter the last cylinder or size in KB,MB or GB
-> Enter 'p' to verify the partition table
-> Finally save the partition table by entering 'w'
Command used to inform the kernel of partition table changes:
# partprobe
Filesystems
Redhat Enterprise Linux supports the below type of filesystems.
1. Local or Disk based Filesystems such as ext2, ext3, ext4, xfs.
2. Memory based filesystems such as tmpfs, proc, ramfs.
2. Network based Filesystem such as nfs, cifs.
3. Shared Storage based Filesystem such asgfs1, gfs2.
The ext2 or second extended filesystem was used long back and now-a-days we don't create these type of filesystem because of size restrictions and slow performance.
A strange limitation of Ext2 is it supports only upto the date January 18, 2038.
Some limitations of ext2 are
Max File Size = 16GB-2TB
Max Filesystem Size = 2-32 TB
Ext3 Filesystem :
Ext3 filesystem has been the most commonly used filesystem. It is actually an journalled Ext2 filesystem.
Ext3 filesystems can be remounted as Ext2 filesystems without any conversion.
On high-end storage devices, Ext3 has some limitations in that it can only scale to a maximum of 16TB. On a 1TB S-ATA drive, the performance of the Ext3 filesystem repair utility (fsck), which
is used to verify and repair the filesystem after a crash, is extremely long. For many users that require high availability, the Ext3 filesystem typically supports close to 2-4TB of storage.
Ext4 Filesystem :
Ext4 is the fourth generation of the Ext filesystem family and is the default filesystem in Red Hat Enterprise Linux 6. Ext4 has been offered in test previews since Red Hat Enterprise Linux 5.4, giving customers confidence in its maturity. Some features of Ext4 are extent-based metadata, delayed allocation, large storage support, journal check-summing. Filesystem repair time (fsck) in Ext4 is much faster than in Ext2 and Ext3. Currently, Red Hat’s maximum supported size for Ext4 is 16TB in both Red Hat Enterprise Linux 5 and Red Hat Enterprise Linux 6
XFS Filesystem:
XFS is a robust and mature 64-bit journaling filesystem that supports very large files and filesystems on a single host. Red Hat’s maximum supported XFS filesystem image is 100TB. XFS is one of the highest performing filesystems on large systems with enterprise workloads.
Some features of XFS are
• delayed allocation
• dynamically allocated inodes
• b-tree indexing for scalability of free space management
• ability to support a large number of concurrent operations
• extensive run-time metadata consistency checking
• sophisticated metadata read-ahead algorithms
• tightly integrated backup and restore utilities
• online defragmentation
• online filesystem growing
• comprehensive diagnostics capabilities
• scalable and fast repair utilities
And also the other OS based filesystems (given below) are also supported in Redhat linux such as
UFS: Used in Solaris and early BSD operating systems. Linux provides read and write support is experimental.
FAT: Windows based filesystem.
NTFS: Windows NT based filesystem. Unlike FAT, it is a b-tree file system, meaning it has a performance and reliability advantage over FAT.
Which filesystem should I use ?
For large server/storage device, you can go for XFS.
Generally Ext3/Ext4 should be fine for most of the filesystems.
If your existing workload has performed well with Ext3, staying with Ext3 on Red Hat Enterprise Linux 5 or migrating to Ext4 on Red Hat Enterprise Linux 6 should provide you and your applications with a very familiar environment. Two key advantages of Ext4 over Ext3 on the same storage include faster filesystem check and repair times and higher streaming read and write performance on high-speed devices.
In general Ext3 or Ext4 is better if an application uses a single read/write thread and small files, while XFS shines when an application uses multiple read/write threads and bigger files.
Configuration Files:
1. /etx/fstab - You need to edit this file to automate the file system mounts:
2. /etc/mtab - An entry will be added/removed to this file every time a filesystem gets mounted/unmounted.
Now let us look at the commands to manage the filesystems.
Q. How to list current mounts:
A.
# mount
# cat /etc/mtab
Q. How to create an Ext4 filesystem on a disk/partition/LV :
A.
# mkfs -t ext4 /dev/sdb
# mkfs -t ext4 /dev/sdb1
# mkfs -t ext4 /dev/vg00/lvol1
Here mention the file system type after the flag 't'.
Above command can be used to create any type of file system
Whereas below commands are restricted to specific types only.
EXT2 : mke2fs or mkfs.ext2
EXT3 : mkfs.ext3
Reiserfs: mkfs.reiserfs
vfat : mkfs.vfat
xfs : mkfs.xfs
MSDos : mkdosfs or mkfs.msdos
minix : mkfs.minix
xiafs : mkfs.xiafs
NTFS : mkntfs
Q. How to run file system check ( you need unmount a filesystem before proceeding with fsck command) :
A. fsck -t ext2 /dev/sdb1
Q. How to check all file systems except the mounted ones:
A.
# fsck -m -A
File system specific fsck commands:
EXT2 : fsck.ext2 or e2fsck
Reiserfs: reiserfsck
JFS : fsck.jfs
xfs : fsck.xfs
xiafs : fsck.xiafs
minix : fsck.minix
Q. How to mount a ext2 file system:
A.
#mount -t ext2 /dev/sdb1 /mnt/usb
Q. How to mount all filesystems:
A.
# mount -a
Q. To mount all ext2 file systems:
A.
# mount -a -t ext2
Q. Unmount a file system:
A.
# umount /mnt/usb
Q. To unmount all the mounted filesystems (except / and currently used ones):
A.
# umount -a
Q. To list open files on a mounted file system:
A.
# /usr/bin/lsof +D /mnt/usb
Q. To adjust tunable filesystem paramets on ext2/ext3 filesystems:
A.
# tune2fs /dev/sdb1
Q. To list the contents of the filesystem superblock:
A. You can use any of the below commands.
# tune2fs -l /dev/sdb1
# dumpe2fs -b /dev/sdb1
Q. To extend /data filesystem (without unmounting) :
A.
# ext2online -v /data
Q. How to display the filesystem size, usage, free space, mount points, etc..
A:
# df -h
Q. How to shrink a filesystem
A. You can not do an online filesystem shrink.
You need to unmount a filesystem before reducing its size.
Perform the following steps (1 to 7) to reduce a filesystem size.
1. Unmount the filesystem
# umount /mntpoint
2. Do filesystem check
# e2fsck -f /dev/mapper/vgname-lvname
3. Reduce the filesystem to 25GB
# resize2fs /dev/mapper/vgname-lvname 25G
4. Reduce the logical volume
# lvresize -L 25G /dev/mapper/vgname-lvname
5. Verify the LV Size
# lvdisplay /dev/vgname/lvname
6. Mount the filesystem
# mntpoint
7. Verify the filesystem size
# df -h /mntpoint
1. Local or Disk based Filesystems such as ext2, ext3, ext4, xfs.
2. Memory based filesystems such as tmpfs, proc, ramfs.
2. Network based Filesystem such as nfs, cifs.
3. Shared Storage based Filesystem such asgfs1, gfs2.
Disk Based Filesystems:
Ext2 Filesystem :The ext2 or second extended filesystem was used long back and now-a-days we don't create these type of filesystem because of size restrictions and slow performance.
A strange limitation of Ext2 is it supports only upto the date January 18, 2038.
Some limitations of ext2 are
Max File Size = 16GB-2TB
Max Filesystem Size = 2-32 TB
Ext3 Filesystem :
Ext3 filesystem has been the most commonly used filesystem. It is actually an journalled Ext2 filesystem.
Ext3 filesystems can be remounted as Ext2 filesystems without any conversion.
On high-end storage devices, Ext3 has some limitations in that it can only scale to a maximum of 16TB. On a 1TB S-ATA drive, the performance of the Ext3 filesystem repair utility (fsck), which
is used to verify and repair the filesystem after a crash, is extremely long. For many users that require high availability, the Ext3 filesystem typically supports close to 2-4TB of storage.
Ext4 Filesystem :
Ext4 is the fourth generation of the Ext filesystem family and is the default filesystem in Red Hat Enterprise Linux 6. Ext4 has been offered in test previews since Red Hat Enterprise Linux 5.4, giving customers confidence in its maturity. Some features of Ext4 are extent-based metadata, delayed allocation, large storage support, journal check-summing. Filesystem repair time (fsck) in Ext4 is much faster than in Ext2 and Ext3. Currently, Red Hat’s maximum supported size for Ext4 is 16TB in both Red Hat Enterprise Linux 5 and Red Hat Enterprise Linux 6
XFS Filesystem:
XFS is a robust and mature 64-bit journaling filesystem that supports very large files and filesystems on a single host. Red Hat’s maximum supported XFS filesystem image is 100TB. XFS is one of the highest performing filesystems on large systems with enterprise workloads.
Some features of XFS are
• delayed allocation
• dynamically allocated inodes
• b-tree indexing for scalability of free space management
• ability to support a large number of concurrent operations
• extensive run-time metadata consistency checking
• sophisticated metadata read-ahead algorithms
• tightly integrated backup and restore utilities
• online defragmentation
• online filesystem growing
• comprehensive diagnostics capabilities
• scalable and fast repair utilities
And also the other OS based filesystems (given below) are also supported in Redhat linux such as
UFS: Used in Solaris and early BSD operating systems. Linux provides read and write support is experimental.
FAT: Windows based filesystem.
NTFS: Windows NT based filesystem. Unlike FAT, it is a b-tree file system, meaning it has a performance and reliability advantage over FAT.
Which filesystem should I use ?
For large server/storage device, you can go for XFS.
Generally Ext3/Ext4 should be fine for most of the filesystems.
If your existing workload has performed well with Ext3, staying with Ext3 on Red Hat Enterprise Linux 5 or migrating to Ext4 on Red Hat Enterprise Linux 6 should provide you and your applications with a very familiar environment. Two key advantages of Ext4 over Ext3 on the same storage include faster filesystem check and repair times and higher streaming read and write performance on high-speed devices.
In general Ext3 or Ext4 is better if an application uses a single read/write thread and small files, while XFS shines when an application uses multiple read/write threads and bigger files.
Configuration Files:
1. /etx/fstab - You need to edit this file to automate the file system mounts:
2. /etc/mtab - An entry will be added/removed to this file every time a filesystem gets mounted/unmounted.
Now let us look at the commands to manage the filesystems.
Q. How to list current mounts:
A.
# mount
# cat /etc/mtab
Q. How to create an Ext4 filesystem on a disk/partition/LV :
A.
# mkfs -t ext4 /dev/sdb
# mkfs -t ext4 /dev/sdb1
# mkfs -t ext4 /dev/vg00/lvol1
Here mention the file system type after the flag 't'.
Above command can be used to create any type of file system
Whereas below commands are restricted to specific types only.
EXT2 : mke2fs or mkfs.ext2
EXT3 : mkfs.ext3
Reiserfs: mkfs.reiserfs
vfat : mkfs.vfat
xfs : mkfs.xfs
MSDos : mkdosfs or mkfs.msdos
minix : mkfs.minix
xiafs : mkfs.xiafs
NTFS : mkntfs
Q. How to run file system check ( you need unmount a filesystem before proceeding with fsck command) :
A. fsck -t ext2 /dev/sdb1
Q. How to check all file systems except the mounted ones:
A.
# fsck -m -A
File system specific fsck commands:
EXT2 : fsck.ext2 or e2fsck
Reiserfs: reiserfsck
JFS : fsck.jfs
xfs : fsck.xfs
xiafs : fsck.xiafs
minix : fsck.minix
Q. How to mount a ext2 file system:
A.
#mount -t ext2 /dev/sdb1 /mnt/usb
Q. How to mount all filesystems:
A.
# mount -a
Q. To mount all ext2 file systems:
A.
# mount -a -t ext2
Q. Unmount a file system:
A.
# umount /mnt/usb
Q. To unmount all the mounted filesystems (except / and currently used ones):
A.
# umount -a
Q. To list open files on a mounted file system:
A.
# /usr/bin/lsof +D /mnt/usb
Q. To adjust tunable filesystem paramets on ext2/ext3 filesystems:
A.
# tune2fs
Q. To list the contents of the filesystem superblock:
A. You can use any of the below commands.
# dumpe2fs -b /dev/sdb1
Q. To extend /data filesystem (without unmounting) :
A.
# umount /mntpoint
2. Do filesystem check
# e2fsck -f /dev/mapper/vgname-lvname
3. Reduce the filesystem to 25GB
# resize2fs /dev/mapper/vgname-lvname 25G
4. Reduce the logical volume
# lvresize -L 25G /dev/mapper/vgname-lvname
5. Verify the LV Size
# lvdisplay /dev/vgname/lvname
6. Mount the filesystem
# mntpoint
7. Verify the filesystem size
# df -h /mntpoint
Package(RPM) Management
RPM:
- Is a tool for the management of source files, packages, build process
- Includes a distribution method and formart for binery files, including pre and postinstall scrpits
Database of the installed packages - /var/lib/rpm
To access the database, use the rpm command
To install a package:
# rpm -ivh package-name.rpm
To upgrade a package:
# rpm -Uvh package-name.rpm
To erase/uninstall a package:
# rpm -evh package-name.rpm
To freshen a package: [ Only installs if the old version was installed ]
# rpm -F package-name.rpm
Query a package:
# rpm -q package-name
To list all the installed packages:
# rpm -qa
To show the package owning a specific file:
# rpm -qf /usr/bin/ls
To list the files owned by a package:
# rpm -ql package-name.rpm
To display package information:
# rpm -qi package-name.rpm
To verifiy a package:
# rpm -V package-name
To verify the package signature:
# rpm --checksig package-name.rpm
To import a public key for a package:
# rpm --import path-to-public-key-file
Integrated package Management:
RdHat: redhat-config-packages
SuSE: yast
Red Hat Online Update:
- Create and manage account and systems thru http://rhn.redhat.com
- Register individual systems with
# up2date --register
- User 'up2date' command to update the systems
SuSE Online Update:
- Command:
'you' or
'yast' -> Online Update
- It downloads and installs the patches freom any SuSE mirror server
- You can create internal mirrors in your network
- Is a tool for the management of source files, packages, build process
- Includes a distribution method and formart for binery files, including pre and postinstall scrpits
Database of the installed packages - /var/lib/rpm
To access the database, use the rpm command
To install a package:
# rpm -ivh package-name.rpm
To upgrade a package:
# rpm -Uvh package-name.rpm
To erase/uninstall a package:
# rpm -evh package-name.rpm
To freshen a package: [ Only installs if the old version was installed ]
# rpm -F package-name.rpm
Query a package:
# rpm -q package-name
To list all the installed packages:
# rpm -qa
To show the package owning a specific file:
# rpm -qf /usr/bin/ls
To list the files owned by a package:
# rpm -ql package-name.rpm
To display package information:
# rpm -qi package-name.rpm
To verifiy a package:
# rpm -V package-name
To verify the package signature:
# rpm --checksig package-name.rpm
To import a public key for a package:
# rpm --import path-to-public-key-file
Integrated package Management:
RdHat: redhat-config-packages
SuSE: yast
Red Hat Online Update:
- Create and manage account and systems thru http://rhn.redhat.com
- Register individual systems with
# up2date --register
- User 'up2date' command to update the systems
SuSE Online Update:
- Command:
'you' or
'yast' -> Online Update
- It downloads and installs the patches freom any SuSE mirror server
- You can create internal mirrors in your network
Volume Group
Create a VG:
# vgcreate vg00 /dev/hda1 /dev/hdb1
Create a VG by mentioning the PE size:
# vgcreate -s 10M vg01 /dev/hda1 /dev/hdb1
To display all the VGs:
# vgdisplay
To display more info on a particular VG:
# vgdisplay -v vgname
To display only active VGs:
# vgdisplay -A
Activate a VG :
# vgchange -a y vgname
De-activate a VG:
# vgchange -a n vgname
Extend a VG:
# vgextend vgname /dev/hdb1 /dev/hdc2
Reduce a VG:
# vgreduce vgname /dev/hdc2
Remove a VG:
# vgremove vgname
Import a VG into a system:
# vgimport vgname
Export a VG from a system:
# vgexport vgname
To learn new VGs:
# vgscan
To backup VGDA to /etc/lvm/backup/vg_name:
# vgcfgbackup vgname
To restore VG meta data from /etc/lvm/backup/vg_name or a file to the disk
# vgcfgrestore -f filename -n vgname vgname
To recreate VG directory and logical volume special files:
# vgmknodes vgname
# vgcreate vg00 /dev/hda1 /dev/hdb1
Create a VG by mentioning the PE size:
# vgcreate -s 10M vg01 /dev/hda1 /dev/hdb1
To display all the VGs:
# vgdisplay
To display more info on a particular VG:
# vgdisplay -v vgname
To display only active VGs:
# vgdisplay -A
Activate a VG :
# vgchange -a y vgname
De-activate a VG:
# vgchange -a n vgname
Extend a VG:
# vgextend vgname /dev/hdb1 /dev/hdc2
Reduce a VG:
# vgreduce vgname /dev/hdc2
Remove a VG:
# vgremove vgname
Import a VG into a system:
# vgimport vgname
Export a VG from a system:
# vgexport vgname
To learn new VGs:
# vgscan
To backup VGDA to /etc/lvm/backup/vg_name:
# vgcfgbackup vgname
To restore VG meta data from /etc/lvm/backup/vg_name or a file to the disk
# vgcfgrestore -f filename -n vgname vgname
To recreate VG directory and logical volume special files:
# vgmknodes vgname
Logical volume
To report information about logical volumes:
# lvs
To create a logical volume in an existing volume group:
Method 1 - By mentioning the size:
# lvcreate -L 1G -n lv01 vg01 /dev/sdb1
Method 2 - By mentioning the # of LEs:
# lvcreate -l 32 -n lv01 vg01
You can now use /dev/vg01/lv01 as a block device111111
To scan all disks for Logical volumes:
# lvscan
To change the minor number of a LV:
# lvchange --minor 98 lv_name
To change the permission:
Read-Only:
# lvchange -p r lv_name
Read/Write:
# lvchange --permission r/w lv_name
To expand a LV:
# lvresize -L +1G lv_name
To reduce the size of a LV:
# lvresize -L -512M lv_name
To display the attributes of a LV:
# lvdisplay -v /dev/datavg/loglv
To remove a LV:
# lvremove /dev/vg01/lv01
# lvs
To create a logical volume in an existing volume group:
Method 1 - By mentioning the size:
# lvcreate -L 1G -n lv01 vg01 /dev/sdb1
Method 2 - By mentioning the # of LEs:
# lvcreate -l 32 -n lv01 vg01
You can now use /dev/vg01/lv01 as a block device111111
To scan all disks for Logical volumes:
# lvscan
To change the minor number of a LV:
# lvchange --minor 98 lv_name
To change the permission:
Read-Only:
# lvchange -p r lv_name
Read/Write:
# lvchange --permission r/w lv_name
To expand a LV:
# lvresize -L +1G lv_name
To reduce the size of a LV:
# lvresize -L -512M lv_name
To display the attributes of a LV:
# lvdisplay -v /dev/datavg/loglv
To remove a LV:
# lvremove /dev/vg01/lv01
Physical Volume
Physical Volume:
You can create PV on a hard disk or partiiosn (of type '8e' / Linux LVM)
To initialize a PV on a partition:
# pvcreate /dev/sdb1
To initialize multiple PVs:
# pvcreate /dev/sdb1 /dev/sdb2 /dev/sdb3
To forcibly initialize a PV on a disk :
# pvcreate -f /dev/sdb
Above command initializes a PV by putting a volume group descriptor area a.k.a VGDA at the start of the PV
To show the information about a PV:
# pvdisplay /dev/sdb1
To report information about PVs:
# pvs
To scan all disks for Physical volumes:
# pvscan
To scan/show PVs only for exported VGs:
# pvscan -e
To scan/show PVs not belonging to any VG:
# pvscan -n
To expand a PV after enlarging the partition with fdisk:
# pvresize /dev/sdb1
To shrink a PV on a partition prior to shrinking the partition with fdisk:
# pvresize --setphysicalvolumesize 40G /dev/sdb1
To view PEs:
# pvdata -E /dev/vg1/lv1
To move PEs between PVs :
# pvmove -n lv1 /dev/sdd1 /dev/sdd2
You can create PV on a hard disk or partiiosn (of type '8e' / Linux LVM)
To initialize a PV on a partition:
# pvcreate /dev/sdb1
To initialize multiple PVs:
# pvcreate /dev/sdb1 /dev/sdb2 /dev/sdb3
To forcibly initialize a PV on a disk :
# pvcreate -f /dev/sdb
Above command initializes a PV by putting a volume group descriptor area a.k.a VGDA at the start of the PV
To show the information about a PV:
# pvdisplay /dev/sdb1
To report information about PVs:
# pvs
To scan all disks for Physical volumes:
# pvscan
To scan/show PVs only for exported VGs:
# pvscan -e
To scan/show PVs not belonging to any VG:
# pvscan -n
To expand a PV after enlarging the partition with fdisk:
# pvresize /dev/sdb1
To shrink a PV on a partition prior to shrinking the partition with fdisk:
# pvresize --setphysicalvolumesize 40G /dev/sdb1
To view PEs:
# pvdata -E /dev/vg1/lv1
To move PEs between PVs :
# pvmove -n lv1 /dev/sdd1 /dev/sdd2
LVM Limits
Max # of VG - 99
Max # of LV - 256
Max size of a LV - 512MB - 2TB (32bit)
Max size of a LV - 512MB - 1PB (64bit)
Max # of LE - 65534
Max # of PE - 65534
Max # of LV - 256
Max size of a LV - 512MB - 2TB (32bit)
Max size of a LV - 512MB - 1PB (64bit)
Max # of LE - 65534
Max # of PE - 65534
Subscribe to:
Posts (Atom)