November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Categories

November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Disable or enable the IPv6 protocol

Disable or enable the IPv6 protocol

Disabling IPv6 support in Red Hat Enterprise Linux 7

Disable ipv6 built-in kernel module.

Edit /etc/default/grub and append ipv6.disable=1 to GRUB_CMDLINE_LINUX like the following sample:
Raw

GRUB_CMDLINE_LINUX=”rd.lvm.lv=rhel/swap crashkernel=auto rd.lvm.lv=rhel/root ipv6.disable=1″

Run the grub2-mkconfig command to regenerate the grub.cfg file:
Raw

# grub2-mkconfig -o /boot/grub2/grub.cfg

Alternatively, on UEFI systems, run the following:
Raw

# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg

Reboot the system to disable IPv6 support.
Note: While following above method if you notice any Selinux denied messages in audit.log file such as avc: denied { module_request } then disable the ipv6 from /etc/sysctl.d/ipv6.conf file shown below instead.

Alternatively, this can be done via sysctl settings. Please be aware that this breaks SSH Xforwarding unless sshd_config contains AddressFamily inet.

Create a new file named /etc/sysctl.d/ipv6.conf and add the following options:
Raw

# To disable for all interfaces
net.ipv6.conf.all.disable_ipv6 = 1
# the protocol can be disabled for specific interfaces as well.
net.ipv6.conf..disable_ipv6 = 1

The new settings would then need to be reloaded with:
Raw

# sysctl -p /etc/sysctl.d/ipv6.conf

Then rebuild the Initial RAM Disk Image using:
Raw

# dracut -f

Optionally to prevent rpc* messages output after disabling ipv6, edit /etc/netconfig for the lines starting with udp6 and tcp6; change the “v” in the third column to “-“(hyphen/dash). Please refer to rpc* messages output after disabling ipv6.
Re-enabling IPv6 support in Red Hat Enterprise Linux 7

Edit /etc/default/grub and delete the entry ipv6.disable=1 from the GRUB_CMDLINE_LINUX, like the following sample:
Raw

GRUB_CMDLINE_LINUX=”rd.lvm.lv=rhel/swap crashkernel=auto rd.lvm.lv=rhel/root”

Run the grub2-mkconfig command to regenerate the grub.cfg file:
Raw

# grub2-mkconfig -o /boot/grub2/grub.cfg

Alternatively, on UEFI systems, run the following:
Raw

# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg

Delete the file /etc/sysctl.d/ipv6.conf which contains the entry:
Raw

# To disable for all interfaces
net.ipv6.conf.all.disable_ipv6 = 1
# the protocol can be disabled for specific interfaces as well.
net.ipv6.conf..disable_ipv6 = 1

If the Initial RAM Disk image was created earlier while disabling IPv6 , only then carry out this step.
Raw

# dracut -f

Check the content of the file /etc/ssh/sshd_config and make sure the AddressFamily line is commented:
Raw

#AddressFamily inet

Make sure the following line exists in /etc/hosts, and is not commented out:
Raw

::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

Reboot the system to enable IPv6 support.

Disabling IPv6 support in Red Hat Enterprise Linux 6

Create a file /etc/modprobe.d/ipv6.conf with the following contents:
Raw

options ipv6 disable=1

Disable the ip6tables service from starting at boot by issuing the following command:
Raw

# chkconfig ip6tables off

Alternatively, the IPv6 support can also be disabled in the kernel through /etc/sysctl.conf by setting following parameter:
Raw

# IPv6 support in the kernel, set to 0 by default
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1

Please be aware that this breaks SSH Xforwarding unless AddressFamily inet is set in sshd_config.

Comment out any IPv6 addresses found in /etc/hosts, including ::1 localhost address
Raw

# cp -p /etc/hosts /etc/hosts.disableipv6
# sed -i ‘s/^[[:space:]]*::/#::/’ /etc/hosts

Optionally to prevent rpc.nfsd setting up IPv6 sockets while NFS server is running, edit /etc/netconfig for the lines starting with udp6 and tcp6; change the “v” in the third column to “-“(hyphen/dash)

Reboot the system to disable IPv6 support.

Note: The solution above only disables (unhooks all of the calls) the ipv6 module, but doesn’t prevent it from loading. Unloading the module isn’t recommended due to the dependency factors it has with other modules (for example: bonding) and services. To prevent the module from loading, modify /etc/modprobe.d/ipv6.conf with the following contents:
Raw

install ipv6 /bin/true

