Entries Tagged as 'Linux'

Quick LVM

The following is to quickly configure new added hard drive for CentOS 5.

This creates a partition for the disk

#fdisk /dev/sda

This creates a volume group descriptor at the start of disk.

# pvcreate /dev/sda

This creates a volume group descriptor at the start of the /dev/sda1 partition.

# pvcreate /dev/sda1

This creates a voluem group

# vgcreate NewVolGroup /dev/sda1

If you want to create an logic volume that uses the entire volume group, use vgdisplay to find the “Total PE” size, then use that when running lvcreate.

# vgdisplay NewVolGroup | grep “Total PE”
Total PE 10230
# lvcreate -l 10230 NewVolGroup -n NewLogicVol

This creates a file system

# mkfs.ext3 -b 4096 /dev/NewVolGroup/NewLogicVol

Mount to somewhere

# mkdir /somewhere
# mount /dev/NewVolGroup/NewLogicVol /somewhere

Add one line to /etc/fstab

/dev/NewVolGroup/NewLogicVol /somewhere ext3 defaults 1 2

Done

I also would like to add a diagram from linuxconfig.org

Lvm

How to get percentage of package loss

Due to testing on the network, the package lost rate is needed. The following bash script shows how to get percentage of package loss. I split IP address to four segments since it will be easy to manipulate for loop.

PINGTMP=/tmp/ping.tmp

IP_1=`echo $IPADDRESS | awk -F”.” ‘{print $1}’`
IP_2=`echo $IPADDRESS | awk -F”.” ‘{print $2}’`
IP_3=`echo $IPADDRESS | awk -F”.” ‘{print $3}’`
IP_4=`echo $IPADDRESS | awk -F”.” ‘{print $4}’`
ping -t 5 -c 2 $IP_1.$IP_2.$IP_3.$IP_4 > $PINGTMP
pack_loss=`awk ‘/statistics/{getline;print $6}’ $PINGTMP`
echo $pack_loss

How to Enable IP Forwarding

One Linux computer box could be as a router if it has more than one NIC. Howerver, it would not forward packages as normal router does. Here is a simple example: Host1—Host2—Host3. Host2 will be router to let Host1 connects to Host3. You may find out Host1 cannot PING Host3. To solve it, there are two ways to enable ip_forward on Host2.

1. Simple but will lost at next reboot

echo 1 > /proc/sys/net/ipv4/ip_forward

2. Change Configuration at next reboot
“vi /etc/sysctl.conf ” to change following configuration:

# Controls IP packet forwarding
net.ipv4.ip_forward = 1

Of course, the best way to enable IP forwarding is to configure iptables, which will be more secured.

dmidecode – Get More Info from BIOS

Sometimes you want to know some hardware information, such as L1/L2 cache size, Memory and CPU. There is a tool to allow us to read those information. Since the output will be many lines, you can either put them to a temp file, or use grep to get information you want.

#dmidecode > tempfile

#dmidecode | grep key words

Linux Kernel 2.6.24 – (2)

Let’s continue to view what’s new on Linux Kernel 2.6.24.

1. SPI/SDIO support in the MMC layer

MultiMedia Card (MMC) subsystem maintainer Pierre Ossman described what he plans to push upstream, “this release will probably be one of the biggest ones for the MMC layer so far. The major pieces are SDIO and SPI support, but there are several small nuggets as well.” Regarding the new Secure Digital Input Output (SDIO) stack he noted, “gone are the days of having to rely on proprietary stacks for SDIO support in Linux.

2. USB authorization

As part of the efforts to make the USB layer ready for wireless USB, Linux 2.6.24 is getting support for USB device authorization, which allows you to control if a USB device (wireless or not) can be used or not in a system.

3. Per-device dirty memory thresholds

