Wednesday, April 3, 2013

Aligning Linux VM LVM Disks to NetApp NFS recommendation

Aligning disks of virtual machines with the underlying storage system is very important as it helps in the I/O performance. Lets examine aligning an existing misaligned disk on a Linux (Redhat/ CentOS). For NetApp NFS we have to change the starting sector on linux partition to 64 (63 by default). For more information about alignment and recommendations look up NetApp documentation.
Scenario
We have a Logical volume VolGroup01 with 1 disk /dev/sdb which is not aligned with the underlying storage system. 
Plan to fix this.
We will add a disk of same size to the VM let say its /dev/sdc.
We partition it with the proper alignment
Add this to the VolGroup01 
Move data from /dev/sdb to this new disk 
Remove /dev/sdb from the VolGroup01
Remove the disk from the VM.

The process.





Checking the existing disk which which is misaligned.
# sfdisk -uS -l /dev/sdb

Disk /dev/sdb: 13054 cylinders, 255 heads, 63 sectors/track
Units = sectors of 512 bytes, counting from 0

   Device Boot    Start       End   #sectors  Id  System
/dev/sdb1            63 209712509  209712447  8e  Linux LVM
/dev/sdb2             0         -          0   0  Empty
/dev/sdb3             0         -          0   0  Empty
/dev/sdb4             0         -          0   0  Empty


Formating the New Disk
 
# fdisk /dev/sdc

Command (m for help): u
Changing display/entry units to sectors

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First sector (63-209715199, default 63): 64
Last sector, +sectors or +size{K,M,G} (64-209715199, default 209715199):
Using default value 209715199

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)

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

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


Checking New Disk partition
 

# sfdisk -uS -l /dev/sdc

Disk /dev/sdc: 13054 cylinders, 255 heads, 63 sectors/track
Units = sectors of 512 bytes, counting from 0

   Device Boot    Start       End   #sectors  Id  System
/dev/sdc1            64 209715199  209715136  8e  Linux LVM
/dev/sdc2             0         -          0   0  Empty
/dev/sdc3             0         -          0   0  Empty
/dev/sdc4             0         -          0   0  Empty

# pvcreate /dev/sdc1
  Writing physical volume data to disk "/dev/sdc1"
  Physical volume "/dev/sdc1" successfully created

# vgextend VolGroup01 /dev/sdc1
  Volume group "VolGroup01" successfully extended
#pvmove /dev/sdb1

This will move all data off of the old disk to the new disk. This process will take time depending on the size of the disk.
#vgreduce VolGroup01 /dev/sdb1
  Removed "/dev/sdb1" from volume group "VolGroup01"




Remove the other non-aligned disk from the VM after shutting down the VM.
Now the disks are aligned.
In VMware after reboot the disk label changes so checking the alignment on the renamed disk /dev/sdc is re-labeled as /dev/sdb

#sfdisk -uS -l /dev/sdb

Disk /dev/sdb: 13054 cylinders, 255 heads, 63 sectors/track
Units = sectors of 512 bytes, counting from 0

   Device Boot    Start       End   #sectors  Id  System
/dev/sdb1            64 209715199  209715136  8e  Linux LVM
/dev/sdb2             0         -          0   0  Empty
/dev/sdb3             0         -          0   0  Empty
/dev/sdb4             0         -          0   0  Empty

Tuesday, January 22, 2013

Combine multiple PDF files to one

You can use gs (ghostscript) to combine multiple pdf files to one as follows


gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=combined.pdf file1.pdf file2.pdf


  • gs -- starts the Ghostscript program
  • -dBATCH -- once Ghostscript processes the PDF files, it should exit. If you don't include this option, Ghostscript will just keep running
  • -dNOPAUSE -- forces Ghostscript to process each page without pausing for user interaction
  • -q -- stops Ghostscript from displaying messages while it works
  • -sDEVICE=pdfwrite -- tells Ghostscript to use its built-in PDF writer to process the files
  • -sOutputFile=combined.pdf -- tells Ghostscript to save the combined PDF file with the name that you specified

--
This is exact copy from "link" made a note on this blog for reference in case of non-availability of the original source.

Friday, February 17, 2012

find cdrom/dvdrom device Linux

$ eject -n
eject: device is '/your/cd_dvd/device'

Saturday, October 1, 2011

Search and Replace large files inplace

using sed

find /path/to/files -type f -exec sed -i 's/fromString/toString/g' {} \;


using perl

find /path/to/files -type f -exec perl -pi -e  's/fromString/toString/g' {} \;

Thursday, June 23, 2011

Command to see CDP packets and identify the cisco switch and port your machine is connected to

# tcpdump -nn -vvv -i eth0 -s 1500 -c 1 'ether[20:2] == 0x2000'

Tuesday, March 22, 2011

Screen Capture Fedora

For screen capture with audio I have used gtk-RecordMyDesktop

# yum install gtk-recordmydesktop

Options for selecting window or fullscreen are available.