Disabling ipv6 in the sysctl.conf will ensure ipv6 isn’t used even if the ipv6 module is loaded and can work as a short term solution (until a full reboot)
There is a special case where this might not work, please see The “ipv6 disable=1” option does not seem to work on Red Hat Enterprise Linux 6 system.

Re-enabling IPv6 support in Red Hat Enterprise Linux 6

Review the files under /etc/modprobe.d/ and remove (or comment out) any of the following lines:
Raw

options ipv6 disable=1
install ipv6 /bin/true
blacklist ipv6
alias ipv6 off

Configure the ip6tables service to start at boot by issuing the following command:
Raw

# chkconfig ip6tables on

Make sure the following options to your /etc/sysctl.conf are set to default value ‘0’
Raw

# ipv6 support in the kernel, set to 0 by default
net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.default.disable_ipv6 = 0

Make sure the following line exists in /etc/hosts and is not commented out:
Raw

::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

Edit /etc/netconfig for the lines starting with udp6 and tcp6; change the “-“(hyphen/dash) in the third column to “v”

Reboot the system to activate IPv6 support.

Disabling IPv6 support in Red Hat Enterprise Linux 5

Remove the following line (if present) from the /etc/modprobe.conf file:
Raw

alias net-pf-10 ipv6

Add the following line to the /etc/modprobe.conf file:
Raw

alias net-pf-10 off

In versions of Red Hat Enterprise Linux before 5.4, add the following line to the /etc/modprobe.conf file:
Raw

alias ipv6 off

In Red Hat Enterprise Linux 5.4 and later, add the following line to the /etc/modprobe.conf file:
Raw

options ipv6 disable=1

To prevent errors during the network initscript start routine, change the NETWORKING_IPV6 parameter in the /etc/sysconfig/network file to the following:
Raw

NETWORKING_IPV6=no

Comment out any IPv6 addresses found in /etc/hosts, including ::1 localhost address
Raw

# cp -p /etc/hosts /etc/hosts.disableipv6
# sed -i ‘s/^[[:space:]]*::/#::/’ /etc/hosts

Disable the ip6tables service from starting at boot by issuing the following command:
Raw

# chkconfig ip6tables off

Reboot the system to disable IPv6 support.

Re-enabling IPv6 support in Red Hat Enterprise Linux 5

Remove the following lines (if present) from the /etc/modprobe.conf file:
Raw

alias net-pf-10 off
alias ipv6 off
options ipv6 disable=1

Add the following line to the /etc/modprobe.conf file (if not present already):
Raw

alias net-pf-10 ipv6

Change the NETWORKING_IPV6 parameter in the /etc/sysconfig/network file to the following:
Raw

NETWORKING_IPV6=yes

Make sure the following line exists in /etc/hosts and is not commented out:
Raw

::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

Configure the ip6tables service to start at boot by issuing the following command:
Raw

# chkconfig ip6tables on

Reboot the system to re-enable IPv6 support.

Disabling IPv6 support in Red Hat Enterprise Linux 4

Remove the following line (if present) from the /etc/modprobe.conf file:
Raw

alias net-pf-10 ipv6

Add the following line to the /etc/modprobe.conf file:
Raw

alias net-pf-10 off

Comment out any IPv6 addresses found in /etc/hosts, including ::1 localhost address
Raw

# cp -p /etc/hosts /etc/hosts.disableipv6
# sed -i ‘s/^[[:space:]]*::/#::/’ /etc/hosts

Reboot the system to disable IPv6 support.

Re-enabling IPv6 support in Red Hat Enterprise Linux 4

Remove the following line from the /etc/modprobe.conf file:
Raw

alias net-pf-10 off

Add the following line to the /etc/modprobe.conf file:
Raw

alias net-pf-10 ipv6

Make sure the following line exists in /etc/hosts, and is not commented out.
Raw

::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

Reboot the system to re-enable IPv6 support.

Additional notes

Disabling IPv6 by blacklisting the module invalidates bonding in the system.

MySQL 5.8 starts and then instantly stops

MySQL 5.8 starts and then instantly stops
Everything worked perfectly except one of the final steps, launching mysql:

mysqld –skip-grant-tables –user=mysql
Was giving me the following message and then shutting down:

[ERROR] Can’t find messagefile ‘/usr/share/errmsg.sys’
After some googling I found the solution to be adding the following flag:

–lc-messages-dir=”/usr/local/mysql/share/english/”
To launch it and have it actually work, I used the following command:

mysqld –skip-grant-tables –user=mysql –lc-messages-dir=”/usr/local/mysql/share/english/

Compare Linux XFS vs EXT4 File System

Linux Operating System has lots of different file system alternatives, with all the existing default is commonly used ext4. File systems are generally utilized in order for handling how the information is kept soon after any program no longer is utilizing it, how accessibility to the information is managed, what other information (metadata) is linked to the data itself, etc. This article helps you to understand the difference between Linux XFS vs EXT4 File System.

Compare Linux XFS vs EXT4 File SystemLinux XFS vs EXT4
Ext4 File System:
Ext4 is short for fourth extended file system, it was introduced in 2008. It is really a reliable file system which has long been the default option for almost the majority of all distributions for the past couple of years, it is produced from an aging code base. Using several techniques ext4 improved in speed compair with ext3. It’s a journaling file system because of this it will maintain a journal of where the files are mainly located on the disk as well as any other changes that occur to the disk. If your system crashes, the chance of file system corruption is less due to journaling.

Maximum Individual file size can be from 16 GB to 16 TB
Maximum File System Size is 1EB(exabyte)
Maximum it contains 64,000 subdirectories (32,000 in ext3)

XFS File System:
XFS is a high-performance 64-bit journaling file system, which was designed by SGI for their IRIX platform. XFS features a variety of improvements that allow it to be stand out on the list of file system crowd, for example journaling for metadata operations, scalable/parallel I/O, suspend/resume I/O, online defragmentation, delayed allocation for performance, etc.

XFS was combined into Linux kernel in about 2002 and In 2009 RHEL Linux version 5.4 usage of the XFS file system. XFS has always been a preferred option for many enterprise systems particularly with massive amount of data, because of its high performance, architectural scalability and robustness. Now RHEL/CentOS 7 and Oracle Linux utilize XFS as their default file system.

Maximum Individual file size can be from 16 TB 16 Exabytes
Maximum File System Size is 8EB(exabyte)
Drawback: XFS file system cannot be shrunk and poor performance with deletions of the large numbers of files.

Common Commands for ext3/4 and XFS:
Task ext3/4 XFS
Create a file system mkfs.ext4 or mkfs.ext3 mkfs.xfs
File system check e2fsck xfs_repair
Resizing a file system resize2fs xfs_growfs
Save an image of a file system e2image xfs_metadump and xfs_mdrestore
Label or tune a file system tune2fs xfs_admin
Backup a file system dump and restore xfsdump and xfsrestore
Generic tools for ext2 and XFS:
Task ext4 XFS
Quota quota xfs_quota
File mapping filefrag xfs_bmap
I hope this article provides you the information about, difference Linux XFS vs EXT4 File System. Thank you for studying!!. Be Social and share it in social media,if you really feel worth sharing it.

LVM(LOGICAL VOLUME MANAGER)

LVM(LOGICAL VOLUME MANAGER)
LVM(LOGICAL VOLUME MANAGER)
—————————————–

1>first create partion

#partprobe -s

#pvcreate /dev/sda?

#pvcreate /dev/sda?

#vgcreate vg0 /dev/sda? /dev/sda?

#vgdisplay

#pvdisplay

#lvdisplay

#lvcreate -n lvm0 -L 150M vg0 (where -n—->name, -L—>length)

#lvdisplay

#mkfs.ext3 /dev/vg0/lvm0

#mkdir /mnt/lvm1

#mount /dev/vg0/lvm0 /mnt/lvm0

#vim /etc/fstab
/dev/vg0/lvm0 /mnt/lvm0 ext3 defaults 0 0

#mount -a

——————————————————————————–

Steps To Extend The LVM
—————————–

#lvextend -L 300M /dev/vg0/lvm0
(OR)
#lvextend -L +150M /dev/vg0/lvm0

#lvdisplay

#df -h

#resize2fs /dev/vg0/lvm0 (To give the information abt changing the size to the system)

#df -h
——————————————————————————–

Steps To Reduce The Size Of LVM
———————————–

#umount /mnt/lvm0

#e2fsck -f /dev/vg0/lvm0 (forcefully check the file system type)

#resize2fs /dev/vg0/lvm0 200M

#lvreduce -L 200M /dev/vg0/lvm0

#lvdisplay /dev/vg0/lvm0

#mount /dev/vg0/lvm0 /mnt/lvm0

#df -h
——————————————————————————–

To Extend Existing VG
—————————
1> create a partion

#partprobe -s

#pvcreate /dev/sda?

