Showing posts with label unix. Show all posts
Showing posts with label unix. Show all posts

Friday, April 13, 2012

Unix: Adding a new disk to VM Image


1.Execute the following command to see all the disks that are present on the machine
fdisk -l
Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000ac560   

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1         993     7976241   83  Linux
/dev/sda2             994        1044      409657+   5  Extended
/dev/sda5             994        1044      409626   82  Linux swap / Solaris

Disk /dev/sdb: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xe8768ce7
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         391     3140676   83  Linux Disk

/dev/sdc: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

Disk /dev/sdc doesn't contain a valid partition table


2.Execute the following commands to create the partitions
fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x261e87e6.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

The number of cylinders for this disk is set to 1305.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
   p
   Partition number (1-4): 1
   First cylinder (1-1305, default 1):
   Using default value 1
   Last cylinder, +cylinders or +size{K,M,G} (1-1305, default 1305):
   Using default value 1305

   Command (m for help): w
   The partition table has been altered!

   Calling ioctl() to re-read partition table.
   Syncing disks.


3.Create the file system
mkfs.ext3 /dev/sdc1

4.mount the file system
mount /dev/sdc /filepath
  

Unix: Increase system's file descriptor size


This is a common problem with DB servers with heavy transactions.
The server usually throws “too many open files” errors and no new processes could be started.

check the fd size via:
$ulimit -a   # see all the kernel parameters
$ulimit -n   #see the number of open files
$ulimit -n 9000  #  set the number open files to 9000

First, in order to set this options automatically  you have to edit the etc/security/limits.conf file.
root soft  nofile 9000
root hard  nofile 65000

Second you have to add a line in the /etc/pam.d/common-session file:
$ sudo gedit /etc/pam.d/common-session #open the file in gedit
 
Then add the line:
session required pam_limits.so

Unix: Swap Size Increase




To check memory:
free -m
Sample output:
             total       used       free     shared    buffers     cached
Mem:          8105       1292       6812          0         38        483

-/+ buffers/cache:        770       7334
Swap:         1906          0       1906

Swap size increment helps to improve system performance. Suppose we are increasing swap size by 2GB.
dd if=/dev/zero of=/swap_file bs=1M count=2048

This will create file (swapfile) of size 2GB
mkswap /swap_file

add this file to your swap pool
swapon /swap_file

free -m
Sample output:
             total       used       free     shared    buffers     cached
Mem:          8105       1292       6812          0         38        483

-/+ buffers/cache:        770       7334
Swap:         XXXX          0       1906

To make it turn on at every bootup, open up /etc/fstab:
vi /etc/fstab
/swap_file none swap sw 0 0

 

Ubuntu 3GB Ram Limitation and Solution


Ubuntu 32-Bit machine is bound to use maximum of 3 GB RAM, Below are the steps to use > 3GB RAM.
$ free -m
Sample output:
             total       used       free     shared    buffers     cached
Mem:          3291        801       2489          0         95        342

-/+ buffers/cache:        363       2927
Swap:         1906          0       1906

Open terminal and type the following command if you are using Ubuntu version Ubuntu v9.04 and earlier:
$ sudo apt-get update
$ sudo sudo apt-get install linux-headers-server linux-image-server linux-server

If you are using Ubuntu v9.10 (Karmic Koala) and above, enter:
$ sudo apt-get install linux-generic-pae linux-headers-generic-pae

Once kernel images installed, just reboot your workstation, type:
$ sudo reboot

After reboot, login into your system and type the following command to verify memory usage:
$ free -m
Sample output:
             total       used       free     shared    buffers     cached
Mem:          8105       1292       6812          0         38        483

-/+ buffers/cache:        770       7334
Swap:         1906          0       1906