<?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"
	>

<channel>
	<title>OSS Robot</title>
	<atom:link href="http://jjester.com/techblog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://jjester.com/techblog</link>
	<description>Open Source Geekery</description>
	<pubDate>Fri, 03 Sep 2010 18:57:42 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>Nagios failover setup</title>
		<link>http://jjester.com/techblog/?p=150</link>
		<comments>http://jjester.com/techblog/?p=150#comments</comments>
		<pubDate>Fri, 03 Sep 2010 18:47:20 +0000</pubDate>
		<dc:creator>admin0</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jjester.com/techblog/?p=150</guid>
		<description><![CDATA[Once you have nagios configured you can setup a failover setup where if the nagios master is offline then a standby slave will enable notifications and checking. Here are the setup notes and as custome script i wrote in pythong to achieve this.
the following command checks if nagios is running locally
[root@scrappy nagios]# /usr/local/nagios/libexec/check_nagios -F /usr/local/nagios/var/status.dat [...]]]></description>
			<content:encoded><![CDATA[<p>Once you have nagios configured you can setup a failover setup where if the nagios master is offline then a standby slave will enable notifications and checking. Here are the setup notes and as custome script i wrote in pythong to achieve this.</p>
<p>the following command checks if nagios is running locally</p>
<p>[root@scrappy nagios]# /usr/local/nagios/libexec/check_nagios -F /usr/local/nagios/var/status.dat -e 1 -C &#8216;/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg&#8217;</p>
<p>NAGIOS OK: 1 process, status log updated 5 seconds ago</p>
<p>now, set in nrpe config as following on remote slave/master to verify is running. must restart nrpe on machine installed on to reread nrpe.cfg</p>
<p>command[check_nagios_failover]=/usr/local/nagios/libexec/check_nagios -F /usr/local/nagios/var/status.dat -e 1 -C &#8216;/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg&#8217;</p>
<p>test nrpe remote command.</p>
<p>[root@scrappy nagios]# /usr/local/nagios/libexec/check_nrpe -H james -c check_nagios_failover</p>
<p>NAGIOS OK: 15 processes, status log updated 0 seconds ago</p>
<p>modify nagios.cfg on nagios slave. restart nagios.</p>
<p>execute_service_checks=0</p>
<p>enable_notifications=0</p>
<p>check_external_commands=1</p>
<p>now set crontab on slave to check for master failure.</p>
<p>[root@scrappy etc]# crontab -l</p>
<p>* * * * * nagios /usr/local/nagios/set_slave_status.py &gt; /dev/null</p>
<p>Create script and modify master ip.</p>
<pre class="php">

#!/usr/bin/python

import os

import commands

import sys

master='james'

slave='scrappy'

tmp_file='/tmp/nagios-failover-state.txt'

commandfile='/usr/local/nagios/var/rw/nagios.cmd'

now=commands.getoutput('date +%s')

<a href="mailto:email='email@domain.com'">email=&#8217;</a><a href="mailto:email@domain.com">email@domain.com</a>&#8216;

out=commands.getoutput(&#8217;/usr/local/nagios/libexec/check_nrpe -H &#8216;+master+&#8217; -c check_nagios_failover&#8217;)

#if not 0, then master is down.

master_return_val=out.find(&#8217;OK&#8217;)

#store state information

def failover_save_state(x):

fh=open(tmp_file,&#8217;w')

fh.write(x)

fh.close()

def sync_nagios_files():

os.system(&#8217;rsync -av &#8216;+master+&#8217;:/usr/local/nagios/etc/objects/* /usr/local/nagios/etc/objects/&#8217;)

os.system(&#8217;/etc/init.d/nagios reload&#8217;)

print &#8220;Master conf files synced with Slave.&#8221;

#read current state information

fh=open(tmp_file,&#8217;r')

current_state=fh.readlines()

fh.close()

current_state=current_state[0]

#enable or disable checks for hosts

#print current_state

if master_return_val &lt;= 0 and current_state is not &#8216;enabled&#8217;:

if current_state==&#8217;enabled&#8217;:

print &#8220;Nagios slave (&#8221;+slave+&#8221;) is active. Nagios master (&#8221;+master+&#8221;) is down. No state change&#8221;

else:

os.system(&#8217;/usr/bin/printf &#8220;[%lu] ENABLE_NOTIFICATIONS\n&#8221; &#8216;+now+&#8217; &gt; &#8216;+commandfile)

os.system(&#8217;/usr/bin/printf &#8220;[%lu] START_EXECUTING_HOST_CHECKS\n&#8221; &#8216;+now+&#8217; &gt; &#8216;+commandfile)

os.system(&#8217;/usr/bin/printf &#8220;[%lu] START_EXECUTING_SVC_CHECKS\n&#8221; &#8216;+now+&#8217; &gt; &#8216;+commandfile)

os.system(&#8217;echo elvis has left the building | mail -s &#8220;[Nagios] Master Down! Slave Enabled.&#8221; &#8216;+email)

print &#8220;Nagios Failover enabled&#8221;

failover_save_state(&#8217;enabled&#8217;)

sync_nagios_files()

elif current_state is not &#8216;disabled&#8217;:

if current_state==&#8217;disabled&#8217;:

print &#8220;Nagios master (&#8221;+master+&#8221;) is enabled. No state change.&#8221;

else:

os.system(&#8217;/usr/bin/printf &#8220;[%lu] DISABLE_NOTIFICATIONS\n&#8221; &#8216;+now+&#8217; &gt; &#8216;+commandfile)

os.system(&#8217;/usr/bin/printf &#8220;[%lu] STOP_EXECUTING_HOST_CHECKS\n&#8221; &#8216;+now+&#8217; &gt; &#8216;+commandfile)

os.system(&#8217;/usr/bin/printf &#8220;[%lu] STOP_EXECUTING_SVC_CHECKS\n&#8221; &#8216;+now+&#8217; &gt; &#8216;+commandfile)

os.system(&#8217;echo We are all out of donuts. | mail -s &#8220;[Nagios] Master Restored. Slave Disabled.&#8221; &#8216;+email)

print &#8220;Nagios master restored&#8221;

failover_save_state(&#8217;disabled&#8217;)

sync_nagios_files()
</pre>
<p>make executable</p>
<p> </p>
<p>[root@scrappy nagios]# chown nagios.nagios /usr/local/nagios/etc/set_slave_status.py</p>
<p>[root@scrappy etc]# chmod o=rwx set_slave_status.py</p>
]]></content:encoded>
			<wfw:commentRss>http://jjester.com/techblog/?feed=rss2&amp;p=150</wfw:commentRss>
		</item>
		<item>
		<title>Network copy tests</title>
		<link>http://jjester.com/techblog/?p=149</link>
		<comments>http://jjester.com/techblog/?p=149#comments</comments>
		<pubDate>Mon, 23 Aug 2010 20:28:06 +0000</pubDate>
		<dc:creator>admin0</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jjester.com/techblog/?p=149</guid>
		<description><![CDATA[What is faster cp or rsync? Each test is done twice to verify consistency. Let&#8217;s find out&#8230;
Rsync over NFS
#donkey:~# time rsync -av /mnt/backupserv/10gb /data/10gb
sending incremental file list
10gb
sent 10738729030 bytes  received 31 bytes  41223528.07 bytes/sec
total size is 10737418240  speedup is 1.00
real    4m19.773s
user    1m31.566s
sys     2m23.025s
#donkey:~# time rsync /mnt/backupserv/10gb /data/10gb
real    4m15.026s
user    1m26.453s
sys     2m24.837s
RSYNC direct
#donkey:~# time rsync -av backupserv:/mnt/data/10gb [...]]]></description>
			<content:encoded><![CDATA[<p>What is faster cp or rsync? Each test is done twice to verify consistency. Let&#8217;s find out&#8230;</p>
<p>Rsync over NFS</p>
<p>#donkey:~# time rsync -av /mnt/backupserv/10gb /data/10gb<br />
sending incremental file list<br />
10gb</p>
<p>sent 10738729030 bytes  received 31 bytes  41223528.07 bytes/sec<br />
total size is 10737418240  speedup is 1.00</p>
<p>real    4m19.773s<br />
user    1m31.566s<br />
sys     2m23.025s<br />
#donkey:~# time rsync /mnt/backupserv/10gb /data/10gb</p>
<p>real    4m15.026s<br />
user    1m26.453s<br />
sys     2m24.837s</p>
<p>RSYNC direct</p>
<p>#donkey:~# time rsync -av backupserv:/mnt/data/10gb /data/<br />
receiving incremental file list<br />
10gb</p>
<p>sent 30 bytes  received 10738729035 bytes  33401956.66 bytes/sec<br />
total size is 10737418240  speedup is 1.00</p>
<p>real    5m21.004s<br />
user    3m6.644s<br />
sys     2m1.376s</p>
<p>#donkey:~# time rsync -av backupserv:/mnt/data/10gb /data/<br />
receiving incremental file list<br />
10gb</p>
<p>sent 30 bytes  received 10738729035 bytes  32790012.41 bytes/sec<br />
total size is 10737418240  speedup is 1.00</p>
<p>real    5m26.857s<br />
user    3m5.924s<br />
sys     2m8.372s</p>
<p>CP over NFS</p>
<p>#donkey:~# time cp /mnt/backupserv/10gb /data/</p>
<p>real    2m17.176s<br />
user    0m0.024s<br />
sys     0m57.276s</p>
<p>#donkey:~# time cp /mnt/backupserv/10gb /data/</p>
<p>real    2m16.983s<br />
user    0m0.020s<br />
sys     0m57.920s</p>
]]></content:encoded>
			<wfw:commentRss>http://jjester.com/techblog/?feed=rss2&amp;p=149</wfw:commentRss>
		</item>
		<item>
		<title>Bacula: &#8216;query&#8217; command doest work.</title>
		<link>http://jjester.com/techblog/?p=148</link>
		<comments>http://jjester.com/techblog/?p=148#comments</comments>
		<pubDate>Mon, 02 Aug 2010 22:44:00 +0000</pubDate>
		<dc:creator>admin0</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jjester.com/techblog/?p=148</guid>
		<description><![CDATA[Need to move sample-query.sql into /etc/bacula.
*query
Automatically selected Catalog: MyCatalog
Using Catalog &#8220;MyCatalog&#8221;
Available queries:
1: List up to 20 places where a File is saved regardless of the directory
2: List where the most recent copies of a file are saved
3: List last 20 Full Backups for a Client
4: List all backups for a Client after a specified time
5: [...]]]></description>
			<content:encoded><![CDATA[<p>Need to move sample-query.sql into /etc/bacula.</p>
<p>*query<br />
Automatically selected Catalog: MyCatalog<br />
Using Catalog &#8220;MyCatalog&#8221;<br />
Available queries:<br />
1: List up to 20 places where a File is saved regardless of the directory<br />
2: List where the most recent copies of a file are saved<br />
3: List last 20 Full Backups for a Client<br />
4: List all backups for a Client after a specified time<br />
5: List all backups for a Client<br />
6: List Volume Attributes for a selected Volume<br />
7: List Volumes used by selected JobId<br />
8: List Volumes to Restore All Files<br />
9: List Pool Attributes for a selected Pool<br />
10: List total files/bytes by Job<br />
11: List total files/bytes by Volume<br />
12: List Files for a selected JobId<br />
13: List Jobs stored on a selected MediaId<br />
14: List Jobs stored for a given Volume name<br />
15: List Volumes Bacula thinks are in changer<br />
16: List Volumes likely to need replacement from age or errors<br />
17: List Volumes Bacula thinks are eligible for the changer<br />
18: List Volumes by Volume:<br />
19: List Volumes by Jobs:<br />
20: List Volumes for a jobname:</p>
]]></content:encoded>
			<wfw:commentRss>http://jjester.com/techblog/?feed=rss2&amp;p=148</wfw:commentRss>
		</item>
		<item>
		<title>Using Tar for Backups</title>
		<link>http://jjester.com/techblog/?p=147</link>
		<comments>http://jjester.com/techblog/?p=147#comments</comments>
		<pubDate>Fri, 23 Jul 2010 22:14:33 +0000</pubDate>
		<dc:creator>admin0</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jjester.com/techblog/?p=147</guid>
		<description><![CDATA[Update file that already exists in tar archive
[root@james ~]# tar -uvf ./test.tar updatefile
Append file that doesnt not exist to archive.
[root@james ~]# tar -rvf ./test.tar newfilesfile
Extract one file from archive.
[root@james ~]# tar -xvf ./test.tar somefile
 
]]></description>
			<content:encoded><![CDATA[<p>Update file that already exists in tar archive<br />
[root@james ~]# tar -uvf ./test.tar updatefile<br />
Append file that doesnt not exist to archive.<br />
[root@james ~]# tar -rvf ./test.tar newfilesfile<br />
Extract one file from archive.<br />
[root@james ~]# tar -xvf ./test.tar somefile</p>
<p> </p>
]]></content:encoded>
			<wfw:commentRss>http://jjester.com/techblog/?feed=rss2&amp;p=147</wfw:commentRss>
		</item>
		<item>
		<title>Working with &#8216;Apt&#8217; in Ubuntu</title>
		<link>http://jjester.com/techblog/?p=146</link>
		<comments>http://jjester.com/techblog/?p=146#comments</comments>
		<pubDate>Sat, 10 Jul 2010 16:08:40 +0000</pubDate>
		<dc:creator>admin0</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jjester.com/techblog/?p=146</guid>
		<description><![CDATA[Search for a package
apt-cache search &#60;phrase&#62;
Install a package
apt-get install &#60;package&#62;
Upgrade kernel

apt-get dist-upgrade
]]></description>
			<content:encoded><![CDATA[<p><strong>Search for a package</strong></p>
<p>apt-cache search &lt;phrase&gt;</p>
<p><strong>Install a package</strong></p>
<p>apt-get install &lt;package&gt;</p>
<p><strong>Upgrade kernel<br />
</strong><br />
apt-get dist-upgrade</p>
]]></content:encoded>
			<wfw:commentRss>http://jjester.com/techblog/?feed=rss2&amp;p=146</wfw:commentRss>
		</item>
		<item>
		<title>Using the &#8216;touch&#8217; command</title>
		<link>http://jjester.com/techblog/?p=145</link>
		<comments>http://jjester.com/techblog/?p=145#comments</comments>
		<pubDate>Wed, 07 Jul 2010 23:13:42 +0000</pubDate>
		<dc:creator>admin0</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jjester.com/techblog/?p=145</guid>
		<description><![CDATA[Create a new file using touch and modify its access time.
Set the date to Feb 1st, 2009 @ 730am.
[root@stone backups]# touch testfile2 -t 200902010730 testfile2

Verify settings..

[root@stone backups]# ls -la &#124; grep testfile2
-rw-r&#8211;r&#8211;  1 root katze          0 Feb  1  2009 testfile2


]]></description>
			<content:encoded><![CDATA[<p>Create a new file using touch and modify its access time.</p>
<p>Set the date to Feb 1st, 2009 @ 730am.</p>
<p>[root@stone backups]# touch testfile2 -t 200902010730 testfile2</p>
<div>
<div>Verify settings..
</div>
<div>[root@stone backups]# ls -la | grep testfile2</div>
<div>-rw-r&#8211;r&#8211;  1 root katze          0 Feb  1  2009 testfile2</div>
<div></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://jjester.com/techblog/?feed=rss2&amp;p=145</wfw:commentRss>
		</item>
		<item>
		<title>UFW Firewall HOWTO</title>
		<link>http://jjester.com/techblog/?p=144</link>
		<comments>http://jjester.com/techblog/?p=144#comments</comments>
		<pubDate>Tue, 25 May 2010 23:04:46 +0000</pubDate>
		<dc:creator>admin0</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jjester.com/techblog/?p=144</guid>
		<description><![CDATA[Add rule
root@firefly:/data/music# ufw allow from 10.200.80.132 to any port 3689
Delete rule by line number.
root@firefly:/data/music# ufw delete 1
Deleting:
allow 3689
Proceed with operation (y&#124;n)? y
Rule deleted

View current rules
root@firefly:/data/music# ufw status
Status: active
To                         Action      From
&#8211;                         &#8212;&#8212;      &#8212;-
22                         ALLOW       Anywhere
21                         ALLOW       Anywhere
3689                       ALLOW       10.200.80.132
]]></description>
			<content:encoded><![CDATA[<p><strong>Add rule</strong></p>
<p>root@firefly:/data/music# ufw allow from 10.200.80.132 to any port 3689</p>
<p><strong>Delete rule by line number.</strong></p>
<p>root@firefly:/data/music# ufw delete 1<br />
Deleting:<br />
allow 3689<br />
Proceed with operation (y|n)? y<br />
Rule deleted</p>
<p><strong><br />
View current rules</strong></p>
<p>root@firefly:/data/music# ufw status<br />
Status: active</p>
<p>To                         Action      From<br />
&#8211;                         &#8212;&#8212;      &#8212;-<br />
22                         ALLOW       Anywhere<br />
21                         ALLOW       Anywhere<br />
3689                       ALLOW       10.200.80.132</p>
]]></content:encoded>
			<wfw:commentRss>http://jjester.com/techblog/?feed=rss2&amp;p=144</wfw:commentRss>
		</item>
		<item>
		<title>Python: simple salary calc script</title>
		<link>http://jjester.com/techblog/?p=143</link>
		<comments>http://jjester.com/techblog/?p=143#comments</comments>
		<pubDate>Fri, 21 May 2010 18:13:01 +0000</pubDate>
		<dc:creator>admin0</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jjester.com/techblog/?p=143</guid>
		<description><![CDATA[#!/usr/bin/python
def main():
salary1 = input(&#8221;Enter Salary #1: &#8220;)
salary2 = input(&#8221;Enter Salary #2: &#8220;)
# SET GLOBAL TO SHARE VARS
global x
global y
if(salary1 &#60; salary2):
x=salary1
y=salary2
else:
y=salary1
x=salary2
def make_percent():
global total
total = 100-(float(x)/float(y)*100)
total=int(round(total,0))
print &#8220;Total Difference:&#8221;,total,&#8221;%&#8221;
main()
make_percent()
root@donkey:~/tech/core# python calc_number_diff.py
Enter Salary #1: 75
Enter Salary #2: 76
Total Difference: 1 %
]]></description>
			<content:encoded><![CDATA[<p>#!/usr/bin/python</p>
<p>def main():<br />
salary1 = input(&#8221;Enter Salary #1: &#8220;)<br />
salary2 = input(&#8221;Enter Salary #2: &#8220;)</p>
<p># SET GLOBAL TO SHARE VARS<br />
global x<br />
global y</p>
<p>if(salary1 &lt; salary2):<br />
x=salary1<br />
y=salary2<br />
else:<br />
y=salary1<br />
x=salary2</p>
<p>def make_percent():<br />
global total</p>
<p>total = 100-(float(x)/float(y)*100)<br />
total=int(round(total,0))<br />
print &#8220;Total Difference:&#8221;,total,&#8221;%&#8221;</p>
<p>main()<br />
make_percent()</p>
<p>root@donkey:~/tech/core# python calc_number_diff.py<br />
Enter Salary #1: 75<br />
Enter Salary #2: 76<br />
Total Difference: 1 %</p>
]]></content:encoded>
			<wfw:commentRss>http://jjester.com/techblog/?feed=rss2&amp;p=143</wfw:commentRss>
		</item>
		<item>
		<title>Working with LVM. Or as i like to call, super raid0!</title>
		<link>http://jjester.com/techblog/?p=140</link>
		<comments>http://jjester.com/techblog/?p=140#comments</comments>
		<pubDate>Wed, 17 Mar 2010 03:57:31 +0000</pubDate>
		<dc:creator>admin0</dc:creator>
		
		<category><![CDATA[Linux]]></category>

		<category><![CDATA[Raid]]></category>

		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jjester.com/techblog/?p=140</guid>
		<description><![CDATA[Install packages
apt-get install lvm2 dmsetup mdadm reiserfsprogs xfsprogs
Create partitions
fdisk /dev/sda
-create new partition (&#8217;n')
-change system partition type to lvm (&#8217;t')
-enter &#8216;8e&#8217; for hex partition type
-write partition table to disk (&#8217;w')
Create physical volume
root@backupserv:~# pvcreate /dev/sdb1 /dev/sda2 /dev/sdc1
Can&#8217;t open /dev/sdb1 exclusively.  Mounted filesystem?
Wiping software RAID md superblock on /dev/sda2
Physical volume &#8220;/dev/sda2&#8243; successfully created
Wiping software RAID md superblock on [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Install packages</strong></p>
<p>apt-get install lvm2 dmsetup mdadm reiserfsprogs xfsprogs</p>
<p><strong>Create partitions</strong></p>
<p>fdisk /dev/sda</p>
<p>-create new partition (&#8217;n')<br />
-change system partition type to lvm (&#8217;t')<br />
-enter &#8216;8e&#8217; for hex partition type<br />
-write partition table to disk (&#8217;w')</p>
<p><strong>Create physical volume</strong></p>
<p>root@backupserv:~# pvcreate /dev/sdb1 /dev/sda2 /dev/sdc1<br />
Can&#8217;t open /dev/sdb1 exclusively.  Mounted filesystem?<br />
Wiping software RAID md superblock on /dev/sda2<br />
Physical volume &#8220;/dev/sda2&#8243; successfully created<br />
Wiping software RAID md superblock on /dev/sdc1<br />
Physical volume &#8220;/dev/sdc1&#8243; successfully created</p>
<p>root@backupserv:~# pvdisplay<br />
&#8220;/dev/sda2&#8243; is a new physical volume of &#8220;903.57 GB&#8221;<br />
&#8212; NEW Physical volume &#8212;<br />
PV Name               /dev/sda2<br />
VG Name<br />
PV Size               903.57 GB<br />
Allocatable           NO<br />
PE Size (KByte)       0<br />
Total PE              0<br />
Free PE               0<br />
Allocated PE          0<br />
PV UUID               zsP1EO-SlwB-nryo-gEP7-fInc-hJc4-ytVpLX</p>
<p>&#8220;/dev/sdc1&#8243; is a new physical volume of &#8220;931.51 GB&#8221;<br />
&#8212; NEW Physical volume &#8212;<br />
PV Name               /dev/sdc1<br />
VG Name<br />
PV Size               931.51 GB<br />
Allocatable           NO<br />
PE Size (KByte)       0<br />
Total PE              0<br />
Free PE               0<br />
Allocated PE          0<br />
PV UUID               V3RZ2b-FBsM-HoI6-aQED-ouu9-LpR1-m02VLO</p>
<p><strong>Create a Volume Group</strong><br />
root@backupserv:~# vgcreate data /dev/sdc1 /dev/sda2<br />
Volume group &#8220;data&#8221; successfully created</p>
<p>root@backupserv:~# vgdisplay<br />
&#8212; Volume group &#8212;<br />
VG Name               data<br />
System ID<br />
Format                lvm2<br />
Metadata Areas        2<br />
Metadata Sequence No  1<br />
VG Access             read/write<br />
VG Status             resizable<br />
MAX LV                0<br />
Cur LV                0<br />
Open LV               0<br />
Max PV                0<br />
Cur PV                2<br />
Act PV                2<br />
VG Size               1.79 TB<br />
PE Size               4.00 MB<br />
Total PE              469780<br />
Alloc PE / Size       0 / 0<br />
Free  PE / Size       469780 / 1.79 TB<br />
VG UUID               XJVXrA-m5xO-GARp-6WT0-JFlX-7ARj-jxJChV</p>
<p>root@backupserv:~# vgscan<br />
Reading all physical volumes.  This may take a while&#8230;<br />
Found volume group &#8220;data&#8221; using metadata type lvm2fdisk /dev/sda</p>
<p><strong>Create Logical Volume</strong></p>
<p>root@backupserv:~# lvcreate &#8211;name share1 &#8211;size 100G data<br />
Logical volume &#8220;share1&#8243; created<br />
root@backupserv:~# lvcreate &#8211;name share2 &#8211;size 500G data<br />
Logical volume &#8220;share2&#8243; created</p>
<p>*run lvscan for new logical volume scan.</p>
<p><strong>Format partition</strong></p>
<p>root@backupserv:~# mkfs.ext3 /dev/data/share1<br />
mke2fs 1.41.9 (22-Aug-2009)<br />
Filesystem label=<br />
OS type: Linux<br />
Block size=4096 (log=2)<br />
Fragment size=4096 (log=2)<br />
6553600 inodes, 26214400 blocks<br />
1310720 blocks (5.00%) reserved for the super user<br />
First data block=0<br />
Maximum filesystem blocks=0<br />
800 block groups<br />
32768 blocks per group, 32768 fragments per group<br />
8192 inodes per group<br />
Superblock backups stored on blocks:<br />
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,<br />
4096000, 7962624, 11239424, 20480000, 23887872</p>
<p>Writing inode tables: 192/800</p>
<p><strong>Mount device</strong></p>
<p>root@backupserv:~# mkdir /mnt/share2<br />
root@backupserv:~# mount /dev/data/share2 /mnt/share2<br />
/dev/mapper/data-share2<br />
516061624    202652 489644572   1% /mnt/share2</p>
<p><strong>Deleting an Volume Group<br />
</strong></p>
<p>root@backupserv:~# vgremove data<br />
Do you really want to remove volume group &#8220;data&#8221; containing 2 logical volumes? [y/n]: yes<br />
Can&#8217;t remove open logical volume &#8220;share1&#8243;<br />
root@backupserv:~# umount /mnt/share*<br />
root@backupserv:~# vgremove data<br />
Do you really want to remove volume group &#8220;data&#8221; containing 2 logical volumes? [y/n]: yes<br />
Do you really want to remove active logical volume &#8220;share1&#8243;? [y/n]: yes<br />
Logical volume &#8220;share1&#8243; successfully removed<br />
Do you really want to remove active logical volume &#8220;share2&#8243;? [y/n]: yes<br />
Logical volume &#8220;share2&#8243; successfully removed<br />
Volume group &#8220;data&#8221; successfully removed</p>
<p><strong>Delete Physical Volume</strong></p>
<p>root@backupserv:~# pvremove /dev/sdc1 /dev/sdb1<br />
Labels on physical volume &#8220;/dev/sdc1&#8243; successfully wiped<br />
Physical Volume /dev/sdb1 not found</p>
<p>ref: http://www.howtoforge.com/linux_lvm_p2</p>
<p><strong>Adding Additional Disk to LVM</strong></p>
<p>create fdisk LVM partition first&#8230;.</p>
<p>root@backupserv:~# pvcreate /dev/sdb1<br />
Physical volume &#8220;/dev/sdb1&#8243; successfully created</p>
<p>root@backupserv:~# vgextend vol1 /dev/sdb1<br />
Volume group &#8220;vol1&#8243; successfully extended<br />
root@backupserv:~# vgdisplay vol1<br />
&#8212; Volume group &#8212;<br />
VG Name               vol1<br />
System ID<br />
Format                lvm2<br />
Metadata Areas        3<br />
Metadata Sequence No  5<br />
VG Access             read/write<br />
VG Status             resizable<br />
MAX LV                0<br />
Cur LV                1<br />
Open LV               1<br />
Max PV                0<br />
Cur PV                3<br />
Act PV                3<br />
VG Size               2.70 TB<br />
PE Size               4.00 MB<br />
Total PE              708246<br />
Alloc PE / Size       469238 / 1.79 TB<br />
Free  PE / Size       239008 / 933.62 GB<br />
VG UUID               RS2K3i-SOJ8-a230-fcQL-8PX0-Bpuj-qSUYKz</p>
<p>root@backupserv:~# lvextend -L +930G /dev/vol1/data1 /dev/sdb1<br />
Extending logical volume data1 to 2.70 TB<br />
Logical volume data1 successfully resized</p>
<p>root@backupserv:~# resize2fs /dev/vol1/data1<br />
resize2fs 1.41.9 (22-Aug-2009)<br />
Filesystem at /dev/vol1/data1 is mounted on /mnt/data; on-line resizing required<br />
old desc_blocks = 115, new_desc_blocks = 173<br />
&#8230;.</p>
<p>*watch more space become available with &#8216;watch df -h&#8217;</p>
]]></content:encoded>
			<wfw:commentRss>http://jjester.com/techblog/?feed=rss2&amp;p=140</wfw:commentRss>
		</item>
		<item>
		<title>Find: xargs -vs- exec</title>
		<link>http://jjester.com/techblog/?p=138</link>
		<comments>http://jjester.com/techblog/?p=138#comments</comments>
		<pubDate>Tue, 16 Mar 2010 20:24:37 +0000</pubDate>
		<dc:creator>admin0</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://jjester.com/techblog/?p=138</guid>
		<description><![CDATA[&#8216;-exec&#8217; using trailing &#8216;\&#8217;
[root@monk ~]# tar -cvf test.tar install.log
install.log
[root@monk ~]# time find /tmp/conf-2-xp -name *.xad -exec tar &#8211;append &#8211;file=/root/test.tar {} +;
find: /tmp/conf-2-xp/9a2f6257887d6e51f58ce2/amd64: Permission denied
find: /tmp/conf-2-xp/9a2f6257887d6e51f58ce2/i386: Permission denied
find: /tmp/conf-2-xp/System Volume Information: Permission denied
tar: Removing leading `/&#8217; from member names
real    0m15.239s
user    0m0.464s
sys     0m2.628s
[root@monk ~]# du -h test.tar
310M    test.tar
[root@monk ~]# rm -f test.tar
*delete fiel and recreate since we [...]]]></description>
			<content:encoded><![CDATA[<p><strong>&#8216;-exec&#8217; using trailing &#8216;\&#8217;</strong></p>
<p>[root@monk ~]# tar -cvf test.tar install.log<br />
install.log<br />
[root@monk ~]# time find /tmp/conf-2-xp -name *.xad -exec tar &#8211;append &#8211;file=/root/test.tar {} +;<br />
find: /tmp/conf-2-xp/9a2f6257887d6e51f58ce2/amd64: Permission denied<br />
find: /tmp/conf-2-xp/9a2f6257887d6e51f58ce2/i386: Permission denied<br />
find: /tmp/conf-2-xp/System Volume Information: Permission denied<br />
tar: Removing leading `/&#8217; from member names</p>
<p>real    0m15.239s<br />
user    0m0.464s<br />
sys     0m2.628s<br />
[root@monk ~]# du -h test.tar<br />
310M    test.tar<br />
[root@monk ~]# rm -f test.tar</p>
<p>*delete fiel and recreate since we are appending and comparing file size after each run.</p>
<p><strong>&#8216;-exec&#8217; using trailing &#8216;+&#8217;</strong></p>
<p>[root@monk ~]# tar -cvf test.tar install.log<br />
install.log<br />
[root@monk ~]# time find /tmp/conf-2-xp -name *.xad -exec tar &#8211;append &#8211;file=/root/test.tar {} \;<br />
find: /tmp/conf-2-xp/9a2f6257887d6e51f58ce2/amd64: Permission denied<br />
find: /tmp/conf-2-xp/9a2f6257887d6e51f58ce2/i386: Permission denied<br />
&#8230;<br />
real    0m39.015s<br />
user    0m2.739s<br />
sys     0m21.893s<br />
[root@monk ~]# du -h test.tar<br />
310M    test.tar</p>
<p><strong>Using xargs.</strong></p>
<p>*use -print0 option to prevent whitespace issue. &#8216;xargs -0&#8242; passes first argument.</p>
<p>[root@monk ~]# rm test.tar<br />
rm: remove regular file `test.tar&#8217;? yes<br />
[root@monk ~]# tar -cvf test.tar install.log<br />
install.log<br />
[root@monk ~]# time find /tmp/conf-2-xp -name &#8216;*.xad&#8217; -print0 | xargs -0 tar &#8211;append &#8211;file=/root/test.tar;<br />
find: /tmp/conf-2-xp/9a2f6257887d6e51f58ce2/amd64: Permission denied<br />
find: /tmp/conf-2-xp/9a2f6257887d6e51f58ce2/i386: Permission denied<br />
find: /tmp/conf-2-xp/System Volume Information: Permission denied<br />
tar: Removing leading `/&#8217; from member names</p>
<p>real    0m15.073s<br />
user    0m0.446s<br />
sys     0m2.774s<br />
[root@monk ~]# du -h test.tar<br />
310M    test.tar</p>
<p>Result: Using &#8216;+&#8217; is two times faster than using &#8216;\&#8217;. -exec and xargs are about the same speed, when using &#8216;+&#8217; for -exec.</p>
]]></content:encoded>
			<wfw:commentRss>http://jjester.com/techblog/?feed=rss2&amp;p=138</wfw:commentRss>
		</item>
	</channel>
</rss>
