<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>UtahSysAdmin.com</title>
	<atom:link href="http://utahsysadmin.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://utahsysadmin.com</link>
	<description>Ramblings of a Utah System Administrator</description>
	<lastBuildDate>Mon, 07 May 2012 03:17:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Removing a LVM Volume Group in Linux</title>
		<link>http://utahsysadmin.com/2011/01/10/removing-a-lvm-volume-group-in-linux/</link>
		<comments>http://utahsysadmin.com/2011/01/10/removing-a-lvm-volume-group-in-linux/#comments</comments>
		<pubDate>Mon, 10 Jan 2011 17:52:35 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://www.utahsysadmin.com/?p=243</guid>
		<description><![CDATA[What if you created a volume group in LVM and no longer need it? Well, to properly clean everything up follow the steps below. First, let&#8217;s identify the target.  In this case, I made a temporary /u2 partition, that I now no longer need: # df -h /u2 Filesystem Size Used Avail Use% Mounted on [...]]]></description>
			<content:encoded><![CDATA[<p>What if you <a title="Add a hard drive in LVM" href="http://www.utahsysadmin.com/2008/10/10/add-a-hard-drive-in-linux-with-lvm/">created a volume group in LVM</a> and no longer need it?  Well, to properly clean everything up follow the steps below.</p>
<p>First, let&#8217;s identify the target.  In this case, I made a temporary /u2 partition, that I now no longer need:</p>
<blockquote><p># df -h /u2<br />
Filesystem            Size  Used Avail Use% Mounted on<br />
/dev/mapper/VolGroup02-LogVol00<br />
148G   88G   53G  63% /u2</p></blockquote>
<p>Of course, we need to unmount the drive:</p>
<blockquote><p># umount /u2</p></blockquote>
<p>Let&#8217;s take a look at the volume we will be removing.  Notice there is a logical volume and a corresponding physical volume:</p>
<blockquote><p># vgdisplay /dev/mapper/VolGroup02<br />
&#8212; Volume group &#8212;<br />
VG Name               VolGroup02<br />
System ID<br />
Format                lvm2<br />
Metadata Areas        1<br />
Metadata Sequence No  2<br />
VG Access             read/write<br />
VG Status             resizable<br />
MAX LV                0<br />
<strong>Cur LV                1</strong><br />
Open LV               0<br />
Max PV                0<br />
<strong>Cur PV                1</strong><br />
Act PV                1<br />
VG Size               150.00 GB<br />
PE Size               4.00 MB<br />
Total PE              38399<br />
Alloc PE / Size       38399 / 150.00 GB<br />
Free  PE / Size       0 / 0<br />
VG UUID               7tVffs-U3id-Nksb-Yoqk-37Qg-JptR-bJYCy7</p></blockquote>
<p>Next, we&#8217;ll deactivate the logical volume, then remove it:</p>
<blockquote><p># lvchange -an /dev/mapper/VolGroup02-LogVol00<br />
# lvremove /dev/mapper/VolGroup02-LogVol00<br />
Logical volume &#8220;LogVol00&#8243; successfully removed</p></blockquote>
<p>If you look at the volume group now, you can see the logical volume has been removed.</p>
<blockquote><p># vgdisplay /dev/mapper/VolGroup02<br />
&#8212; Volume group &#8212;<br />
VG Name               VolGroup02<br />
System ID<br />
Format                lvm2<br />
Metadata Areas        1<br />
Metadata Sequence No  3<br />
VG Access             read/write<br />
VG Status             resizable<br />
MAX LV                0<br />
<strong>Cur LV                0</strong><br />
Open LV               0<br />
Max PV                0<br />
Cur PV                1<br />
Act PV                1<br />
VG Size               150.00 GB<br />
PE Size               4.00 MB<br />
Total PE              38399<br />
Alloc PE / Size       0 / 0<br />
Free  PE / Size       38399 / 150.00 GB<br />
VG UUID               7tVffs-U3id-Nksb-Yoqk-37Qg-JptR-bJYCy7</p></blockquote>
<p>Let&#8217;s take a look at the physical volume before changing it:</p>
<blockquote><p># pvdisplay /dev/sdc1<br />
&#8212; Physical volume &#8212;<br />
PV Name               /dev/sdc1<br />
<strong>VG Name               VolGroup02</strong><br />
PV Size               150.00 GB / not usable 2.00 MB<br />
Allocatable           yes<br />
PE Size (KByte)       4096<br />
Total PE              38399<br />
Free PE               38399<br />
Allocated PE          0<br />
PV UUID               B9zc6s-BvKl-TkWn-YTX9-lsBY-tstd-wQZFY3</p></blockquote>
<p>Now we will go ahead and remove the volume group from the system, which also clears the physical volume for removal:</p>
<blockquote><p># vgremove /dev/mapper/VolGroup02<br />
Volume group &#8220;VolGroup02&#8243; successfully removed</p></blockquote>
<p>You can see that the physical volume is no longer tied to a volume group:</p>
<blockquote><p># pvdisplay /dev/sdc1<br />
&#8220;/dev/sdc1&#8243; is a new physical volume of &#8220;150.00 GB&#8221;<br />
&#8212; NEW Physical volume &#8212;<br />
PV Name               /dev/sdc1<br />
<strong>VG Name</strong><br />
PV Size               150.00 GB<br />
Allocatable           NO<br />
PE Size (KByte)       0<br />
Total PE              0<br />
Free PE               0<br />
Allocated PE          0<br />
PV UUID               B9zc6s-BvKl-TkWn-YTX9-lsBY-tstd-wQZFY3</p></blockquote>
<p>We no longer need this hard drive, so we can now remove it:</p>
<blockquote><p># pvremove /dev/sdc1<br />
Labels on physical volume &#8220;/dev/sdc1&#8243; successfully wiped</p></blockquote>
<p>One last item of cleanup, remove the corresponding line in /etc/fstab:</p>
<blockquote><p># vi /etc/fstab</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://utahsysadmin.com/2011/01/10/removing-a-lvm-volume-group-in-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sending mail from command line using Mutt</title>
		<link>http://utahsysadmin.com/2011/01/06/sending-mail-from-command-line-using-mutt/</link>
		<comments>http://utahsysadmin.com/2011/01/06/sending-mail-from-command-line-using-mutt/#comments</comments>
		<pubDate>Thu, 06 Jan 2011 22:29:18 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://www.utahsysadmin.com/?p=237</guid>
		<description><![CDATA[I use this to attach reports (pdfs, etc) to emails in my scripts. Small Perl snippet: system("/usr/bin/mutt -i $file_with_body_content -a $file_to_attach -s "Some Random Report $report_date" $mailto &#60; /dev/null"); And since this has now bitten me twice, make sure that there are no variables with carriage returns at the end. In my case, both times [...]]]></description>
			<content:encoded><![CDATA[<p>I use this to attach reports (pdfs, etc) to emails in my scripts.  Small Perl snippet:</p>
<blockquote><p><code>system("/usr/bin/mutt -i $file_with_body_content -a $file_to_attach -s "Some Random Report $report_date" $mailto &lt; /dev/null");</code></p></blockquote>
<p>And since this has now bitten me twice, make sure that there are no variables with carriage returns at the end.  In my case, both times I forgot to chomp($report_date) and could not figure out why the attachments were displaying inline instead of as proper attachments when I received the email.</p>
]]></content:encoded>
			<wfw:commentRss>http://utahsysadmin.com/2011/01/06/sending-mail-from-command-line-using-mutt/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Useful Networker Commands</title>
		<link>http://utahsysadmin.com/2010/09/18/useful-networker-commands/</link>
		<comments>http://utahsysadmin.com/2010/09/18/useful-networker-commands/#comments</comments>
		<pubDate>Sun, 19 Sep 2010 03:45:19 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://www.utahsysadmin.com/?p=232</guid>
		<description><![CDATA[For use with EMC (Legato) Networker&#8230; Move everything off of a specific volume onto another pool (Careful, does not take into account possible clones &#8211; add /cloneid somehow to the end. I haven&#8217;t been able to automate that yet): # for i in `/usr/sbin/mminfo -q &#8220;volume=OLDVOLUME&#8221; -r &#8220;ssid&#8221;`; do /usr/sbin/nsrstage -v -b NEWPOOL -s NETWORKERSERVERNAME [...]]]></description>
			<content:encoded><![CDATA[<p>For use with EMC (Legato) Networker&#8230;</p>
<p>Move everything off of a specific volume onto another pool (Careful, does not take into account possible clones &#8211; add /cloneid somehow to the end.  I haven&#8217;t been able to automate that yet):<br />
# for i in `/usr/sbin/mminfo -q &#8220;volume=OLDVOLUME&#8221; -r &#8220;ssid&#8221;`; do /usr/sbin/nsrstage -v -b NEWPOOL -s NETWORKERSERVERNAME -m -S $i; done</p>
<p>Remove everything off of a specific volume (again does not take into account clones):<br />
# for i in `/usr/sbin/mminfo -q &#8220;volume=OLDVOLUME&#8221; -r &#8220;ssid&#8221;`; do /usr/sbin/nsrmm -e now -d -v -y -S $i; done</p>
<p>Clone all savesets from the last 24 hours to the &#8220;Tape&#8221; pool:<br />
# /usr/sbin/nsrclone -S -e now -C 1 -b Tape -y month</p>
<p>Clone all savesets from the last 24 hours from a specific pool to the &#8220;Tape&#8221; pool and set retention to a month:<br />
# /usr/sbin/nsrclone -S -e now -C 2 -B SOMEPOOL -b Tape -y month</p>
]]></content:encoded>
			<wfw:commentRss>http://utahsysadmin.com/2010/09/18/useful-networker-commands/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Random Useful Scripts</title>
		<link>http://utahsysadmin.com/2010/09/18/random-useful-scripts/</link>
		<comments>http://utahsysadmin.com/2010/09/18/random-useful-scripts/#comments</comments>
		<pubDate>Sun, 19 Sep 2010 03:20:54 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://www.utahsysadmin.com/?p=222</guid>
		<description><![CDATA[Convert plain text to passwd crypt: #!/usr/bin/perl print "Enter the password you would like to use: "; $pass1 = &#60;STDIN&#62;; if ($pass1) { my $salt = join('', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[rand 64, rand 64]); my $cryptpw = crypt($pass1, $salt); print "The encrypted password suitable for passwd is $cryptpwn"; } Convert base64 encoded to plain [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>Convert plain text to passwd crypt:</p></blockquote>
<pre>#!/usr/bin/perl

print "Enter the password you would like to use:  ";
$pass1 = &lt;STDIN&gt;;

if ($pass1) {
	my $salt =
	   join('', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[rand 64, rand 64]);
	my $cryptpw = crypt($pass1, $salt);
	print "The encrypted password suitable for passwd is $cryptpwn";
}</pre>
<blockquote><p>Convert base64 encoded to plain text:</p></blockquote>
<pre>#!/usr/bin/perl

use MIME::Base64;

print "Enter the encoded data:  ";
$code = &lt;STDIN&gt;;

if ($code) {
	my $decrypted = decode_base64($code);
	print "The decrypted data is:n"$decrypted"n";
}</pre>
<blockquote><p>Create 10 random passwords:</p></blockquote>
<pre>#!/usr/bin/perl

sub randomPassword {
 my $password;
 my $_rand;

 my $password_length = $_[0];
 if (!$password_length) {
  $password_length = 10;
 }

 my @chars = split(" ",
 "a b c d e f g h i j k l m n o
  A B C D E F G H I J K L M N O
  p q r s t u v w x y z
  P Q R S T U V W X Y Z
  0 1 2 3 4 5 6 7 8 9");

 srand;

 for (my $i=0; $i &lt;= $password_length ;$i++) {
  $_rand = int(rand 62);
  $password .= $chars[$_rand];
 }
 return $password;
}

for ($i=0; $i &lt; 10; $i++){
	print randomPassword(8) . &quot;n&quot;;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://utahsysadmin.com/2010/09/18/random-useful-scripts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add hard drive to extend existing LVM volume</title>
		<link>http://utahsysadmin.com/2009/12/08/add-hard-drive-to-extend-lvm/</link>
		<comments>http://utahsysadmin.com/2009/12/08/add-hard-drive-to-extend-lvm/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 18:09:05 +0000</pubDate>
		<dc:creator>Kevin</dc:creator>
				<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://www.utahsysadmin.com/?p=204</guid>
		<description><![CDATA[Previously I posted how to add a hard drive and create a new volume in LVM. This time we&#8217;ll add a new hard drive and then increase or extend the size of an existing volume or partition. This is an example using an RHEL 5 derivative, OEL 5. The server is really a VM inside [...]]]></description>
			<content:encoded><![CDATA[<p>Previously I posted <a href="http://www.utahsysadmin.com/2008/10/10/add-a-hard-drive-in-linux-with-lvm/">how to add a hard drive and create a new volume in LVM</a>.  This time we&#8217;ll add a new hard drive and then increase or extend the size of an existing volume or partition.  This is an example using an RHEL 5 derivative, OEL 5.  The server is really a VM inside VMware vSphere 4, but that is of no consequence to what we are doing.</p>
<p>In this example, we have an existing /data partition of 350 GB.  Well, it&#8217;s just not big enough, so we&#8217;ll add another 100 GB hard drive and give it to the /data partition.</p>
<p>After adding the 100 GB hard drive to the VM through vCenter, connect to the server through SSH or the console.  Here&#8217;s the existing setup:</p>
<blockquote><p># df -h<br />
Filesystem            Size  Used Avail Use% Mounted on<br />
/dev/mapper/VolGroup00-LogVol00<br />
7.7G  2.2G  5.2G  30% /<br />
/dev/sda1              99M   24M   71M  26% /boot<br />
tmpfs                 1.5G     0  1.5G   0% /dev/shm<br />
<strong>/dev/mapper/VolGroup01-LogVol00<br />
345G   15G  313G   5% /data</strong></p></blockquote>
<blockquote><p># cat /proc/scsi/scsi<br />
Attached devices:<br />
Host: scsi0 Channel: 00 Id: 00 Lun: 00<br />
Vendor: VMware   Model: Virtual disk     Rev: 1.0<br />
Type:   Direct-Access                    ANSI SCSI revision: 02<br />
Host: scsi0 Channel: 00 Id: 01 Lun: 00<br />
Vendor: VMware   Model: Virtual disk     Rev: 1.0<br />
Type:   Direct-Access                    ANSI SCSI revision: 02</p></blockquote>
<p>First we tell Linux to find the new drive in the correct location:</p>
<blockquote><p><code># echo "scsi add-single-device 0 0 2 0" &gt; /proc/scsi/scsi</code></p></blockquote>
<p>Now we see the new drive has been detected:</p>
<blockquote><p># cat /proc/scsi/scsi<br />
Attached devices:<br />
Host: scsi0 Channel: 00 Id: 00 Lun: 00<br />
Vendor: VMware   Model: Virtual disk     Rev: 1.0<br />
Type:   Direct-Access                    ANSI SCSI revision: 02<br />
Host: scsi0 Channel: 00 Id: 01 Lun: 00<br />
Vendor: VMware   Model: Virtual disk     Rev: 1.0<br />
Type:   Direct-Access                    ANSI SCSI revision: 02<br />
Host: scsi0 Channel: 00 Id: 02 Lun: 00<br />
Vendor: VMware   Model: Virtual disk     Rev: 1.0<br />
Type:   Direct-Access                    ANSI SCSI revision: 02</p></blockquote>
<p>If we check fdisk, we see the new drive is blank like we expect:</p>
<blockquote><p># fdisk -l</p>
<p>Disk /dev/sda: 12.8 GB, 12884901888 bytes<br />
255 heads, 63 sectors/track, 1566 cylinders<br />
Units = cylinders of 16065 * 512 = 8225280 bytes</p>
<p>Device Boot      Start         End      Blocks   Id  System<br />
/dev/sda1   *           1          13      104391   83  Linux<br />
/dev/sda2              14        1566    12474472+  8e  Linux LVM</p>
<p>Disk /dev/sdb: 375.8 GB, 375809638400 bytes<br />
255 heads, 63 sectors/track, 45689 cylinders<br />
Units = cylinders of 16065 * 512 = 8225280 bytes</p>
<p>Device Boot      Start         End      Blocks   Id  System<br />
/dev/sdb1               1       45689   366996861   83  Linux</p>
<p>Disk /dev/sdc: 107.3 GB, 107374182400 bytes<br />
255 heads, 63 sectors/track, 13054 cylinders<br />
Units = cylinders of 16065 * 512 = 8225280 bytes</p>
<p><strong>Disk /dev/sdc doesn&#8217;t contain a valid partition table</strong></p></blockquote>
<p>So let&#8217;s give it a partition:</p>
<blockquote><p># fdisk /dev/sdc<br />
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel<br />
Building a new DOS disklabel. Changes will remain in memory only,<br />
until you decide to write them. After that, of course, the previous<br />
content won&#8217;t be recoverable.</p>
<p>The number of cylinders for this disk is set to 13054.<br />
There is nothing wrong with that, but this is larger than 1024,<br />
and could in certain setups cause problems with:<br />
1) software that runs at boot time (e.g., old versions of LILO)<br />
2) booting and partitioning software from other OSs<br />
(e.g., DOS FDISK, OS/2 FDISK)<br />
Warning: invalid flag 0&#215;0000 of partition table 4 will be corrected by w(rite)</p>
<p>Command (m for help): <strong>n</strong><br />
Command action<br />
e   extended<br />
p   primary partition (1-4)<br />
<strong>p</strong><br />
Partition number (1-4): <strong>1</strong><br />
First cylinder (1-13054, <strong>default 1</strong>):<br />
Using default value 1<br />
Last cylinder or +size or +sizeM or +sizeK (1-13054, <strong>default 13054</strong>):<br />
Using default value 13054</p>
<p>Command (m for help): <strong>p</strong></p>
<p>Disk /dev/sdc: 107.3 GB, 107374182400 bytes<br />
255 heads, 63 sectors/track, 13054 cylinders<br />
Units = cylinders of 16065 * 512 = 8225280 bytes</p>
<p>Device Boot      Start         End      Blocks   Id  System<br />
/dev/sdc1               1       13054   104856223+  83  Linux</p>
<p>Command (m for help): <strong>w</strong><br />
The partition table has been altered!</p>
<p>Calling ioctl() to re-read partition table.<br />
Syncing disks.</p></blockquote>
<p>Fdisk now confirms that everything looks good:</p>
<blockquote><p># fdisk -l</p>
<p>Disk /dev/sda: 12.8 GB, 12884901888 bytes<br />
255 heads, 63 sectors/track, 1566 cylinders<br />
Units = cylinders of 16065 * 512 = 8225280 bytes</p>
<p>Device Boot      Start         End      Blocks   Id  System<br />
/dev/sda1   *           1          13      104391   83  Linux<br />
/dev/sda2              14        1566    12474472+  8e  Linux LVM</p>
<p>Disk /dev/sdb: 375.8 GB, 375809638400 bytes<br />
255 heads, 63 sectors/track, 45689 cylinders<br />
Units = cylinders of 16065 * 512 = 8225280 bytes</p>
<p>Device Boot      Start         End      Blocks   Id  System<br />
/dev/sdb1               1       45689   366996861   83  Linux</p>
<p><strong>Disk /dev/sdc: 107.3 GB, 107374182400 bytes<br />
255 heads, 63 sectors/track, 13054 cylinders<br />
Units = cylinders of 16065 * 512 = 8225280 bytes</strong></p>
<p><strong> Device Boot      Start         End      Blocks   Id  System<br />
/dev/sdc1               1       13054   104856223+  83  Linux</strong></p></blockquote>
<p>Verify that LVM can see the drive:</p>
<blockquote><p># lvmdiskscan<br />
&#8230;skip&#8230;<br />
/dev/sdc1                [      100.00 GB]<br />
&#8230;skip&#8230;</p></blockquote>
<p>Create a physical volume within LVM:</p>
<blockquote><p># pvcreate /dev/sdc1<br />
Physical volume &#8220;/dev/sdc1&#8243; successfully created</p></blockquote>
<p>Add/Extend this physical volume to the volume group:</p>
<blockquote><p># vgextend VolGroup01 /dev/sdc1<br />
Volume group &#8220;VolGroup01&#8243; successfully extended</p></blockquote>
<p>Extend the logical volume to use the full size of the volume group:</p>
<blockquote><p># lvm lvextend -l +100%FREE /dev/VolGroup01/LogVol00<br />
Extending logical volume LogVol00 to 449.99 GB<br />
Logical volume LogVol00 successfully resized</p></blockquote>
<p>Actually resize the partition for the OS to recognize the new size:</p>
<blockquote><p># resize2fs -p /dev/mapper/VolGroup01-LogVol00<br />
resize2fs 1.39 (29-May-2006)<br />
Filesystem at /dev/mapper/VolGroup01-LogVol00 is mounted on /data; on-line resizing required<br />
Performing an on-line resize of /dev/mapper/VolGroup01-LogVol00 to 117961728 (4k) blocks.<br />
The filesystem on /dev/mapper/VolGroup01-LogVol00 is now 117961728 blocks long.</p></blockquote>
<p>And the new drive space is now available to the user, who is already busy filling it:</p>
<blockquote><p># df -h<br />
Filesystem            Size  Used Avail Use% Mounted on<br />
/dev/mapper/VolGroup00-LogVol00<br />
7.7G  2.2G  5.2G  30% /<br />
/dev/sda1              99M   24M   71M  26% /boot<br />
tmpfs                 1.5G     0  1.5G   0% /dev/shm<br />
/dev/mapper/VolGroup01-LogVol00<br />
443G   48G  373G  12% /data</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://utahsysadmin.com/2009/12/08/add-hard-drive-to-extend-lvm/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