When a process writes data to the disk, the data is stored temporally in ‘dirty’ memory until the kernel decides to write the data to the disk (‘cleaning’ the memory used to store the data). A process can ‘dirty’ the memory faster than the data is written to the disk, so the kernel throttles processes when there’s too much dirty memory around. The problem with this mechanism is that the dirty memory thresholds are global, the mechanism doesn’t care if there are several storage devices in the system, much less if some of them are faster than others. There are a lot of scenarios where this design harms performance. For example, if there’s a very slow storage device in the system (ex: a USB 1.0 disk, or a NFS mount over dialup), the thresholds are hit very quickly – not allowing other processes that may be working in much faster local disk to progress. Stacked block devices (ex: LVM/DM) are much worse and even deadlock-prone (check the LWN article).

4. PID and network namespaces

Linux 2.6.24 adds PID namespaces and basic support for network namespaces. They’re used through the CLONE_NEWPID and CLONE_NEWNET clone() flags.

5. Large Receive Offload (LRO) support for TCP traffic

LRO combines received tcp packets to a single larger tcp packet and passes them then to the network stack in order to increase performance (throughput). After many out-of-the-tree iterations, mainline Linux is getting support for this feature

6. Task Control Groups

There have been various proposals in the Linux arena for resource management/accounting and other task grouping subsystems in the kernel (Resgroups, User Beancounters, NSProxy cgroups, and others). Task Control Groups is the framework that is getting merged in 2.6.24 to fulfill the functionality that lead to the creation of such proposals.

7. Linux Kernel Markers

The Linux Kernel Markers implement static probing points for the Linux kernel. Dynamic probing system like kprobes/dtrace can put probes pretty much anywhere. However, the scripts that dynamic probing points use can become quickly outdated, because a small change in the kernel may trigger a rewrite of the script, which needs to be maintained and updated separately, and will not work for all kernel versions.

8. Read-only bind mounts

Read-only bind mounts (mount –bind) allows a read-only view into a read-write filesystem. In the process of doing that, it also provides infrastructure for keeping track of the number of writers to any given mount. This has a number of uses. It allows chroots to have parts of filesystems writable. It will be useful for containers in the future because users may have root inside a container, but should not be allowed to write to somefilesystems.

9. x86-32/64 arch reunification

When support for the x86-64 AMD architecture was developed, it was decided to develop it as a “fork” of the traditional x86 architecture for comodity reasons. Many patches needed to patch a file in the i386 architecure directory, and another similar patch for the duplicated file in the x86_64 directory. It has been decided to unify both architectures in the same directory again.

Note: All quoted description is from kernelnewbie.org.

What’s New on Linux Kernel 2.6.24 – (1)

Linux Kernel released a stable version 2.6.24. According to one of Linux Editor, Marius Nestor, The release is the hottest Linux kernel ever! Why? Several improvements are as following:

1. Improved CFS

Briefly, CFS allows you to safeguard your files in encrypted form in a normal directory. By using a key (or password, if you will), you temporarily decrypt your files to clear-text form for the window of time in which you need to work with them.

2. Add Tickless feature for x86-64?PPC?UML?ARM?MIPS architecture.

“The tickless kernel feature (CONFIG_NO_HZ) enables ‘on-demand’ timer interrupts: if there is no timer to be expired for say 1.5 seconds when the system goes idle, then the system will stay totally idle for 1.5 seconds. This should bring cooler CPUs and power savings: on our (x86) testboxes we have measured the effective IRQ rate to go from HZ to 1-2 timer interrupts per second.

“This feature is implemented by driving ‘low res timer wheel’ processing via special per-CPU high-res timers, which timers are reprogrammed to the next-low-res-timer-expires interval. This tickless-kernel design is SMP-safe in a natural way and has been developed on SMP systems from the beginning.”

3. Patch for Anti-fragmentation

The anti-fragmentation strategy has memory overhead. This patch allows
the strategy to be disabled for small memory systems or if it is known the
workload is suffering because of the strategy. It also acts to show where
the anti-frag strategy interacts with the standard buddy allocator.

