Monday, 30 June 2014

Add some specific word to some files using For Loop

We Need to add the line/change it from unlimited to 500 for MAX_EMAIL_PER_HOUR=500
for all packages/files under the folder.

Step 1
---------
cp -rpf /var/cpanel/packages /var/cpanel/packages_org
Step 2
--------
2).ls /var/cpanel/packages > test.txt

 #but we need to remove some files which have spaces[in between] from the list test.txt, then need to add the entry MAX_EMAIL_PER_HOUR=500 for that files manually. Because it does not recognize the spaces b/w single file.
E.G:
 johnhe3_WebFarm Beef(single file)
For loop consider it as two files johnhe3_WebFarm,Beef.

Step 3
--------
3).for i in `cat test.txt`; do if [ -z `grep -w 'MAX_EMAIL_PER_HOUR' "$i" | cut -d = -f1` ]; then echo -e 'MAX_EMAIL_PER_HOUR=500' >> "$i"; else sed -i 's/MAX_EMAIL_PER_HOUR=unlimited/MAX_EMAIL_PER_HOUR=500/g' "$i"; fi; done

Friday, 27 June 2014

Kernel Compile

Kernel compilation:
-------------------

cd /usr/src

wget ftp://ftp.kernel.org/pub/linux/kernel/v3.x/linux-3.13.6.tar.gz

tar xvf linux-3.13.6.tar.gz

cd linux-3.13.6

make menuconfig
--------------------------------
This for xen virtualiaztion support

Go into Processor type and features

Statically enable all XEN features

Go back to the  main menu and enter Device Drivers menu, then enter block devices menu

Statically enable the 2 XEN options

Go back to the Device Drivers menu and go down to XEN driver suppport

Statically enable all features

Go back to Device Drivers, go into Network device support and statically enable the 2 XEN options at the bottom

Exit out and save.
-----------------------------------

But you run directly " make menuconfig " & save, it creates new .config file.
But if you copied the config-`uname -r` file to /usr/src/linux-3.13.6 and run " make menuconfig ".
Now it included the new entries[e.g xen support] in that old config file.

Note to make sure all options are selected, Run

cat /usr/src/linux-3.13.6/.config | grep XEN

You should see the same as

CONFIG_XEN=y
CONFIG_XEN_DOM0=y
CONFIG_XEN_PRIVILEGED_GUEST=y
CONFIG_XEN_PVHVM=y
CONFIG_XEN_MAX_DOMAIN_MEMORY=500
CONFIG_XEN_SAVE_RESTORE=y
CONFIG_XEN_DEBUG_FS=y
CONFIG_PCI_XEN=y
CONFIG_XEN_PCIDEV_FRONTEND=y
CONFIG_XEN_BLKDEV_FRONTEND=y
CONFIG_XEN_BLKDEV_BACKEND=y
CONFIG_NETXEN_NIC=m
CONFIG_XEN_NETDEV_FRONTEND=y
CONFIG_XEN_NETDEV_BACKEND=y
CONFIG_INPUT_XEN_KBDDEV_FRONTEND=y
CONFIG_HVC_XEN=y
CONFIG_HVC_XEN_FRONTEND=y
# CONFIG_XEN_WDT is not set
CONFIG_XEN_FBDEV_FRONTEND=y
CONFIG_XEN_BALLOON=y
CONFIG_XEN_BALLOON_MEMORY_HOTPLUG=y
CONFIG_XEN_SCRUB_PAGES=y
CONFIG_XEN_DEV_EVTCHN=y
CONFIG_XEN_BACKEND=y
CONFIG_XENFS=y
CONFIG_XEN_COMPAT_XENFS=y
CONFIG_XEN_SYS_HYPERVISOR=y
CONFIG_XEN_XENBUS_FRONTEND=y
CONFIG_XEN_GNTDEV=y
CONFIG_XEN_GRANT_DEV_ALLOC=y
CONFIG_SWIOTLB_XEN=y
CONFIG_XEN_PCIDEV_BACKEND=y
CONFIG_XEN_PRIVCMD=y
CONFIG_XEN_ACPI_PROCESSOR=y

If it looks good then continue otherwise please correct before hand.


SECTION 2:
----------------------------------
make bzImage

make modules

make modules_install

cp -a arch/x86/boot/bzImage /boot/vmlinuz-3.13.6

cp -a System.map /boot/System.map-3.13.6

cp -a .config /boot/config-3.13.6

depmod –a

mkinitramfs -o /boot/initrd.img-3.13.6 3.13.6

Modify GRUB to boot in XEN mode

vi /boot/grub/grub.conf

scroll down to the current setting and add the following above your current boot config, you will need to edit the lines to match your root and paths to the files.

title Xen 4.4.0 / Debian GNU/Linux, kernel 3.13.6
root (hd0,0)
kernel /xen.gz
module /vmlinuz-3.13.6 root=root=UUID=03f9e700-ba18-41a1-bbe7-65a372716c73 ro console=tty0
module /initrd.img-3.4.5

---------------------------------------------------

We can also use the below commands instead of section2,

--------------------------------------------------
Compile the main kernel:
# make
Compile the kernel modules:
# make modules
Install the kernel modules:
# make modules_install
At this point, you should see a directory named /lib/modules/3.9.3/ in your system.
 
Install the new kernel on the system:
# make install
The make install command will create the following files in the /boot directory.
  • vmlinuz-3.9.3 – The actual kernel
  • System.map-3.9.3 – The symbols exported by the kernel
  • initrd.img-3.9.3 – initrd image is temporary root file system used during boot process
  • config-3.9.3 – The kernel configuration file
----------------------------------------------

save and reboot.