#vgextend vg0 /dev/sda?

#vgdispaly

Linux Boot Process

***************
Summary
=======

A) START – BIOS (Basic Input Output System) = when BIOS load in RAM Called BOOT STARPPING – CMOS = Called this process KERNAL LANDING –
MBR in Hard Disk – BOOTLOADER – KERNEL – INITRD IMAGE – Inittab = Upto this process called USER LANDING

B) There are two tyeps of boot loader in linux

a) LILO
i) 1st stage
ii) 2nd stage

b) GRUB
i) 1st stage
ii) 1.5 stage(This stage is optional)
iii) 2nd stage

Scratch \ start
============
A) Power on by USER

B) Power goes into SMPS.

C) Power goes into MOTHERBOARD.

D) Power goes then into CPU’s single pin.

E) Then CPU awakes BIOS.

F) Bios goes into RAM and start POST (power on self test) —>means BIOS will
check all hardware and periferels. This step is called BOOTSTRAPPING.

G) Then Bios goes into CMOS (Complementary metal.oxide.semiconductor) to check
the which device load in RAM. We can change the CMOS. CMOS is samll program
which take the information from Bios. CMOS battery supply power to CMOS
program. Therefore always change the CMOS battery after every 6 months.
Bios read the CMOS program for load the device.

H) BIOS load first sector / first track / 0 cylinder of harddisk ie. MBR(master boot record) into RAM.

a) MBR size is 512 MB. It divided into three parts:-
1) Bootsector(446 bytes),partition table(64 bytes),magic number(2 bytes)
Where boot sector contains boot loader (LILO or GRUB for linux and NTLDR
for windows)
2) Partion table contains 4 programs of 16 bytes.So we can create only 4
partition in a harddisk,ie four primary partition and last primary will
be extended by logical partition
3) Magic number of 2 bytes contais 0 or 1.If 0 means no and 1 means yes.
If bootsector and partition table in MBR contains errors then magic
number will be 0 otherwise 1.

##############################################################################
MBR(master Boot Record) First secter of harddisk=512 bytes
********************************************
446 bytes – Boot sector –
LILO or GRUB for linux and NTLDR for windows
===========================================================================

64 bytes – Partition table –
1st primary partition 16 bytes
2nd primary partition 16 bytes
3rd primary partition 16 bytes
4th primary partition 16 bytes / extended partition can be subdivided into logical partitions
===========================================================================
2 bytes – Magic number –
If bootsector and partition table in MBR contains errors |
then magic number will be 0 otherwise 1.

#################################################################################

I) Bios first check whether magic number is yes or no in MBR
If yes it will go for active partition in partition table else displays
error as boot failure. Active partition denoted by * in partition table
of linux and in windows C drive by default.

J) Then goes into first sector of active partition and whatever finds in first
sector of active partition loads in RAM. But its same MBR are there. So
BIOS goes to boot sector of MBR. IN boot sector, there is boot-loader
LILO or GRUB for linux and TLDR for windows. Bios load LILO/GRUB into RAM
for linux and ntldr for windows. NTLDR load windows.

K) In linux ANACONDA INSTALLER load LILO/GRUB in MBR while the time of
installation. LILO/GRUB is powerfull than ntldr. In dual boot first install
windows then install linux.

L) Bios load LILO/GRUB into RAM. This is called the FIRST STAGE OF BOOT
PROCESS. The purpose of first stage to load Second Stage ie boot.b.

M) LILO have a Map Code file. In this file have a address of ‘boot.b’ in CHS
format. LILO can not read this format. Therefore call the Bios to read
this file. If you change the path of LILO in configuration file then you
need to re-read LILO conf file. Using this command ‘/$ lilo -v’

N) Bios read map code and load BOOT.B file in RAM. This step called SECOND
STAGE OF BOOT PROCESS.

O) Map and Message these two file locate in the Boot.b file. Once again boot.b
can’t read these two files, therefore boot.b file again call the Bios for
read this two files. Bios read this files and load into RAM. Message file
show the splash screen to select the OS.

##########################################
Prompt message
************
Timeout (in seconds)
Default OS (if you not select any os)

=============================================
/boot/boot.b (2nd stage of boot loading)
=============================================
/boot/map | /boot/message
/boot/boot.0300 | /boot/boot.0800
=============================================

###########################################

P) After slecet the linux os boot.b load the Linux Kernal in RAM. Kernal
located in /boot/vmlinuz-2.4.20-8, in comparc’d format. At the loading time
LILO un-comparc’d it and load into RAM.
This steps called KERNEL LANDING.

