Tip for significantly increasing battery life / reducing power consumption (Thinkpad X220)

The biggest win was setting i915.i915_enable_rc6=1 on the kernel command 
line, although I've read that this can cause some instability, depending 
on you kernel and usage -- had a couple of crashes/freezes a 6 months 
ago, but it seems pretty stable now.  The benefits for a laptop 
definitely out-weigh the inconvenience or a few rare freezes, but it 
would be different for a server.

Might try out the other kernel line options and see if I can do better :-)

Here's my /etc/rc.d/rc.local file in case you are interested:
-------------------------------------
#!/bin/bash

echo 5 > /proc/sys/vm/laptop_mode
echo 0 > /proc/sys/kernel/nmi_watchdog
echo 1 > /sys/devices/system/cpu/sched_mc_power_savings
echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo 1500 > /proc/sys/vm/dirty_writeback_centisecs
for i in /sys/bus/usb/devices/*/power/autosuspend; do echo 1 > $i; done
for i in /sys/bus/usb/devices/*/power/level; do echo auto > $i; done
echo min_power > /sys/class/scsi_host/host0/link_power_management_policy
echo min_power > /sys/class/scsi_host/host1/link_power_management_policy
echo Y > /sys/module/snd_hda_intel/parameters/power_save_controller
echo 1 > /sys/module/snd_hda_intel/parameters/power_save
for i in /sys/bus/{pci,i2c}/devices/*/power/control; do echo auto > $i; done

iwconfig wlan0 power on

Credits

CentOS 7 Tips

Newer kernel can improve random read and write IO by 25% – 50% in some cases, at least if you are utilizing SSD storage, or use this "cloud" thing called KVM. This performance boost comes from the newish blk-mq update to the Linux block device subsystem. To upgrade CentOS from Kernel 3.10.x to 3.17.x do the following: '''note: you may need to change the minor versions as the kernel is updated, so if copypasta doesn't work, please make sure you are replacing the versions in the commands with the correct version''' Get the key and install the repo so we can has the access to latest centos kernels. You should make sure there isn't a newer version of elrepo before you copypasta these commands. That should help to ensure you always get the latest kernel for CentOS 7. Keep in mind that removing the stock kernel will set you adrift from the rest of the boring and slow CentOS world, which is ok with me, but it might not be ok with your boss so I'm just giving you a fair warning.

rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org 
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm 

Remove the old CentOS 7 kernel tools, headers and libs, in the case of CentOS 7 we are removing the 3.10 Kernel and replacing with the 3.17 kernel. I don't really suggest doing this on a production server, at least until you have finalized everything and are happy with the results. You already knew that though, right? 🙂

yum remove kernel-headers-3.10.0-123.9.2.el7.x86_64 kernel-tools-3.10.0-123.9.2.el7.x86_64 kernel-tools-libs-3.10.0-123.9.2.el7.x86_64

*http://elrepo.org/tiki/tiki-index.php Edit repo and set "enabled=" in the kernel section to "1" to enable access to the latest kernel

vim /etc/yum.repos.d/elrepo.repo

[elrepo-kernel]
name=ELRepo.org Community Enterprise Linux Kernel Repository - el7
baseurl=http://elrepo.org/linux/kernel/el7/$basearch/
        http://mirrors.coreix.net/elrepo/kernel/el7/$basearch/
        http://jur-linux.org/download/elrepo/kernel/el7/$basearch/
        http://repos.lax-noc.com/elrepo/kernel/el7/$basearch/
        http://mirror.ventraip.net.au/elrepo/kernel/el7/$basearch/
mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo-kernel.el7
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
protect=0

Update Yum so that CentOS 7 pulls the newer 3.17 kernel packages from the repo we just installed.

yum update

Install the new 3.17 kernel and it's packages / libraries / tools, you might see a different kernel version than the one talked about here, so you may need to slightly modify the rest of these steps.

yum install kernel-ml.x86_64 kernel-ml-devel.x86_64 kernel-ml-headers.x86_64 kernel-ml-tools.x86_64 kernel-ml-tools-libs.x86_64 kernel-ml-tools-libs-devel.x86_64

Verify the latest kernel is available by running the following command which will parse grub2.cfg and output the available kernels to boot from

awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg


CentOS Linux, with Linux 3.17.1-1.el7.elrepo.x86_64
CentOS Linux, with Linux 3.10.0-123.el7.x86_64
CentOS Linux, with Linux 3.10.0-123.9.2.el7.x86_64
CentOS Linux, with Linux 3.10.0-123.8.1.el7.x86_64
CentOS Linux, with Linux 0-rescue-8a06d0a454c348f5911cbf876baa0e02
CentOS Linux Memtest memtest86+-4.20

If the CentOS kernel version 3.17.x is listed first, then set grub to use 0 which will set the system to boot off the newer kernel. You might want to leave some of the older 3.10.x kernels on the system in case you decide to revert to the stock CentOS 7 kernel, but you can always modify the default kernel to use later on.

grub2-set-default 0

Update the grub2 config so it's aware of the changes we just made.

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

Reboot the server and cross your fingers! If all goes well the server should come back online and boot CentOS 7 with the 3.17 kernel

reboot

To see if this is the case, run

uname -a

==Upgrade CentOS 7 Kernel to 4.0.1== Why upgrade CentOS from the stock 3.10.x kernel to a newer 4.0.1.x kernel? '''[http://wiki.mikejung.biz/Category:Performance Performance]''', especially if you use '''[http://wiki.mikejung.biz/KVM_/_Xen KVM]'''. I found that the 3.17 kernel can improve random read and write IO by 25% – 50% in some cases. The Linux 4.0 Kernel builds on top of all the previous performance gains found in the 3.17 kernel. To upgrade CentOS from Kernel 3.10.x to 4.0.1 do the following: ' Get the key and install the repo so we can has the access to latest centos kernels. You should make sure there isn't a newer version of elrepo before you copypasta these commands. That should help to ensure you always get the latest kernel for CentOS 7. Keep in mind that removing the stock kernel will set you adrift from the rest of the boring and slow CentOS world, which is ok with me, but it might not be ok with your boss so I'm just giving you a fair warning.

rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org 
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm 

Remove the old CentOS 7 kernel tools, headers and libs, in the case of CentOS 7 we are removing the 3.10 Kernel and replacing with the 4.0.1 kernel. I don't really suggest doing this on a production server, at least until you have finalized everything and are happy with the results. You already knew that though, right? 🙂

yum remove kernel-headers-3.10.0-123.9.2.el7.x86_64 kernel-tools-3.10.0-123.9.2.el7.x86_64 kernel-tools-libs-3.10.0-123.9.2.el7.x86_64

*http://elrepo.org/tiki/tiki-index.php Edit repo and set "enabled=" in the kernel section to "1" to enable access to the latest kernel

vim /etc/yum.repos.d/elrepo.repo

[elrepo-kernel]
name=ELRepo.org Community Enterprise Linux Kernel Repository - el7
baseurl=http://elrepo.org/linux/kernel/el7/$basearch/
        http://mirrors.coreix.net/elrepo/kernel/el7/$basearch/
        http://jur-linux.org/download/elrepo/kernel/el7/$basearch/
        http://repos.lax-noc.com/elrepo/kernel/el7/$basearch/
        http://mirror.ventraip.net.au/elrepo/kernel/el7/$basearch/
mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo-kernel.el7
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
protect=0

Update Yum so that CentOS 7 pulls the newer 4.0.1 kernel packages from the repo we just installed.

yum update

Install the new 4.0.1 kernel and it's packages / libraries / tools, you might see a different kernel version than the one talked about here, so you may need to slightly modify the rest of these steps.

yum install kernel-ml kernel-ml-headers kernel-ml-tools kernel-ml-tools-libs kernel-ml-tools-libs-devel

If the CentOS kernel version 4.0.1 is listed first, then set grub to use 0 which will set the system to boot off the newer kernel. You might want to leave some of the older 3.10.x kernels on the system in case you decide to revert to the stock CentOS 7 kernel, but you can always modify the default kernel to use later on.

grub2-set-default 0

Update the grub2 config so it's aware of the changes we just made.

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

Reboot the server and cross your fingers! If all goes well the server should come back online and boot CentOS 7 with the 4.0.1 kernel

reboot

== Activate tuned latency-performance for CentOS 7== Tuned should already be installed for Cent 7, and the default profile is balanced. Depending on what you are doing, you may see better '''[http://wiki.mikejung.biz/Performance_Analysis performance]''' by changing the profile to "latency-performance". Please note that if you use "tuned-adm" you are enabling a static profile which is different than running the "tuned" dynamic daemon which will analyze historical performance data and attempt to tune the server's settings on the fly. Personally I don't used the daemon, but I wanted to mention there is a dynamic "tuned" daemon, as well as a static "tuned-adm" utility which is a one off config changer.

tuned-adm profile latency-performance

To see what the active profile is:

tuned-adm active

For more information on tuned-adm options, check out the man page.

man tuned-adm

*'''latency-performance''' — "Profile for low latency performance tuning. Disables power saving mechanisms. CPU governor is set to performance and locked to the low C states (by PM QoS). CPU energy performance bias to performance." This profile is the Parent profile to "network-latency". For CentOS 7, the latency-performance profile includes the following tweaks

force_latency=1
governor=performance
energy_perf_bias=performance
min_perf_pct=100
kernel.sched_min_granularity_ns=10000000
vm.dirty_ratio=10
vm.dirty_background_ratio=3
vm.swappiness=10
kernel.sched_migration_cost_ns=5000000

*'''network-latency''' — This is a Child profile of "latency-performance". That this means is that if you were to activate network-latency profile via tuned, it would automatically enable latency-performance, then make some additional tweaks to improve network latency. As you can see, the network-latency profile includes "latency-performance", however it also disables transparent hugepages, and makes some net.core kernel tweaks. '''Please note:''' network-latency disables Cent 7's automatic NUMA balancing, so if you are not manually pinning processes to nodes, then you might actually see some reduced performance by enabling network-latency.

include=latency-performance
transparent_hugepages=never
net.core.busy_read=50
net.core.busy_poll=50
net.ipv4.tcp_fastopen=3
kernel.numa_balancing=0

*'''throughput-performance''' — This is the Parent profile to virtual-guest, virtual-host and network-throughput. This profile is optimized for large, streaming files or any high throughput workloads. *'''virtual-guest''' — "Profile optimized for virtual guests based on throughput-performance profile. It additionally decreases virtual memory swapiness and increases dirty_ratio settings." *'''virtual-host''' — "Profile optimized for virtual hosts based on throughput-performance profile. It additionally enables more aggressive write-back of dirty pages." tuned-adm profiles can be found in this directory

/usr/lib/tuned/

To learn more about each profile you can navigate to the profile directory and take a look at the profile's tuned.conf which shows what tweaks are done. The 3 most common profiles seem to be the virtual-guest, virtual-host, and latency-performance profiles. There is a "balanced" profile, but if you are running a server you will almost always want to set "latency-performance" unless you are running a storage node that deal with large, streaming files, in that case "throughput-performance" might make more sense. CentOS 7 is pretty smart about picking a profile to use when it starts up. If CentOS 7 is run as a guest using '''[http://wiki.mikejung.biz/KVM_/_Xen KVM]''', then you may see that the virtual-guest profile is active. If you are using CentOS 7 to run KVM on, and to host guests then you might see that the profile for virtual-host is active. Personally I prefer to use '''latency-performance''' profile most of the time because it really does seem to boost random read IO at the expense of slightly lower random writes (100 – 200 iops slower than virtual-guest) , and help improve overall CPU performance, at least that's what I've found when I '''[http://wiki.mikejung.biz/Benchmarking benchmark]''' servers using '''[http://wiki.mikejung.biz/Sysbench Sysbench]'''. In general you will almost always see a 1.5x – 2x performance boost for random reads if you are using SSD backed storage. == CentOS 7 RPM commands and options== ===How to search and view specific rpm packages on CentOS 7=== To search for available packages on CentOS 7 you can use the yum search command

yum search $example

Find all packages installed on CentOS 7

rpm -qa 

Find all MySQL RPM packages installed on CentOS 7 you can pipe the output of -qa to grep and use -i to match upper and lower case. If you want to find all mysql related rpms use the command below.

rpm -qa | grep -i mysql

=== List all files in RPM package === Simply run this command against any RPM you want to inspect.

rpm -qlp $package.rpm

Here is an example of the output.

rpm -qlp MySQL-shared-compat-5.1.49-1.rhel5.x86_64.rpm

/usr/lib64/libmysqlclient.so
/usr/lib64/libmysqlclient.so.12
/usr/lib64/libmysqlclient.so.12.0.0
/usr/lib64/libmysqlclient.so.14
/usr/lib64/libmysqlclient.so.14.0.0
/usr/lib64/libmysqlclient.so.15
/usr/lib64/libmysqlclient.so.15.0.0
/usr/lib64/libmysqlclient.so.16
/usr/lib64/libmysqlclient.so.16.0.0
/usr/lib64/libmysqlclient_r.so
/usr/lib64/libmysqlclient_r.so.12
/usr/lib64/libmysqlclient_r.so.12.0.0
/usr/lib64/libmysqlclient_r.so.14
/usr/lib64/libmysqlclient_r.so.14.0.0
/usr/lib64/libmysqlclient_r.so.15
/usr/lib64/libmysqlclient_r.so.15.0.0
/usr/lib64/libmysqlclient_r.so.16
/usr/lib64/libmysqlclient_r.so.16.0.0

=== Extract RPM packages Using rpm2cpio === Create a new directory, then copy over the RPM into that directory. Then run this command to extract the files into your directory.

rpm2cpio MySQL-shared-compat-5.1.49-1.rhel5.x86_64.rpm | cpio  -idmv
./usr/lib64/libmysqlclient.so
./usr/lib64/libmysqlclient.so.12
./usr/lib64/libmysqlclient.so.12.0.0
./usr/lib64/libmysqlclient.so.14
./usr/lib64/libmysqlclient.so.14.0.0
./usr/lib64/libmysqlclient.so.15
./usr/lib64/libmysqlclient.so.15.0.0
./usr/lib64/libmysqlclient.so.16
./usr/lib64/libmysqlclient.so.16.0.0
./usr/lib64/libmysqlclient_r.so
./usr/lib64/libmysqlclient_r.so.12
./usr/lib64/libmysqlclient_r.so.12.0.0
./usr/lib64/libmysqlclient_r.so.14
./usr/lib64/libmysqlclient_r.so.14.0.0
./usr/lib64/libmysqlclient_r.so.15
./usr/lib64/libmysqlclient_r.so.15.0.0
./usr/lib64/libmysqlclient_r.so.16
./usr/lib64/libmysqlclient_r.so.16.0.0
22600 blocks

== Install EPEL Repo CentOS 7 == Please make sure you are downloading the latest release for EPEL as it gets updated frequently. As of January 19th 2015, the latest EPEL release is 7-5 but before use the commands below, check out this link to make sure you wget the latest release! http://mirrors.liquidweb.com/fedora-epel/7/x86_64/repoview/epel-release.html All you need to do is grab the rpm and install it, then update yum and you should be all set.

wget http://mirrors.liquidweb.com/fedora-epel/7/x86_64/e/epel-release-7-5.noarch.rpm
rpm -iv epel-release-7-5.noarch.rpm
yum update

== How to view all installed rpms on centos 7 == You can use rpm -qa to view all of the currently installed rpms on centos 7

rpm -qa

== How to install NOVM on CentOS 7 == *https://github.com/google/novm To make and run novm on CentOS 7 do the following

yum install go fakeroot
git clone https://github.com/google/novm.git
cd novm/
make

To make an RPM of novm on CentOS 7 do the following

yum install go fakeroot
git clone https://github.com/google/novm.git
cd novm/
make rpm
rpm -iv novm-0.0-164.gb7c9c78.x86_64.rpm

If you get the error "bin/sh: gofmt: command not found" when attempting to run the make command, then you should make sure GO is installed, once that is the case the make command should build novm successfully. After you make novm you can find two binaries under the bin directory where you built novm.

/novm/bin/

noguest
novmm

novmm command line options

Usage of ./novmm:
  -cmdline="": linux command line
  -controlfd=-1: bound control socket
  -debug=false: devices start debugging
  -init=false: real in-guest init?
  -initrd="": initial ramdisk image
  -paused=false: start with model and vcpus paused
  -setup="": linux boot params (vmlinuz)
  -statefd=0: machine state file
  -step=false: step instructions
  -stop=false: wait for a SIGCONT before running
  -sysmap="": kernel symbol map
  -trace=false: trace kernel symbols on exit
  -vmlinux="": linux kernel binary (ELF)

novm noguest command line options

./noguest --help
Usage of ./noguest:
  -control="/dev/vport0p0": control file
  -serverfd=-1: run RPC server

==CPUFreq and CPU Governors == To view what CPUFreq drivers are available for CentOS 7 run this command

ls -1 /lib/modules/`uname -r`/kernel/arch/x86/kernel/cpu/cpufreq/

To load the acpi-cpufreq module run modprobe, if it's already loaded then you can skip this step. Generally speaking you always want to load the '''acpi-cpufreq''' instead of the other CPU freq options, so unless you have a specific reason to load something else, always use acpi-cpufreq. If you are having issues using CPUFreq you might as well make sure it's loaded before trying to troubleshoot too much further.

modprobe acpi-cpufreq

Once the driver is loaded you can install and run cpupowerutils which will let you know what the current frequency of your CPUs is, and what CPU governors are available to be used on your system.

yum install cpupowerutils

cpupower frequency-info --governors

Generally speaking, the performance governor is the best option to use if you are configuring a server that's going to be used all the time. Forcing the CPU governor to run in performance mode can help improve IO and reduce latency in some cases.

cpupower frequency-set --governor performance

For Official RHEL docs please visit this [https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Power_Management_Guide/cpufreq_setup.html link] ==How to install FIO on CentOS 7== The easiest way to install FIO on CentOS 7 is to install the lastest version of the EPEL repo, update YUM and then install fio. This will install FIO-2.1.11-1 which appears to be relatively up to date.

wget http://mirrors.liquidweb.com/fedora-epel/7/x86_64/e/epel-release-7-5.noarch.rpm
rpm -iv epel-release-7-5.noarch.rpm
yum update
yum install fio -y

To run a basic '''FIO random write''' test on CentOS 7, use the command below. This uses the "libaio" engine for IO, uses and IO depth of 32, uses file block size of 4KB and runs 8 Jobs, or processes each writing to a 4GB file for a total of 4 minutes, results are then grouped together which basically combines all 8 job results into one overall report summary. Fio is pretty flexible when it comes to displaying output, I suggest you view the fio man page for a list if the filters for the output.

fio --name=randfile --ioengine=libaio --iodepth=32 --rw=randwrite --bs=4k --direct=0 --size=4G --numjobs=8 --runtime=240 --group_reporting

To run a basic '''FIO random read''' test on CentOS 7, use the command below. This uses the "libaio" engine for IO, uses and IO depth of 32, uses file block size of 4KB and runs 8 Jobs, or processes each reading from a 4GB file for a total of 4 minutes, results are then grouped together which basically combines all 8 job results into one overall report summary.

fio --name=randfile --ioengine=libaio --iodepth=32 --rw=randread --bs=4k --direct=0 --size=4G --numjobs=8 --runtime=240 --group_reporting

==How to install Phoronix Test Suite CentOS 7== To install the latest version of Phoronix Test Suite on CentOS 7, run the commands below. Basically we are just installing some dependencies for Phoronix (PHP stuff), grabbing the latest stable generic package, renaming it to something we can extract, extracting the test suite, then running Phoronix's installer script.

yum install php-cli php-xml php-gd php-json -y
wget http://www.phoronix-test-suite.com/download.php?file=phoronix-test-suite-5.4.1
mv download.php\?file\=phoronix-test-suite-5.4.1 phoronix-test-suite-5.4.1.tar.gz
tar zxvf phoronix-test-suite-5.4.1.tar.gz
cd phoronix-test-suite/
./install-sh

Once the installer script completes you can start using Phoronix to test out performance. For example, if you want to run the nginx test you would run this command '''note''' for whatever reason the nginx and sometimes apache test fails to run, I've found that disabling IPV6 fixes the issue, obviously if you use IPV6 then don't do this, but if you get an error run the command below to resolve the issue. The command is just disabling ipv6 in '''[[Sysctl tweaks|sysctl.conf]]'''

echo "net.ipv6.conf.all.disable_ipv6 = 1" >> /etc/sysctl.conf
sysctl -p
/usr/bin/phoronix-test-suite benchmark pts/nginx

For more information on Phoronix and available tests, check out this '''[http://wiki.mikejung.biz/Benchmarking#Phoronix_Test_Suite page]'''. == systemctl apache CentOS 7 == To start '''[http://wiki.mikejung.biz/Apache Apache]''' using systemctl

systemctl start  httpd.service

To stop httpd using systemctl

systemctl stop  httpd.service

To restart httpd using systemctl

systemctl restart  httpd.service

==Using Numastat on CentOS 7 == With CentOS 7, numastat has received some updates that make it easier to view memory usage on a per node basis. The updates make numastat's output look more like the output from /proc/meminfo. You can use numastat to determine how much memory each '''[http://wiki.mikejung.biz/NUMA NUMA]''' node is using. Numastat will also show the amount of total NODEs on the server, this can be useful if you are trying to determine if a server / CPU utilizing multiple banks of RAM (like an E5-2690), or if it just uses a single bank of RAM (like an E3-1220). If you use the option "-c" when you run numastat, it will shrink the output based on the data being displayed. This option helps make the output more readable. numastats "-m" makes the memory information appear to be more /proc/meminfo like. "-z" will remove any rows that have no data, cleaning up the output and only displaying relevant information.

numstat -mzcs

CentOS 7 supports automatic NUMA balancing. The kernel is able to detect what memory pages are being used by processes and their threads, then attempts to balance the pages / schedule CPU time on the closest CPU to those memory pages. The idea is to try and get processes to run on the CPU that is the shortest distance from the memory bank. Ideally, data in memory should be processed on the closest CPU to avoid latency, which can significantly slow down a program that is using large amounts of RAM. ==Using lscpu on CentOS 7 == Similar to the numastat utility, you can use lscpu to view advanced CPU information which provides NUMA NODE counts, and information about what CPU / Core uses which NUMA Node. lscpu is part of the util-linux package, you can install this on CentOS 7 by using yum.

yum install util-linux

To run lscpu you can simply run lscpu!

lscpu

Credits

Tweaking CentOS 7

I’ve been a happy CentOS user ever since version 6.3. CentOS and Debian are two linux flavours that I have been playing around with since past few weeks and found both to be amazingly stable and smooth.

Ever since CentOS 7 came out, I was itching to try it. I’m a regular reader of dedoimedo’s linux musings. That guy has been writing awesome articles after articles on Linux apart from other topics. His article on CentOS 6 made me try it out so I was waiting for his take on CentOS 7. His first article seemed that he had tried it a bit too early so I thought it’s better to wait and watch. His second article – CentOS 7 – The perfect desktop guide is what got me going.

There are quite a few useful repos mentioned in the guide. The real cherry on the cake though, is nux’s CentOS 7 Repo. It’s got a lot of useful stuff. Really useful stuff that matters.

He is the creator of Stella Linux which is simply the most amazing Linux Distro. It’s a remix of CentOS (That’s how nux prefers to call it). It’s awesome.

Ok. Let’s start tweaking CentOS 7. One note before we start. I had selected the “Development and Creative Workstation” option from the Software Selection Section so that it would automatically install a lot of packages during installation itself. You might need to install other packages if you have selected any other option.

First off, as given in the guide above, run the update command:

Note – You’ll have to run all the commands as root.

yum update

Reboot and check if all looks fine.

Install the epel, elrepo and the nux repository. I had the epel repo pre installed so shown below are steps to install the elrepo and nux repositories only.

 rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
 rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
 rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm

Run the yum update command once again.

Note – Please check for the latest packages before you run the commands. As pointed out by Ruud de Bruin, the Nux Repo link is updated. Thanks Ruud.

The very next thing I did was installed the latest kernel-ml from Nux’s repo. That’s because with the stock kernel I was having issues toggling screen brightness and after some googling around I had found that 3.16.2 fixes that and few other issues (while on Stella Linux 6.5). So off I went installing it.

 yum --enablerepo=elrepo-kernel install kernel-ml

That gave me kernel version 3.16.2. So I rebooted once again, selected the kernel version 3.16.2 and all fine and dandy after that. Brightness toggle works perfectly. System boots a little faster as well.

The fonts appeared fuzzy. Well, a good .fonts.conf file should solve that. I had one lying around since my last tryst with Debian. This is an exact copy of what I found on the Debian Forum. It had worked well on Stella Linux 6.5 (Which is a remix of CentOS 6.5). Here’s the content of that file.

    <?xml version="1.0"?>
    <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
    <fontconfig>
     <match target="font">
      <edit mode="assign" name="hinting" >
       <bool>true</bool>
      </edit>
     </match>
     <match target="font" >
      <edit mode="assign" name="autohint" >
       <bool>true</bool>
      </edit>
     </match>
     <match target="font">
      <edit mode="assign" name="hintstyle" >
      <const>hintslight</const>
      </edit>
     </match>
     <match target="font">
      <edit mode="assign" name="rgba" >
       <const>rgb</const>
      </edit>
     </match>
     <match target="font">
      <edit mode="assign" name="antialias" >
       <bool>true</bool>
      </edit>
     </match>
     <match target="font">
       <edit mode="assign" name="lcdfilter">
       <const>lcddefault</const>
       </edit>
     </match>
    </fontconfig>

I copied this to my home folder. Remember, the name of the file has to be .fonts.conf. Notice the “.” at the beginning. It has to be in your home folder. So say, your home folder is at /home/yourname, then you’ll need to ensure that you copy the file in that location.

[pmu@localhost ~]$ pwd
/home/pmu
[pmu@localhost ~]$ ls -a | grep ".fonts.conf"
.fonts.conf
[pmu@localhost ~]$

Logged out and logged back in. The application and browser fonts were much better now. But for best effects, we’ll install infinality. It really makes a huge difference. And this is where nux’s repo comes in. He has done all the hard work already. We just need to install the packages like so:

 yum --enablerepo=nux-dextop install fontconfig-infinality
 yum --enablerepo=nux-dextop install cairo
 yum --enablerepo=nux-dextop install libXft
 yum --enablerepo=nux-dextop install freetype-infinality

Rebooted once again. And man, I could tell the difference. The fonts were amazingly clear. Way better even than on Windows.

Here’s some screen shots:

Section of a page.

Section of a page.

google search page screenshot

libreoffice

Download Window Screenshot. Check out the beautiful fonts.

Download Window Screenshot. Check out the beautiful fonts.

Adobe's full page

Adobe’s full page

Tweak Tool Screenshot that shows my chosen Fonts Settings.

Tweak Tool Screenshot that shows my chosen Fonts Settings.

That's how my vim looks in CentOS 7

Vim with a few tweaks.

The second last screenshot here shows the changes I have done to some default fonts. CentOS 7 looks way snappier to me this way. Like I said earlier, The fonts were amazingly clear. Way better even than on Windows. No kidding.Windows…heck, I needed to install the packages so that I could mount my USB Disks that are NTFS partitioned.

 yum install ntfs*

Okie….Did that, and was able to access my windows partitions without any problems.

Now we’ll install sensors package so that I’d know how’s the laptop temperature doing:

 yum install lm_sensors

And configure it as a root by running the following command and selecting the answers to the interactive questions.

sensors-detect

Though I like the default adwaita theme, the icons could be really better. Once again the nux repos come to the rescue.

yum --enablerepo=nux-dextop install faience-icon-theme

Select the theme in the Tweak Tool as shown below:

select_icon_theme

Now the icons look much much better.

icons

myhome

I left out the touchpad settings. Here’s how we go about it.

Hit the “Windows” key, and you’ll get a screen like this.

type_here

Now type the word “touchpad” (without quotes)

touchpad

Click on that option and then change the setting the way you want.

This is how my settings look:

mouse_settings

I have enabled the “Two Finger Scroll” and most importantly the “Tap to click” option.

That’s it (for now). We are done. All thanks to dedoimedo and nux, I got a snappy looking CentOS 7 running right now. Infact I wrote this blog on CentOS 7.

As mentioned earlier, I was a happy camper with CentOS 6.5 (Stella Linux actually). Then CentOS 7 came around and curiosity got better of me. I was able to install and tweak it to my liking as given in my Tweaking CentOS 7 post, yet one thing bothered me ~ It didn’t offer the dual boot option that CentOS 6.5 had.

Or so I thought.

A little googling, and I was able to dual boot CentOS 7 and Windows 7 !!

Here’s the points to note before you try this.

1) I am NOT using UEFI. My laptop (A Thinkpad T430) boots using the good old way of booting..the (now legacy) BIOS.

2) I had Windows 7 pre installed before installing CentOS 7. If you install CentOS 7 (Or any other Linux, or any other UNIX like OS for that matter) and then install Windows 7, then Windows 7 will overwrite the earlier entries. So you have to install Windows first.

3) I had freed up some space from the Windows Partition and installed CentOS 7 on that partition. There are a lot of guides on the net that would show you how to go about this. Follow them carefully. As always, back up your data, create a system image first and then proceed.

Now, before you run the commands given below, please go through the points given above.

Done? Good. Now let’s proceed.

I still don’t have a very clear understanding of Grub2, but what has given below has worked. So here we go.

Login as a root by typing su – (note the space between su and the space)

su -

Type in the password. Now you should be at the root prompt.

Now copy the grub.cfg file to another location as shown below ( in my case, I copied it to the root’s home. You can copy it to any place you want.)

cp /boot/grub2/grub.cfg orig.grub.cfg

Now we run the all important command.

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

That’s it. Really. Here’s the output in my case.

[root@localhost ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.16.2-1.el7.elrepo.x86_64
Found initrd image: /boot/initramfs-3.16.2-1.el7.elrepo.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-123.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-123.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-123.6.3.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-123.6.3.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-327fe33f3b364802871211321a2790b7
Found initrd image: /boot/initramfs-0-rescue-327fe33f3b364802871211321a2790b7.img
Found Windows 7 (loader) on /dev/sda1
Found Windows 7 (loader) on /dev/sda2
done
[root@localhost ~]#

I’ve highligted the Windows lines in a different color just so that they are clearly visible.

The red and bold highlight of the root prompt is due to a setting that I have in my .bashrc of root. We’ll talk about that just in a minute because we need to see if our fiddling has been successful or not. So go ahead and reboot. This time, the Grub Menu will show the entries for Windows. Boot into Windows and see if everything works fine (It should, but then, why not login and check).

Now back to the red root prompt.

Here’s the line that you’ll have to stick at the very end of your .bashrc file in root. Please do be careful.

export PS1="\[$(tput setaf 1)\]\[$(tput bold)\][\u@\h \W]\\$ \[$(tput sgr0)\]"

So after you are done, this is how your .bashrc will look

# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
    . /etc/bashrc
fi
export PS1="\[$(tput setaf 1)\]\[$(tput bold)\][\u@\h \W]\\$ \[$(tput sgr0)\]"

Note – I have highlighted the line so that it’s clearly visible.

Log out and re login as root. You should see a nice bold and red prompt now. 🙂

Here’s where I got it from. Thanks to Noah Petherbridge, I now have a nice root prompt – https://www.kirsle.net/wizards/ps1.html

Credits

Run Windows XP for Free in Windows 8

The free WindowsXPMode_en-us.exe file, there's a VirtualXPVHD file containing the Windows XP virtual machine, which you can open in VirtualBox. Here are the steps to get this working:

  1. Download WindowsXPMode_en-us.exe from Microsoft. You'll need to run the validation tool to prove your copy of Windows is valid.
  2. Then use 7-Zip or another archive tool to open the EXE file as an archive.
  3. Within that archive, find the "sources/xpm" file within it, and extract that folder to your hard drive.
  4. Finally, in the extracted xpm file, you'll find a file called VirtualXPVHD. Rename it with a VHD extension.

In VirtualBox, open the VirtualXPVHD virtual machine, and voila! You've got Windows XP Mode (running Windows XP Professional) in Windows 8, no need for the XP license.

 

Credits

Java Runtime Environment from Java.com on SL7 / Centos 7

If a browser plugin and Java runtime are all that is required, as opposed to a full Java development environment, the Oracle (formerly Sun) Java Runtime Environment (JRE) RPMs work for all currently supported CentOS versions, and are arguably the most compatible with web pages that require a Java plugin. The Java versions shown below are current as of this writing. Always use the latest available version for your architecture (i386 32-bit or x86_64/amd64 64-bit) and adjust accordingly.

Java 1.7 and Java 1.8 are now available, while Java 1.6 has been deprecated. However the same procedure as below can be used with any of them. The only difference is that the new versions are distributed directly as a rpm package so instead of the shell command which unpacks and installs the ".bin" package, simply use yum to install the downloaded rpm package, just as you would install any other rpm; for instance: yum install ./jre-8u11-linux-i586.rpm

 

Java i386 JRE and plugin

Due to the way the libraries bundled in the package were built, the browser plugin included in Java 1.7 >= 1.7.0.65 no longer works on CentOS 5. The package can be sucessfully installed but firefox will not enable the plugin due to missing GLIBC symbols. Please use the plugin from Java 1.8 instead.

Download the latest Linux RPM (self-extracting file), currently jre-6u30-linux-i586-rpm.bin, from java.com then as root install and configure the alternatives system and plugins.

 

# cd [download directory]
# sh ./jre-6u30-linux-i586-rpm.bin
# alternatives --config java
There are 2 programs which provide 'java'.
  Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
   2           /usr/lib/jvm/jre-1.5.0-gcj/bin/java
Enter to keep the current selection[+], or type selection number:

Note number of versions, N, and use N+1 (if there is no output from the previous command, just imagine that N=0) – For example, if 2 versions were installed then:

 

# alternatives --install /usr/bin/java java /usr/java/latest/bin/java 3
# alternatives --config java
There are 3 programs which provide 'java'.
  Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
   2           /usr/lib/jvm/jre-1.5.0-gcj/bin/java
   3           /usr/java/latest/bin/java
Enter to keep the current selection[+], or type selection number: 3
# java -version
java version "1.6.0_30"
Java(TM) SE Runtime Environment (build 1.6.0_30)
Java HotSpot(TM) Client VM (build 20.1-b02, mixed mode, sharing)

Create links in the Mozilla Plugins directory so Java will work in supported browsers such as Firefox.

 

# cd /usr/lib/mozilla/plugins/
# ln -fs /usr/java/latest/lib/i386/libnpjp2.so

Skip to the section on testing the browser plugin.

 

Java x86_64 JRE and plugin

Download the latest Linux RPM (self-extracting file), currently jre-6u30-linux-x64-rpm.bin, from java.com then as root install and configure the alternatives system and plugins:

 

# cd [download directory]
# sh ./jre-6u30-linux-x64-rpm.bin
# alternatives --config java
There are 4 programs which provide 'java'.
  Selection    Command
-----------------------------------------------
   1           /usr/lib/jvm/jre-1.4.2-gcj/bin/java
   2           /usr/java/jre1.6.0_13/bin/java
   3           /usr/java/jre1.6.0_18/bin/java
*+ 4           /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
Enter to keep the current selection[+], or type selection number:

Note number of versions, N, and use N+1 (if there is no output from the previous command, just imagine that N=0) – For example, if 4 versions were installed then:

 

# alternatives --install /usr/bin/java java /usr/java/latest/bin/java 5
# alternatives --config java
There are 5 programs which provide 'java'.
  Selection    Command
-----------------------------------------------
   1           /usr/lib/jvm/jre-1.4.2-gcj/bin/java
   2           /usr/java/jre1.6.0_13/bin/java
   3           /usr/java/jre1.6.0_18/bin/java
*+ 4           /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
   5           /usr/java/latest/bin/java
Enter to keep the current selection[+], or type selection number: 5
# java -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_30)
Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)

Create links in the Mozilla Plugins directory so Java will work in supported browsers such as Firefox.

 

# cd /usr/lib64/mozilla/plugins/
# ln -fs /usr/java/latest/lib/amd64/libnpjp2.so

 

Test browser

Exit Firefox if it is running and [re]start Firefox. Type "about:plugins" in the URL field. It should show Java enabled.

Verify installed version at Java.com, Test installed version at Java.com or at javatester.org.

 

Remove old versions

Oracle recommends removing old Java versions as they represent a security risk if left installed. By default, the installation procedure above will not remove old versions so we must do this manually:

 

# rpm -qa jre\*
jre-1.6.0_13-fcs.x86_64
jre-1.6.0_18-fcs.x86_64
jre-1.6.0_30-fcs.x86_64
# rpm -e jre-1.6.0_18-fcs.x86_64 jre-1.6.0_13-fcs.x86_64

 

Credits

setup multimedia on SL 7 / CentOS 7

Step 1: Install the nux-dextop repository

Run this command to install the nux-dextop repository.

 

yum -y install http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm

Step 2: Install the adobe repository

Run this command to install the adobe repository.

 

yum -y install http://linuxdownload.adobe.com/linux/x86_64/adobe-release-x86_64-1.0-1.noarch.rpm

Step 3: Install the desired packages

This command will download the flash plugin for Firefox.

 

yum install flash-plugin

This command will download the java plugin for Firefox.

 

yum install icedtea-web

This command will install Handbrake, VLC and smplayer.

 

yum install vlc smplayer ffmpeg HandBrake-{gui,cli}

The following command installs a decoder and codecs which are required to play certain types of media. Their usage may be legally restricted in some areas. Obtain legal advice if you are uncertain about the laws in your locality.

 

yum install libdvdcss gstreamer{,1}-plugins-ugly gstreamer-plugins-bad-nonfree gstreamer1-plugins-bad-freeworld

Final note

Notice that you have the CentOS, Nux-Dextop and Adobe repos enabled by default and there should be no issues with running "yum update" or "yum upgrade" in the future.

 

Credits

Interconnecting the LANs (Questions/Answers)

Questions and Problems
——————————————————————————————————-
Section 4-2

1. What are the seven layer s of the OSI model?
     i. 7-Application
     ii. 6-Presentation
     iii. 5-Session
     iv. 4-Transport
     v. 3-Network
     vi. 2-Data Link
     vii. 1-Physical

2. Which OSI layer is responsible for adding a header that includes routing information?
     i. Network Layer

3. Which OSI layer is considered the media access control layer?
     i. Data Link Layer

4. Which OSI layer combines messages and segments into packets?
     i. Transport Layer

5. Which OSI layer is responsible for the mechanical connection to the network?
     i. Physical Layer

6. The OSI layer responsible for data compression and encryption is which layer?
     i. Presentation Layer

7. TCP functions at what layer of the OSI model?
     i. Transport Layer

8. HTTP functions at what layer of the OSI model?
     i. Application Layer

9. IP and IPX are examples of protocols that operate in what layer of the OSI model?
     i. Network Layer

10. The network interface card operates at what layer of the OSI model?
     i. Physical Layer

11. Why are the layers of the OSI model important to the network administrator?
     i. To troubleshoot network problems by verifying functionality of each layer.
     ii. In many cases it requires the network administrator to isolate at what layer the network problem occurs.

——————————————————————————————————-
Section 4-3

12. What is a bridge?
     i. A networking device that uses the MAC address to forward data and interconnect two LANs.

13. Define a segment.
     i. A section of a network separated by bridges, switches and routers.

14. What information is stored in a bridge table?
     i. MAC addresses and port locations for hosts connected to the bridge ports.

15. What is an association on a bridge and how is it used?
     i. Indicates that the destination MAC address for a host is connected to one of the ports on the bridge.

16. Excessive amounts of broadcasts on a network are called a ___________.
     i. Broadcast Storm

17. What command is used on a computer to view the contents of the ARP cache?
     i. arp -a

18. An empty ARP cache indicates what?
     i. The MAC addresses in the bridge table have all expired from no data traffic and have been deleted.

19. Why do entries into the bridging table have a limited lifetime?
     i. MAC addresses into the bridge table are temporary. The MAC address entry to the bridge table remains active as long as there is periodic data traffic activity from that host on its port. Therefore the MAC address entries have become inactive and therefore the expiration timer has expired and not renewed since no new data traffic has occurred.

20. Which of the following are advantages of using a bridge to interconnect LANs?
     b. Relatively inexpensive
     d. Easy to install
     e. Reduces collision domains

——————————————————————————————————-
Section 4-4

21. The network switch operates at what layer of the OSI model?
     i. 2: Data Link Layer

22. Another name for a switch is
     b. Multiport bridge
     
23. How does a switch provide a link with minimal collisions?
     i. Simultaneous direct data connections for multiple pairs of hosts connected to the network.
     ii. Only two computers that established the link will be communicating over the channel.
     iii. Their link is isolated from any other data traffic.

24. The link for a switch connection is isolated from other data traffic except for what type of messages?
     i. Multicast Messages – Message are sent to a specific group of hosts on the network.
     ii. Broadcast Messages – Message is sent to all devices connected to the LAN.

25. Explain what data traffic is sent across a network when a computer pings another computer. A hub is used to interconnect the computers.
     i. And echo request is sent, the HUB broadcasts the request to all computers connected to the LAN, The computer that holds the IP address replies with its MAC address to the HUB, the HUB then sends the requests back to the computer that initiated the ping command and a direct line of communication is established between the two computers. The computer that initiated the ping command then receives the data packets from the destination computer.

26. Explain what data traffic is seen by computer 3 when computer 1 pings computer 2 in a LAN. A switch is used to interconnect the computers.
     i. Computer 3 only sees/receives an ARP request asking who has the specific IP address because after that a direct line of communication between computer 1 and 2 is established by the switch that prevents computer 3 from seeing the data traffic between computers 1 and 2.

27. Explain the concept of dynamic assignment on a switch.
     i. MAC addresses are assigned to a port when a host is connected.

28. Define aging time on a switch.
     i. The length of time a MAC address remains assigned to a port.

29. Explain how a switch learns MAC addresses, and where does a switch store the address.
     i. By extracting the MAC address information from the headers of Ethernet data packet header of transmitted data packets.
     ii. The switch then maps the extracted MAC address to the port where the data packet came in and stores it in the Content Addressable Memory (CAM).
     iii. Content Addressable Memory (CAM) – A table of MAC addresses and port mapping used by the switch to identify connected networking devices.

30. What happens if a MAC address is not stored in CAM on a switch?
     i. Flooding – Term used to describe what happens when a switch doesn’t have the destination MAC address stored in CAM.
     ii. The packet is transmitted out all switch ports except for the port where the packet is received.

31. What two modes are used by a switch to forward frames?
     i. Store- and-Forward
     ii. Cut-Through

32. What switch mode offers minimum latency?
     i. Cut-Through

33. What is error threshold, and what mode is it associated with?
     i. Error Threshold – The point where the number of errors in the data packets has reached a threshold and the switch changes from the cut-through to the store-and-forward mode.
     ii. Adaptive Cut-Through mode – Switches when the errors in the data packets has been exceeded

34. Explain the difference in store-and-forward and the cut-through mode on a switch.
     I. Store-and-Forward – The entire frame of data is received before any decision is made regarding forwarding the data packet to its destination. (The switch checks the data packet for errors before it is sent on to the destination.)
     II. Cut-Through – The data packet is forwarded to the destination as soon as the destination MAC address has been read.  (No error checking)
          i. Fast-Forward- Minimum switch latency
          ii. Fragment-Free – Fragment collision are filtered out by the switch.
               1. Fragments occur within the first 64 bytes of a data packet and if the packet is not 64 bytes it is discarded. Therefore no fragments.

35. How does a layer 3 switch differ from a layer 2 switch?
     i. They still work at layer 2 of the OSI model but additionally work at Layer 3 Network and use IP addressing for making decision s to route a data packet to the best direction.
     ii. They use ASICs (application specific integrated circuits) – Hardware to handle the packet switching.
     iii. They do Wire Speed Routing – Data packets are processed as fast as they are arriving.

36. What is mean by the term wire-speed routing?
     i. Data packets are processed as fast as they are arriving.

——————————————————————————————————-
Section 4-5

37. A router uses the network address on a data packet for what purpose?
     i. To make routing decisions regarding forwarding data packets.

38. What is the logical address?
     i. Describes the IP address location of the network and the address location of the host in the network.

39. The physical connection where a router connects to the network is called the . . .
     d. Router interface

40. The connection to the router’s console input is typically which of the following?
     a. RS-232
   
41. AUI stand for . . .
     d. Attachment Unit Interface

42. The AUI port on a router connects to what networking protocol?
     d. Ethernet

——————————————————————————————————-
Section 4-6

43. Define Enterprise Network.
     i. A term used to describe the network used by a large company.

44. The router interface most commonly used to interconnect LANs in a campus network is. . .
     c. Ethernet
   
45. Serial interfaces on a router are typically used to
     c. Connect to communication carriers
   
46. The designation E0 indicates. . .
     a. Ethernet port 0
   
47. Routing  tables on a router keep track of
     d. Routes to use for forwarding data to its destination

48. The convention used for naming of the serial port 0 n a router is . . .
     a. S0
     
49. Define the term gateway
     i. Describes the networking device that enables hosts in a LAN to connect to networks (and hosts) outside the LAN.

——————————————————————————————————-
Section 4-7

50. What is the purpose of the fast link pulse?
     i. The auto negotiation protocol uses the (FLP) to carry the information between each end of a data link.
     ii. (FLP) Fast Link Pulse – Carries the configuration information between each end of a data link.

51. Define full duplex.
     i. The communication device can transmit between each end of a data link.

52. Define half duplex.
     i. The communication device can transmit and receive at the same time.

53. Which of the following is a disadvantage of the auto-negotiation protocol?
     b. A failed negotiation on a functioning link can cause a link failure.
 

Credits: http://pcr-tech-sc.2302233.n4.nabble.com/Chapter-4-Interconnecting-the-LANs-Questions-Answers-td3891785.html

Create a bootable Pendrive to install Windows 7

  1. Format the Pendrive or USB drive in NTFS format first.
  2. From the start menu right click on the command prompt and select “Run as administrator“.
  3. Now type the following commands (Press enter key after each command).
  4. diskpart. This is to open the disk partition program.
  5. Now to show the list of drives type list disk.
  6. You can see disk’s listed there. Note down the disk number of your pendrive eg. Disk .
  7. Now type SELECT DISK X (where X is the number you noted down for the pendrive from step 5)
  8. Now type CLEAN.
  9. Now type the following commands by pressing enter after each one.
  10. CREATE PARTITION PRIMARY
  11. SELECT PARTITION 1 (Assuming your pendrive/ USB drive is 1).
  12. ACTIVE
  13. FORMAT FS=NTFS
  14. ASSIGN
  15. EXIT (Now the disk partition program will exit). Now we need to give some more commands.
  16. Now insert the Windows 7 Installation DVD and to your DVD drive.
  17. Here i am assuming DVD drive as G and Pendrive as I.(Change it accordingly).
  18. Now type G: CD BOOT
  19. Now type this command BOOTSECT.EXE / NT60 I: to update your USB drive with bootmgr code.
  20. Finally copy all the contents from the Windows 7 DVD to your Pendrive. Make sure you don’t cause any errors.
  21. Plug / Insert your pendrive to your PC and restart the system.
  22. Now Enter the Bios system accordingly by pressing the Delete key. (This might be sometimes F2 or F12. It depends on the type of your system. Any how during the start up your system will display which key to press to enter the Bios).
  23. Now select the USB/ Pendrive as the first boot driver.(Set the first boot priority to USB drive.).
  24. Now save the settings in Bios and restart and you will be able to Install Windows 7 using that pendrive.

Credits: http://www.computingunleashed.com/install-windows-7-from-pendrive-how-to.html