4. New wireless drivers and configuration interface

(To Be Continued…)

Remote Desktop from Linux to Windows

I mentioned before about how to remote login your desktop. Here I would like to add more stuff. It was widely used from Linux platform to login Windows platform. If you don’t have VNC server running on your Windows, you can use rdesktop.

Ubuntu 7.10 has already had rdesktop. For Fedora 8, you can “yum -y install rdesktop“. You can connect to your Windows desktop by typing:

rdesktop -f -u username domain_name/IP address

You also can get more options by “man rdesktop“.

Histories Should Be Remebered

Ethernet

Birth Year: 1973

Father: Robert M. Metcalfe

ethernet73.gif

C Language

Birth Year: 1973

Father: Dennis Ritchie of Bell Laboratiries

C was developed from 1969 to 1973 by Dennis Ritchie of Bell Laboratories. The American National Standard Institute (ANSI) ratified the ANSI C standard in 1989. The standard defines the C language and a set of library functions known as the C standard library. Kernighan and Ritchie describe ANSI C in their classic book, which is known affectionately as “K&R”. In Ritchie’s words, C is “quirky, flawed, and an enormous success.”

GNU Project

Birth Year: 1984

Father: Richard Stallman

richard_stallman.jpg

The GNU project is a tax-exempt charity started by Richard Stallman in 1984, with the ambitious goal of developing a complete Unix-like system whose source code is unencumbered by restrictions on how it can be modified or distributed. As of 2002, the GNU project has developed an environment with all the major components of a Unix operation system, except for the kernel, which was developed separately by the Linux project.

Linux

Birth Year: 1991

Father: Linus Torvalds

linus_torvalds.jpg

From:torvalds@klaava.Helsinki.FI (Linus Benedict Torvalds)
Newsgroup: comp.os.minix
Subject: What would you like to see most in minix?
Summary: small poll for my new operating system
Message-ID: 1991Aug25, 20578.9541@klaava.Helsinki.FI
Date: 25 Aug 91 20:57:08 GMT
Organization: University of Helsinki. 

Hello everybody out there using minix- 

I'm doing a (free) operating system (just a hobby, won't be big
and professional like gnu) for 386(486) AT clones. This has
been brewing since april, and is starting to get ready. I'd like
any feedback on things people like/dislike in minix; as my OS
resembles it somewhat (same physical layout of the file-sytem
due to practical reasons)among other things. 

I've currently ported bash (1.08) an gcc (1.40), and things seem to work.
This implies that i'll get something practical within a few months, and I'd
like to know what features most people want. Any suggestions are welcome,
but I won't promise I'll implement them :-)  

Linus Torvalds torvalds@kruuna.helsinki.fi

PPTP Client for Ubuntu 7.10

PPTP is most popular VPN used by people who want to connect to workplace from home. From the network layer point of view, PPTP is layer 2 protocol, which is using L2TP. In the industry, Layer 3 protocol, IPSec, is well used. There is Linux open-source VPN package named SWAN. You can dig it if you are interesting in that.

Now, we turn back to our topic. We assume that PPTP server is setup already.

First, we need to apt-get pptp package

sudo apt-get install network-manager-pptp

Then, go to network icon to configure VPN

pptp1.jpg

Then, add a VPN network.

configure_pptp_add.png

Following the instruction, we can complete PPTP configuration.

configure_pptp_tunnel.png

Last, we can simply click network icon and choose VPN we have already setup. After authentication, we have connected to workplace network.

Multimedia For Fedora 8

After installation of Fedora 8, we need more rpm package. So, we need Fedora 8 Repository RPM.

Then, we can get mplayer and xine, which are the most popular tools for multimedia.

For Video

yum -y install mplayer-gui xine xine-lib-extras-nonfree libquicktime libdvdcss vlc

For Audio

yum -y install lame normalize grip gstreamer-plugins-ugly