Q) Once kernel load into RAM then kernel himself load the INITRD IMAGE in RAM.
Initrd image also in comparc’d format. Initrd image have a linuxrc script.
Initrd image run the linuxrc script.

R) Linuxrc script load ext3.o filesystem, jbd.o harddisk driver and others
*.o driver. Linuxrc script mount ‘/’ as a read only partition, it is call

S) Init – System Daemon this script run by linuxrc script
(located at /sbin/init )

a) Inittab this is a script file at /etc/inittab

1) check default runlevel

2) RC.SYSINIT this is a important file for boot
processing. This file read only one time at the
booting time and located at /etc/rc.d/rc.sysinit.
(as a sub-shell ). This script called ‘systemv’.

i) Network – reload the /etc/sysconfig/network this file
Set the hostname, this file run command $ hostname,
if hostname found then set it, else set the default
hostname i.e. ‘localhost’

ii) mounts ‘/proc’ filesystem (command mount -n -t proc /proc /proc)

iii) /etc/init.d/functions (same env)
After finish the proc mounting inittab run this file.
This cmd set around 23 functions.

iv) global UMASK
v) global PATH
vi) defines 17 shell functions
1) success
2) failure
3) passed
4) warning
5) echo_success
6) echo_failure
7) echo_passed
8) echo_warning
9) killproc
10) pidofproc
11) pidfileofproc
12) action
13) checkpid
14) confirm
15) status
16) strstr
17) daemon
vii) /etc/redhat-release
This cmnd display redhat version
which install your system.

viii) Then display interactive mode to
customize start. Press ‘I’ option to
boot manually.

ix) Set Localtime /etc/localtime
‘hwclock’ & ‘date’ cmnd change
/etc/localtime & /etc/adjtime file.

x) /proc -to check kernel parameters

xi) /etc/sysctl.conf -for kernal tunning

xii) Keyboard Mapping

xiii) FASTBOOT – if we create a blank
file as a ‘fastboot’ in ‘/’ then
fsck not process

xiv) /etc/sysconfig/readonly-root
– rwtab file, all file system
mounted as a read only

xv) /etc/rwtab.d/* – some exceptional
files in read write mode

xvi) FSCK – goto fstab and check the
parameter in 5th column if there are
‘1’ then run fsck cmnd, else check
next line.

xvii) Mounting tmpfs – /dev/shm shared
application memory.

xviii) Read /etc/fstab file and remounts
‘/’ read-write mode and all others
partition.

xix) Quota on.

xx) Enableing SWAP partition.

xxi) /bin/dmesg – /var/log/dmesg
collect hardware info from
BIOS and display.

b) RC scripts – /etc/rc.d/rc ( as a subshell )
RC manage the which services started and which not started.
This script read any time.

i) checks runlevel ( function )

ii) finding previous runlevel

iii) /etc/init.d/functions (same env)

iv) checks user confirmation mode and
interactive mode / startup. Setting new runlevel

v) /etc/rc.d/rc3.d/K* (K – means stop)
This is used for stop. However here are 5 functions
1) STOP
2) START
3) RESTART
4) STATUS
5) CONDRESTART

vi) /etc/rc.d/rc3.d/S* (S – means start)
This is used for start only. Same as above. However
some files are in this directory, those are symblink
with some files that located in ‘/etc/init.d/’. These
files called Init Script file. These files
run by /etc/init.d/function cmd

vii) /usr/bin/rhgb-client functions,used only stop
( start
stop
restart
status
condrestart )

viii) /etc/rc.d/rc.local this is a last file
run by rc script. If you want to run some cmnd
automatic then you can enter those cmnd or scirpt
in this file.

c) Now part ofthe /sbin/init call /etc/inittab file. inittab read
/sbin/shutdown -t3 -r now
poweroff considerations – /sbin/shutdown -f -h +2
poweron considerations – /sbin/shutdown -c
power ok wait
Now inttab read following line in his file
1:2345:respawn:/sbin/mingetty tty1
IF runlevel 5 then – /etc/X11/predfm -nodaemon

I) Inittab call MINGETTY
a) loads /dev/tty1
b) Reads /etc/issue file
c) /bin/login
1) /usr/bin/passwd
i)PAM (Plugabel Authantication Module) security.
ii) /etc/passwd
iii) /etc/shadow
iv) /etc/group
v) /etc/gshadow

d) puts login daemon in sleep state

e) root/.hushlogin exists ? Ja! mail,motd,lastlog NOT RUN!

f) /etc/motd (Message of the day)

g) lastlog* using /var/log/lastlog

h) Checks user’s mail – /var/spool/mail/root

i) wakes the /bin/login process which forks off as
independent application daemon & mingetty goes to Zombie state.

2) login calls /bin/bash
puts login to sleep state

3) /etc/profile (global sets HOSTNAME, HISTSIZE, PATH etc)
a) /etc/inputrc (sets keyboard mappings)
b) /etc/termcap (sets term. capabilities)
c) /etc/profile.d/*.sh ( 13 files )
customize *.sh files
( colorls.sh
vim.sh
glib2.sh
gnome-ssh-askpass.sh
krb5.sh
lam.sh
lang.sh
less.sh
mc.sh
pvm.sh
qt.sh
vim.sh
which-2.sh
xpvm.sh )

J) /etc/bash.rc – global shell

a) umask – permission set
1) root -0 – 0022
2) above uid 99 (user) – 0022

b) PS1 – define veriable (roota@localhost#). we can change ‘#’ to ‘$’
i.e. ‘root@localohost$’

K) Users profile
a) /root/.bash_profile
b) /root/.bashrc
c) /root/.bash_history
d) /root/.bash_logout

========================
END OF THE BOOT PROCESS.
========================

PXE Network Installation with Kick start

Just configured and tested PXE Network Installation . Its Amazing!!

Please bear with my rough notes on this Topic :

>> Mount your CENTOS DVD to /media .

>>>yum -y install dhcp tftp-server syslinux vsftpd system-config-kickstart

>>> Configure DHCP Server as below :

#vi /etc/dhcpd.conf

ddns-update-style interim;

ignore client-updates;

allow booting;

allow bootp;

authoritative;

subnet 192.168.182.0 netmask 255.255.255.0 {

range dynamic-bootp 192.168.182.138 192.168.182.254;

default-lease-time 21600;

max-lease-time 43200;

next-server 192.168.182.137;

filename “pxelinux.0”;

}

>>>> Configure TFTP Server

# vi /etc/xinetd.d/tftp

service tftp

{

socket_type = dgram

protocol = udp

wait = yes

user = root

server = /usr/sbin/in.tftpd

server_args = -s /tftpboot

disable = no

per_source = 11

cps = 100 2

flags = IPv4

}

>>> copy all boot required files to tftp-server’s home directory

#cp -a /media/isolinux/* /tftpboot/

>>> create a new directory at /tftpboot/pxelinux.cfg

>>> # cp /tftpboot/isolinux.cfg /tftpboot/pxelinux.cfg/default

>>> #cp /usr/lib/syslinux/pxelinux.0 /tftpboot/

>>> # service xinetd start

>>>>> Configure FTP server to provide CD Dump.

# cp -vr /media/* /var/ftp/pub

>>> Ensure that anonymous_enable=YES at /etc/vsftpd/vsftpd.conf and start the

VSFTPD service

>>> At Client Machine ,go to BIOS setting and change the boot device priority to

keep “Network boot from xxxx ” at first position

>>> The above Steps will facilitate you with Network Installation in Attended Mode

i.e you have to physically do package selection and other stuff manually .

To configure unattended Network Installation , follow these steps:

1. Go to your PXE Server and check for kickstart file at /root/anaconda-
ks.cfg, uncomment the following lines for Partitions: (Note: you can also edit this

file with system-config-kickstart utility as per your requirements)

clearpart –linux

part /boot –fstype ext3 –size=100

part swap –size=2000

part / –fstype ext3 –size=100 –grow

save this file and copy it to /var/ftp/pub.

#cp /root/anaconda-ks.cfg /var/ftp/pub (Please ensure required permission is

granted for this kickstart file).

2. Go to your Client Machine ,boot again and at boot option give :

linux ks=ftp://192.168.182.137/pub/anaconda-ks.cfg and there you go , your

Installation will be unattended .

NOTE : You can completely make Installation unattended , meaning you don’t even

have to specify the boot option (eg: linux ks=ftp://192.168.182.137/pub/

anaconda-ks.cfg) . Even this can be automated to make your Installation completely

INDEPENDENT from you . For this follow this steps:

1. Edit /tftpboot/pxelinux.cfg/default file and add the following lines :

label linux

kernel vmlinuz

append initrd=initrd.img linux ks=ftp://192.168.182.137/pub/anaconda-ks.cfg

2. Save the above file and Start your Client Machine’s Installation .

ENJOY PXE!!!!!!

Thanks

SSH passwordless multiple login

SSH passwordless multiple login

I’ve already written about howto log in, on your local system, and make passwordless ssh connections using ssh-keygen command. However, you cannot just follow these instructions over and over again, as you will overwrite the previous keys.
It is also possible to upload multiple public keys to your remote server, allowing one or more users to log in without a password from different computers.
Step # 1: Generate first ssh key
Type the following command to generate your first public and private key on a local workstation. Next provide the required input or accept the defaults. Please do not change the filename and directory location.
workstation#1 $ ssh-keygen -t rsa
Finally, copy your public key to your remote server using scp
workstation#1 $ scp ~/.ssh/id_rsa.pub user@remote.server.com:.ssh/authorized_keys
Step # 2: Generate next/multiple ssh key
a) Login to 2nd workstation
b) Download original the authorized_keys file from remote server using scp:
workstation#2 $ scp user@remote.server.com:.ssh/authorized_keys ~/.ssh
c) Now create the new pub/private key:
workstation#2 $ ssh-keygen -t rsa
d) Now you have new public key. APPEND this key to the downloaded authorized_keys file using cat command:
workstation#2 $ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
e) Finally upload authorized_keys to remote server again:
workstation#2 $ scp ~/.ssh/authorized_keys user@remote.server.com:.ssh/
You can repeat step #2 for each user or workstations for remote server.
Step #3: Test your setup
Now try to login from Workstation #1, #2 and so on to remote server. You should not be asked for a password:
workstation#1 $ ssh user@remote.server.com
workstation#2 $ ssh user@remote.server.com
Updated for accuracy.

LVM Snapshot : Backup & restore LVM Partition in linux

An LVM snapshot is an exact mirror copy of an LVM partition which has all the data from the LVM volume from the time the snapshot was created. The main advantage of LVM snapshots is that they can reduce the amount of time that your services / application are down during backups because a snapshot is usually created in fractions of a second. After the snapshot has been created, we can back up the snapshot while our services and applications are in normal operation.

LVM snapshot is the feature provided by LVM(Logical Volume Manager) in linux. While creating lvm snapshot , one of most common question comes to our mind is that what should be the size of snapshot ?

“snapshot size can vary depending on your requirement but a minimum recommended size is 30% of the logical volume for which you are taking the snapshot but if you think that you might end up changing all the data in logical volume then make the snapshot size same as logical volume ”

Scenario : We will take snapshot of /home which is LVM based parition.

[root@localhost ~]# df -h /home/
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_home
5.0G 139M 4.6G 3% /home

Taking Snapshot of ‘/dev/mapper/VolGroup-lv_home’ partition.

LVM snapshot is created using lvcreate command , one must have enough free space in the volume group otherwise we can’t take the snapshot , Exact syntax is given below :

# lvcreate -s -n -L
http://www.nextstep4it.com/categories/unix-command/lvm-snapshot/

Example :

[root@localhost ~]# lvcreate -s -n home_snap -L1G /dev/mapper/VolGroup-lv_home
Logical volume “home_snap” created

Now verify the newly create LVM ‘home_snap’ using lvdisplay command

Now Create the mount point(directory ) and mount it
[root@localhost ~]# mkdir /mnt/home-backup
[root@localhost ~]# mount /dev/mapper/VolGroup-home_snap /mnt/home-backup/
[root@localhost ~]# ls -l /mnt/home-backup/

Above command will show all directories and files that we know from our /home partition

Now take the backup of snapshot on /opt folder .

[root@localhost ~]# tar zcpvf /opt/home-backup.tgz /mnt/home-backup/

If you want the bitwise backup , then use the below command :

[root@localhost ~]# dd if=/dev/mapper/VolGroup-home_snap of=/opt/bitwise-home-backup
10485760+0 records in
10485760+0 records out
5368709120 bytes (5.4 GB) copied, 79.5741 s, 67.5 MB/s

Restoring Snapshot Backup :

If anything goes wrong with your /home file system , then you can restore the backup that we have taken in above steps. You can also mount the lvm snapshot on /home folder.

Remove LVM snapshot

Once you are done with lvm snapshot backup and restore activity , you should umount and remove lvm snapshot partition using below commands as snapshot is consuming system resources like diskspace of respective voulme group.

[root@localhost ~]# umount /mnt/home-backup/
[root@localhost ~]# lvremove /dev/mapper/VolGroup-home_snap
Do you really want to remove active logical volume home_snap? [y/n]: y
Logical volume “home_snap” successfully removed

pam_tally2 command – lock & unlock ssh failed logins in linux

pam_tally2 command – lock & unlock ssh failed logins in linux

pam_tally2 command is used to lock and unlock ssh failed logins in linux like operating system. To implment a security feature like a user’s account must be locked after a number of failed login attempts . We can achieve this security via pam module called pam_tally2. This module can display user’s login attempts,set counts on individual basis, unlock all user counts.

pam_tally2 comes in two parts: pam_tally2.so and pam_tally2. The former is the PAM module and the latter, a stand-alone program. pam_tally2 is an application which can be used to interrogate and manipulate the counter file

In this article we will discuss how to lock and unlock user’s account after reaching a fixed number of failed ssh attempts inRHEL 6.X / CentOS 6.X

By default pam_tally2 module is already installed in linux. To set the lock and unlock rules, edit the two files : ‘/etc/pam.d/system-auth’ & ‘/etc/pam.d/password-auth’ and add the below line at the starting of auth section in both the files

auth required pam_tally2.so file=/var/log/tallylog deny=3 even_deny_root unlock_time=120

And then add the below line in the account Section in both the files

account required pam_tally2.so

Sample File of /etc/pam.d/system-auth

Sample File of /etc/pam.d/password-auth

whereas :
file=/var/log/tallylog – Default log file whic keep login counts.
deny=3 – Deny access after 3 attempts and lock down user.
even_deny_root – Policy is also apply to root user.
unlock_time=1200 – Account will be locked till 20 Min after that it will be unlocked
Now Try to Login the linux box with incorrect password :

Now check user’s login attempts using pam_tally2 Command
[root@localhost ~]# pam_tally2 -u nextstep4it
Login Failures Latest failure From
nextstep4it 3 06/14/14 02:01:25 192.168.1.8

Now reset or unlock user’s account’s using pam_tally2 command :
[root@localhost ~]# pam_tally2 –user nextstep4it –reset
Login Failures Latest failure From
nextstep4it 4 06/14/14 02:20:42 192.168.1.8

Now Verify the login Attempt is reset or not
[root@localhost ~]# pam_tally2 –user nextstep4it
Login Failures Latest failure From
nextstep4it 0

Hardware Serial Numbers Linux Command to Retrieve

Hardware Serial Numbers Linux Command to Retrieve

Ever needed to obtain the serial number (or other details) for a remote server? Couldn’t be bothered to walk/run/drive/fly all the way there just to read a sticky label on the back or bottom of said server? Read on then.
The command you want to run, as root, is dmidecode. For example, to get the make and model and serial number of a server, do this:
dmidecode -t system
The result will be similar to:
# dmidecode 2.11
SMBIOS 2.5 present.

Handle 0x0002, DMI type 1, 27 bytes
System Information
Manufacturer: Dell Inc.
Product Name: Vostro 1720
Version: Null
Serial Number: 996C4L1
UUID: Not Settable
Wake-up Type: Power Switch
SKU Number: Null
Family: Vostro

Handle 0x000F, DMI type 12, 5 bytes
System Configuration Options
Option 1: Jumper settings can be described here.

Handle 0x0018, DMI type 32, 20 bytes
System Boot Information
Status: No errors detected
Other options for the -t parameter are:
bios – tells you all about your bios.
system – tells you about the system hardware.
baseboard – all about the mother board.
chassis – all you need to know about the “box” the system is made up of.
processor – fairly obvious.
memory – again, fairly obvious.
cache – information about your CPU cache.
connector – what sockets are present on the computer. USB, firewire, ethernet etc.
slot – appears to be the bus information, and voltages present, supplied etc.
There’s brief help available:
dmidecode –help

Usage: dmidecode [OPTIONS]
Options are:
-d, –dev-mem FILE Read memory from device FILE (default: /dev/mem)
-h, –help Display this help text and exit
-q, –quiet Less verbose output
-s, –string KEYWORD Only display the value of the given DMI string
-t, –type TYPE Only display the entries of given type
-u, –dump Do not decode the entries
–dump-bin FILE Dump the DMI data to a binary file
–from-dump FILE Read the DMI data from a binary file
-V, –version Display the version and exit
However, to find out the different types you can supply, you need to supply an erroneous type:
dmidecode -t left_leg

Invalid type keyword: left_leg
Valid type keywords are:
bios
system
baseboard
chassis
processor
memory
cache
connector
slot