<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1822605347830719087</id><updated>2012-01-24T21:21:39.924+11:00</updated><category term='Scripting'/><category term='Performance'/><category term='Tips/Tricks'/><category term='RHCE/RHCA'/><category term='Apps'/><category term='Linux'/><category term='Troubleshooting'/><category term='Solaris'/><category term='NMS'/><category term='Storage'/><category term='Windows'/><category term='Virtualization'/><category term='Security'/><category term='Cluster'/><category term='Server Provisioning'/><category term='Linux Internals'/><title type='text'>UNIX/LINUX TECH NOTES</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://honglus.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://honglus.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default?start-index=101&amp;max-results=100'/><author><name>honglus</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>102</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1822605347830719087.post-5053839768600916580</id><published>2012-01-24T21:18:00.002+11:00</published><updated>2012-01-24T21:21:39.943+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><category scheme='http://www.blogger.com/atom/ns#' term='Performance'/><title type='text'>Tune nscd(name service cache daemon)</title><content type='html'>nscd provides caching for the passwd,group,and hosts tables, it can boot performance for situations, in which the tables need to be serviced remotely&amp;nbsp; e.g. LDAP authentication and DNS. &lt;br /&gt;However, sometimes, it cause trouble.In Red Hat Linux 5 , nscd always return the old entry until the TTL(default is 1hour) is reached, even restarting nscd won’t flush the cache. &lt;br /&gt;There are two solutions:&lt;br /&gt;&lt;strong&gt;1.Disable persistent caching &lt;/strong&gt;&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Persistent caching is enabled by default&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$cat /etc/nscd.conf&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;persistent              passwd          yes&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;persistent              group           yes&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;persistent              hosts           yes&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;positive-time-to-live   hosts           3600&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#So the entries are saved to relative tables&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$rpm -ql nscd&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;..&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/var/db/nscd/group&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/var/db/nscd/hosts&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/var/db/nscd/passwd…&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#change them to no&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;persistent              passwd          no&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;persistent              group           no&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;persistent              hosts           no&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;With persistent caching disabled, restart nscd will discard the entries in memory.&lt;br /&gt;&lt;strong&gt;2.Flush entries by invalidating the&amp;nbsp; table&amp;nbsp;&lt;/strong&gt;&lt;br /&gt;The entries in tables (group/passwd/hosts) can manually flushed by the ‘invalidate ‘parameter.&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$nscd --invalidate=hosts&lt;/pre&gt;&lt;/pre&gt;Since it is natural for anyone to try restart nscd to resolve the issue and the operation of rebuilding cache is not expensive, I think option 1 is better.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1822605347830719087-5053839768600916580?l=honglus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://honglus.blogspot.com/feeds/5053839768600916580/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://honglus.blogspot.com/2012/01/tune-nscdname-service-cache-daemon.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/5053839768600916580'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/5053839768600916580'/><link rel='alternate' type='text/html' href='http://honglus.blogspot.com/2012/01/tune-nscdname-service-cache-daemon.html' title='Tune nscd(name service cache daemon)'/><author><name>honglus</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1822605347830719087.post-6020607528717578148</id><published>2012-01-10T22:53:00.003+11:00</published><updated>2012-01-11T23:59:01.155+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Scripting'/><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><title type='text'>Force puppet agent to regenerate certificate request</title><content type='html'>If puppet agent’s certificate is accidentally revoked or deleted, you can force agent to regenerate certificate request.&lt;br /&gt;&lt;br /&gt;In general, it is impossible un-revoke a certificate unless the revoke reason is certificateHold, But puppet can hack it. The solution is to recover all revoked certificates then revoke other certificates which don’t need to be recovered&lt;br /&gt;&lt;pre&gt;$rm /etc/puppetlabs/puppet/ssl/ca/ca_crl.pem&lt;br /&gt;$rm /etc/puppetlabs/puppet/ssl/crl.pem&lt;br /&gt;#At this point, all revoked certificates become valid certificates.&lt;br /&gt;#So you need to revoke all certificates which don’t need to be recovered&lt;br /&gt;$puppet cert --revoke foo&lt;br /&gt;&lt;/pre&gt;The following method of regenerating new certificate seems to be a better.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;The following is tested in Puppet Enterprise 2, but it should work for puppet open source as well.&lt;br /&gt;$ puppet --version&lt;br /&gt;2.7.6 (Puppet Enterprise 2.0.0)&lt;br /&gt;&lt;strong&gt;Force agent to regenerate certificate request by generate command&lt;/strong&gt;&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;[puppet agent]$ puppet  certificate   generate    web1  --ca-location  remote&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;warning: peer certificate won't be verified &lt;span style="color: blue;"&gt;in&lt;/span&gt; this SSL session&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;err: Error 400 on SERVER: web1 already has a revoked certificate; ignoring certificate request&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;err: Try 'puppet help certificate generate' &lt;span style="color: blue;"&gt;for&lt;/span&gt; usage&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#It because the revoked certificate still exist in the server, it need to be deleted&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;[puppet master]$ puppet cert list –all&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;- web1                                     (BA:18:D1:86:D6:5E:9E:99:55:39:3D:67:79:BF:BD:D0) (certificate revoked)&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;[puppet master]$ puppet cert clean web1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#re-run the command, the warning is expected because the request hasn’t been signed by master yet&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;[puppet agent]$puppet   certificate   generate    web1  --ca-location  remote&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;warning: peer certificate won't be verified &lt;span style="color: blue;"&gt;in&lt;/span&gt; this SSL session&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;true&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#The pending request appears in master &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;[puppet master]$ puppet cert list&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;web1 (3B:ED:D9:8D:2F:C2:A1:D3:89:B4:D0:FD:41:7E:5E:0C)&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Sign the certificate&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;[puppet master]&lt;span style="color: green;"&gt;# puppet cert sign web1&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;strong&gt;If the above doesn’t work for you, the last resort is to clean agent’s ssl files&lt;/strong&gt;&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;[puppet agent]$ puppet --genconfig | grep certdir&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;certdir = /etc/puppetlabs/puppet/ssl/certs&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$cd /etc/puppetlabs/puppet/ssl/&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$find . –type f –&lt;span style="color: darkblue;"&gt;exec&lt;/span&gt; rm {} \;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$service pe-puppet restart&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;[puppet master]$ puppet cert list&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;web1 (3B:ED:D9:8D:2F:C2:A1:D3:89:B4:D0:FD:41:7E:5E:0C)&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Sign the certificate&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;puppet master]&lt;span style="color: green;"&gt;# puppet cert sign web1&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1822605347830719087-6020607528717578148?l=honglus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://honglus.blogspot.com/feeds/6020607528717578148/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://honglus.blogspot.com/2012/01/force-puppet-agent-to-regenerate.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/6020607528717578148'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/6020607528717578148'/><link rel='alternate' type='text/html' href='http://honglus.blogspot.com/2012/01/force-puppet-agent-to-regenerate.html' title='Force puppet agent to regenerate certificate request'/><author><name>honglus</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1822605347830719087.post-3770002291544567208</id><published>2012-01-10T22:40:00.004+11:00</published><updated>2012-01-10T22:56:46.085+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Scripting'/><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><title type='text'>Augeas quickstart</title><content type='html'>Augeas is a configuration editing tool. It parses configuration files in their native formats and transforms them into a tree. Configuration changes are made by manipulating this tree and saving it back into native config files.    &lt;br /&gt;Configuration files support is provided by “lenses”. The default lenses are provided in augeas-lib package &lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ rpm -ql pe-augeas-libs | grep lenses&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/opt/puppet/share/augeas/lenses/dist&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/opt/puppet/share/augeas/lenses/dist/aliases.aug&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;…&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;If your configuration is not listed, you can write your own lenses definition file.&lt;br /&gt;Language bindings are available:&lt;br /&gt;Ruby, Python, OCaml, Perl, Haskell, PHP, Lua, and Java &lt;br /&gt;Augeas has two main directories:&lt;br /&gt;- augeas: augeas configuration directory. e.g control loading lenses &lt;br /&gt;- files: user data directory tree. e.g /etc/hosts is mapped to /files/etc/hosts&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$augtool&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;augtool&amp;gt; ls /&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;augeas/ = (none)&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;files/ = (none)&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;strong&gt;Sample hosts file to be tested&lt;/strong&gt;&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$cat /etc/hosts&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;# comment test1&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;# comment test2&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;172.16.1.11 web1 web1.example.com server1.example.com&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#######Augeas translate above hosts file to &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;augtool&amp;gt;  &lt;span style="color: darkblue;"&gt;print&lt;/span&gt; /files/etc/hosts&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/&lt;span style="color: green;"&gt;#comment[1] = "comment test1"&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/&lt;span style="color: green;"&gt;#comment[2] = "comment test2"&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/1/ipaddr = "&lt;span style="color: darkred;"&gt;172.16.1.11&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/1/canonical = "&lt;span style="color: darkred;"&gt;web1&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/1/&lt;span style="color: blue;"&gt;alias&lt;/span&gt;[1] = "&lt;span style="color: darkred;"&gt;web1.example.com&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/1/&lt;span style="color: blue;"&gt;alias&lt;/span&gt;[2] = "&lt;span style="color: darkred;"&gt;server1.example.com&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;strong&gt;Adding a new comment&lt;/strong&gt;&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;augtool&amp;gt; set /files/etc/hosts/&lt;span style="color: green;"&gt;#comment[last()+1] "comment test3"&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;augtool&amp;gt; &lt;span style="color: darkblue;"&gt;print&lt;/span&gt;  /files/etc/hosts/&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/&lt;span style="color: green;"&gt;#comment[1] = "comment test1"&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/&lt;span style="color: green;"&gt;#comment[2] = "comment test2"&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/1/ipaddr = "&lt;span style="color: darkred;"&gt;172.16.1.11&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/1/canonical = "&lt;span style="color: darkred;"&gt;web1&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/1/&lt;span style="color: blue;"&gt;alias&lt;/span&gt;[1] = "&lt;span style="color: darkred;"&gt;web1.example.com&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/1/&lt;span style="color: blue;"&gt;alias&lt;/span&gt;[2] = "&lt;span style="color: darkred;"&gt;server1.example.com&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/&lt;span style="color: green;"&gt;#comment[3] = "comment test3"&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;########New comment will be added to last line.&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;########If you want to append it next to #comment[2], use insert&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;augtool&amp;gt; ins &lt;span style="color: green;"&gt;#comment after /files/etc/hosts/#comment[last()]&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;augtool&amp;gt; &lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;augtool&amp;gt; set  /files/etc/hosts/&lt;span style="color: green;"&gt;#comment[last()] "comment test3"&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;augtool&amp;gt; &lt;span style="color: darkblue;"&gt;print&lt;/span&gt; /files/etc/hosts&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/&lt;span style="color: green;"&gt;#comment[1] = "comment test1"&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/&lt;span style="color: green;"&gt;#comment[2] = "comment test2"&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/&lt;span style="color: green;"&gt;#comment[3] = "comment test3"&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/1/ipaddr = "&lt;span style="color: darkred;"&gt;172.16.1.11&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/1/canonical = "&lt;span style="color: darkred;"&gt;web1&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/1/&lt;span style="color: blue;"&gt;alias&lt;/span&gt;[1] = "&lt;span style="color: darkred;"&gt;web1.example.com&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/1/&lt;span style="color: blue;"&gt;alias&lt;/span&gt;[2] = "&lt;span style="color: darkred;"&gt;server1.example.com&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;strong&gt;Adding a host entry.&lt;/strong&gt;&lt;br /&gt;You can’t use last() to auto increase it from hosts/1 to hosts/2, because&amp;nbsp; “1” or “2” is label name not an index number like #comment[1]/#comment[2].&lt;br /&gt;The trick is to use “01,02,03” etc.&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;augtool&amp;gt; set /files/etc/hosts/01/ipaddr 172.16.1.12&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;augtool&amp;gt;set /files/etc/hosts/01/canonical web2&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##at this point, it is hosts/01 added&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;augtool&amp;gt; &lt;span style="color: darkblue;"&gt;print&lt;/span&gt; /files/etc/hosts&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/&lt;span style="color: green;"&gt;#comment[1] = "comment test1"&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/&lt;span style="color: green;"&gt;#comment[2] = "comment test2"&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/&lt;span style="color: green;"&gt;#comment[3] = "coment test3"&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/1/ipaddr = "&lt;span style="color: darkred;"&gt;172.16.1.11&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/1/canonical = "&lt;span style="color: darkred;"&gt;web1&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/1/&lt;span style="color: blue;"&gt;alias&lt;/span&gt;[1] = "&lt;span style="color: darkred;"&gt;web1.example.com&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/1/&lt;span style="color: blue;"&gt;alias&lt;/span&gt;[2] = "&lt;span style="color: darkred;"&gt;server1.example.com&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/01&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/01/ipaddr = "&lt;span style="color: darkred;"&gt;172.16.1.12&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/01/canonical = "&lt;span style="color: darkred;"&gt;web2&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;####after save and load, hosts/2 is added&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;augtool&amp;gt; save&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Saved 1 file(s)&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;augtool&amp;gt; &lt;span style="color: darkblue;"&gt;load&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;augtool&amp;gt; &lt;span style="color: darkblue;"&gt;print&lt;/span&gt; /files/etc/hosts&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/&lt;span style="color: green;"&gt;#comment[1] = "comment test1"&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/&lt;span style="color: green;"&gt;#comment[2] = "comment test2"&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/&lt;span style="color: green;"&gt;#comment[3] = "coment test3"&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/1/ipaddr = "&lt;span style="color: darkred;"&gt;172.16.1.11&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/1/canonical = "&lt;span style="color: darkred;"&gt;web1&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/1/&lt;span style="color: blue;"&gt;alias&lt;/span&gt;[1] = "&lt;span style="color: darkred;"&gt;web1.example.com&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/1/&lt;span style="color: blue;"&gt;alias&lt;/span&gt;[2] = "&lt;span style="color: darkred;"&gt;server1.example.com&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/2&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/2/ipaddr = "&lt;span style="color: darkred;"&gt;172.16.1.12&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/2/canonical = "&lt;span style="color: darkred;"&gt;web2&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;strong&gt;Change an entry by referencing to itself&lt;/strong&gt;&lt;br /&gt;Change the comment “comment test1” to “newcomment test1” &lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Change the comment “comment test1” to “newcomment test1” &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;augtool&amp;gt; /set files/etc/hosts/&lt;span style="color: green;"&gt;#comment[.='comment test1'] 'newcomment test1'&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;augtool&amp;gt; &lt;span style="color: darkblue;"&gt;print&lt;/span&gt; /files/etc/hosts/&lt;span style="color: green;"&gt;#comment&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/&lt;span style="color: green;"&gt;#comment[1] = "newcomment test1"&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/&lt;span style="color: green;"&gt;#comment[2] = "comment test2"&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/&lt;span style="color: green;"&gt;#comment[3] = "comment test3&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Change any comment starting with comment to ‘oldcomment’ by regex match&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;augtool&amp;gt;setm /files/etc/hosts  &lt;span style="color: green;"&gt;#comment[.=~regexp('comment.*')] 'oldcomment'&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;augtool&amp;gt; &lt;span style="color: darkblue;"&gt;print&lt;/span&gt; /files/etc/hosts/&lt;span style="color: green;"&gt;#comment&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/&lt;span style="color: green;"&gt;#comment[1] = "newcomment test1"&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/&lt;span style="color: green;"&gt;#comment[2] = "oldcomment"&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/&lt;span style="color: green;"&gt;#comment[3] = "oldcomment"&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Usually, regex match is used to delete entries. e.g delete comment test[23]&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;augtool&amp;gt; &lt;span style="color: darkblue;"&gt;print&lt;/span&gt; /files/etc/hosts/&lt;span style="color: green;"&gt;#comment&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/&lt;span style="color: green;"&gt;#comment[1] = "comment test1"&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/&lt;span style="color: green;"&gt;#comment[2] = "comment test2"&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/&lt;span style="color: green;"&gt;#comment[3] = "comment test3"&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;augtool&amp;gt; rm /files/etc/hosts/&lt;span style="color: green;"&gt;#comment[.=~regexp('comment test[23]')]&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;rm : /files/etc/hosts/&lt;span style="color: green;"&gt;#comment[.=~regexp('comment test[23]')] 2&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;augtool&amp;gt; &lt;span style="color: darkblue;"&gt;print&lt;/span&gt; /files/etc/hosts/&lt;span style="color: green;"&gt;#comment&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/&lt;span style="color: green;"&gt;#comment = "comment test1"&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;augtool&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;strong&gt;Change an entry by referencing to relative nodes&lt;/strong&gt;&lt;br /&gt;e.g change ip of&amp;nbsp; a host ‘web1’&amp;nbsp; to 172.16.11.11&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;augtool&amp;gt; &lt;span style="color: darkblue;"&gt;print&lt;/span&gt; /files/etc/hosts/1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/1/ipaddr = "&lt;span style="color: darkred;"&gt;172.16.1.11&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/1/canonical = "&lt;span style="color: darkred;"&gt;web1&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/1/&lt;span style="color: blue;"&gt;alias&lt;/span&gt;[1] = "&lt;span style="color: darkred;"&gt;web1.example.com&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/1/&lt;span style="color: blue;"&gt;alias&lt;/span&gt;[2] = "&lt;span style="color: darkred;"&gt;server1.example.com&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;augtool&amp;gt; set /files/etc/hosts&lt;span style="color: green;"&gt;/*/&lt;/span&gt;ipaddr[../canonical = 'web1'] 172.16.11.11&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;augtool&amp;gt; &lt;span style="color: darkblue;"&gt;print&lt;/span&gt; /files/etc/hosts/1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/1/ipaddr = "&lt;span style="color: darkred;"&gt;172.16.11.11&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/1/canonical = "&lt;span style="color: darkred;"&gt;web1&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/1/&lt;span style="color: blue;"&gt;alias&lt;/span&gt;[1] = "&lt;span style="color: darkred;"&gt;web1.example.com&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/1/&lt;span style="color: blue;"&gt;alias&lt;/span&gt;[2] = "&lt;span style="color: darkred;"&gt;server1.example.com&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#multiple conditions can be joined together &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;augtool&amp;gt; match /files/etc/hosts&lt;span style="color: green;"&gt;/*/&lt;/span&gt;ipaddr[../canonical = 'web1' &lt;span style="color: blue;"&gt;and&lt;/span&gt; ../&lt;span style="color: blue;"&gt;alias&lt;/span&gt; = 'server1.example.com']&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/1/ipaddr = 172.16.11.11&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;augtool&amp;gt; match /files/etc/hosts&lt;span style="color: green;"&gt;/*[canonical = 'web1' and alias = 'server1.example.com']&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/files/etc/hosts/1 = (none)&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;strong&gt;Comment or uncomment a line&lt;/strong&gt;&lt;br /&gt;Comment or uncomment is difficult for Augeas to implement, it can only be achieved by inserting a new line after the comment line then removing the old line.&lt;br /&gt;You can extend Augeas to include ‘comment’ and ‘uncomment’ functions. The following code is an example for puppet.&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##Define a function &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;define augeasnew ($file,$line){&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$&lt;span style="color: darkblue;"&gt;exp&lt;/span&gt;=regsubst($line[0], '^(un)?comment *(.*)' , '\2')&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;case&lt;/span&gt; $line[0] {&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/^uncomment/: {&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: darkblue;"&gt;exec&lt;/span&gt; {"&lt;span style="color: darkred;"&gt;/bin/sed -i -e '/${exp}/s/#//g' $file&lt;/span&gt;":&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;onlyif =&amp;gt; "&lt;span style="color: darkred;"&gt;/bin/grep '${exp}' ${file} | /bin/grep '#' &lt;/span&gt;",}&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/^comment/: {&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: darkblue;"&gt;exec&lt;/span&gt; {"&lt;span style="color: darkred;"&gt;/bin/sed -i -e '/${exp}/ s/^/#/' $file&lt;/span&gt;":&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;onlyif =&amp;gt; "&lt;span style="color: darkred;"&gt;/bin/grep '${exp}' ${file} | /bin/grep -v '#' &lt;/span&gt;",}&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;default: {&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;augeas {'augeas-chg-any':&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;context =&amp;gt; "&lt;span style="color: darkred;"&gt;/files/${file}&lt;/span&gt;",&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;changes =&amp;gt; $line, }&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##execute the function&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;augeasnew {'chg-hosts-file':&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;file =&amp;gt; '/etc/hosts',&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Mulitple Augeas commands can be stored in an array&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#However,none-Augeas command (uncomment or comment) can only be stored in first element of an array.&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#line =&amp;gt; ["set  1/ipaddr '10.1.1.1'" , "set 2/ipaddr '10.1.1.2'",],&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;line =&amp;gt; ["&lt;span style="color: darkred;"&gt;comment  c line1&lt;/span&gt;",],&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;strong&gt;Troubleshooting.&lt;/strong&gt;&lt;br /&gt;You can check /augeas//error for detailed errors, for example, Augeas can’t load /etc/sudoers&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;augtool&amp;gt; &lt;span style="color: darkblue;"&gt;print&lt;/span&gt; /augeas//error&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/augeas/files/etc/sudoers/error = "&lt;span style="color: darkred;"&gt;parse_failed&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/augeas/files/etc/sudoers/error/pos = "&lt;span style="color: darkred;"&gt;1998&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/augeas/files/etc/sudoers/error/line = "&lt;span style="color: darkred;"&gt;62&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/augeas/files/etc/sudoers/error/char = "&lt;span style="color: darkred;"&gt;0&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/augeas/files/etc/sudoers/error/lens = "&lt;span style="color: darkred;"&gt;/opt/puppet/share/augeas/lenses/dist/sudoers.aug:478.10-.57:&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/augeas/files/etc/sudoers/error/message = "&lt;span style="color: darkred;"&gt;Iterated lens matched less than it should&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;In this &lt;span style="color: blue;"&gt;case&lt;/span&gt;, error is encountered &lt;span style="color: blue;"&gt;in&lt;/span&gt; line 62. &lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$sed -n '62&lt;span style="color: darkblue;"&gt;p&lt;/span&gt;' /etc/sudoers&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Defaults   !visiblepw&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;#You can upgrade Augeas &lt;span style="color: blue;"&gt;or&lt;/span&gt; comment out the line to resolve the issue&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;b&gt;Reference:&lt;/b&gt;&lt;br /&gt;&lt;a href="http://augeas.net/tour.html"&gt;http://augeas.net/tour.html&lt;/a&gt;&lt;br /&gt;&lt;a href="http://augeas.net/page/Path_expressions"&gt;http://augeas.net/page/Path_expressions&lt;/a&gt;&lt;br /&gt;&lt;a href="http://docs.puppetlabs.com/references/2.6.8/function.html"&gt;http://docs.puppetlabs.com/references/2.6.8/function.html&lt;/a&gt;&lt;br /&gt;&lt;a href="http://docs.puppetlabs.com/guides/language_guide.html"&gt;http://docs.puppetlabs.com/guides/language_guide.html&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1822605347830719087-3770002291544567208?l=honglus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://honglus.blogspot.com/feeds/3770002291544567208/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://honglus.blogspot.com/2012/01/augeas-quick-start.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/3770002291544567208'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/3770002291544567208'/><link rel='alternate' type='text/html' href='http://honglus.blogspot.com/2012/01/augeas-quick-start.html' title='Augeas quickstart'/><author><name>honglus</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1822605347830719087.post-7697607534259231010</id><published>2012-01-05T23:52:00.009+11:00</published><updated>2012-01-10T22:42:14.529+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Scripting'/><category scheme='http://www.blogger.com/atom/ns#' term='Server Provisioning'/><category scheme='http://www.blogger.com/atom/ns#' term='Windows'/><category scheme='http://www.blogger.com/atom/ns#' term='Virtualization'/><title type='text'>Vsphere PowerCLI script to clone and customize Windows guest OS</title><content type='html'>&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; margin-bottom: 0em; margin-left: 0em; margin-right: 0em; margin-top: 0em; width: 650px;"&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt;&lt;span class="Apple-style-span" style="white-space: normal;"&gt;VMware can also customize Windows guest OS by Windows sysprep tool, though the process is more complex than Linux guest OS&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="white-space: normal;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="white-space: normal;"&gt;There are two options to clone and “sysprep” VMware Windows guest OS:&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="white-space: normal;"&gt;1.Install sysprep tools in Windows guest OS and &amp;nbsp;run sysprep.exe &amp;nbsp;in guest OS command line, then clone it by VMware&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="white-space: normal;"&gt;2.Install sysprep tools in Virutal Center and let VMware tools in Windows guest in to control sysprep process either by GUI or script. &amp;nbsp;(It seems sysprep rely on VMware tools, so the VMware tools must be installed in guest OS)&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="white-space: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin-bottom: 0em; margin-left: 0em; margin-right: 0em; margin-top: 0em; width: 650px;"&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt;&lt;span class="Apple-style-span" style="white-space: normal;"&gt;Option #2 is the preferred method, because you can use script to easily customize unique information e.g computer name, ip addresses etc.&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin-bottom: 0em; margin-left: 0em; margin-right: 0em; margin-top: 0em; width: 650px;"&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt;&lt;span class="Apple-style-span"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="white-space: normal;"&gt;&lt;b&gt;Install sysprep tools in Virtual Center&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="white-space: normal;"&gt;&lt;a href="http://kb.vmware.com/kb/1005593" target="_blank"&gt;VMware KB: Sysprep file locations and versions&amp;nbsp;&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="white-space: normal;"&gt;Windows Vista onwards(vista/2008/7/2008R2/) don’t need this step, because its sysprep is built-in.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="white-space: normal;"&gt;&lt;b&gt;Create guest customization by GUI&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="white-space: normal;"&gt;&amp;nbsp;Virtual Center -&amp;gt; view-&amp;gt; management -&amp;gt; “customization specification manager”. Create a new customization and select it when asked for guest customization information in GUI clone action.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="white-space: normal;"&gt;&lt;b&gt;Create guest customization by script.&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="white-space: normal;"&gt;Customization by GUI is not flexible, customization by script can be created on the fly. The following is enhancement to the clonevm.ps1 in&amp;nbsp;&lt;a href="http://honglus.blogspot.com/2010/10/vsphere-powercli-script-to-clone-and.html" target="_blank"&gt;Vsphere PowerCLI script to clone and customize Linux guest OS&lt;/a&gt;, just replace the “Identity for Linux” part with following code block&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; margin-bottom: 0em; margin-left: 0em; margin-right: 0em; margin-top: 0em; width: 100%;"&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman';"&gt;&lt;span class="Apple-style-span" style="white-space: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class="Apple-style-span" style="font-family: consolas, 'Courier New', courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: 12px;"&gt;$s_ostype=Retrieve-values $lines  "&lt;/span&gt;&lt;/span&gt;&lt;span style="color: darkred; font-family: consolas, 'Courier New', courier, monospace; font-size: 12px;"&gt;ostype&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: consolas, 'Courier New', courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: 12px;"&gt;"&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;if&lt;/span&gt; ( $s_ostype -eq "&lt;span style="color: darkred;"&gt;linux&lt;/span&gt;" ) { &lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;## Identity for Linux &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$vmclonespec_os.identity= New-&lt;a href="http://www.ruby-doc.org/docs/rdoc/1.9/classes/Object.html" style="color: red;"&gt;Object&lt;/a&gt; VMware.Vim.CustomizationLinuxPrep&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$vmclonespec_os.identity.hostname= New-&lt;a href="http://www.ruby-doc.org/docs/rdoc/1.9/classes/Object.html" style="color: red;"&gt;Object&lt;/a&gt; VMware.Vim.CustomizationFixedName&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$vmclonespec_os.identity.hostname.name= $s_dstname&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$vmclonespec_os.identity.domain=$s_domain&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;elseif ( $s_ostype -eq "&lt;span style="color: darkred;"&gt;windows&lt;/span&gt;" ) {&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;# WinOptions&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$vmclonespec_os.Options = New-&lt;a href="http://www.ruby-doc.org/docs/rdoc/1.9/classes/Object.html" style="color: red;"&gt;Object&lt;/a&gt;  VMware.Vim.CustomizationWinOptions&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$vmclonespec_os.Options.ChangeSID = 1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#sysprep&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$vmclonespec_os.identity = New-&lt;a href="http://www.ruby-doc.org/docs/rdoc/1.9/classes/Object.html" style="color: red;"&gt;Object&lt;/a&gt; VMware.Vim.CustomizationSysprep&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;# GUIUnattended&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$vmclonespec_os.Identity.GuiUnattended = New-&lt;a href="http://www.ruby-doc.org/docs/rdoc/1.9/classes/Object.html" style="color: red;"&gt;Object&lt;/a&gt; VMware.Vim.CustomizationGuiUnattended&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$vmclonespec_os.Identity.GuiUnattended.AutoLogon = 0&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#timezone codes: http://msdn.microsoft.com/en-us/library/ms145276(v=sql.90).aspx&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$vmclonespec_os.Identity.GuiUnattended.TimeZone  = 255&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$vmclonespec_os.Identity.GuiUnattended.Password = New-&lt;a href="http://www.ruby-doc.org/docs/rdoc/1.9/classes/Object.html" style="color: red;"&gt;Object&lt;/a&gt; VMware.Vim.CustomizationPassword&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$vmclonespec_os.Identity.GuiUnattended.Password.PlainText = 1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$vmclonespec_os.Identity.GuiUnattended.Password.Value = "&lt;span style="color: darkred;"&gt;Secret01&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;# Identification&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$vmclonespec_os.Identity.Identification = New-&lt;a href="http://www.ruby-doc.org/docs/rdoc/1.9/classes/Object.html" style="color: red;"&gt;Object&lt;/a&gt; VMware.Vim.CustomizationIdentification&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$vmclonespec_os.Identity.Identification.joinWorkgroup = "&lt;span style="color: darkred;"&gt;workgroup2&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;## Userdata&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$vmclonespec_os.identity.userData = New-&lt;a href="http://www.ruby-doc.org/docs/rdoc/1.9/classes/Object.html" style="color: red;"&gt;Object&lt;/a&gt; VMware.Vim.CustomizationUserData&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$vmclonespec_os.identity.userData.computerName = New-&lt;a href="http://www.ruby-doc.org/docs/rdoc/1.9/classes/Object.html" style="color: red;"&gt;Object&lt;/a&gt; VMware.Vim.CustomizationFixedName&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$vmclonespec_os.identity.userData.computerName.name = $s_dstname&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$vmclonespec_os.Identity.UserData.FullName = "&lt;span style="color: darkred;"&gt;Administrator&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$vmclonespec_os.Identity.UserData.OrgName="&lt;span style="color: darkred;"&gt;myOrg&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$vmclonespec_os.Identity.UserData.Productid="&lt;span style="color: darkred;"&gt;&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;else&lt;/span&gt; {&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;write-host "&lt;span style="color: darkred;"&gt;Unknown ostype: $s_ostype. Please set it to linux or windows&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: darkblue;"&gt;exit&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;}&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt;NOTES:&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt;&amp;nbsp;- The guest OS(Windows/Linux) will be forcefully rebooted by Vmware tools again in ~1 minute after you power it on, so don’t login in a hurry to check the result.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, sans-serif;"&gt;&amp;nbsp;- The script only works in a live session to Virtualcenter, it doesn’t work in a direct login session to ESX host.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1822605347830719087-7697607534259231010?l=honglus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://honglus.blogspot.com/feeds/7697607534259231010/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://honglus.blogspot.com/2012/01/vsphere-powercli-script-to-clone-and.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/7697607534259231010'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/7697607534259231010'/><link rel='alternate' type='text/html' href='http://honglus.blogspot.com/2012/01/vsphere-powercli-script-to-clone-and.html' title='Vsphere PowerCLI script to clone and customize Windows guest OS'/><author><name>honglus</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1822605347830719087.post-1817904560845802589</id><published>2012-01-05T23:30:00.002+11:00</published><updated>2012-01-05T23:32:29.184+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Server Provisioning'/><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><title type='text'>Bootstrap Puppet Enterprise (PE) Puppet Client for RHEL</title><content type='html'>Puppet Enterprise(PE) packs all required packages, modules into a tar file.   &lt;br /&gt;The file also includes a shell installation script to install packages and modules and do other customizations tasks. So only installing agent packages “pe-puppet pe-mcollective” can’t setup agent station properly. &lt;br /&gt;It is ideal to have PE agent installed automatically along with OS,the installer script can use answer file to automate the process.   &lt;br /&gt;The following codes can be put in RHEL kickstart postrun section to bootstrap PE agent.&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Download Puppet Enterprise(PE) (manage up to 10 nodes free)&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#http://puppetlabs.com/puppet/puppet-enterprise/&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#e.g  puppet-enterprise-2.0.0-el-5-x86_64.tar.gz&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;...&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;%post&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;PKG=puppet-enterprise-2.0.0-el-5-x86_64&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;cd /tmp &amp;amp;&amp;amp; wget -O ${PKG}.tar.gz http://172.16.1.1/boot/os/rhel-5.6-x64/${PKG}.tar.gz  &amp;amp;&amp;amp; tar -zxf ${PKG}.tar.gz  &amp;amp;&amp;amp; cd /tmp/${PKG} &amp;amp;&amp;amp; \&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;cat &amp;gt;answerfile&amp;lt;&amp;lt;&lt;span style="color: blue;"&gt;END&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;q_install=y&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;q_puppet_cloud_install=n&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;q_puppet_enterpriseconsole_install=n&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;q_puppet_symlinks_install=y&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;q_puppetagent_certname=$(hostname -s)&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;q_puppetagent_install=y&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;q_puppetagent_server=puppet&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;q_puppetmaster_install=n&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;q_vendor_packages_install=n&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;q_install=y&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;END&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;[ -e answerfile ] &amp;amp;&amp;amp; ./puppet-enterprise-installer -a answerfile  2&amp;gt;&amp;amp;1 | tee  /tmp/install_${PKG}.log&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;rm -rf /tmp/${PKG}*&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;sync&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: darkblue;"&gt;exit&lt;/span&gt; 0&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;Connect to puppet server after installation finished&lt;br /&gt;&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Verify puppet agent is running&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;[Puppet Client]$/etc/init.d/pe-puppet status&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Puppet server should be able to see the client’s pending certificate request&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;[Puppet Master]$puppet cert list&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;web2 (A1:08:15:EF:1F:5D:F9:C5:D9:A0:F3:F2:FD:FF:CE:09)&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Approve the client by signing the cert request&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;[Puppet Master]$puppet cert sign web2&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1822605347830719087-1817904560845802589?l=honglus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://honglus.blogspot.com/feeds/1817904560845802589/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://honglus.blogspot.com/2012/01/bootstrap-puppet-enterprise-pe-puppet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/1817904560845802589'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/1817904560845802589'/><link rel='alternate' type='text/html' href='http://honglus.blogspot.com/2012/01/bootstrap-puppet-enterprise-pe-puppet.html' title='Bootstrap Puppet Enterprise (PE) Puppet Client for RHEL'/><author><name>honglus</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1822605347830719087.post-8127448840194564485</id><published>2011-12-07T20:58:00.012+11:00</published><updated>2011-12-23T21:57:36.115+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Server Provisioning'/><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><category scheme='http://www.blogger.com/atom/ns#' term='Windows'/><title type='text'>Build a Linux PXE server to provision Linux and Windows Servers</title><content type='html'>Windows Deployment Service (WDS)/SCCM is the traditional way to provision&amp;nbsp; Windows servers, However if you need to provision both Linux and Windows Servers, it would be nice to have a all-in-one server. Before Windows Preinstallation Environment (WinPE) was developed, disk imaging tool like ghost is used to deploy syspreped windows OS as non-windows based provision solution. WinPE is part of Windows Automated Installation Kit(WAIK), it includes, imagex, a tool to capture image on file system level rather than raw sector level.   &lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;&lt;br /&gt;&lt;h3&gt;&lt;strong&gt;The PXE Server presented here has the following features:&lt;/strong&gt;&lt;/h3&gt;- Support any PXE capable Linux distribution and most Windows versions: 2000/2003/XP/Vista/7/2008/2008 R2. Potentially, support any other PXE capable server e.g Solaris&lt;br /&gt;- Zero touch installation/full automation    &lt;br /&gt;- Dynamic loading configuration using CGI script of your choice PHP/Perl ...&lt;br /&gt;- Downloading kernel/images over http which is more reliable and faster than tftp, additionally, http makes it possible to provision over remote site &lt;br /&gt;&lt;h4&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Environment setup&lt;/span&gt;&lt;/h4&gt;&lt;strong&gt;&lt;/strong&gt;7 VMS in Virtualbox 4( for testing provision Centos 5.5, Windows 2003, and Windows 2008 R2)    &lt;br /&gt;- PXE server: Centos 5.5    &lt;br /&gt;- PXE Linux Client: Centos 5.5    &lt;br /&gt;- WAIK tools computer: Windows 2008 R2     &lt;br /&gt;- PXE Windows Client(imagex/sysprep target): Windows 2008 R2    &lt;br /&gt;- PXE Windows Client(imagex/sysprep target): Windows 2003 R2    &lt;br /&gt;- Imagex/sysprep source: Windows 2008 R2     &lt;br /&gt;- Imagex/sysprep source: Windows 2003 R2 &lt;br /&gt;Notes:   &lt;br /&gt;- Select PCnet-fast III network adapter to support PXE boot    &lt;br /&gt;- Windows VM must have at least 1G RAM, because WinPE ISO memdisk will consume few hundreds of MB    &lt;br /&gt;- Setup samba share in PXEServer to store Windows imagex(.wim ) files,autoscript for disk partitioning/apply .wim image etc(autorun.bat). &lt;br /&gt;&lt;strong&gt;Install TFTP/DHCP&lt;/strong&gt;    &lt;br /&gt;Refer to &lt;a href="http://honglus.blogspot.com/2011/06/setup-pxe-boot-server-for-linux-server.html"&gt;http://honglus.blogspot.com/2011/06/setup-pxe-boot-server-for-linux-server.html&lt;/a&gt;    &lt;br /&gt;Just the filename parameter need to be set to:&amp;nbsp; filename "gpxelinux.0"; &lt;br /&gt;&lt;strong&gt;Install pxeserver(syslinux)     &lt;br /&gt;&lt;/strong&gt;The original syslinux package in Centos 5.5 doesn't support memdisk, I use syslinux-4.03    &lt;br /&gt;Upgrade to syslinux-4.03 with RPM binary package, but the gpxelinux.0 need to customized and compiled from source. &lt;br /&gt;&lt;strong&gt;gPXE/pxelinux backgroud&lt;/strong&gt;    &lt;br /&gt;gPXE(&lt;a href="http://etherboot.org/wiki/index.php)"&gt;http://etherboot.org/wiki/index.php)&lt;/a&gt; or it is successor iPXE (&lt;a href="http://www.ipxe.org/)"&gt;http://www.ipxe.org/)&lt;/a&gt; support dynamic configuration using any CGI script and support kernel/images loading over http.    &lt;br /&gt;Because gPXE/iPXE doesn't support memdisk, which is essential for loading winPE ISO image, we have to use pxelinux in syslinux. Fortunately, syslinux integrates gPXE, so we can switch between gPXE and pxelinux freely using CGI script. That is, use gPXE for Linux, use pxelinux for Windows &lt;br /&gt;&lt;strong&gt;Compile customized gPXE in syslinux source file&lt;/strong&gt;&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$cd ${syslinux source}/gpxe/ &lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$vi pxelinux.gpxe&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#!gpxe&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;set use-cached 0&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;dhcp net0&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;chain http://pxe-server/boot/home.php?mac=${net0/mac}&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;# "!gpxe" is interpreter, not a comment line &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;# chain http://pxe-server/boot/home.php?mac=${net0/mac}?will pass the MAC address to a CGI script, which can generate individual configuration based on MAC address&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#To use the DNS name, pxe-server, a working DNS server need to be advertised to DHCP client.&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$make&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$cp gpxelinux.0 /tftpboot/&lt;/pre&gt;&lt;/pre&gt;&lt;b&gt;How does the CGI script work?&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;A CGI script, php in this example, retrieve the MAC address passed by gPXE request, lookup host-os mapping table, then generate PXE configuration dynamically.&lt;br /&gt;&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#The configuration file to define which OS to apply based on MAC address&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$cat ${wwwroot}/boot/hosts/host-os.conf &lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Mac               os&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;08:00:27:4d:4d:aa, centos-5.5-i386&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;08:00:27:b2:40:3e, windows-2008r2-x64&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Linux Server can use gPXE directly&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$curl http://pxe-server/boot/home.php?mac=08:00:27:4d:4d:aa&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#!gpxe&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;imgfree&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;kernel http://pxe-server/boot/os/centos-5.5-i386/pxeboot/vmlinuz ksdevice=link  ks=http://pxe-server/boot/hosts/linux-ks/08-00-27-4d-4d-aa.txt&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;initrd http://pxe-server/boot/os/centos-5.5-i386/pxeboot/initrd.img &lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;boot&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Windows server has to rely on pxelinux to support memdisk(part of syslinux package)&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$curl http://pxe-server/boot/home.php?mac=08:00:27:b2:40:3e&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#!gpxe&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;imgload pxelinux.0&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;boot pxelinux.0&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#A pxelinux config is generated in the mean time &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$cat  /tftpboot/pxelinux.cfg/01-08-00-27-b2-40-3e &lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;default pe&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;label  pe&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;kernel http://pxe-server/boot/os/memdisk&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;append iso&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;initrd http://pxe-server/boot/os/w2k8_pe_x64.iso&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;span class="Apple-style-span" style="font-size: 19px; font-weight: bold;"&gt;&lt;strong&gt;Implementing Zero touch installation/full automation&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;&lt;/strong&gt;Booting up the server via PXE is the first phrase of zero touch installation, OS level automation is done by Linux unattended install: e.g. Kickstart for Redhat Linux family or Windows unattended install:syspreped windows, startnet.cmd in winPE, autoscript in a network share &lt;br /&gt;The following focus on Windows unattended install.&lt;br /&gt;&lt;strong&gt;Download WAIK for Windows 7/Windows 2008 R2&lt;/strong&gt;&lt;br /&gt;&lt;a href="http://www.microsoft.com/download/en/details.aspx?id=5753"&gt;http://www.microsoft.com/download/en/details.aspx?id=5753&lt;/a&gt;&lt;br /&gt;How can you use WAIK for Windows 2008 R2 to deploy Windows2000/xp/2003&lt;br /&gt;&amp;nbsp;It is true that you can't run setup.exe of Windows 2003 in 2008 R2 winPE, but we use imagex tool to capture files, so it works on most Windows OS. &lt;br /&gt;&lt;strong&gt;Create winPE ISO&lt;/strong&gt;&lt;br /&gt;Install the WAIK &amp;nbsp;in WAIK tools computer&lt;br /&gt;Steps to create winPE ISO&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Open the deployment tools command prompt&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#amd64 is for 64bit, use x86 for 32bit&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$\&amp;gt;copype.cmd amd64 C:\winpe_amd64&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;####Optional:Mount the wim file in order to add auto deploy script, you can skip this step to make it easier to get it going.&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;####BEGIN script customization&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$\&amp;gt;imagex /mountrw c:\winpe_amd64\winpe.wim 1 c:\winpe_amd64\mount&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#modify C:\winpe_amd64\mount\Windows\System32\starnet.cmd, add following lines below 'wpeinit'&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;REM -- Start&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;REM Mount Linux samba share&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;net use J: \\pxe-server\windows-media&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;REM go to &lt;span style="color: darkblue;"&gt;sub&lt;/span&gt;-dir(dirname is the mac address) of the samba share &lt;span style="color: blue;"&gt;and&lt;/span&gt; run the auto script&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;J:&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;for&lt;/span&gt; /F  "&lt;span style="color: darkred;"&gt;usebackq tokens=2 delims=:&lt;/span&gt;"  %%i IN (`ipconfig /all ^| find /i "&lt;span style="color: darkred;"&gt;physical address&lt;/span&gt;" `) DO cd %%i&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;autorun.bat&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;REM -- &lt;span style="color: blue;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$\&amp;gt;imagex /unmount c:\winpe_amd64\mount /commit&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#####END script customization&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$\&amp;gt;copy "&lt;span style="color: darkred;"&gt;C:\Program Files\Windows AIK\Tools\amd64\imagex.exe&lt;/span&gt;"  C:\winpe_amd64\ISO\&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$\&amp;gt;copy C:\winpe_amd64\winpe.wim C:\winpe_amd64\ISO\sources\boot.wim&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$\&amp;gt;Oscdimg -n -bC:\winpe_amd64\Etfsboot.com C:\winpe_amd64\ISO C:\winpe_amd64\winpe_amd64.iso&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;&lt;strong&gt;How to do sysprep in Windows 2003?&lt;br /&gt;&lt;/strong&gt;On imagex/sysprep source computer:&lt;br /&gt;Download the latest sysprep tool: &lt;a href="http://www.microsoft.com/download/en/details.aspx?id=14830"&gt;http://www.microsoft.com/download/en/details.aspx?id=14830&lt;/a&gt;&lt;br /&gt;WindowsServer2003-KB926028-v2-x86-ENU.exe /x to extract the deploy.cab file&lt;br /&gt;Extract files in deploy.cab to c:\sysprep&lt;br /&gt;Run setupmgr.exe to create answer file c:\sysprep\Sysprep.inf&lt;br /&gt;Run sysprep /reseal to prepare the OS for imaging&lt;br /&gt;&lt;strong&gt;How to do sysprep in Windows 2008 R2?&lt;/strong&gt;&lt;br /&gt;On WAIK tool computer:&lt;br /&gt;Open Windows system image manager?in WAIK to create unattended answer file&lt;br /&gt;Click New answer file?to select a windows catalogue file (.clg) in installation media \Deploy\Operating Systems\Windows Server 2008 R2 x64\sources\.&lt;br /&gt;In the Windows images?panel, right click various parameters to add to answer file&lt;br /&gt;Detailed instruction:&lt;br /&gt;&lt;a href="http://briandesmond.com/blog/how-to-sysprep-in-windows-server-2008-r2-and-windows-7/"&gt;http://briandesmond.com/blog/how-to-sysprep-in-windows-server-2008-r2-and-windows-7/&lt;/a&gt;&lt;br /&gt;On imagex/sysprep source computer:&lt;br /&gt;Retrieve above new answer file *.xml, Run sysprep /generalize /oobe /shutdown /unattend:unattend.xml? &lt;br /&gt;&lt;strong&gt;Capture image in imagex/sysprep source computer&lt;/strong&gt;&lt;br /&gt;This is manual process, because it is once-off job&lt;br /&gt;Once the imagex/sysprep source computer is shutdown, Reboot it with winpe_amd64.iso by mounting to CDROM or loading via PXE&lt;br /&gt;#The files source is the partition with windows folder, It could be d:, because W2k8 assign c: to the small system partition by default, which&amp;nbsp; doesn't need to be captured.&lt;br /&gt;$\&amp;gt;imagex /compress fast&amp;nbsp; /capture [c:|d:]&amp;nbsp; $sambashare:\boot.wim "w2k8 R2 64bit"&lt;br /&gt;Copy the boot.wim to samba share, which will be used by imagex /apply.&lt;br /&gt;&lt;strong&gt;Apply image in imagex/sysprep target computer&lt;/strong&gt;&lt;br /&gt;This need to be full automatic process, boot winpe_amd64.iso via PXE. Once winPE is initialized, it will mount the sambashare, cd to its own directory and run auorun.bat, which will partition disk and apply the image.&lt;br /&gt;&lt;br /&gt;It is zero touch installation, no human intervention is needed, however, unlike kickstart, computer name/IP address etc can't be configured automatically. Well, in theory, you can specify the information in sysprep then re-capture image for each unique configuration, but it defeats the purpose of saving time in provision. The other way is fresh installation by giving answer file in samba share to setup.exe.&lt;br /&gt;&amp;nbsp;But it can only be used for Visa/2008/7/2008 R2, because there is no winPE which support running setup.exe of pre-Vista Windows&lt;br /&gt;&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ ls $sambashare\08-00-27-b2-40-3e&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;autorun.bat  boot.wim  diskpart.txt&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ cat $sambashare\08-00-27-b2-40-3e\autorun.bat &lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;diskpart /s diskpart.txt&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;PATH=%PATH%;c:;d:;e:;f:&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;imagex /apply boot.wim 1 c: &amp;amp;&amp;amp; bcdboot c:\windows /s c: &amp;amp;&amp;amp; &lt;span style="color: darkblue;"&gt;exit&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#bcdboot c:\windows is not needed for pre-Vista Windows, but it does no harm.&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;It is done, if you have setup answer file properly, the imagex/sysprep target computer should be able to boot smoothly without any human intervention.&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: large; font-weight: bold;"&gt;Issues&amp;nbsp; encountered:&lt;/span&gt;&lt;br /&gt;&lt;b&gt;Q&lt;/b&gt;: DNS name is not resolvable in gPXE.&lt;br /&gt;&lt;b&gt;A&lt;/b&gt;: Make sure set use-cached 0 is set in pxelinux.gpxe, then recompile&lt;br /&gt;$vi pxelinux.gpxe&lt;br /&gt;#!gpxe&lt;br /&gt;set use-cached 0&lt;br /&gt;dhcp net0&lt;br /&gt;chain http://pxe-server/boot/home.php?mac=${net0/mac}&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q:&lt;/b&gt; gPXE couldn't boot Linux kernel with error:Kernel panic not syncing: VFS: unable to mount root fs&lt;br /&gt;&lt;b&gt;A:&lt;/b&gt;Make sure imgfree is the first statement in Linux pxe config&lt;br /&gt;&amp;nbsp;$curl http://pxe-server/boot/home.php?mac=08:00:27:4d:4d:aa&lt;br /&gt;#!gpxe&lt;br /&gt;imgfree&lt;br /&gt;kernel http://pxe-server/boot/os/centos-5.5-i386/pxeboot/vmlinuz ksdevice=link&amp;nbsp; ks=http://pxe-server/boot/hosts/linux-ks/08-00-27-4d-4d-aa.txt&lt;br /&gt;initrd http://pxe-server/boot/os/centos-5.5-i386/pxeboot/initrd.img&lt;br /&gt;boot&lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q:&lt;/b&gt;Error in imagex /apply after booting winPE via PXE: Not Enough Server Storage is available to process is command&lt;br /&gt;&lt;b&gt;A:&lt;/b&gt; Make sure the Windows VM have at least 1G RAM, because winPE ISO will consume a few hundreds MB as memdisk &lt;br /&gt;&lt;br /&gt;&lt;b&gt;Q:&lt;/b&gt;What if the winPE doesn't recognize the device (RAID/NIC) with default drivers.&lt;br /&gt;&lt;b&gt;A:&lt;/b&gt;Add customize driver to winPE, refer to &lt;a href="http://technet.microsoft.com/en-us/library/dd744371%28WS.10%29.aspx"&gt;http://technet.microsoft.com/en-us/library/dd744371%28WS.10%29.aspx&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1822605347830719087-8127448840194564485?l=honglus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://honglus.blogspot.com/feeds/8127448840194564485/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://honglus.blogspot.com/2011/12/build-linux-pxe-server-to-provision.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/8127448840194564485'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/8127448840194564485'/><link rel='alternate' type='text/html' href='http://honglus.blogspot.com/2011/12/build-linux-pxe-server-to-provision.html' title='Build a Linux PXE server to provision Linux and Windows Servers'/><author><name>honglus</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1822605347830719087.post-892288663392654494</id><published>2011-10-13T15:09:00.006+11:00</published><updated>2011-10-13T15:35:23.940+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><category scheme='http://www.blogger.com/atom/ns#' term='Troubleshooting'/><category scheme='http://www.blogger.com/atom/ns#' term='Performance'/><title type='text'>Collectl, an all-in-one tool for collecting Linux statistical data</title><content type='html'>Collectl,collect for Linux, is a single tool which integrates functions of various tools:sar,iostat,mpstat,top,slaptop,netstat,nfstat,ps .. . &lt;br /&gt;- Supported: Linux   &lt;br /&gt;- Requirement: Perl    &lt;br /&gt;&lt;strong&gt;Collectl features:     &lt;br /&gt;&lt;/strong&gt; - run in command line or run as daemon     &lt;br /&gt;- Various output formats: raw,gunplot,gexprt(ganglia),sexpr,lexpr,csv(--sep ,)    &lt;br /&gt;- Send data to other programs (ganglia) remotely via socket instead of writing to a file    &lt;br /&gt;- IPMI monitoring for fans and temperature sensors    &lt;br /&gt;- Support module (Perl scripts)&amp;nbsp; for customized checks     &lt;br /&gt;- Monitor process’s disk read/write, find the top processes keeping disk busy    &lt;br /&gt;The last one is the &lt;strong&gt;most impressive&lt;/strong&gt; feature, I haven’t found other Linux tools can do it. (DTtrace can in Solaris)&lt;br /&gt;&lt;strong&gt;collectl&amp;nbsp; examples&lt;/strong&gt;&lt;br /&gt;&lt;pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#help, all options &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$collect –x&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#-s?, what to monitor:&lt;/span&gt;&lt;span class="Apple-style-span" style="color: green;"&gt;c – cpu&lt;/span&gt;&lt;span class="Apple-style-span" style="color: green;"&gt; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: green;"&gt;d – disk &lt;/span&gt;&lt;span class="Apple-style-span" style="color: green;"&gt;“collectl   --showsubsys”&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span class="Apple-style-span" style="color: green;"&gt;#-c 5 : collect 5 samples and exit&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#-oT:  T - preface output with time only ; “collectl   --showoptions”&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$collectl   -sc -c5 -i2 --verbose -oT&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;waiting &lt;span style="color: blue;"&gt;for&lt;/span&gt; 2 second sample...&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;# CPU SUMMARY (INTR, CTXSW &amp;amp; PROC /sec)&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Time      User  Nice   Sys  Wait   IRQ  Soft Steal  Idle  CPUs  Intr  Ctxsw  Proc  RunQ   Run   Avg1  Avg5 Avg15&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;12:39:34      0     0     0     0     0     1     0    97     1  1082     23     0    76     1   0.42  0.42  0.44&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;12:39:36      0     0     0     0     0     1     0    97     1  1088     24     0    76     1   0.42  0.42  0.44&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;The following demonstrates how collectl identify the process reading/writing most data to disk&lt;br /&gt;&lt;span class="Apple-style-span" style="background-color: white; color: green; font-family: consolas, 'Courier New', courier, monospace; font-size: 12px; white-space: pre;"&gt;#Hammer disk by&amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="background-color: white; color: green; font-family: consolas, 'Courier New', courier, monospace; font-size: 12px; white-space: pre;"&gt;writing 50mb data &lt;/span&gt;&lt;span class="Apple-style-span" style="background-color: white; color: green; font-family: consolas, 'Courier New', courier, monospace; font-size: 12px; white-space: pre;"&gt;with dd &lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$dd &lt;span style="color: blue;"&gt;if&lt;/span&gt;=/dev/urandom of=&lt;span style="color: darkblue;"&gt;test&lt;/span&gt; bs=1k count=50000&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#collectl identifies the “dd” process&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#in top mode, sort by  “iokb   total I/O KB” ; “collectl –showtopopts”&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$collectl -i2  --top iokb&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;TOP PROCESSES sorted by iokb (counters are /sec) 12:50:31&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;# PID  User     PR  PPID THRD S   VSZ   RSS CP  SysT  UsrT Pct  AccuTime  RKB  WKB MajF MinF Command&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;6861  root     18  6784    0 R    3M  572K  0  0.91  0.00  45   0:00.91    0 3680    0   97 dd&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;1  root     15     0    0 S    2M  632K  0  0.00  0.00   0   0:28.21    0    0    0    0 init&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;2  root     RT     1    0 S     0     0  0  0.00  0.00   0   0:00.00    0    0    0    0 migration/0&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1822605347830719087-892288663392654494?l=honglus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://honglus.blogspot.com/feeds/892288663392654494/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://honglus.blogspot.com/2011/10/collectl-all-in-one-tool-for-collecting.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/892288663392654494'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/892288663392654494'/><link rel='alternate' type='text/html' href='http://honglus.blogspot.com/2011/10/collectl-all-in-one-tool-for-collecting.html' title='Collectl, an all-in-one tool for collecting Linux statistical data'/><author><name>honglus</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1822605347830719087.post-7165665824140553492</id><published>2011-10-11T17:15:00.003+11:00</published><updated>2011-10-11T17:19:35.704+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><category scheme='http://www.blogger.com/atom/ns#' term='Troubleshooting'/><title type='text'>Understanding Red Hat Linux recovery runlevels</title><content type='html'>If Linux system can boot but hang during starting a service, booting to “recovery runlevels” can skip the service and gain shell to troubleshoot.   &lt;br /&gt;If Linux system can’t boot at all,&amp;nbsp; booting from rescue CD (first installation media) and type “linux rescue” to gain shell to troubleshoot    &lt;br /&gt;&lt;strong&gt;Red Hat Linux boot order&lt;/strong&gt;&lt;br /&gt;&lt;pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;The BIOS -&amp;gt;MBR-&amp;gt;Boot Loader-&amp;gt;Kernel-&amp;gt;/sbin/init-&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/etc/inittab-&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/etc/rc.d/rc.sysinit-&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/etc/rc.d/rcX.d/ &lt;span style="color: green;"&gt;#where X is run level in /etc/inittab&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;run script with K &lt;span style="color: blue;"&gt;then&lt;/span&gt; script with S&lt;/pre&gt;&lt;/pre&gt;&lt;strong&gt;Recovery runlevels&lt;/strong&gt;&lt;br /&gt;- runlevel&amp;nbsp; 1 &lt;br /&gt;Execute up to /etc/rc.d/rc.sysinit and /etc/rc.d/rc1.d/&lt;br /&gt;Runlevel 1 is identical to singleuser mode. It is switched to singleuser mode in last step, just a number of trivial scripts executed before that.&lt;br /&gt;&amp;nbsp;$ls&amp;nbsp; /etc/rc.d/rc1.d/S*&lt;br /&gt;&amp;nbsp;/etc/rc.d/rc1.d/S02lvm2-monitor&amp;nbsp; /etc/rc.d/rc1.d/S13cpuspeed&amp;nbsp; /etc/rc.d/rc1.d/S99singlesingleuser &lt;br /&gt;&lt;br /&gt;- single&lt;br /&gt;Execute up to /etc/rc.d/rc.sysinit&lt;br /&gt;&lt;br /&gt;- Emergency&lt;br /&gt;Does not execute /etc/rc.d/rc.sysinit. &lt;br /&gt;&amp;nbsp;Because rc.sysinit is not executed, file system is mounted in read-only mode. You need run “mount –o rw,remount /” to remount it in read-write mode.&lt;br /&gt;emergency runlevel is Red Hat term, it is identical to&amp;nbsp; “init=/bin/sh” in any Linux distribution&lt;br /&gt;&lt;strong&gt;How to go to a&amp;nbsp; runlevel&lt;/strong&gt;&lt;br /&gt;In the grub menu, type “a” to append one of following options to boot line.&lt;br /&gt;1&amp;nbsp;&amp;nbsp; &lt;br /&gt;single&amp;nbsp;&amp;nbsp; &lt;br /&gt;emergency&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;init=/bin/sh&lt;br /&gt;&lt;a href="http://honglus.blogspot.com/2011/03/when-centos-hung-on-starting-up-boot.html" target="_blank"&gt;When Centos hung on starting up boot services, how to get to shell without rescue CD&lt;/a&gt;&lt;br /&gt;&lt;a href="http://honglus.blogspot.com/2009/03/rhce-notes-troubleshooting-booting.html" target="_blank"&gt;RHCE Notes - Troubleshooting booting issue&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1822605347830719087-7165665824140553492?l=honglus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://honglus.blogspot.com/feeds/7165665824140553492/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://honglus.blogspot.com/2011/10/understanding-red-hat-linux-recovery.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/7165665824140553492'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/7165665824140553492'/><link rel='alternate' type='text/html' href='http://honglus.blogspot.com/2011/10/understanding-red-hat-linux-recovery.html' title='Understanding Red Hat Linux recovery runlevels'/><author><name>honglus</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1822605347830719087.post-4307631714288772652</id><published>2011-10-11T12:33:00.002+11:00</published><updated>2011-10-11T12:35:18.311+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tips/Tricks'/><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><title type='text'>Advanced RPM topics</title><content type='html'>&lt;strong&gt;Query     &lt;br /&gt;&lt;/strong&gt;“queryformat”&amp;nbsp; option can query every piece information of a rpm package, the&amp;nbsp; information tags (macros ) are returned&amp;nbsp; by “rpm –querytags” command&lt;br /&gt;&lt;pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#list top 2 rpm packages sorted by installation time&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$rpm -qa  | xargs -I{} rpm -q --queryformat "&lt;span style="color: darkred;"&gt;{}        %{installtime}\n&lt;/span&gt;" {} | sort -rn -k2 | head -2&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;collectl-3.5.1-1        1317864013&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;git-1.7.4.1-1.el5        1316484590&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#unfortunately the time returned is unixtime.  You can convert it to human readable format by  “date –d @timestring” e.g &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$date -d @1317864013&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Thu Oct  6 12:20:13 EST 2011&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#but there is a shortcut  “--last”&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ rpm -qa --last  | head -2&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;collectl-3.5.1-1                              Thu 06 Oct 2011 12:20:13 PM EST&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;git-1.7.4.1-1.el5                             Tue 20 Sep 2011 12:09:50 PM EST&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;"rpm -qa" supports regular expression itself, rather than pipe to grep e.g “rpm -qa | grep perl”&lt;br /&gt;“rpm –qa perl\*” also works. There is no improvement on speed but typing become lesser.&lt;br /&gt;&lt;strong&gt;requires and provides&lt;/strong&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="background-color: white; color: green; font-family: consolas, 'Courier New', courier, monospace; font-size: 12px; white-space: pre;"&gt;#You can check the package dependency before install the package &lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ rpm -qp --requires git-1.7.6-1.el5.rf.i386.rpm&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;..&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;libssl.so.6 &lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;…&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#To meet the dependency, you want to check who provides libssl.so.6 &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$yum whatprovides libssl.so.6&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;openssl-0.9.8e-20.el5.i686 : The OpenSSL toolkit&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Repo        : base&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Matched from:&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Other       : libssl.so.6&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#if openssl has been installed, “rpm -q –whatprovides” can also provide the answer&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$rpm -q --whatprovides libssl.so.6&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;openssl-0.9.8e-12.el5_4.6&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;&lt;strong&gt;rpm scriptlets&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#query all nopre|nopost|nopreun|nopostun  scripts&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$rpm -q --scripts xinetd&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;postinstall scriptlet (using /bin/sh):&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;if&lt;/span&gt; [ $1 = 1 ]; &lt;span style="color: blue;"&gt;then&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/sbin/chkconfig --add xinetd&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;fi&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;preuninstall scriptlet (using /bin/sh):&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;if&lt;/span&gt; [ $1 = 0 ]; &lt;span style="color: blue;"&gt;then&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/sbin/service xinetd stop &amp;gt; /dev/null 2&amp;gt;&amp;amp;1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/sbin/chkconfig --del xinetd&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;fi&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;postuninstall scriptlet (using /bin/sh):&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;if&lt;/span&gt; [ $1 -ge 1 ]; &lt;span style="color: blue;"&gt;then&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/sbin/service xinetd condrestart &amp;gt;/dev/null 2&amp;gt;&amp;amp;1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Fi&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#query postinstall script only&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ rpm -q --queryformat "&lt;span style="color: darkred;"&gt;%{POSTIN}&lt;/span&gt;"  xinetd&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;if&lt;/span&gt; [ $1 = 1 ]; &lt;span style="color: blue;"&gt;then&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/sbin/chkconfig --add xinetd&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Don’t run the scripts during install/remove&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;rpm –i –noscripts|nopre|nopost|nopreun|nopostun   pkgname&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;rpm –e –noscripts|nopre|nopost|nopreun|nopostun   pkgname&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;&lt;strong&gt;Extract rpm contents without install&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#use rpm2cpio to extract everything&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$mkdir /tmp/epel&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ cd /tmp/epel&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ rpm2cpio /root/epel-release-5-4.noarch.rpm | cpio -ivd&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;./etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;..&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#use rpm2cpio to extract particular file&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$rpm2cpio /root/epel-release-5-4.noarch.rpm | cpio -ivd  ./usr/share/doc/epel-release-5&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#another way is to use rpm install with alternative root&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ rpm --root /tmp/epel/ -ivh  --nodeps /root/epel-release-5-4.noarch.rpm&lt;/pre&gt;&lt;/pre&gt;&lt;a href="http://honglus.blogspot.com/2011/09/recover-corrupted-rpm-database.html" target="_blank"&gt;Recover corrupted rpm database&lt;/a&gt;&lt;br /&gt;&lt;a href="http://honglus.blogspot.com/2011/05/build-rpm-from-source-file.html" target="_blank"&gt;Build RPM from source file&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1822605347830719087-4307631714288772652?l=honglus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://honglus.blogspot.com/feeds/4307631714288772652/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://honglus.blogspot.com/2011/10/advanced-rpm-topics.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/4307631714288772652'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/4307631714288772652'/><link rel='alternate' type='text/html' href='http://honglus.blogspot.com/2011/10/advanced-rpm-topics.html' title='Advanced RPM topics'/><author><name>honglus</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1822605347830719087.post-1518354837948748571</id><published>2011-09-15T16:17:00.002+10:00</published><updated>2011-09-15T16:18:46.269+10:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Tips/Tricks'/><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><title type='text'>Get information for inode or block of a file and vice versa</title><content type='html'>Debugfs can retrieve a file’s inode or block information and vice versa, it is provided by e2fsprogs package, which should be installed by default.    &lt;br /&gt;&lt;b&gt;Find a file’s information for inode or block&lt;/b&gt;&lt;br /&gt;&lt;pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#find a file’s inode id by ls, the sample file’s inode number is 12&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ls -li /boot/message&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;12 -rw-r--r-- 1 root root 80032 Mar 13  2009 /boot/message&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#find a file’s inode or block info by debugfs&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$echo "&lt;span style="color: darkred;"&gt;stat message&lt;/span&gt;" | debugfs /dev/sda1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;debugfs 1.39 (29-May-2006)&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;debugfs:  Inode: 12   Type: regular    Mode:  0644   Flags: 0x0   Generation: 3354433043&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;User:     0   Group:     0   Size: 80032&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;a href="http://www.ruby-doc.org/docs/rdoc/1.9/classes/File.html" style="color: red;"&gt;File&lt;/a&gt; ACL: 4640    Directory ACL: 0&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Links: 1   Blockcount: 162&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Fragment:  Address: 0    Number: 0    Size: 0&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;ctime: 0x4e2371f6 -- Mon Jul 18 09:36:22 2011&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;atime: 0x49b95d4d -- Fri Mar 13 06:06:53 2009&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;mtime: 0x49b95d4d -- Fri Mar 13 06:06:53 2009&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;BLOCKS:&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;(0-11):7681-7692, (IND):7693, (12-78):7694-7760&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;TOTAL: 80&lt;/pre&gt;&lt;/pre&gt;&lt;b&gt;Find a file based on inode or block info&lt;/b&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="background-color: white; color: green; font-family: consolas, 'Courier New', courier, monospace; font-size: 12px; white-space: pre;"&gt;#find a file based on inode number by find, but it may take long time to search&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$find /boot/ -inum 12&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/boot/message&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#find a file based on inode number by debugfs&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$echo -e "&lt;span style="color: darkred;"&gt;ncheck 12&lt;/span&gt;" | debugfs /dev/sda1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;debugfs:  Inode Pathname&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;12    /message&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##find a file based on block number by debugfs&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#use icheck to find inode number based on block number first&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$echo -e "&lt;span style="color: darkred;"&gt;icheck 7693 &lt;/span&gt;" | debugfs /dev/sda1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;debugfs:  Block Inode number&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;7693  12&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#then use ncheck find the file by inode number&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$echo -e "&lt;span style="color: darkred;"&gt;ncheck 12 &lt;/span&gt;" | debugfs /dev/sda1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;debugfs:  Inode Pathname&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;12    /message&lt;/pre&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1822605347830719087-1518354837948748571?l=honglus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://honglus.blogspot.com/feeds/1518354837948748571/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://honglus.blogspot.com/2011/09/get-information-for-inode-or-block-of.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/1518354837948748571'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/1518354837948748571'/><link rel='alternate' type='text/html' href='http://honglus.blogspot.com/2011/09/get-information-for-inode-or-block-of.html' title='Get information for inode or block of a file and vice versa'/><author><name>honglus</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1822605347830719087.post-1713072573680489859</id><published>2011-09-15T11:30:00.003+10:00</published><updated>2011-09-15T16:20:47.900+10:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><category scheme='http://www.blogger.com/atom/ns#' term='Troubleshooting'/><title type='text'>Recover corrupted RPM database</title><content type='html'>RPM database consists of a number Berkeley DB&amp;nbsp;&amp;nbsp; files in&amp;nbsp; /var/lib/rpm, the exception&amp;nbsp; is&amp;nbsp; __db.* files, which like cache files are updated for every rpm operation and they can be safely deleted.&lt;br /&gt;&lt;pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#tested in Centos 5.5 &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ ls /var/lib/rpm&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Basenames     __db.001  __db.003  Filemd5s  Installtid  Packages      Provideversion  Requireversion  Sigmd5&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Conflictname  __db.002  Dirnames  Group     Name         Providename   Pubkeys         Requirename  Sha1header      Triggername&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ file /var/lib/rpm/Packages&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/var/lib/rpm/Packages: Berkeley DB (&lt;a href="http://www.ruby-doc.org/docs/rdoc/1.9/classes/Hash.html" style="color: red;"&gt;Hash&lt;/a&gt;, version 8, native byte-order)&lt;/pre&gt;&lt;/pre&gt;&lt;b&gt;If one of the DB files is partially corrupted and it is still readable by /usr/lib/rpm/rpmdb_dump, you can reload the DB file and rebuild db&lt;/b&gt;.&lt;br /&gt;&lt;span class="Apple-style-span" style="background-color: white; font-family: consolas, 'Courier New', courier, monospace; font-size: 12px; white-space: pre;"&gt;$cd /var/lib/rpm&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$rm -f __db*      &lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$mv Packages Packages.orig&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$/usr/lib/rpm/rpmdb_dump Packages.orig | /usr/lib/rpm/rpmdb_load Packages&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$/usr/lib/rpm/rpmdb_verify Packages&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#if you got this error: db_verify: PANIC: fatal region error detected; run recovery&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#make sure /var/lib/rpm/__db.* are cleaned&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#It is unlikely to rebuilddb if rpmdb_verify fails&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$rpm -v –rebuilddb&lt;/pre&gt;&lt;/pre&gt;&lt;b&gt;If one of the DB files is completely corrupted and it is not readable by rpmdb_dump, you have to restore from backup,&lt;/b&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="background-color: white; font-family: consolas, 'Courier New', courier, monospace; font-size: 12px; white-space: pre;"&gt;$cd  /var/lib/rpm&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$cp Packages Packages.bak&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#simulate a damaged RPM DB file&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ &amp;gt;Packages&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ cp Packages.bak  Packages&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;# Simply restoring  from backup file won’t work&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#file verification is successful &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ /usr/lib/rpm/rpmdb_verify Packages&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#but any rpm operation fails&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$rpm -qa &lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;error: rpmdbNextIterator: skipping h&lt;span style="color: green;"&gt;&lt;span style="color: black;"&gt;#     294 Header V3 DSA signature: BAD, key ID e8562897&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Even “rpm –rebuilddb” fails&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$rm -f __db.*&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$rpm –rebuilddb&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;error: rpmdbNextIterator: skipping h&lt;span style="color: green;"&gt;&lt;span style="color: black;"&gt;#     294 Header V3 DSA signature: BAD, key ID e8562897&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Notice the error about signature: BAD? The Pubkeys have to be cleaned as well.&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ mv Pubkeys Pubkeys.bak&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#all good after removing Pubkeys file, a new Pubkeys is generated automatically on “rpm –rebuilddb”&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ rm -f __db.*&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ rpm –rebuilddb&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ rpm -qa | head -2&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;man-pages-2.39-15.el5_4&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;bash-3.2-24.el5&lt;/pre&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1822605347830719087-1713072573680489859?l=honglus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://honglus.blogspot.com/feeds/1713072573680489859/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://honglus.blogspot.com/2011/09/recover-corrupted-rpm-database.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/1713072573680489859'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/1713072573680489859'/><link rel='alternate' type='text/html' href='http://honglus.blogspot.com/2011/09/recover-corrupted-rpm-database.html' title='Recover corrupted RPM database'/><author><name>honglus</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1822605347830719087.post-8002073667138637635</id><published>2011-08-04T21:35:00.008+10:00</published><updated>2011-08-04T22:11:33.263+10:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><title type='text'>Authenticate Linux users by Windows AD: LDAP+Kerberos or Winbind method</title><content type='html'>Authenticating Linux users by Windows AD has become popular in many organizations for the convenience of centralized account management. It makes sense, if you need existing Windows account to login to Linux servers, but it doesn’t make sense to install a new Windows AD for the sole purpose of authenticating Linux users, just because Windows has a nice GUI. Redhat Directory Server/Centos Directory Server/389 Directory Server all&amp;nbsp; are capable of doing such task beautifully by ldap+StartTLS or ldap+Kerberos. &lt;br /&gt;At least, there are 4 ways to authenticate Linux users by Windows AD:    &lt;br /&gt;&lt;strong&gt;1.&amp;nbsp;&amp;nbsp;&amp;nbsp; Linux Clients use Linux LDAP server synchronized with Windows AD.      &lt;br /&gt;&lt;/strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Replicate a subtree of Windows AD accounts to Linux Ldap Server (Redhat Directory Server/Centos Directory Server/389 Directory Server), Linux users authenticate against the&amp;nbsp;&amp;nbsp; Linux LDAP Server either by Ldap+StartTLS or Ldap+Kerberos     &lt;br /&gt;A more complex approach, it is for those who don’t like a Windows AD sitting in datacenter.     &lt;br /&gt;&lt;strong&gt;2.&amp;nbsp;&amp;nbsp;&amp;nbsp; Linux Client use LDAP or LDAP+SSL(ldaps) or LDAP+StartTLS      &lt;br /&gt;&lt;/strong&gt;User information store: LDAP     &lt;br /&gt;Authentication: LDAP or LDAP+SSL(ldaps) or LDAP+StartTLS     &lt;br /&gt;Limitation: Client can login but can’t change its password     &lt;br /&gt;&lt;strong&gt;3.&amp;nbsp;&amp;nbsp;&amp;nbsp; Linux Client use ldap+Kerberos      &lt;br /&gt;&lt;/strong&gt;User information store: LDAP     &lt;br /&gt;Authentication: Kerberos     &lt;br /&gt;The most popular approach, work out of the box, no need to install additional software. User can change&amp;nbsp; its password. &lt;br /&gt;A vbscript to add unix user to windows AD.&lt;br /&gt;&lt;a href="http://honglus.blogspot.com/2009/04/add-unix-user-to-windows-ad-by-vbscript.html"&gt;http://honglus.blogspot.com/2009/04/add-unix-user-to-windows-ad-by-vbscript.html&lt;/a&gt;&lt;br /&gt;&lt;strong&gt;4.&amp;nbsp;&amp;nbsp;&amp;nbsp; Linux Client use samba Winbind      &lt;br /&gt;&lt;/strong&gt;User information store: Winbind local file or winbind ldap     &lt;br /&gt;Authentication: Winbind     &lt;br /&gt;Cons to solution #3 ldap+Kerberos approach:     &lt;br /&gt;- /etc/init.d/windbind dameon need to be running     &lt;br /&gt;- The Linux client&amp;nbsp; has to be joined to the domain, it is showed in computers container.     &lt;br /&gt;- The UID/GID is derived from Windows SID(ID = RID - BASE_RID + LOW RANGE ID, "man 8 idmap_rid"), you don’t seem to have a choice to set to a specific number.     &lt;br /&gt;Pros to solution #3 ldap+Kerberos approach:     &lt;br /&gt;- No need to insall Service for Unix in Windows&lt;br /&gt;This post demonstrate method #3 ldap+kerberos and #4&amp;nbsp; Winbind.&lt;br /&gt;Linux OS: Centos 5.5    &lt;br /&gt;Windows OS: Window 2003     &lt;br /&gt;FQDN: server1.ad.example.com     &lt;br /&gt;Domainname/Realm: ad.example.com&lt;br /&gt;&lt;h4&gt;Linux Clients use&amp;nbsp; ldap+Kerberos &lt;/h4&gt;&lt;strong&gt;&lt;/strong&gt;    &lt;br /&gt;&lt;strong&gt;Setup Windows Server&lt;/strong&gt;     &lt;br /&gt;- Install&amp;nbsp; “Windows Services for UNIX Version 3.5” for Windows 2003     &lt;br /&gt;&amp;nbsp;&amp;nbsp; Windows 2003 R2 or Windows 2008 has built-in component “Server for NIS Service”     &lt;br /&gt;- Create a generic user account for Linux nss-ldap client to run ldap query with the credentials.     &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; e.g username=Linux-bind-user&amp;nbsp; password=Redhat123     &lt;br /&gt;- Create a test group, go to “Unix Attribute tab” to set GID etc     &lt;br /&gt;- Create a test user, go to “Unix Attribute tab”, to set uid/homedir/shell/gid etc     &lt;br /&gt;- Modify default domain security group policy to allow users change password immediately, by default it is 1 day, change it to 0 day. &lt;br /&gt;&lt;strong&gt;Set up Linux client&lt;/strong&gt;&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#make sure the following pkgs are installed &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;krb5-workstation&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;openldap-clients&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;nss_ldap&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;pam_krb5&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Edit configuration files: /etc/nsswitch.conf; /etc/ldap.conf; /etc/krb5.conf; /etc/pam.d/system-auth&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#The easiest way is to run authconfig-tui.&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Before run the command, empty config files for easy reading&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$cat /dev/null &amp;gt;/etc/ldap.conf ; cat /dev/null &amp;gt; /etc/krb5.conf&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$authconfig-tui       &lt;span style="color: green;"&gt;#select use ldap for “User information” and “use md5 passwords, use shadow passwords, use Kerberos,local authorization is sufficient” for authentication.&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$cat /etc/ldap.conf&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;uri ldap://server1.ad.example.com/&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;base cn=Users,dc=ad,dc=example,dc=com&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;ssl no&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;binddn cn=linux-bind-user,cn=users,dc=ad,dc=example,dc=com&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;bindpw Redhat123&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##Map Unix account attributes to Winnows SFU 3.5 attributes&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##NOTE: Windows 2003 R2/Windows 2008 use different name&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##In either scheme, the attribute can be retrieved by ldapsearch command&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#$ldapsearch –x –W –b ”cn=Users,dc=ad,dc=example,dc=com” –D “cn=linux-bind-user,cn=users,dc=ad,dc=example,dc=com” &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#....&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#msSFU30Name: jsmith&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#msSFU30UidNumber: 10001&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#...&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;nss_map_objectclass posixAccount User&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;nss_map_objectclass shadowAccount User&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;nss_map_objectclass posixGroup Group&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;nss_map_attribute uid sAMAccountName&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;nss_map_attribute uidNumber msSFU30uidNumber&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;nss_map_attribute gidNumber msSFU30gidNumber&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;nss_map_attribute gecos         name&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;nss_map_attribute homeDirectory msSFU30HomeDirectory&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;nss_map_attribute loginShell msSFU30loginShell&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;pam_login_attribute sAMAccountName&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;pam_filter objectclass=User&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;nss_base_password cn=Users,dc=ad,dc=example,dc=com&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;nss_base_shadow cn=Users,dc=ad,dc=example,dc=com&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;nss_base_group cn=Users,dc=ad,dc=example,dc=com&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;pam_password ad&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Optional, "referrals yes" try to connect both ldap://server1.ad.example.com and ldap://ad.example.com&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;referrals       no&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$cat /etc/krb5.conf&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##[logging] section is not needed, I think, it is  for KDC daemon running locally only&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;[libdefaults]&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;default_realm = AD.EXAMPLE.COM                    &lt;span style="color: green;"&gt;#realm name MUST be in capitals &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;dns_lookup_realm = &lt;span style="color: blue;"&gt;false&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;dns_lookup_kdc = &lt;span style="color: blue;"&gt;false&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;[realms]&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;AD.EXAMPLE.COM = {&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;kdc = server1.ad.example.com&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;admin_server = server1.ad.example.com&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##domain to realm mapping is also optional for user login, it is for the host added to KDC as principal to provide service&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;[domain_realm]&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;.example.com = AD.EXAMPLE.COM&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;example.com = AD.EXAMPLE.COM&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#nsswitch.conf system-auth don’t need to be further customization after “authconfig-tui” is run, just post them for reference&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$cat /etc/nsswitch.conf&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;passwd:     files ldap&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;shadow:     files ldap&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;group:      files ldap&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$grep krb5  /etc/pam.d/&lt;span style="color: darkblue;"&gt;system&lt;/span&gt;-auth&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;auth        sufficient    pam_krb5.so use_first_pass&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;account     [default=bad success=ok user_unknown=ignore] pam_krb5.so&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;password    sufficient    pam_krb5.so use_authtok&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;session     optional      pam_krb5.so&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Test LDAP+Kerberos&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Query LDAP user information or run getent password|shadow|group to list all &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$id jsmith &lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;uid=10001(jsmith) gid=10000(unix-&lt;span style="color: darkblue;"&gt;test&lt;/span&gt;-group) groups=10000(unix-&lt;span style="color: darkblue;"&gt;test&lt;/span&gt;-group)&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Troubleshooting&lt;/strong&gt; &lt;br /&gt;Error:&lt;br /&gt;pam_krb5[5330]: password change failed for jsmith@AD.EXAMPLE.COM: Password change rejected, Password change rejected&lt;br /&gt;Solution:&lt;br /&gt;test changing password in Windows GUI, Make sure the password meet password complexity policy and minimum change day is 0&lt;br /&gt;&lt;br /&gt;Error:&lt;br /&gt;&amp;nbsp;Authentication failure (Cannot find KDC for requested realm) &lt;br /&gt;$ kinit&lt;br /&gt;kinit(v5): Cannot find KDC for requested realm while getting initial credentials&lt;br /&gt;Solution:&lt;br /&gt;check the relam spelling is correct and all in UPPER case, e.g AD.EXAMPLE.COM &lt;br /&gt;&lt;br /&gt;ERROR: &lt;br /&gt;&amp;nbsp;Authentication failure (Clock skew too great) &lt;br /&gt;Solution:&lt;br /&gt;synchronize datetime with AD and enable ntpd&lt;br /&gt;$ntpdate -s server1.ad.example.com&lt;br /&gt;&lt;br /&gt;Enable DEBUG:&lt;br /&gt;$cat /etc/ldap.conf &lt;br /&gt;&amp;nbsp;debug 7&lt;br /&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;Linux Clients use&amp;nbsp; samba Winbind&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Windows required software&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Windows Services &lt;span style="color: blue;"&gt;for&lt;/span&gt; UNIX is &lt;span style="color: blue;"&gt;not&lt;/span&gt; needed&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Linux required software&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;samba-client&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;samba-common&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;krb5-workstation&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Clear /etc/ldap.conf and /etc/krb5.conf in last test&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$cat /dev/null &amp;gt;/etc/ldap.conf; $cat /dev/null &amp;gt;/etc/krb5.conf; &lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$authconfig-tui&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#select use winbind for “User information” and “use md5 passwords, use shadow passwords, use winbind,local authorization is sufficient” for authentication.&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#supply following information and  type in "domain admin"'s username password to join domain&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$cat /etc/samba/smb.conf&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;[global]&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#--authconfig--start-line--&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;workgroup = AD&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;password server = server1.ad.example.com&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;realm = AD.EXAMPLE.COM&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;security = ads&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;idmap uid = 16777216-33554431&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;idmap gid = 16777216-33554431&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;template shell = /bin/bash&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;winbind offline logon = &lt;span style="color: blue;"&gt;false&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##above lines are generated by authconfig-tui&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##following 3 parameters need mannual customization&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;winbind use default domain = &lt;span style="color: blue;"&gt;true&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;winbind enum users = yes&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;winbind enum groups = yes&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#--authconfig--end-line--&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##Other files don't need further customization, just paste here for reference&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$cat /etc/krb5.conf&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;[libdefaults]&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;default_realm = AD.EXAMPLE.COM&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;dns_lookup_realm = &lt;span style="color: blue;"&gt;false&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;dns_lookup_kdc = &lt;span style="color: blue;"&gt;false&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;[realms]&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;AD.EXAMPLE.COM = {&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;kdc = server1.ad.example.com&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$grep winbind /etc/pam.d/&lt;span style="color: darkblue;"&gt;system&lt;/span&gt;-auth&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;auth        sufficient    pam_winbind.so use_first_pass&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;account     [default=bad success=ok user_unknown=ignore] pam_winbind.so&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;password    sufficient    pam_winbind.so use_authtok&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$grep winbind /etc/nsswitch.conf&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;passwd:     files winbind&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;shadow:     files winbind&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;group:      files winbind&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;&lt;strong&gt;Test winbind&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$wbinfo -u&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;jsmith&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$gettent passwd&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;jsmith:*:16777216:16777216:John smith:/home/AD/jsmith:/bin/bash&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##Group membership is added by opening the group, then click add member button in Windows GUI&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$id jsmith&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;uid=16777216(jsmith) gid=16777216(domain users) groups=16777216(domain users),16777225(unix-&lt;span style="color: darkblue;"&gt;test&lt;/span&gt;-group)&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1822605347830719087-8002073667138637635?l=honglus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://honglus.blogspot.com/feeds/8002073667138637635/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://honglus.blogspot.com/2011/08/authenticate-linux-users-by-windows-ad.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/8002073667138637635'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/8002073667138637635'/><link rel='alternate' type='text/html' href='http://honglus.blogspot.com/2011/08/authenticate-linux-users-by-windows-ad.html' title='Authenticate Linux users by Windows AD: LDAP+Kerberos or Winbind method'/><author><name>honglus</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1822605347830719087.post-7472339837047782469</id><published>2011-07-31T10:50:00.001+10:00</published><updated>2011-07-31T10:51:11.360+10:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='RHCE/RHCA'/><title type='text'>Passed 3/5 RHCA: EX333 Security Network Services</title><content type='html'>&lt;p&gt;I would probably rate EX333 as the most difficult exam among the 3 exams I have passed, Why&amp;#160; is it so difficult?&lt;/p&gt;  &lt;p&gt;1. The exam objectives are related: for example, Kerberos depends on NIS, without a working NIS, you are doomed.&lt;/p&gt;  &lt;p&gt;2. The exam is broken into morning section and afternoon section, You won’t pass the exam&amp;#160; if either section fails. but&amp;#160; you are still allowed to sit for the afternoon section despite&amp;#160; the result of morning section. &lt;/p&gt;  &lt;p&gt;My blog post for EX333 study notes:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://honglus.blogspot.com/2011/04/authenticate-bind-zone-transfer-with.html" target="_blank"&gt;Authenticate BIND zone transfer with TSIG key&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://honglus.blogspot.com/2011/04/setup-postfix-smtp-password.html" target="_blank"&gt;Setup Postfix SMTP password authentication with SASL&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1822605347830719087-7472339837047782469?l=honglus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://honglus.blogspot.com/feeds/7472339837047782469/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://honglus.blogspot.com/2011/07/passed-35-rhca-ex333-security-network.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/7472339837047782469'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/7472339837047782469'/><link rel='alternate' type='text/html' href='http://honglus.blogspot.com/2011/07/passed-35-rhca-ex333-security-network.html' title='Passed 3/5 RHCA: EX333 Security Network Services'/><author><name>honglus</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1822605347830719087.post-8210606573575794995</id><published>2011-07-06T16:50:00.002+10:00</published><updated>2011-07-06T16:53:10.547+10:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><title type='text'>CentOS Directory Server 8 Quickstart</title><content type='html'>CentOS Directory Server&amp;nbsp; is a rebuild of the Red Hat Directory Server.&amp;nbsp; Red Hat Directory Server, Fedora 389 Directory server,&amp;nbsp; and Sun One Directory Server are similar, because they&amp;nbsp; all originated from Netscape Directory Server (NDS).&amp;nbsp; OpenLDAP is also a member of the extended family , whose root is University of Michigan slapd project, the parent of Netscape Directory Server.&amp;nbsp; The obvious difference is that OpenLDAP doesn't have built-in management console.&lt;br /&gt;&lt;a href="http://lh3.ggpht.com/-nbCs0TpCuac/ThQFmC422qI/AAAAAAAAAJc/QGVKDLMLvX4/s1600-h/image%25255B6%25255D.png"&gt;&lt;img alt="image" border="0" height="462" src="http://lh5.ggpht.com/-M84RCINiA_o/ThQFnRBzbeI/AAAAAAAAAJg/L4P18HEhELg/image_thumb%25255B2%25255D.png?imgmax=800" style="border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: inline;" title="image" width="644" /&gt;&lt;/a&gt;     &lt;br /&gt;&lt;strong&gt;Install CentOS Directory Server (CDS)&amp;nbsp; 8.1.0&amp;nbsp; on Centos&amp;nbsp; 5.5&lt;/strong&gt;&lt;br /&gt;&lt;pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#CDS requires Centos 5.3 or newer&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#install openldap-clients, as CDS ldap clients are not very friendly&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$yum install java-1.6.0-openjdk openldap-clients centos-ds&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Link /usr/bin/java to the java 1.6 binary&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$alternatives --config java&lt;br /&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;&lt;strong&gt;Setup&amp;nbsp; CentOS Directory Server&lt;/strong&gt; &lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Create ldap user/group for ldap daemon&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$groupadd ldap; useradd -g ldap -s /sbin/nologin ldap&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Start installation wizard &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$setup-ds-admin.pl&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#start management console&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$centos-idm-console&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;&lt;strong&gt;CentOS Directory Server directory structure &lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/etc/init.d/dirsrv    &lt;span style="color: green;"&gt;#server startup script&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/etc/init.d/dirsrv-admin   &lt;span style="color: green;"&gt;#admin server startup script&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/etc/dirsrv/slapd-$instance/   &lt;span style="color: green;"&gt;#server config&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/etc/dirsrv/slapd-$instance/dse.ldif   &lt;span style="color: green;"&gt;#server config for "cn=config"&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/etc/dirsrv/slapd-$instance/scheme/99user.ldif &lt;span style="color: green;"&gt;#user defined scheme&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/etc/dirsrv/admin-serv     &lt;span style="color: green;"&gt;#admin server config&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/usr/lib/dirsrv/slapd-$instance/    &lt;span style="color: green;"&gt;#useful scripts: start&amp;amp;stop; backup&amp;amp;restore ...&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/var/lib/dirsrv/slapd-$instance/db/      &lt;span style="color: green;"&gt;#database &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/var/lib/dirsrv/slapd-$instance/bak    &lt;span style="color: green;"&gt;#default backup dir&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/var/log/dirsrv/slapd-$instance/    &lt;span style="color: green;"&gt;#logs&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ldapsearch -x -s base -b "&lt;span style="color: darkred;"&gt;&lt;/span&gt;"  &lt;span style="color: green;"&gt;# Root DSE; Show version, supported plugin etc&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;&lt;strong&gt;CentOS Directory Server backup and restore&lt;/strong&gt; &lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##Backup&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#/etc/dirsrv/slapd-$instance/dse.ldif needs to be backup manually.&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;1) &lt;span style="color: blue;"&gt;in&lt;/span&gt; GUI, &lt;span style="color: darkblue;"&gt;select&lt;/span&gt; backup Directory Server&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;2) &lt;span style="color: blue;"&gt;in&lt;/span&gt; CLI, /usr/lib/dirsrv/slapd-$instance/db2bak&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##Restore&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#stop ldap server&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$service dirsrv stop&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Restore using CLI, Usage: bak2db archivedir [-n backendname]&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$/usr/lib/dirsrv/slapd-station08/bak2db /var/lib/dirsrv/slapd-station08/bak/station08-2011_06_30_15_11_51 -n userRoot&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#By default,  backend instance name is  userRoot or NetscapeRoot&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$grep  nsslapd-backend /etc/dirsrv/slapd-station08/dse.ldif&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;nsslapd-backend: userRoot&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;nsslapd-backend: NetscapeRoot&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;&lt;strong&gt;CentOS Directory Server export and import&lt;/strong&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: green; font-family: consolas, 'Courier New', courier, monospace; font-size: 12px; white-space: pre;"&gt;##---------------------Export to ldif&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;1) &lt;span style="color: blue;"&gt;in&lt;/span&gt; GUI, tasks -&amp;gt; export databases. &lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;2) &lt;span style="color: blue;"&gt;in&lt;/span&gt; CLI, db2ldif&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Find out instance name&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ /usr/lib/dirsrv/slapd-$instance/suffix2instance -s "&lt;span style="color: darkred;"&gt;dc=stationn08, dc=example, dc=com&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Suffix, Instance name pair(s) under "&lt;span style="color: darkred;"&gt;dc=stationn08,dc=example,dc=com&lt;/span&gt;":&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;suffix "&lt;span style="color: darkred;"&gt;dc=station08, dc=example, dc=com&lt;/span&gt;"; instance name "&lt;span style="color: darkred;"&gt;userRoot&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$grep  nsslapd-backend /etc/dirsrv/slapd-station08/dse.ldif&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;nsslapd-backend: userRoot&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;nsslapd-backend: NetscapeRoot&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Export using backend instance name&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$/usr/lib/dirsrv/slapd-$instance/db2ldif -n userRoot -a /tmp/all-userroot.ldif&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Export using suffix name&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$/usr/lib/dirsrv/slapd-$instance/db2ldif -s  'dc=example,dc=com'  -a /tmp/all.ldif&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##---------------------Import from ldif&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#if Server is live&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;in&lt;/span&gt; GUI, Tasks-&amp;gt;Import databases; &lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;in&lt;/span&gt; CLI, ldif2db.pl (It is recommended to use GUI &lt;span style="color: blue;"&gt;for&lt;/span&gt; &lt;span style="color: darkblue;"&gt;import&lt;/span&gt; due to the complexity of the script).&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#If server is offline, use ldif2db script&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$service dirsrv stop&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$/usr/lib/dirsrv/slapd-$instance/ldif2db -n userRoot -i /tmp/all.ldif&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;strong&gt;LDAP command lines&lt;/strong&gt; &lt;br /&gt;CDS has built-in “mozldap-tools”, which have similar commands suites to openldap-clients, but Openldap-clients is easier to use because it support client configuration. &lt;br /&gt;&lt;strong&gt;OpenLDAP client configuration files and command line options&lt;/strong&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: green; font-family: consolas, 'Courier New', courier, monospace; font-size: 12px; white-space: pre;"&gt;##OpenLDAP client configuration files &lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$/etc/openldap/ldap.conf    &lt;span style="color: green;"&gt;#Global client conf, but BINDDN (Authenticated user)  is ignored  in Global conf&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$HOME/ldaprc, $HOME/.ldaprc       &lt;span style="color: green;"&gt;#user ldap configuration file, set BINDDN here&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$CWD/ldaprc                &lt;span style="color: green;"&gt;#local ldap configuration file&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Typical configuration&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$cat /etc/openldap/ldap.conf&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;BASE    dc=station08, dc=example, dc=com&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;URI  ldap://station08.example.com&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$cat /root/.ldaprc&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;BINDDN  cn=Directory Manager&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##common command line options&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;-x         Simple authentication, &lt;span style="color: blue;"&gt;not&lt;/span&gt; SASL bind&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;-W         prompt &lt;span style="color: blue;"&gt;for&lt;/span&gt; bind password&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;-w passwd  bind password (&lt;span style="color: blue;"&gt;for&lt;/span&gt; simple authentication)&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;-D binddn  bind DN    &lt;span style="color: green;"&gt;#username to authenticate&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;-b basedn  base dn &lt;span style="color: blue;"&gt;for&lt;/span&gt; search &lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;-h host    LDAP server&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;-H URI     LDAP Uniform Resource Identifier(s)  &lt;span style="color: green;"&gt;#ldap://station08.example.com:389&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;-c         continuous operation mode (&lt;span style="color: blue;"&gt;do&lt;/span&gt; &lt;span style="color: blue;"&gt;not&lt;/span&gt; stop on errors), useful &lt;span style="color: blue;"&gt;for&lt;/span&gt; skipping entries already exist &lt;span style="color: blue;"&gt;when&lt;/span&gt; importing from ldif.&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;-Z         try to start TLS request (-ZZ to &lt;span style="color: darkblue;"&gt;require&lt;/span&gt; successful response)  &lt;span style="color: blue;"&gt;or&lt;/span&gt; -H ldaps://&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;&lt;strong&gt;Command line Search&amp;nbsp; Operation&lt;/strong&gt; &lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;# by default, search filter is  (objectclass=*) and display  ALL attributes. search is allowed for anonymous user, no password prompted&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ldapsearch -x&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ldapsearch -x -LLL    &lt;span style="color: green;"&gt;#less verbose, -LLL stripeout all comments&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ldapsearch -x  -s base    &lt;span style="color: green;"&gt;#(search scope). one of base, one(one-level sub), sub (whole subtree) or children,  default is sub&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Search filters, RFC 2254&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#NO  "&amp;gt;" or" &amp;lt; "operator&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;= Exact match; &amp;gt;= greater than &lt;span style="color: blue;"&gt;or&lt;/span&gt; equal; &amp;lt;= less than &lt;span style="color: blue;"&gt;or&lt;/span&gt; equal; ~= aproximate match   &lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;*  wildcard&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Logical operators&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;NOT   !   &lt;span style="color: green;"&gt;#( ! (uidNumber=500) )&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;OR   |   &lt;span style="color: green;"&gt;# (| (uidNumber&amp;gt;=502)(uid~=jim))&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;AND   &amp;amp;  &lt;span style="color: green;"&gt;# (&amp;amp; (uidNumber&amp;gt;=502)(uid~=jim))&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Escaped chars &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Character       ASCII value&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;---------------------------&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;*               0x2a&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;(               0x28&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;)               0x29&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;\               0x5c&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;NUL             0x00&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Escaped "&lt;span style="color: darkred;"&gt;(&lt;/span&gt;" can be expressed as  "&lt;span style="color: darkred;"&gt;\(&lt;/span&gt;" &lt;span style="color: blue;"&gt;or&lt;/span&gt; "&lt;span style="color: darkred;"&gt;\28&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;e.g search telephoneNumber: (02)98660000 use ldapsearch -x  '(telephonenumber=\(02\)98660000)'&lt;/pre&gt;&lt;/pre&gt;&lt;strong&gt;Command line&amp;nbsp; change operation&amp;nbsp;&lt;/strong&gt;&lt;br /&gt;Change operation need admin privilege which is specified by&amp;nbsp; BINDDN in /$HOME/.ldaprc or&amp;nbsp; "-D" in CLI&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##types of changing whole record, &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;changetype: add&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;changetype: delete&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;changetype: moddn&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;changetype: modify&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##----------------------changetype: add&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#default change type is add, no need to declare changetype: add,  as long as “-a” is specified in ldapmodify &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$cat /tmp/f1.ldif&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;dn: uid=jsmith,ou=People, dc=station08, dc=example, dc=com&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;uid: jsmith&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;givenName: john&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;objectClass: top&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;objectClass: person&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;objectClass: organizationalPerson&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;objectClass: inetorgperson&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;sn: smith&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;cn: john smith&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ldapmodify -x -W -a -f /tmp/f1.ldif&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Enter LDAP Password:&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;adding new entry "&lt;span style="color: darkred;"&gt;uid=jsmith,ou=People, dc=station08, dc=example, dc=com&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##----------------------changetype: delete&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Option 1, use ldapmodify command&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$cat /tmp/f1.ldif&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;dn: uid=jsmith,ou=People, dc=station08, dc=example, dc=com&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;changetype: delete&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ldapmodify -x -W -f /tmp/f1.ldif&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Enter LDAP Password:&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;deleting entry "&lt;span style="color: darkred;"&gt;uid=jsmith,ou=People, dc=station08, dc=example, dc=com&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Option 2, use ldapdelete command, note the ldif format difference&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#ldapdelete support recursive delete with "-r"&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$cat /tmp/f1.ldif&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;uid=jsmith,ou=People, dc=station08, dc=example, dc=com&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ldapdelete -x -W -f /tmp/f1.ldif&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##----------------------changetype: moddn&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#change RDN relative distingished name, the first part of DN&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Option 1, use ldapmodify command&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$cat /tmp/f1.ldif&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;dn: uid=jsmith,ou=People, dc=station08, dc=example, dc=com&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;changetype: modrdn&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;newrdn: uid=jsmith2&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;deleteoldrdn: 1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ldapmodify -x -W -f /tmp/f1.ldif&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Enter LDAP Password:&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;modifying rdn of entry "&lt;span style="color: darkred;"&gt;uid=jsmith,ou=People, dc=station08, dc=example, dc=com&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;rename completed&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Option 2, use ldapmodrn to achive same result&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ cat /tmp/f1.ldif&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;uid=jsmith,ou=People, dc=station08, dc=example, dc=com&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;uid=jsmith2&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ldapmodrdn -x -r -W -f /tmp/f1.ldif&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##----------------------changetype: modify&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#add, replace,delete attributes of a record, not record itself&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#multile actions separated by "-"&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$cat /tmp/f1.ldif&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;dn: uid=jsmith,ou=People, dc=station08, dc=example, dc=com&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;changetype: modify&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;add: mail&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;mail: jsmith@example.com&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;-&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;delete: facsimileTelephoneNumber&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;-&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;replace: telephonenumber&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;telephonenumber: +1 408 555 1234&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ldapmodify -x -W -f /tmp/f1.ldif&lt;/pre&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1822605347830719087-8210606573575794995?l=honglus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://honglus.blogspot.com/feeds/8210606573575794995/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://honglus.blogspot.com/2011/07/centos-directory-server-8-quickstart.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/8210606573575794995'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/8210606573575794995'/><link rel='alternate' type='text/html' href='http://honglus.blogspot.com/2011/07/centos-directory-server-8-quickstart.html' title='CentOS Directory Server 8 Quickstart'/><author><name>honglus</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/-M84RCINiA_o/ThQFnRBzbeI/AAAAAAAAAJg/L4P18HEhELg/s72-c/image_thumb%25255B2%25255D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1822605347830719087.post-8725663968677711991</id><published>2011-06-26T13:32:00.003+10:00</published><updated>2011-12-07T21:12:18.727+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Server Provisioning'/><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><category scheme='http://www.blogger.com/atom/ns#' term='NMS'/><title type='text'>Spacewalk provision Red Hat Linux by PXE kickstart</title><content type='html'>Spacewalk is an open source (GPLv2) Linux systems management solution. It is the upstream community project from which the Red Hat Network Satellite product is derived. &lt;br /&gt;&lt;strong&gt;What can Spacewalk do:&lt;/strong&gt;     &lt;br /&gt;- YUM repository Server, which is connected by client via yum-rhn-plugin     &lt;br /&gt;- Provision, kickstart, physical or virtual systems (using cobbler)     &lt;br /&gt;- Manage and deploy configuration files, software to a group of servers     &lt;br /&gt;- Monitor your systems (CPU, disk space etc .. ), Inventory your systems (hardware and software information) &lt;br /&gt;&lt;strong&gt;OS supported by Spacewalk:&lt;/strong&gt;     &lt;br /&gt;- Red Hat Linux derivatives (Centos, Fedora, Scientific Linux) and Solaris     &lt;br /&gt;- Limited support for SUSE Linux (AutoYaST Support is planned in V1.5, &lt;a href="https://fedorahosted.org/spacewalk/roadmap"&gt;https://fedorahosted.org/spacewalk/roadmap&lt;/a&gt; )     &lt;br /&gt;- Experimental support for Debian (&lt;a href="https://fedorahosted.org/spacewalk/wiki/Deb_support_in_spacewalk"&gt;https://fedorahosted.org/spacewalk/wiki/Deb_support_in_spacewalk&lt;/a&gt; ) &lt;br /&gt;This post is not a complete guide for spacewalk install and administartion, its goal is to PXE kickstart a pysical server and have it registered to spacewalk server when kickstart complete. Kickstarting a server is easy but having it registered to spacewalk server needs tweaking. &lt;br /&gt;Useful document for Spacewalk:&amp;nbsp; &lt;br /&gt;&lt;a href="http://wiki.centos.org/HowTos/PackageManagement/Spacewalk"&gt;http://wiki.centos.org/HowTos/PackageManagement/Spacewalk&lt;/a&gt;     &lt;br /&gt;&lt;a href="https://fedorahosted.org/spacewalk/wiki/UserDocs"&gt;https://fedorahosted.org/spacewalk/wiki/UserDocs&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://docs.redhat.com/docs/en-US/Red_Hat_Network_Satellite/index.html"&gt;http://docs.redhat.com/docs/en-US/Red_Hat_Network_Satellite/index.html&lt;/a&gt;&lt;br /&gt;This post demonstrate spacewalk 1.4 kickstarting Centos 5.5 i386 &lt;br /&gt;&lt;strong&gt;Steps Summary:&lt;/strong&gt;     &lt;br /&gt;- Setup PXE boot server environment     &lt;br /&gt;- Create OS base channel     &lt;br /&gt;- Create child channel(tools channel)     &lt;br /&gt;- Create distribution tree     &lt;br /&gt;- Create activation key     &lt;br /&gt;- Create kickstart profile &lt;br /&gt;&lt;strong&gt;Setup PXE boot server environment&lt;/strong&gt;     &lt;br /&gt;Setup tftp and dhcpd, refer to &lt;a href="http://honglus.blogspot.com/2011/06/setup-pxe-boot-server-for-linux-server.html"&gt;http://honglus.blogspot.com/2011/06/setup-pxe-boot-server-for-linux-server.html&lt;/a&gt;     &lt;br /&gt;However, you don't bother editing pxelinux.cfg/default, which will be managed by spacewalk. &lt;br /&gt;&lt;strong&gt;Create OS base channel      &lt;br /&gt;&lt;/strong&gt;Navigate to: Channels | Manage software channels | Create new channel     &lt;br /&gt;Channel label is significant, It is channel label, not channel name, is referred for channel operations.     &lt;br /&gt;For GPG key section, refer to “GPG Sign RPM file” &lt;a href="http://honglus.blogspot.com/2011/05/build-rpm-from-source-file.html"&gt;http://honglus.blogspot.com/2011/05/build-rpm-from-source-file.html&lt;/a&gt;     &lt;br /&gt;The GPG pub key need to copied to “/var/www/html/pub”, which can be downloaded by http://Server/pub/MY-GPG-FILE-NAME&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Import OS rpms to OS Base channel&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Before importing rpms, it is recommended to resign all rpms with your own GPG key “ rpm –resign *.rpm”, otherwise you need to import the rpm's original GPG key to all  clients.&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$spacewalk-repo-sync  -c channel-label –-url  http://mirror.centos.org/centos/5/os/i386/&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;# You can also import rpms in installation media by –url file:///media/cdrom&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;strong&gt;Create child channel(tools channel)&lt;/strong&gt;&lt;br /&gt;Create a child channel for the Base channel created in last step, using same GPG information&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#import spacewalk client rpms to the child channel&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$spacewalk-repo-sync  -c child-channel-label  –-url  http://spacewalk.redhat.com/yum/1.4-client/RHEL/5/i386/&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#python-ethtool doesn't exist in above sites, you need to download it manually from EPEL repository http://fedoraproject.org/wiki/EPEL  &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#import a single rpm  to the child channel&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$rhnpush  -c  child-channel-label  -u satadmin python-ethtool*.rpm &lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;strong&gt;Create distribution tree&lt;/strong&gt;&lt;br /&gt;Distribution hold installation files e.g. “images/stage2.img”, which can't be imported to spacewalk channel&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Create distribution tree path&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$mkdir -&lt;span style="color: darkblue;"&gt;p&lt;/span&gt; /var/distro-trees/centos-32-5.5&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Copy everything in installation media except for rpm files to the dir&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#rpm files will be retrieved from channels&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$cd /media/cdrom; find . ! -path "&lt;span style="color: darkred;"&gt;./CentOS/*&lt;/span&gt;"   | cpio -pvd /var/distro-trees/centos-32-5.5&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;Navigate to: Systems | Kickstart | Distributions | Create new distribution&lt;br /&gt;&lt;a href="http://lh5.ggpht.com/-IpI8XTZhvhs/Tgap59Yf5FI/AAAAAAAAAJU/Zo0zEu6GRlw/s1600-h/dist2%25255B6%25255D.jpg"&gt;&lt;img alt="dist2" border="0" height="272" src="http://lh6.ggpht.com/-dbkZAuER8QQ/Tgap62FAWpI/AAAAAAAAAJY/ypaR8NKwqMI/dist2_thumb%25255B2%25255D.jpg?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="dist2" width="644" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Create activation key&lt;/strong&gt;&lt;br /&gt;Activation key is bound to base channel and entitlements, it is used by client to register to spacewalk without password authentication. &lt;br /&gt;Navigate to: Systems | Activation Keys | Create new Key&lt;br /&gt;Select the base channel and enable provisioning add-on entitlements&lt;br /&gt;In child channels, select the child channel.&lt;br /&gt;Optionally, if you want to pull configuration file e.g /etc/ntp.conf during kickstart, you need to create configuration channel and bind the activation key&lt;br /&gt;&lt;strong&gt;Create kickstart profile&lt;/strong&gt;&lt;br /&gt;Navigate to: Systems | Kickstart | Create new kickstart profile&lt;br /&gt;&lt;a href="http://lh3.ggpht.com/-RULb6JW9NKY/TgaoR86FAbI/AAAAAAAAAJE/UASL4nM5jqM/s1600-h/ks%25255B6%25255D.jpg"&gt;&lt;img alt="ks" border="0" height="464" src="http://lh6.ggpht.com/-BApiRnvbtWI/TgaoSry5KOI/AAAAAAAAAJI/LHRZCodpHIA/ks_thumb%25255B2%25255D.jpg?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="ks" width="644" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;In operating systems, select base channel and child channel&lt;br /&gt;&lt;a href="http://lh6.ggpht.com/-zj7byFYV8FU/TgaoTYp-MNI/AAAAAAAAAJM/nROjt5fCVs4/s1600-h/ks2%25255B3%25255D.jpg"&gt;&lt;img alt="ks2" border="0" height="484" src="http://lh5.ggpht.com/-_Nrr33aJje4/TgaoULwWGkI/AAAAAAAAAJQ/nGOQ35_8Cfk/ks2_thumb%25255B1%25255D.jpg?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="ks2" width="581" /&gt;&lt;/a&gt;&lt;br /&gt;In Software,enter the&amp;nbsp; following packages in addition to @ Base&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;rhn-check&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;rhn-setup&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;yum-rhn-plugin&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;python-ethtool&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;python-dmidecode&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;rhncfg-client&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;rhncfg-actions&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Above packages provide rhnreg_ks and rhn_check to register to spacewalk during kickstart, otherwise kickstart postscript will encounter errors:&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/tmp/ks-script-KOlpXy: line 128: rhnreg_ks: command &lt;span style="color: blue;"&gt;not&lt;/span&gt; found&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/tmp/ks-script-KOlpXy: line 134: rhn_check: command &lt;span style="color: blue;"&gt;not&lt;/span&gt; found&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#You can also write your own snipplets in “/var/lib/cobbler/snippets” to add packages dynamically.&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;In Activation Keys, select the activation key&lt;br /&gt;Once kickstart profile is created, some entries are added to pxe configuration file&lt;br /&gt;/tftpboot/pxelinux.cfg/default &lt;br /&gt;Power on the server to be provisioned, when kickstart completed, It should be registered and appeared in spacewalk.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1822605347830719087-8725663968677711991?l=honglus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://honglus.blogspot.com/feeds/8725663968677711991/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://honglus.blogspot.com/2011/06/spacewalk-provision-red-hat-linux-by.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/8725663968677711991'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/8725663968677711991'/><link rel='alternate' type='text/html' href='http://honglus.blogspot.com/2011/06/spacewalk-provision-red-hat-linux-by.html' title='Spacewalk provision Red Hat Linux by PXE kickstart'/><author><name>honglus</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/-dbkZAuER8QQ/Tgap62FAWpI/AAAAAAAAAJY/ypaR8NKwqMI/s72-c/dist2_thumb%25255B2%25255D.jpg?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1822605347830719087.post-1849932535109534832</id><published>2011-06-18T17:58:00.010+10:00</published><updated>2011-12-07T21:12:51.103+11:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Server Provisioning'/><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><title type='text'>Setup PXE Boot Server for Linux Server Provisioning</title><content type='html'>PXE is Preboot eXecution Environment, for PXE to work, NIC and BIOS must both support PXE (Virtualbox pcnet type adapter supports pxe boot)   &lt;br /&gt;&lt;strong&gt;PXE boot server components&lt;/strong&gt;   &lt;br /&gt;- DHCP Server&amp;nbsp;&amp;nbsp;&amp;nbsp; #assign ip address and redirect to tftp Server   &lt;br /&gt;- tftp Server&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #download boot loaders and configuration file   &lt;br /&gt;- syslinux&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #provides stage1 boot loader pxelinux.0, which&amp;nbsp; is installed in boot&amp;nbsp; server, independent of the OS to be provisioned   &lt;br /&gt;&lt;strong&gt;The PXE boot process&lt;/strong&gt;   &lt;br /&gt;1. NIC requests DHCP information (DHCP DHCPDISCOVER to port 67/UDP)   &lt;br /&gt;2. DHCP server provides bootloader name and IP of tftp server   &lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;#relevant DHCP config&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;nextsever "172.16.1.10";  &lt;br /&gt;filename "pxelinux.0";&lt;/pre&gt;3. NIC uses tftp to fetch bootloader into RAM(tftp tftp-server -c get pxelinux.0)&lt;br /&gt;4. BIOS executes bootloader&lt;br /&gt;5. Bootloader uses tftp to find and retrieve configuration file in &lt;strong&gt;following order&lt;/strong&gt;:&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[5.1] MAC address using hex and dashes, prefaced with ARP type code&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[5.2] IP address expressed in hex&lt;br /&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;#Convert decimal to hex by gethostip command &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;$gethostip 192.0.2.91&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;192.0.2.91 192.0.2.91 C000025B&lt;/span&gt;&lt;br /&gt;[5.3]Strips one digit of hex IP at a time from the right-hand side until file is found&lt;br /&gt;[5.4]Last attempt is default&lt;/blockquote&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;As an example, if the boot file name is /tftpboot/pxelinux.0, the Ethernet MAC address is 88:99:AA:BB:CC:DD and the IP&amp;nbsp; address 192.0.2.91, it will try: &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;/tftpboot/pxelinux.cfg/01-88-99-aa-bb-cc-dd&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;/tftpboot/pxelinux.cfg/C000025B&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;/tftpboot/pxelinux.cfg/C000025&lt;br /&gt;... &lt;br /&gt;/tftpboot/pxelinux.cfg/C&lt;br /&gt;/tftpboot/pxelinux.cfg/default&lt;/pre&gt;6. Bootloader load kernel: vmlinuz and initrd.img defined in the configuration file retrieved.&lt;br /&gt;&lt;strong&gt;Install PXE Boot Server components&lt;/strong&gt;&lt;br /&gt;The setup procedure is demonstrated in Centos 5&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;$yum install tftp dhcp syslinux&lt;/span&gt;&lt;br /&gt;tftp&amp;nbsp; configuration is&amp;nbsp; /etc/xinetd.d/tftp&amp;nbsp; and controlled by&amp;nbsp; /etc/init.d/xinetd&lt;br /&gt;&lt;strong&gt;Prepare&amp;nbsp; tftp directory structure&amp;nbsp; and populate initial files&lt;/strong&gt;&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$mkdir -&lt;span style="color: darkblue;"&gt;p&lt;/span&gt; /tftpboot/{pxelinux.cfg,centos-i686-5.5}&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;pxelinux.cfg                &lt;span style="color: green;"&gt;#The directory for client OS configuration files&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;centos-i686-5.5           &lt;span style="color: green;"&gt;#An optional directory to hold vmlinuz, initrd.img specific to a Linux release &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#find pxelinux.0 on PXE boot Server and copy it to tftpboot&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$rpm -ql syslinux | grep pxelinux.0&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/usr/lib/syslinux/pxelinux.0&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$cp /usr/lib/syslinux/pxelinux.0 /tftpboot/&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$cp /usr/lib/syslinux/menu.c32   /tftpboot/&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Copy vmlinuz and initrd.img in installation media for the client OS to be provisioned&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$cp /media/cdrom/images/pxeboot/{initrd.img,vmlinuz} /tftpboot/centos-i686-5.5&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;strong&gt;Create PXE configuration file for client OS&lt;/strong&gt;&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Derive the configuration file name from the ip to be assigned to client OS&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$gethostip 172.16.1.128&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;172.16.1.128 172.16.1.128 AC100180&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Edit config file&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#reference: /usr/share/doc/syslinux*/syslinux.doc&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#sample config: /media/cdrom/isolinux/isolinux.cfg&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$vi /tftpboot/pxelinux.cfg/AC100180&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;default linux&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;prompt 1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#timeout in units of 1/10 s.&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;timeout 20&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#dsplay boot.msg&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;label linux&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;kernel centos-i686-5.5/vmlinuz&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;append initrd=centos-i686-5.5/initrd.img ks=http://172.16.1.10/pxe/centos.ks ksdevice=link&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#if no config for the host defined, default to boot from none-pxe media&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$vi /tftpboot/pxelinux.cfg/default&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;default normal&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;prompt 0&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;label normal&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;localboot 0&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span class="Apple-style-span" style="color: blue;"&gt;##instead of above method,loading specific kernel based on individual config, You can have only one default config, let user choose which kernel to load.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%;"&gt;&lt;span class="Apple-style-span" style="font-family: consolas, 'Courier New', courier, monospace; font-size: 12px;"&gt;$ cat /tftpboot/pxelinux.cfg/default&lt;/span&gt;&lt;span class="Apple-style-span"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; margin: 0em; width: 100%;"&gt;&lt;span class="Apple-style-span"&gt;DEFAULT menu&lt;br /&gt;PROMPT 0&lt;br /&gt;MENU TITLE Select a boot option&lt;br /&gt;TIMEOUT 200&lt;br /&gt;TOTALTIMEOUT 6000&lt;br /&gt;ONTIMEOUT local&lt;br /&gt;&lt;br /&gt;LABEL local&lt;br /&gt;MENU LABEL (local)&lt;br /&gt;MENU DEFAULT&lt;br /&gt;LOCALBOOT 0&lt;br /&gt;&lt;br /&gt;LABEL centos-i686-5.5&lt;br /&gt;kernel /centos-i686-5.5/vmlinuz&lt;br /&gt;MENU LABEL centos-i686-5.5&lt;br /&gt;append initrd /centos-i686-5.5/initrd.img ks=http://172.16.1.10/pxe/centos.ks ksdevice=link&lt;br /&gt;&lt;br /&gt;LABEL centos-x86_64-5.5&lt;br /&gt;kernel /centos-x86_64-5.5/vmlinuz&lt;br /&gt;MENU LABEL centos-x86_64-5.5&lt;br /&gt;append initrd=/centos-x86_64-5.5/initrd.img ks=http://172.16.1.10/pxe/centos.ks ksdevice=link&lt;br /&gt;MENU end&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: consolas, 'Courier New', courier, monospace; font-size: 12px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: consolas, 'Courier New', courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: 12px;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/pre&gt;&lt;br /&gt;&lt;strong&gt;Setup DHCP Server&lt;/strong&gt;&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Activate dhcpd  on specific NIC only.&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$vi /etc/sysconfig/dhcpd&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;DHCPDARGS=eth1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Edit dhcpd configuration file&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#The client OS is assigned  an fixed IP “172.16.1.128” based on mac address, which can be #retrieved &lt;span style="color: blue;"&gt;in&lt;/span&gt; /var/log/messages &lt;span style="color: blue;"&gt;when&lt;/span&gt; client  boot  from pxe the first time.&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$cat /etc/dhcpd.conf&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;# DHCP Server Configuration file.&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#   see /usr/share/doc/dhcp*/dhcpd.conf.sample&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;ddns-update-style interim;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;ignore client-updates;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;subnet 172.16.1.0 netmask 255.255.255.0 {&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;# --- default gateway&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;option routers                  172.16.1.254;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;option subnet-mask              255.255.255.0;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;option domain-name              "&lt;span style="color: darkred;"&gt;example.com&lt;/span&gt;";&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;option domain-name-servers      172.16.1.10;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;range dynamic-bootp 172.16.1.128 172.16.1.200;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#time unit is 1 sec&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;default-lease-time 21600;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;max-lease-time 43200;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;next&lt;/span&gt;-server 172.16.1.10;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;filename "&lt;span style="color: darkred;"&gt;pxelinux.0&lt;/span&gt;";&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;host host1 {&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;hardware ethernet 08:00:27:9b:ac:9b;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;fixed-address 172.16.1.128;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;} &lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;strong&gt;Start dhcp server&lt;/strong&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;$service dhcp start&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;Boot Client&lt;/strong&gt;&lt;br /&gt;Change boot order in BIOS to prefer network boot and power on the Server to be provisioned&lt;br /&gt;- Client boots up automatically after finding configuration file&amp;nbsp; “AC100180”&lt;br /&gt;&lt;a href="http://lh5.ggpht.com/-9YdmBGElYs0/TgMdswraBpI/AAAAAAAAAIs/rjNS74VhfG8/s1600-h/image%25255B6%25255D.png"&gt;&lt;img alt="image" border="0" height="423" src="http://lh6.ggpht.com/-dMB7vPEFojM/TgMduW-hb6I/AAAAAAAAAIw/3wbOdplrj0w/image_thumb%25255B2%25255D.png?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="image" width="644" /&gt;&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;&amp;nbsp;- Client without its configuration file found, waiting for user’s input&lt;br /&gt;&lt;br /&gt;&lt;a href="http://lh4.ggpht.com/-AskNF08TKw4/TgMdvdanDfI/AAAAAAAAAI0/-LWw1I9_1Os/s1600-h/image%25255B7%25255D.png"&gt;&lt;img alt="image" border="0" height="432" src="http://lh5.ggpht.com/-ijx_ZgzJsZU/TgMdwfbQcLI/AAAAAAAAAI4/62gdFgZFOSQ/image_thumb%25255B3%25255D.png?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="image" width="644" /&gt;&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1822605347830719087-1849932535109534832?l=honglus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://honglus.blogspot.com/feeds/1849932535109534832/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://honglus.blogspot.com/2011/06/setup-pxe-boot-server-for-linux-server.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/1849932535109534832'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/1849932535109534832'/><link rel='alternate' type='text/html' href='http://honglus.blogspot.com/2011/06/setup-pxe-boot-server-for-linux-server.html' title='Setup PXE Boot Server for Linux Server Provisioning'/><author><name>honglus</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/-dMB7vPEFojM/TgMduW-hb6I/AAAAAAAAAIw/3wbOdplrj0w/s72-c/image_thumb%25255B2%25255D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1822605347830719087.post-4777991444726953530</id><published>2011-06-15T16:35:00.007+10:00</published><updated>2011-06-15T16:45:15.784+10:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><category scheme='http://www.blogger.com/atom/ns#' term='Virtualization'/><title type='text'>Red Hat Enterprise Virtualization(RHEV) Notes</title><content type='html'>The post only highlight some useful notes, for step-by-step instructions, refer to &lt;a href="https://access.redhat.com/knowledge/docs/Red_Hat_Enterprise_Virtualization_for_Servers/" target="_blank"&gt;Red Hat RHEV document&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;RHEV has two components: Red Hat enterprise Virtualization manager(RHEV-M) and managed hypervisor,which could be RHEV-H(RHEV hypervisor, a trim down version of RHEL) or full-blown RHEL 5.5 (64bit) or newer.&lt;br /&gt;&lt;div style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;strong&gt;Download RHEV&lt;/strong&gt;     &lt;br /&gt;Red Hat doesn’t publish public available evaluation copy, contact sales to get a evaluation copy of RHEV&lt;br /&gt;&lt;strong&gt;RHEV-M notes&lt;/strong&gt;&lt;br /&gt;- RHEV-M 2.2 support Windows 2003 SP2 or Windows 2008 R2, although the RHEV 2.2 document only mentions Windows 2008 R2. Windows 2003 SP2 need some hostfix, just run update all after installing .NET 3.5.1/IIS/PowerShell 2.2.    &lt;br /&gt;Windows 2008 is NOT supported. &lt;br /&gt;- RHEV-M can use hosts file instead of DNS, but the “Do not validate fully qualified computer name checkbox” need to be select when install RHEV-M    &lt;br /&gt;- RHEV-M login rely on Windows account, which can be a generic local account or AD account.     &lt;br /&gt;- RHEV-M's backend DB is&amp;nbsp; SQL Server 2005, by default, it installs&amp;nbsp; “SQL Server 2005 express” locally, there is an option to connect to external DB.&amp;nbsp; &lt;br /&gt;- If the RHEV manager login URL is not redirected after installing trusted certificate and adding trusted website, point URL directly to&amp;nbsp; &lt;a href="https://fqdn/RHEVmanager/WPFclient.xbap"&gt;Https://FQDN/RHEVmanager/WPFclient.xbap&lt;/a&gt;&lt;br /&gt;&lt;strong&gt;RHEV-H notes&lt;/strong&gt;&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#RHEV-H boot prompt options&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;:     &lt;span style="color: green;"&gt;#Just press enter to start installation.&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;:linux &lt;span style="color: blue;"&gt;rescue&lt;/span&gt;     &lt;span style="color: green;"&gt;#same as RHEL rescue mode&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;:linux firstboot   &lt;span style="color: green;"&gt;#invoke interactive installation menu&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;:linux upgrade   &lt;span style="color: green;"&gt;#upgrade hypervisor&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;:linux nocheck   &lt;span style="color: green;"&gt;#disable installation media check&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Hypervisor Configuration Menu&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Red Hat Enterprise Virtualization Hypervisor release 5.5-2.2&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Hypervisor Configuration Menu&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;1) Configure storage partitions    6) Configure the host &lt;span style="color: blue;"&gt;for&lt;/span&gt; Red Hat Enterprise&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Virtualization&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;2) Configure authentication        7) View logs&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;3) Set the hostname                8) Install locally &lt;span style="color: blue;"&gt;and&lt;/span&gt; reboot&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;4) Networking setup                9) Support Menu&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;5) Register Host to RHN&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span class="Apple-style-span" style="font-family: monospace; font-size: small;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas, 'Courier New', courier, monospace; font-size: 12px; margin-bottom: 0em; margin-left: 0em; margin-right: 0em; margin-top: 0em; width: 650px;"&gt;&lt;span style="color: green;"&gt;#options notes&lt;/span&gt;&lt;/pre&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;“5) Register Host to RHN” is optional, just configure 1,2,3,4,6 &lt;span style="color: blue;"&gt;then&lt;/span&gt; choose 8&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;“9) Support Menu” has an option to uninstall  existing RHEV-H&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;strong&gt;Troubleshoot after RHEV-H has been installed.&amp;nbsp;&lt;/strong&gt;&lt;br /&gt;If RHEV-H is successfully connected to RHEV-M, it should be appeared in RHEV-M hosts tab with status “Pending Approval”, click “approve” button will &amp;nbsp;finalize the installation.&amp;nbsp;(“Add host” option only works for RHEL host used as hypervisor host . RHEV-H,a trim down version of RHEL, has to use registration flow)&lt;br /&gt;&amp;nbsp;If for some reason, RHEV-H doesn't appear in RHEV-M, check following first &lt;br /&gt;&amp;nbsp;- RHEV-M&amp;nbsp; Windows 2003 SP2&amp;nbsp; has all latest update&lt;br /&gt;&amp;nbsp;- RHEV-M host name is resolvable, and telnet to the host on 80,443 works. &lt;br /&gt;&amp;nbsp;- Datetime matched in RHEV-H and RHEV-M, /etc/init.d/ntpd is working&lt;br /&gt;then try to re-register RHEV-H to RHEV-M&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#re-invoke the Hypervisor Configuration Menu&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$setup                      &lt;span style="color: green;"&gt;#select option 6 to re-configure hostname for RHEV-M&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#restart registration process&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/etc/init.d/vdsm-reg restart&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#check registration log&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/var/log/vdsm-reg/vdsm-reg.log&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Configure files in RHEV-H &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#vdsm registration script&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#register itself to RHEV-M, it seems it doesn't need to be running once registration is successful&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/etc/init.d/vdsm-reg                 &lt;span style="color: green;"&gt;#start-up script, &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/etc/vdsm-reg/vdsm-reg.conf     &lt;span style="color: green;"&gt;#configuration file&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/var/log/vdsm-reg/vdsm-reg.log    &lt;span style="color: green;"&gt;#log file&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Management agent&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#by default, listening on port 54321 to communicate with RHEV-M&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/etc/init.d/vdsmd&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/etc/vdsm/vdsm.conf&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/var/log/vdsm/vdsm.log&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;You are &lt;span style="color: blue;"&gt;not&lt;/span&gt; supposed to create new configuration files  &lt;span style="color: blue;"&gt;in&lt;/span&gt; RHEV-H, any new files &lt;span style="color: blue;"&gt;in&lt;/span&gt;  /etc/ will be lost after reboot. To survive reboot, you need copy your customization files, e.g /etc/hosts, /etc/resolv.conf, to “/config/etc/” once. Next time RHEV-H boots up, it will synchronize all files &lt;span style="color: blue;"&gt;in&lt;/span&gt; /config/etc&lt;span style="color: green;"&gt;/* to /etc&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;strong&gt;NFS store&lt;/strong&gt; &lt;br /&gt;- The NFS export must writable by vdsm:kvm, (uid:gid 36:36) &lt;br /&gt;- RHEV-M has a windows tool to upload ISO files to ISO domain, The tool go through 2 steps:first upload to SPM(Storage Pool Manager) host, then move from SPM host to NFS. You can actually winscp to NFS directly, then change file ownership to&amp;nbsp; vdsm:kvm.&lt;br /&gt;&lt;strong&gt;Guest OS notes&lt;/strong&gt; &lt;br /&gt;- RHEV 2.2 doesn't support auto-start&amp;nbsp; guest OS, which means if RHEV-M and RHEV-H are rebooted, someone has to login&amp;nbsp; RHEV-M to click “run” for each VM&amp;nbsp; &lt;br /&gt;- RHEL 5.x has built-in VirtIO driver for&amp;nbsp; harddisk and network&amp;nbsp; &lt;br /&gt;- Windows Guest need the virtual floppy file virtio*.vfd copied to ISO domain and mount the floppy (select “run once” select the file as floppy drive)&amp;nbsp; in order for Windows to recognize VirtIO harddisk. Once Windows boots up, install “Guest tools”&amp;nbsp; for VirtIO NIC driver.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1822605347830719087-4777991444726953530?l=honglus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://honglus.blogspot.com/feeds/4777991444726953530/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://honglus.blogspot.com/2011/06/red-hat-enterprise-virtualizationrhev.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/4777991444726953530'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/4777991444726953530'/><link rel='alternate' type='text/html' href='http://honglus.blogspot.com/2011/06/red-hat-enterprise-virtualizationrhev.html' title='Red Hat Enterprise Virtualization(RHEV) Notes'/><author><name>honglus</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1822605347830719087.post-5777949475356263552</id><published>2011-06-11T22:08:00.016+10:00</published><updated>2011-06-16T09:57:10.623+10:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><category scheme='http://www.blogger.com/atom/ns#' term='Virtualization'/><title type='text'>Red Hat RHEV vs Vmware ESX</title><content type='html'>In 2009, Red Hat launched Red Hat enterprise Virtualization (RHEV)&amp;nbsp; to compete in commercial virtualization market dominated by VMware. RHEV has two components: Red Hat enterprise Virtualization manager(RHEV-M) and managed hypervisor,which could be RHEV-H(RHEV hypervisor, a trim down version of RHEL) or full-blown RHEL 5.5 (64bit) or newer&lt;br /&gt;Feature wise, in paper,&amp;nbsp; RHEV looks not too bad, However what will be revealed if dug&amp;nbsp; further into technical details and compared with VMware?&lt;br /&gt;&lt;table border="1" cellpadding="1" cellspacing="0" style="width: 617px;"&gt;&lt;tbody&gt;&lt;tr&gt;       &lt;td valign="top" width="165"&gt;&lt;/td&gt;        &lt;td valign="top" width="175"&gt;RHEV 2.2&lt;/td&gt;        &lt;td valign="top" width="275"&gt;ESX 4&lt;/td&gt;     &lt;/tr&gt;&lt;tr&gt;       &lt;td valign="top" width="166"&gt;&lt;strong&gt;Manager&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="175"&gt;&lt;/td&gt;        &lt;td valign="top" width="274"&gt;&lt;/td&gt;     &lt;/tr&gt;&lt;tr&gt;       &lt;td valign="top" width="167"&gt;Name&lt;/td&gt;        &lt;td valign="top" width="175"&gt;RHEV-M&lt;/td&gt;        &lt;td valign="top" width="274"&gt;vCenter&lt;/td&gt;     &lt;/tr&gt;&lt;tr&gt;       &lt;td valign="top" width="167"&gt;Compatible&amp;nbsp; OS&lt;/td&gt;        &lt;td valign="top" width="175"&gt;Windows 2003          &lt;br /&gt;Windows 20008 R2&lt;/td&gt;        &lt;td valign="top" width="274"&gt;Windows XP          &lt;br /&gt;Windows 2003           &lt;br /&gt;Windows 2008           &lt;br /&gt;Windows 2008 R2&lt;/td&gt;     &lt;/tr&gt;&lt;tr&gt;       &lt;td valign="top" width="167"&gt;Backend DB&lt;/td&gt;        &lt;td valign="top" width="175"&gt;Microsoft SQL Server&lt;/td&gt;        &lt;td valign="top" width="274"&gt;Microsoft SQL server          &lt;br /&gt;Oracle &lt;/td&gt;     &lt;/tr&gt;&lt;tr&gt;       &lt;td valign="top" width="167"&gt;Application Type&lt;/td&gt;        &lt;td valign="top" width="175"&gt;Web application          &lt;br /&gt;(WPF .xbap application)&lt;/td&gt;        &lt;td valign="top" width="274"&gt;Windows native application&lt;/td&gt;     &lt;/tr&gt;&lt;tr&gt;       &lt;td valign="top" width="167"&gt;User Interface &lt;/td&gt;        &lt;td valign="top" width="175"&gt;Web UI&lt;/td&gt;        &lt;td valign="top" width="274"&gt;Web UI          &lt;br /&gt;Windows native application&lt;/td&gt;     &lt;/tr&gt;&lt;tr&gt;       &lt;td valign="top" width="167"&gt;CLI [1]&lt;/td&gt;        &lt;td valign="top" width="175"&gt;Powershell&lt;/td&gt;        &lt;td valign="top" width="274"&gt;Powershell(PowerCLI)          &lt;br /&gt;vCLI&lt;/td&gt;     &lt;/tr&gt;&lt;tr&gt;       &lt;td valign="top" width="167"&gt;SDK&amp;amp;API&lt;/td&gt;        &lt;td valign="top" width="175"&gt;Powershell&lt;/td&gt;        &lt;td valign="top" width="274"&gt;Powershell, Perl,C#, Java          &lt;/td&gt;     &lt;/tr&gt;&lt;tr&gt;       &lt;td valign="top" width="167"&gt;&lt;strong&gt;Hypervisor&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="175"&gt;&lt;/td&gt;        &lt;td valign="top" width="274"&gt;&lt;/td&gt;     &lt;/tr&gt;&lt;tr&gt;       &lt;td valign="top" width="167"&gt;Type&lt;/td&gt;        &lt;td valign="top" width="175"&gt;Linux kernel (KVM)&lt;/td&gt;        &lt;td valign="top" width="274"&gt;Proprietary&lt;/td&gt;     &lt;/tr&gt;&lt;tr&gt;       &lt;td valign="top" width="167"&gt;Manager Agent&lt;/td&gt;        &lt;td valign="top" width="175"&gt;Python script&lt;/td&gt;        &lt;td valign="top" width="274"&gt;Binary daemon&lt;/td&gt;     &lt;/tr&gt;&lt;tr&gt;       &lt;td valign="top" width="167"&gt;HA/Migration [2]&lt;/td&gt;        &lt;td valign="top" width="175"&gt;YES&lt;/td&gt;        &lt;td valign="top" width="274"&gt;YES&lt;/td&gt;     &lt;/tr&gt;&lt;tr&gt;       &lt;td valign="top" width="167"&gt;Manager independent [3]&lt;/td&gt;        &lt;td valign="top" width="175"&gt;NO&lt;/td&gt;        &lt;td valign="top" width="274"&gt;YES&lt;/td&gt;     &lt;/tr&gt;&lt;tr&gt;       &lt;td valign="top" width="167"&gt;CLI [4]&lt;/td&gt;        &lt;td valign="top" width="175"&gt;NO&lt;/td&gt;        &lt;td valign="top" width="274"&gt;esxcfg-*/vimsh&amp;nbsp; commands&lt;/td&gt;     &lt;/tr&gt;&lt;tr&gt;       &lt;td valign="top" width="167"&gt;SDK&amp;amp;API&lt;/td&gt;        &lt;td valign="top" width="175"&gt;NO&lt;/td&gt;        &lt;td valign="top" width="274"&gt;Powershell, Perl,C#, Java&lt;/td&gt;     &lt;/tr&gt;&lt;tr&gt;       &lt;td valign="top" width="167"&gt;Storage&amp;nbsp; Type&amp;nbsp; [5]&lt;/td&gt;        &lt;td valign="top" width="175"&gt;NFS/iSCSI/FC&lt;/td&gt;        &lt;td valign="top" width="274"&gt;local disk/NFS/iSCSI/FC&lt;/td&gt;     &lt;/tr&gt;&lt;tr&gt;       &lt;td valign="top" width="167"&gt;&lt;strong&gt;Guest OS&lt;/strong&gt;&lt;/td&gt;        &lt;td valign="top" width="175"&gt;&lt;/td&gt;        &lt;td valign="top" width="274"&gt;&lt;/td&gt;     &lt;/tr&gt;&lt;tr&gt;       &lt;td valign="top" width="167"&gt;supported OS [6]&lt;/td&gt;        &lt;td valign="top" width="175"&gt;Red Hat Enterprise Linux          &lt;br /&gt;Windows           &lt;/td&gt;        &lt;td valign="top" width="274"&gt;All major Linux distributions          &lt;br /&gt;Windows           &lt;br /&gt;Solaris           &lt;br /&gt;Mac OS/BSD&lt;/td&gt;     &lt;/tr&gt;&lt;tr&gt;       &lt;td valign="top" width="167"&gt;Clone [7]&lt;/td&gt;        &lt;td valign="top" width="175"&gt;Supported&lt;/td&gt;        &lt;td valign="top" width="274"&gt;supported&lt;/td&gt;     &lt;/tr&gt;&lt;tr&gt;       &lt;td valign="top" width="167"&gt;Snapshot [8]&lt;/td&gt;        &lt;td valign="top" width="175"&gt;limited support&lt;/td&gt;        &lt;td valign="top" width="274"&gt;supported&lt;/td&gt;     &lt;/tr&gt;&lt;tr&gt;       &lt;td valign="top" width="167"&gt;Supported Hard disk [9]&lt;/td&gt;        &lt;td valign="top" width="175"&gt;IDE, VirtIO &lt;/td&gt;        &lt;td valign="top" width="274"&gt;IDE,SCSI&lt;/td&gt;     &lt;/tr&gt;&lt;tr&gt;       &lt;td valign="top" width="167"&gt;Cost&lt;/td&gt;        &lt;td valign="top" width="175"&gt;~2/3 of VMware cost&lt;/td&gt;        &lt;td valign="top" width="274"&gt;expensive&lt;/td&gt;     &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;NOTES:&lt;/strong&gt;&lt;br /&gt;[1]&amp;nbsp; Manager CLI:&amp;nbsp; RHEV-M PowerShell has fewer number of cmdlets compared to PowerCLI&lt;br /&gt;&lt;br /&gt;[2] Manager independent: In my opinion, it is RHEV’s&amp;nbsp; biggest mistake in design. RHEV-M is the central brain, the hypervisor is dummy host, which means you are NOT supposed to login to hypervisor to do configuration or VM operation,&amp;nbsp; e.g. add virtual network or start/stop vms. All must be done in RHEV-M. On the other hand, each VMware&amp;nbsp; ESX host is intelligent by design,&amp;nbsp; you can perform almost anything by esxcfg*/vimsh commands. ESX host just rely manager for HA and Distributed Resource Scheduling.(if RHEV-M fails, VMs in RHEV-H will not be interrupted, but don’t touch them, because you can’t restart them without RHEV-M)&lt;br /&gt;&lt;br /&gt;[3] Hypervisor &amp;nbsp;HA: RHEV requires a form of fencing method for HA, e.g smart power switch or LOM card to shoot hypervisor in the head.&lt;br /&gt;&lt;br /&gt;[4] Hypervisor CLI:&amp;nbsp; libvirt CLI tools are supported in KVM, but RHEV doesn’t use libvirt.&lt;br /&gt;&lt;br /&gt;[5] Storage Type: You can’t utilize RHEV-H local storage, it is not visible in manager.RHEV datacenter &amp;nbsp;has a "storage type" (NFS/iSCSI/FC) &amp;nbsp;attribute, only single storage domain with the same type can be attached to datacenter. &lt;br /&gt;&lt;br /&gt;[6] Supported guest OS: In paper, RHEL and Windows are the only supported OS, but you can &amp;nbsp;install almost any x86 OS, because RHEV-H is based on KVM not para-virtualization &lt;br /&gt;&lt;br /&gt;[7] Clone: RHEV doesn’t call it clone,&amp;nbsp; You have to choose a template when creating new VM. VMware support clone from template or VM.&lt;br /&gt;&lt;br /&gt;[8] Snapshot: You have to&amp;nbsp; shutdown&amp;nbsp; RHEV VM to snapshot it.&lt;br /&gt;&lt;br /&gt;[9] VirtIO: RHEL 5.x has built-in VirtIO driver, Other Linux should also has VirtIO driver. for windows,&amp;nbsp; RHEV provide Virtual floppy file, virtio*.vfd,&amp;nbsp; to be used&amp;nbsp; during&amp;nbsp; installation. Any other OS without VirtIO has to use IDE (SCSI is not supported, VirtIO is supposed to deliver better performance than SCSI) &lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Conclusion:&lt;/strong&gt;&lt;br /&gt;In my opinion, so far, RHEV Server is not enterprise ready due to limitations of&amp;nbsp; [3] , [4],&amp;nbsp; and [8]. RHEV&amp;nbsp; Server lose to VMware ESX in almost every feature compared, However, RHEV does a better job in desktop virtualization thanks to Qumranet, whose root was desktop virtualization. (In 2008, Red Hat acquired Qumranet, from which the RHEV-M originated).&lt;br /&gt;&lt;br /&gt;It is reported that Red Hat is developing RHEV 3, which will be based on Jboss (Java) &amp;nbsp;in Linux with PostgreSQL DB backend. Hopefully, RHEV 3 can redesign RHEV-H to make it “intelligent” by integrating libvirt for CLI ability in hypervisor.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1822605347830719087-5777949475356263552?l=honglus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://honglus.blogspot.com/feeds/5777949475356263552/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://honglus.blogspot.com/2011/06/red-hat-rhev-vs-vmware-esx.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/5777949475356263552'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/5777949475356263552'/><link rel='alternate' type='text/html' href='http://honglus.blogspot.com/2011/06/red-hat-rhev-vs-vmware-esx.html' title='Red Hat RHEV vs Vmware ESX'/><author><name>honglus</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1822605347830719087.post-1726703798540846077</id><published>2011-06-08T13:05:00.003+10:00</published><updated>2011-09-15T16:22:12.258+10:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Scripting'/><category scheme='http://www.blogger.com/atom/ns#' term='Tips/Tricks'/><title type='text'>Create a shell script to display progress meter like wget's meter style</title><content type='html'>The following is a shell script to display progress meter like wget's meter style&lt;br /&gt;&lt;strong&gt;The shell script output&lt;/strong&gt;&lt;br /&gt;&lt;pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$./meter.sh &lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;27 % |======================&amp;gt;                                                                   |&lt;/pre&gt;&lt;/pre&gt;&lt;strong&gt;The shell script source code&lt;/strong&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: consolas, 'Courier New', courier, monospace; font-size: 12px; white-space: pre;"&gt;$cat ./meter.sh&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#!/bin/ksh&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Given start number and end number, display  progress meter and percentage like wget's style&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;start=1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#end=333&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;end&lt;/span&gt;=33&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;scale=$(($&lt;span style="color: blue;"&gt;end&lt;/span&gt;/100.0))&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;for&lt;/span&gt; i &lt;span style="color: blue;"&gt;in&lt;/span&gt; {$start..$&lt;span style="color: blue;"&gt;end&lt;/span&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;do&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;m1=$(($i / $scale)); m2=$(( ($&lt;span style="color: blue;"&gt;end&lt;/span&gt; - $i ) / $scale ))&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;integer m1; integer m2&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#fill 2 segments of variable length  with zeros&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;str=$( &lt;span style="color: darkblue;"&gt;printf&lt;/span&gt; "&lt;span style="color: darkred;"&gt;%0${m1}d %s %0${m2}d\n&lt;/span&gt;"   0 "&lt;span style="color: darkred;"&gt;&amp;gt;&lt;/span&gt;" 0  ) &lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;str="&lt;span style="color: darkred;"&gt;|$str|&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#replace first segment zeros with '=' 2nd segment zeros with space then re-join&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;str1=$(echo $str | awk -F' &amp;gt; ' '{ &lt;span style="color: darkblue;"&gt;print&lt;/span&gt; $1 }'); str1=${str1//0/=}&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;str2=$(echo $str | awk -F' &amp;gt; ' '{ &lt;span style="color: darkblue;"&gt;print&lt;/span&gt; $2 }'); str2=${str2//0/' '}&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;str="&lt;span style="color: darkred;"&gt;${str1}&amp;gt;${str2}&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;pct=$(($i * 100 / $&lt;span style="color: blue;"&gt;end&lt;/span&gt; ))&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Beautify the final loop &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;[ $i -eq $&lt;span style="color: blue;"&gt;end&lt;/span&gt; ] &amp;amp;&amp;amp; str=$(echo $str | sed -e 's/ /=/g' -e 's/&amp;gt;/=/g' -e 's/0/=/g' )&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: darkblue;"&gt;print&lt;/span&gt; -n "&lt;span style="color: darkred;"&gt; \\r ${pct} % $str &lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: darkblue;"&gt;sleep&lt;/span&gt; 1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;done&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: white; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: darkblue;"&gt;printf&lt;/span&gt; "&lt;span style="color: darkred;"&gt;\n&lt;/span&gt;"&lt;/pre&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1822605347830719087-1726703798540846077?l=honglus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://honglus.blogspot.com/feeds/1726703798540846077/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://honglus.blogspot.com/2011/06/create-shell-script-to-display-progress.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/1726703798540846077'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/1726703798540846077'/><link rel='alternate' type='text/html' href='http://honglus.blogspot.com/2011/06/create-shell-script-to-display-progress.html' title='Create a shell script to display progress meter like wget&amp;#39;s meter style'/><author><name>honglus</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1822605347830719087.post-7792436208148784393</id><published>2011-05-30T16:15:00.008+10:00</published><updated>2011-05-30T17:32:37.853+10:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><title type='text'>Build RPM from source file</title><content type='html'>Traditionally, Installing &amp;nbsp;from source file need to go through several steps: ./configure;make;make install;make clean. RPM can automate the process by SPEC file. Once binary RPM package is generated, it can be easily distributed to other servers.    &lt;br /&gt;This article use hping3 source file as an example to demonstrate the basics to build RPM. For further information, please refer to &lt;a href="http://rpm5.org/docs/rpm-guide.html"&gt;http://rpm5.org/docs/rpm-guide.html&lt;/a&gt;&lt;br /&gt;&lt;strong&gt;Install rpmbuild &lt;/strong&gt;&lt;br /&gt;&lt;pre&gt;$yum install rpm-build&lt;/pre&gt;&lt;strong&gt;RPM Macros&lt;/strong&gt;&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Various RPM Macros locations&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/usr/lib/rpm/macros &lt;span style="color: green;"&gt;#Global default macros&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/etc/rpm/micros   &lt;span style="color: green;"&gt;#Global user defined macros&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;~/.rpmmacros  &lt;span style="color: green;"&gt;#per-user defined  macros&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;rpmbuild --define 'macro_name value '   &lt;span style="color: green;"&gt;#define at run time&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#display a macro&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ rpm --&lt;span style="color: darkblue;"&gt;eval&lt;/span&gt; %{_vendor}&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;redhat&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#display all macros&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;rpm --showrc&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;strong&gt;Setup build environment&amp;nbsp;&lt;/strong&gt;&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;strong&gt;&lt;span style="color: green;"&gt;#It is preferred to use a non-root user  to to control build&lt;/span&gt;&lt;/strong&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;strong&gt;$useradd builder&lt;/strong&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;strong&gt;$ echo '%_topdir    /home/builder/redhat'  &amp;gt; .rpmmacros&lt;/strong&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;strong&gt;$ mkdir -&lt;span style="color: darkblue;"&gt;p&lt;/span&gt; /home/builder/redhat/{BUILD,RPMS,SOURCES,SPECS,SRPMS}&lt;/strong&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;strong&gt;Building RPM&amp;nbsp; involves following steps:&lt;/strong&gt;&lt;br /&gt;1. Preparing for building, including unpacking the sources&lt;br /&gt;2. Building (compiling) &lt;br /&gt;3. Installing the application or library &lt;br /&gt;4. Cleaning up&lt;br /&gt;5. Customized scripts for pre-install,post-install, pre-uninstall, post-uninstall&lt;br /&gt;6. List files to be packaged into RPM&lt;br /&gt;7. Add changelog&lt;br /&gt;8. GPG sign package&lt;br /&gt;&lt;strong&gt;The first 7 steps are controlled by SPEC&amp;nbsp; file&lt;/strong&gt;&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##This spec file use hping3 source file as an example &lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;[builder]$ cat  /home/builder/redhat/SPECS/hping3.spec&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;%define name hping3&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;%define version 3.0&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Name: %{name}&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Version: %{version}&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Release: 0&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;License: GPL&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##Pick a name in  /usr/share/doc/rpm-*/GROUPS&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Group: Applications/System&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;URL: http://www.hping.org&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##All  source files should be packed  under a dir named:    %{name}-%{version}   e.g. ./hping3-3.0/*&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##Packed file name should be  %{name}-%{version}.XX  e.g. hping3-3.0.tar.gz&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Source: hping3-3.0.tar.gz&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Patch0: hping3.patch&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Patch1: 2.patch&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#PreReq: unzip&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##libpcap is required package for hping to work&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Requires: libpcap&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##gcc and libpcap-devel are required duing compling&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;BuildPreReq: gcc libpcap-devel&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;BuildArch:x86_64&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##BuildRoot is staging area that looks like the final installation directory &lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##all final files are copied to BuildRoot&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;BuildRoot: %{_tmppath}/%{name}-root&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Summary: hping3 is a network tool.&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;%Description&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;hping3 is a network tool able to send custom TCP/IP&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;packets &lt;span style="color: blue;"&gt;and&lt;/span&gt; to display target replies like ping &lt;span style="color: blue;"&gt;do&lt;/span&gt; with&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;ICMP replies.&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##1. Prepare&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;%prep&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;####%setup will go to ~/redhat/BUILD dir and unpack soure files&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;%setup -q&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;%patch0&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##2. Build&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;%build&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;%configure --no-tcl&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;make&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##3. Install&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;%install&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;rm -rf $RPM_BUILD_ROOT&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;mkdir -&lt;span style="color: darkblue;"&gt;p&lt;/span&gt; $RPM_BUILD_ROOT{/usr/sbin,/usr/share/man/man8}&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;install -m 755 hping3   $RPM_BUILD_ROOT/usr/sbin/&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;(cd $RPM_BUILD_ROOT/usr/sbin; ln -s hping3 hping2 ; ln -s hping3 hping )&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;%{__gzip}  ./docs/hping3.8&amp;amp;&amp;amp; \&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;install -m 644 ./docs/hping3.8.gz $RPM_BUILD_ROOT/usr/share/man/man8&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##4. Clean up&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;%clean&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;rm -rf $RPM_BUILD_ROOT&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;make clean&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##-5. customized scripts; view all scripts of a rpm file "rpm -q --scripts file.rpm"&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;####user is not needed, demonstration purpose only&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;%pre&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;useradd hping&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;%post&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;chage -M -1 hping&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#### $1=0 remove; $1=1 first install; $1&amp;gt;=2 upgrade&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;%postun&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;if&lt;/span&gt; [ $1 = 0 ]; &lt;span style="color: blue;"&gt;then&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;userdel -r hping&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;fi&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##6. list files to be packed to RPM&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;%files&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;%defattr(-,root,root)&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;%attr(755,root,root) /usr/sbin/hping*&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;%doc /usr/share/man/man8/hping3.8.gz&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##7. changlog&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;%changelog&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#### date Format:  date +'%a %b %d %Y'&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;* Mon May 30 2004   antirez &amp;lt;email@com&amp;gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;- First public release of hping3&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;strong&gt;Test each stage by rpmbuild&lt;/strong&gt;&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$rpmbuild --help&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Build options with [ &amp;lt;specfile&amp;gt; | &amp;lt;tarball&amp;gt; | &amp;lt;source package&amp;gt; ]:&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;-bp                           build through %prep (unpack sources &lt;span style="color: blue;"&gt;and&lt;/span&gt; apply&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;patches) from &amp;lt;specfile&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;-bc                           build through %build (%prep, &lt;span style="color: blue;"&gt;then&lt;/span&gt; compile)&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;from &amp;lt;specfile&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;-bi                           build through %install (%prep, %build, &lt;span style="color: blue;"&gt;then&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;install) from &amp;lt;specfile&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;-bl                           verify %files section from &amp;lt;specfile&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;-ba                           build source &lt;span style="color: blue;"&gt;and&lt;/span&gt; binary packages from&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&amp;lt;specfile&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;-bb                           build binary package only from &amp;lt;specfile&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;strong&gt;GPG Sign RPM file&lt;/strong&gt;&lt;br /&gt;Sign a package to prove source identity &amp;nbsp;of the file&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Create gpg key pair,remmber the keypass for private key, it will be asked when signing package&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$gpg --gen-key&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Tell rpm which gpg key to use&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ cat ~/.rpmmacros&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;%_topdir    /home/builder/redhat&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;%_signature gpg&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;%_gpg_name rpm &lt;span style="color: darkblue;"&gt;test&lt;/span&gt; &amp;lt;rpm.&lt;span style="color: darkblue;"&gt;test&lt;/span&gt;@com&amp;gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Sign RPM with GPG private key&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Before RPM created, use rpmbuid --sign spec-file&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#After RPM created, use rpm --resign&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$rpm --resign /home/builder/redhat/RPMS/x86_64/hping3-3.0-0.x86_64.rpm&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Export GPG pulic key&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$gpg --export -a &amp;gt; /tmp/my-gpg.pub&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Before import, signature "NOT OK"&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$rpm --checksig hping3-3.0-0.x86_64.rpm&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;hping3-3.0-0.x86_64.rpm: (SHA1) DSA sha1 md5 (GPG) NOT OK (MISSING KEYS: GPG&lt;span style="color: green;"&gt;#31f8d18a)&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Import GPG pub key&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$rpm --&lt;span style="color: darkblue;"&gt;import&lt;/span&gt; /tmp/my-gpg.pub&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#after import,  signature "OK"&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ rpm --checksig hping3-3.0-0.x86_64.rpm&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;hping3-3.0-0.x86_64.rpm: (sha1) dsa sha1 md5 gpg OK&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#list all imported GPG keys&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ rpm -qa gpg*&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;gpg-pubkey-32a349c9-493c185a&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;gpg-pubkey-31f8d18a-4de2fc7b&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;gpg-pubkey-e8562897-459f07a4&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1822605347830719087-7792436208148784393?l=honglus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://honglus.blogspot.com/feeds/7792436208148784393/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://honglus.blogspot.com/2011/05/build-rpm-from-source-file.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/7792436208148784393'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/7792436208148784393'/><link rel='alternate' type='text/html' href='http://honglus.blogspot.com/2011/05/build-rpm-from-source-file.html' title='Build RPM from source file'/><author><name>honglus</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1822605347830719087.post-1146627017781783377</id><published>2011-05-28T15:44:00.004+10:00</published><updated>2011-07-02T15:07:29.908+10:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='RHCE/RHCA'/><title type='text'>Passed 2/5 RHCA: EX436 Clustering and Storage Management</title><content type='html'>EX436 is easier than EX442(System Monitoring and Performance Tuning), because testing subjects are less and the method of testing is just straight forward setup and configuration, unlike EX442, which requires extensive analysis and calculation. &lt;br /&gt;I didn't pay attention to RHEL release during exam, But,RHEL 5.4,is showed in my exam result. Although GFS2 is default starting from RHEL 5.3, GFS is the subject to be tested. I think it won't&amp;nbsp; be changed until RHEL 6 courseware comes out.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;My blog post for EX436 study notes&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://honglus.blogspot.com/2011/05/gfs-global-file-system-quickstart.html"&gt;GFS(Global File System) quickstart&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://honglus.blogspot.com/2011/05/rhcsred-hat-cluster-suite-quorum-disk.html"&gt;RHCS(Red Hat Cluster Suite) quorum disk&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://honglus.blogspot.com/2011/05/rhcsred-hat-cluster-suite-io-fencing.html"&gt;RHCS(Red Hat Cluster Suite) I/O fencing using SNMP IFMIB&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://honglus.blogspot.com/2011/04/do-we-really-need-to-set-partition-type.html"&gt;Do we really need to set partition type to fd(Linux auto raid) for Linux software RAID?&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1822605347830719087-1146627017781783377?l=honglus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://honglus.blogspot.com/feeds/1146627017781783377/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://honglus.blogspot.com/2011/05/passed-25-rhca-ex436-clustering-and.html#comment-form' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/1146627017781783377'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/1146627017781783377'/><link rel='alternate' type='text/html' href='http://honglus.blogspot.com/2011/05/passed-25-rhca-ex436-clustering-and.html' title='Passed 2/5 RHCA: EX436 Clustering and Storage Management'/><author><name>honglus</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1822605347830719087.post-556480787824139248</id><published>2011-05-22T17:43:00.005+10:00</published><updated>2011-05-22T17:52:26.237+10:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Apps'/><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><title type='text'>Subversion Quickstart</title><content type='html'>This short tutorial is intended for new users to grasp subversion quickly.    &lt;br /&gt;Subversion is a open source version control system based on Copy-Modify-Merge&amp;nbsp; model rather than lock-Modify-Unlock model.     &lt;br /&gt;It is primarily used for software development, which allows developers to modify files and directories concurrently (no locking) and switch between versions easily.&amp;nbsp; In system administration world, it could be used to track system changes and roll back changes. &lt;br /&gt;&lt;strong&gt;Fundamental Concepts(don't skip):&lt;br /&gt;&lt;/strong&gt;&amp;nbsp;&lt;strong&gt;- &lt;/strong&gt;The Repository&lt;br /&gt;Repository is a central store for all versions of data, subversion server configuration files are also located in the repository.     &lt;br /&gt;Once repository is created, you are NOT supposed to visit the repository directory other than changing subversion server configuration     &lt;br /&gt;You should modify versions of data in a “working copy” of the repository data. &lt;br /&gt;The repository can be accessed in a number ways: &lt;br /&gt;&lt;pre&gt;file:/// Direct repository access (on local disk)&lt;br /&gt;http:// Access via WebDAV protocol to Subversion-aware Apache server&lt;br /&gt;https:// Same as http://, but with SSL encryption.&lt;br /&gt;svn:// Access via custom protocol to an svnserve server&lt;br /&gt;svn+ssh:// Same as svn://, but through an SSH tunnel&lt;/pre&gt;To setup svnserv server to offer svn:// access over network, you need to enable authentication and authorization&amp;nbsp; by modifying&amp;nbsp; repository-path/conf/{svnserve.conf,passwd,authz} then start “svnserve -d -r repository-path”&lt;br /&gt;&lt;strong&gt;- &lt;/strong&gt;The Working copy directory&lt;br /&gt;A working copy is a subset of repository data. To creating a working copy, use “svn checkout” to checkout the root or sub directory of repository. &lt;br /&gt;You modify data in&amp;nbsp; “working copy” &lt;strong&gt;NOT&lt;/strong&gt;&amp;nbsp; in repository directory&lt;br /&gt;&lt;strong&gt;Install subversion&amp;nbsp;&lt;/strong&gt;&lt;br /&gt;Most Linux distros include subversion by default. to Install in Centos: &lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;$yum install subversion&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;$rpm -qa | grep subv&lt;br /&gt;subversion-1.6.11-7.el5_6.3&lt;/pre&gt;&lt;strong&gt;Create&amp;nbsp; a subversion repository&lt;/strong&gt;&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#It is where all data are saved, you should have enough space&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$svnadmin create /var/svn&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#svnadmin populated the directory with following structure&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#conf is the location of server configuration files&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#db is the location of your versions of data&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ls /var/svn&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;conf  db  &lt;span style="color: darkblue;"&gt;format&lt;/span&gt;  hooks  locks  README.txt&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#It is ideal to create individual directory for different project.&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#-m is to give a description of this operation, later, it can be view with “svn log”&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#This transaction is recorded as revision 1&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#the command is svn not svnadmin&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#svnadmin and svnlook are server side commands, They always action on a PATH  NOT a URL like file:///”&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$svn mkdir file:///var/svn/proj_1 -m "&lt;span style="color: darkred;"&gt;test mkdir&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Committed revision 1.&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Verify the sub dir is created&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$svn list -v  file:///var/svn&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;3 root                  May 22 11:33 ./&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;3 root                  May 22 11:33 proj_1/&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;strong&gt;Import data&amp;nbsp; into the repository&lt;/strong&gt;&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#let's import /etc/sysconfig  into the repository&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#import is used to to populate repository for the first time&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#adding new files later need “svn add” command in a “working copy”&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ svn &lt;span style="color: darkblue;"&gt;import&lt;/span&gt; /etc/sysconfig/  file:///var/svn/proj_1 -m "&lt;span style="color: darkred;"&gt;test import&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Adding         /etc/sysconfig/irda&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Adding         /etc/sysconfig/kernel&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Adding         /etc/sysconfig/syslog&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;..&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Adding         /etc/sysconfig/snmpd.options&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Committed revision 2.&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#let's view the imported files in repository&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#something wrong? Where are those files? even dir “proj_1” doesn't exist&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#let me repeat, you are supposed to modify data in repository directly,  Do this in a “working copy”&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ls  /var/svn&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;conf  db  &lt;span style="color: darkblue;"&gt;format&lt;/span&gt;  hooks  locks  README.txt&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;# if you are curious about where the data is stored, all data are “packed” in a binary file&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ strings /var/svn/db/revs/0/2 | grep $(hostname)&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;HOSTNAME=filer.example.com&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;# or view “svn ls”  and “svn cat”&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;svn cat file:///var/svn/proj_1/network&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;NETWORKING=yes&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;NETWORKING_IPV6=no&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;HOSTNAME=filer.example.com&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;strong&gt;Create a working copy&lt;/strong&gt;&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#create a working copy by checkout proj_1,  The target dir proj_1 will be automatically created, of course, you can name it differently &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$cd /root/svn&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$svn checkout file:///var/svn/proj_1 proj_1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;A    proj_1/irda&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;A    proj_1/kernel&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;A    proj_1/syslog&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#I want to add /etc/hosts to repository&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#any operations in “working copy” should use subversion-aware commands e.g “svn mkdir, svn add, svn mv, svn cp”&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ cd  /root/svn/proj_1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$svn mkdir  ./etc&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ cp /etc/hosts ./etc&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ svn add ./etc/hosts&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;A         etc/hosts&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#commit the changes to repository&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$svn commit -m "&lt;span style="color: darkred;"&gt;added hosts file&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Adding         etc&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Adding         etc/hosts&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Transmitting file data .&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Committed revision 3.&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#svnlook shows the latest version is 3&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$svnlook  youngest  /var/svn&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;3&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$svn log /root/svn/proj_1/&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;------------------------------------------------------------------------&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;r3 | root | 2011-05-22 11:33:03 +1000 (Sun, 22 May 2011) | 1 line&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;added hosts file&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;------------------------------------------------------------------------&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;r2 | root | 2011-05-22 11:29:17 +1000 (Sun, 22 May 2011) | 1 line&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: darkblue;"&gt;test&lt;/span&gt; &lt;span style="color: darkblue;"&gt;import&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;------------------------------------------------------------------------&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;r1 | root | 2011-05-22 11:29:05 +1000 (Sun, 22 May 2011) | 1 line&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: darkblue;"&gt;test&lt;/span&gt; mkdir&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;------------------------------------------------------------------------&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$svn diff -r 2:3  /root/svn/proj_1/&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Index: /root/svn/proj_1/etc/hosts&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;===================================================================&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;--- /root/svn/proj_1/etc/hosts  (revision 0)&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;+++ /root/svn/proj_1/etc/hosts  (revision 3)&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;@@ -0,0 +1,8 @@&lt;/pre&gt;&lt;/pre&gt;&lt;strong&gt;Rollback to previous versions&lt;/strong&gt; &lt;br /&gt;That is where subversion shines, no matter how many changes you have made, one simple command can switch versions &lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ svn update -r 2 /root/svn/proj_1/&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;D    /root/svn/proj_1/etc&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Updated to revision 2.&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ ls ./etc&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;ls: ./etc: No such file &lt;span style="color: blue;"&gt;or&lt;/span&gt; directory&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$svn update -r 3 /root/svn/proj_1/&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;A    /root/svn/proj_1/etc&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;A    /root/svn/proj_1/etc/hosts&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Updated to revision 3.&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ ls ./etc&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;hosts&lt;/pre&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1822605347830719087-556480787824139248?l=honglus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://honglus.blogspot.com/feeds/556480787824139248/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://honglus.blogspot.com/2011/05/subversion-quickstart.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/556480787824139248'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/556480787824139248'/><link rel='alternate' type='text/html' href='http://honglus.blogspot.com/2011/05/subversion-quickstart.html' title='Subversion Quickstart'/><author><name>honglus</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1822605347830719087.post-8347869550843015037</id><published>2011-05-17T21:59:00.010+10:00</published><updated>2011-06-08T22:26:21.715+10:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Storage'/><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><category scheme='http://www.blogger.com/atom/ns#' term='Cluster'/><title type='text'>GFS (Global File System) quickstart</title><content type='html'>&lt;strong&gt;What is GFS?     &lt;br /&gt;&lt;/strong&gt;GFS allow all nodes to have direct CONCURRENT write access to the same shared BLOCK storage.     &lt;br /&gt;For local file system e.g ext3, A shared BLOCK storage can be mounted in multiple nodes, but CONCURRENT write access is not allowed&lt;br /&gt;For NFS, the CONCURRENT write access is allowed, but it is not direct BLOCK device, which introduce delay and another layer of failure.    &lt;br /&gt;&lt;strong&gt;GFS requirements:     &lt;br /&gt;&lt;/strong&gt; - A shared block storage (iSCSI, FC SAN etc.. )    &lt;br /&gt;- RHCS (Red hat Cluster suite) (although GFS can be mounted in standalone server without cluster, it is primarily used for testing purpose or recovering data when cluster fails)    &lt;br /&gt;- RHEl 3.x onwards (RHEL derivatives: Centos/Fedora), it should work in other Linux distributions, since GFS and RHCS have been open sourced.    &lt;br /&gt;&lt;strong&gt;GFS specifications:     &lt;br /&gt;&lt;/strong&gt; - RHEL 5.3 onwards use GFS2    &lt;br /&gt;- RHEl 5/6.1 supports maximum 16 nodes    &lt;br /&gt;- RHEL 5/6.1 64 bit supports maximum file system size of 100TB (8 EB in theory)    &lt;br /&gt;- Supports: data and metadata journaling, quota, acl, Direct I/O, growing file system online, dynamic inodes (convert inode block to data block)&amp;nbsp; &lt;br /&gt;- LVM snapshot of CLVM under GFS&amp;nbsp; is NOT yet supported.    &lt;br /&gt;&lt;strong&gt;GFS components:&lt;/strong&gt;    &lt;br /&gt;RHCS components: OpenAIS, CCS, fenced, CMAN and CLVMD (Clustered LVM)    &lt;br /&gt;GFS specific component: Distributed Lock Manager (DLM)&lt;br /&gt;&lt;strong&gt;Install RHCS and GFS&amp;nbsp; rpms&lt;/strong&gt;    &lt;br /&gt;Luci (Conga project) is the easiest way to install and configure RHCs and GFS.&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#GFS specific packages:&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#RHEL 5.2 or lower versions &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$yum install gfs-utils    kmod-gfs &lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#RHEL 5.3 onwards, gfs2 module is part of kernel &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$yum install gfs2-utils   &lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;strong&gt;Create GFS on LVM&lt;/strong&gt;&lt;br /&gt;You can create GFS on raw device, but LVM is recommended for consistent device names and the ability to extend device&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Assume you have setup and tested a working RHCS&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Edit cluster lock type in /etc/lvm/lvm.conf on ALL nodes&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;locking_type=3 &lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Create PV/VG/LV as if in standalone system ONCE in any ONE of the nodes&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Start Cluster and clvmd on ALL nodes &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Better use luci GUI interface to start whole cluster &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$Service cman start&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$Service rgmanager start&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$servcie clvmd start&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Create GFS ONCE in any ONE of the nodes&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;# -p lock_dlm is required in cluster mode. Lock_nolock is for standalone system&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;# -t cluster1:gfslv      ( Real cluster-name: arbitrary  GFS name )&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;# Above information is stored in GFS superblock, which can be changed with “gfs_tool sb” without re-initializing GFS e.g change lock type: "gfs_tool sb /device proto lock_nolock" &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#-j 2: the number of journals, minimum 1 for each node. The default journal size is 128Mib, can be overridden by -J&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#additional journal can be added with gfs_jadd&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;gfs_mkfs -&lt;span style="color: darkblue;"&gt;p&lt;/span&gt; lock_dlm -t cluser1:gfslv -j 2 /dev/vg01/lv01&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Mount GFS in cluster member by /etc/fstab&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#put GFS mount in /etc/fstab in ALL nodes&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#NOTE:&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Cluster service can mount GFS without /etc/fstab after adding GFS as resource, but It can only mount on one node (the active node).  Since GFS is supposed to be mounted on all nodes at the same&lt;/span&gt; &lt;span class="Apple-style-span" style="color: green;"&gt;time. /etc/fstab is a must, GFS resource is optional.&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#GFS mount options: lockproto, locktable are optional, mount can obtain the information from superblock automatically&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$cat /etc/fstab&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/dev/vg01/lv01          /mnt/gfs                gfs     defaults 0 0&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Mount all GFS mounts&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;service gfs start&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;strong&gt;GFS command lines&lt;/strong&gt;&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;####Check GFS super block &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#some values can be changed by “gfs_tool sb”&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$gfs_tool sb /dev/vg01/lv01 all&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;sb_bsize = 4096&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;sb_lockproto = lock_dlm&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;sb_locktable = cluster1:gfslv01&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;.. &lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;####GFS tunable parameters &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#view parameters&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;gfs_tool gettune &amp;lt;mountpoint&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#set parameters &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#The parameters don’t persist after re-mount, You can customize /etc/init.d/gfs to set tunable parameters on mounting&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;gfs_tool settune &amp;lt;mountpoint&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;####Performance related parameters&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#like other file system, you can disable access time update by mount option “noatime”&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#GFS can also allow you to control how often to update access time&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$gfs_tool gettune /mnt/gfs | grep atime_quantum   &lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;atime_quantum=3660          &lt;span style="color: green;"&gt;#in secs&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Disable quota, if not needed&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#GFS2 remove the parameter and implement it in mount option “quota=off”&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$gfs_tool settune /mnt/gfs quota_enforce 0&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#GFS direct I/O&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Enable directI/O for database files, if DB has its own buffering mechanism to avoid “double” buffering &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$gfs_tool setflag directio /mnt/gfs/&lt;span style="color: darkblue;"&gt;test&lt;/span&gt;.1     &lt;span style="color: green;"&gt;#file attribute&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$gfs_tool setflag inherit_directio /mnt/gfs/db/     &lt;span style="color: green;"&gt;#DIR attribute&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$gfs_tool clearflag directio /mnt/gfs/&lt;span style="color: darkblue;"&gt;test&lt;/span&gt;.1              &lt;span style="color: green;"&gt;#remove attribute&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$gfs_tool stat  inherit_directio /mnt/gfs/file     &lt;span style="color: green;"&gt;# view attribute&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#enable data journal for very small files&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#disable data journal for large files&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$gfs_tool setflag inherit_jdata  /mnt/gfs/db/     &lt;span style="color: green;"&gt;#Enable  data journal (only metadata  has journal  by default) on a dir. (if operate on a file, the file must be zero size)&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;###GFS backup, CLVM doesn't support snapshot&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$gfs_tool freeze /mnt/gfs          &lt;span style="color: green;"&gt;#change GFS to read-only (done once in any one of the nodes)&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$gfs_tool unfreeze /mnt/gfs&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;###GFS repair &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#after unmount GFS on all nodes&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$gfs_fsck  -v /dev/vg01/lv01         &lt;span style="color: green;"&gt;# gfs_fsck -v -n /dev/vg01/lv01 : -n answer no to all questions, inspect gfs only without making changes&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;b&gt;GFS implementation scenarios:&lt;/b&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;GFS’s strength is the ability to do concurrent write to the same block device, It make it possible for Active-Active cluster nodes to write to the same block device, but there are few such cases in real life.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;In Active-Active cluster nodes (all nodes perform the same task), RHCS can’t do load balancing itself, it requires external load balancer&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;b&gt;&amp;nbsp;- Database server cluster&lt;/b&gt;: In theory, all nodes can write to the same DB file concurrently, However, the performance will be degraded, because all nodes try to lock the file via &lt;/span&gt;&lt;span class="apple-style-span"&gt;&lt;span style="color: #333333; font-family: Verdana, sans-serif; font-size: 9pt; line-height: 115%;"&gt;Distributed Lock Manager&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US"&gt;.&amp;nbsp; You can assign different task to cluster nodes to write to different DB file, e.g. node-A run DB-A and node-B run DB-B, but this can be done, without GFS, by mounting&amp;nbsp; ext3 on individual iSCSI/FC disk.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;GFS doesn’t lose to ext3 in above scenario, but its lack of LVM snapshot of in GFS‘s CLVMD kills my inspiration of using DB on GFS&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;b&gt;&amp;nbsp;- Application server cluster:&lt;/b&gt; e.g. Apache, Jboss server cluster. It is the true that GFS can simply application package deployment because all nodes can share the same application package binaries. But if you only use two nodes cluster, deploying application twice is not big hassle. Maintaining single copy of application binaries is convenient, but at risk of single point of failure.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal"&gt;&lt;span lang="EN-US"&gt;&lt;b&gt;&amp;nbsp;- NFS Cluster:&lt;/b&gt; Because NFS is I/O bound, Why would you run Active-Active NFS cluster with CPU/memory resource in nodes are not being fully utilized?&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1822605347830719087-8347869550843015037?l=honglus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://honglus.blogspot.com/feeds/8347869550843015037/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://honglus.blogspot.com/2011/05/gfs-global-file-system-quickstart.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/8347869550843015037'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/8347869550843015037'/><link rel='alternate' type='text/html' href='http://honglus.blogspot.com/2011/05/gfs-global-file-system-quickstart.html' title='GFS (Global File System) quickstart'/><author><name>honglus</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1822605347830719087.post-73827044589443832</id><published>2011-05-10T21:00:00.004+10:00</published><updated>2011-05-10T21:09:57.373+10:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Storage'/><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><title type='text'>LVM2: device filter and LVM metadata restore</title><content type='html'>&lt;strong&gt;Customize LVM device filter to get rid of the annoying “/dev/cdrom: open failed” warning&lt;/strong&gt;&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##/dev/cdrom: open failed warning&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$pvcreate /dev/sdb1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/dev/cdrom: &lt;span style="color: darkblue;"&gt;open&lt;/span&gt; failed: Read-only file &lt;span style="color: darkblue;"&gt;system&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ vgcreate vg01 /dev/sdb1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/dev/cdrom: &lt;span style="color: darkblue;"&gt;open&lt;/span&gt; failed: Read-only file &lt;span style="color: darkblue;"&gt;system&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##The error because LVM scan all device files by default, you can exclude some device files by device filters&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##File /etc/lvm/cache/.cache contains the device file names scanned by LVM&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ cat /etc/lvm/cache/.cache&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;persistent_filter_cache {&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;valid_devices=[&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;"&lt;span style="color: darkred;"&gt;/dev/ram11&lt;/span&gt;",&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;"&lt;span style="color: darkred;"&gt;/dev/cdrom&lt;/span&gt;",&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##Edit /etc/lvm/lvm.conf, Change default filter  &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;filter = [ "&lt;span style="color: darkred;"&gt;a/.*/&lt;/span&gt;" ]&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#to&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;filter = [ "&lt;span style="color: darkred;"&gt;r|/dev/cdrom|&lt;/span&gt;","&lt;span style="color: darkred;"&gt;r|/dev/ram*|&lt;/span&gt;" ]&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##You need to delete the cache file or ran vgscan to regenerate the file&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$rm /etc/lvm/cache/.cache   OR vgscan&lt;/pre&gt;&lt;/pre&gt;&lt;strong&gt;LVM metadata backup and restore&amp;nbsp;&lt;/strong&gt;&lt;br /&gt;LVM record every LVM VG and LV metadata operation and save it to /etc/lvm/backup automatically, old version backup files are archived to /etc/lvm/archive. &lt;br /&gt;The backup file can be used to rollback LVM metadata changes, for example, if you have removed the VG/PV or even re-initialize disk with pvcreate, Don't panic,as long as file system was not re-created, you can use vgcfgrestore to restore all the data.&lt;br /&gt;The following is to demonstrate how to recover a LV after it is completed destroyed from PV level (pvremove)&lt;br /&gt;1.Create test LV and write some data&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$pvcreate  /dev/sdb1 /dev/sdb2&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Physical volume "&lt;span style="color: darkred;"&gt;/dev/sdb1&lt;/span&gt;" successfully created&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Physical volume "&lt;span style="color: darkred;"&gt;/dev/sdb2&lt;/span&gt;" successfully created&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$vgcreate vg01  /dev/sdb1 /dev/sdb2&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Volume group "&lt;span style="color: darkred;"&gt;vg01&lt;/span&gt;" successfully created&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ lvcreate -L100M -n lv01 vg01&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Logical volume "&lt;span style="color: darkred;"&gt;lv01&lt;/span&gt;" created&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ mkfs.ext3 /dev/vg01/lv01&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ mount /dev/vg01/lv01 /mnt/&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$cp /etc/hosts /mnt/&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ ls /mnt/&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;hosts  lost+found&lt;/pre&gt;&lt;/pre&gt;2.Destroy LV,VG,and PV&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$vgremove vg01&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Do you really want to remove volume group "&lt;span style="color: darkred;"&gt;vg01&lt;/span&gt;" containing 1 logical volumes? [y/n]: y&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Do you really want to remove active logical volume lv01? [y/n]: y&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Logical volume "&lt;span style="color: darkred;"&gt;lv01&lt;/span&gt;" successfully removed&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Volume group "&lt;span style="color: darkred;"&gt;vg01&lt;/span&gt;" successfully removed&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#VG is removed and PV was also wiped out&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ pvcreate /dev/sdb1 /dev/sdb2&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Physical volume "&lt;span style="color: darkred;"&gt;/dev/sdb1&lt;/span&gt;" successfully created&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Physical volume "&lt;span style="color: darkred;"&gt;/dev/sdb2&lt;/span&gt;" successfully created&lt;/pre&gt;&lt;/pre&gt;3.Lets recover the LV and the data&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##Find out the backup file to restore from&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$vgcfgrestore -l vg01&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;..&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;file:         /etc/lvm/archive/vg01_00002.vg&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;VG name:      vg01&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Description:  Created *before* executing 'vgremove vg01'&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Backup time:  Tue May 10 15:41:31 2011&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##first attempt failed, because PV UUID is changed&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ vgcfgrestore -f /etc/lvm/archive/vg01_00002.vg vg01&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Couldn't find device with uuid 'pVf1J2-rAsd-eWkD-mCJc-S0pc-47zc-ImjXSB'.&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Couldn't find device with uuid 'J14aVl-mbuj-k9MM-63Ad-TBAa-S0xF-VElV2W'.&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Cannot restore Volume Group vg01 with 2 PVs marked as missing.&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Restore failed.&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##Find old UUID&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ grep -B 2 /dev/sdb /etc/lvm/archive/vg01_00002.vg&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;pv0 {&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;id = "&lt;span style="color: darkred;"&gt;pVf1J2-rAsd-eWkD-mCJc-S0pc-47zc-ImjXSB&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;device = "&lt;span style="color: darkred;"&gt;/dev/sdb1&lt;/span&gt;"    &lt;span style="color: green;"&gt;# Hint only&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;--&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;pv1 {&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;id = "&lt;span style="color: darkred;"&gt;J14aVl-mbuj-k9MM-63Ad-TBAa-S0xF-VElV2W&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;device = "&lt;span style="color: darkred;"&gt;/dev/sdb2&lt;/span&gt;"    &lt;span style="color: green;"&gt;# Hint only&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##Recreate PV with the old UUID&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ pvcreate -u pVf1J2-rAsd-eWkD-mCJc-S0pc-47zc-ImjXSB /dev/sdb1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Physical volume "&lt;span style="color: darkred;"&gt;/dev/sdb1&lt;/span&gt;" successfully created&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ pvcreate -u J14aVl-mbuj-k9MM-63Ad-TBAa-S0xF-VElV2W  /dev/sdb2&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Physical volume "&lt;span style="color: darkred;"&gt;/dev/sdb2&lt;/span&gt;" successfully created&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##run vgcfgrestore again&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ vgcfgrestore -f /etc/lvm/archive/vg01_00002.vg vg01&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Restored volume group vg01&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##data was also recovered&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ mount /dev/vg01/lv01 /mnt/&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;mount: special device /dev/vg01/lv01 does &lt;span style="color: blue;"&gt;not&lt;/span&gt; exist&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ lvchange -a y vg01/lv01&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ mount /dev/vg01/lv01 /mnt/&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ cat /mnt/hosts&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;127.0.0.1       localhost&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;..&lt;/pre&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1822605347830719087-73827044589443832?l=honglus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://honglus.blogspot.com/feeds/73827044589443832/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://honglus.blogspot.com/2011/05/lvm2-device-filter-and-lvm-metadata.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/73827044589443832'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/73827044589443832'/><link rel='alternate' type='text/html' href='http://honglus.blogspot.com/2011/05/lvm2-device-filter-and-lvm-metadata.html' title='LVM2: device filter and LVM metadata restore'/><author><name>honglus</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1822605347830719087.post-1979843398346145118</id><published>2011-05-07T17:12:00.004+10:00</published><updated>2011-05-08T09:40:42.486+10:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><category scheme='http://www.blogger.com/atom/ns#' term='Cluster'/><title type='text'>RHCS(Red Hat Cluster Suite) quorum disk</title><content type='html'>The last post "&lt;a href="http://honglus.blogspot.com/2011/05/rhcsred-hat-cluster-suite-io-fencing.html" target="_blank"&gt;RHCS I/O fencing&lt;/a&gt;" is about dealing with split-brain situation, in which cluster members lost heartbeat communication and each believe it is legitimate to write data to the shared storage.     &lt;br /&gt;&lt;strong&gt;Methods to deal with split-brain situation:      &lt;br /&gt;&lt;/strong&gt;1. Redundant heartbeat path     &lt;br /&gt;network port communication plus serial port communication     &lt;br /&gt;2. I/O fencing     &lt;br /&gt;Remaining nodes separate failed node from its storage either by shutdown/reboot power port or storage port     &lt;br /&gt;3. Quorum disk     &lt;br /&gt;Quorum disk is a kind of I/O fencing, but the reboot action is executed by failed node's own quorum daemon. It also has &lt;strong&gt;additional feature&lt;/strong&gt;: contributing vote to cluster. if you want the last standing node to keep the multiple-nodes cluster&amp;nbsp; running, quorum disk appears to be the only solution.&lt;br /&gt;&lt;strong&gt;RHCS (Red Hat Cluster Suite) Quorum disk facts      &lt;br /&gt;&lt;/strong&gt;- A shared block device (SCSI/iSCSI/FC..), Device size requirement is approximately 10MiB     &lt;br /&gt;- Supports maximum 16 nodes, nodes id must be sequentially ordered     &lt;br /&gt;- Quorum disk can contribute&amp;nbsp; votes. In multiple nodes cluster, together with quorum vote, the last standing node can still keep the cluster running     &lt;br /&gt;- single node votes+1 &amp;lt;=Quorum's disk vote &amp;lt; nodes total votes     &lt;br /&gt;- The failure of the shared quorum disk won’t result in cluster failure, as long as Quorum's disk vote &amp;lt; nodes total votes &lt;br /&gt;- each node write its own health information in its own region, the health is determined by external checking program such as "ping"&lt;br /&gt;&lt;strong&gt;Setup Quorum disk&lt;/strong&gt;&lt;br /&gt;&lt;pre&gt;#initialise quorum disk once in any node &lt;br /&gt;mkqdisk -c /dev/sdx -l myqdisk &lt;/pre&gt;&lt;strong&gt;Add quorum disk to cluster&amp;nbsp;&lt;/strong&gt;&lt;br /&gt;Use luci or system-config-cluster to add quorum disk, following is the result xml file&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&amp;lt;clusternodes&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&amp;lt;clusternode name="&lt;span style="color: darkred;"&gt;station1.example.com&lt;/span&gt;" nodeid="&lt;span style="color: darkred;"&gt;1&lt;/span&gt;" votes="&lt;span style="color: darkred;"&gt;2&lt;/span&gt;"&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&amp;lt;fence/&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&amp;lt;/clusternode&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&amp;lt;clusternode name="&lt;span style="color: darkred;"&gt;station2.example.com&lt;/span&gt;" nodeid="&lt;span style="color: darkred;"&gt;2&lt;/span&gt;" votes="&lt;span style="color: darkred;"&gt;2&lt;/span&gt;"&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&amp;lt;fence/&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&amp;lt;/clusternode&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&amp;lt;clusternode name="&lt;span style="color: darkred;"&gt;station3.example.com&lt;/span&gt;" nodeid="&lt;span style="color: darkred;"&gt;3&lt;/span&gt;" votes="&lt;span style="color: darkred;"&gt;2&lt;/span&gt;"&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&amp;lt;fence/&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&amp;lt;/clusternode&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&amp;lt;/clusternodes&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#expected votes =9=(nodes total votes + quorum disk votes) = (2+2+2+3)       &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&amp;lt;cman expected_votes="&lt;span style="color: darkred;"&gt;9&lt;/span&gt;"/&amp;gt; &lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Health check result is writen to quorum disk every 2 secs&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#if health check fails over 5 tko, 10 (2*5) secs, the node is rebooted by quorum daemon&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Each heuristic check is run very 2 secs and earn 1 score,if shell script return is 0&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&amp;lt;quorumd interval="&lt;span style="color: darkred;"&gt;2&lt;/span&gt;" label="&lt;span style="color: darkred;"&gt;myqdisk&lt;/span&gt;" min_score="&lt;span style="color: darkred;"&gt;2&lt;/span&gt;" tko="&lt;span style="color: darkred;"&gt;5&lt;/span&gt;" votes="&lt;span style="color: darkred;"&gt;3&lt;/span&gt;"&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&amp;lt;heuristic interval="&lt;span style="color: darkred;"&gt;2&lt;/span&gt;" program="&lt;span style="color: darkred;"&gt;ping -c1 -t1 192.168.1.60&lt;/span&gt;" score="&lt;span style="color: darkred;"&gt;1&lt;/span&gt;"/&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&amp;lt;heuristic interval="&lt;span style="color: darkred;"&gt;2&lt;/span&gt;" program="&lt;span style="color: darkred;"&gt;ping -c1 -t1 192.168.1.254&lt;/span&gt;" score="&lt;span style="color: darkred;"&gt;1&lt;/span&gt;"/&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&amp;lt;/quorumd&amp;gt;&lt;/pre&gt;&lt;/pre&gt;&lt;strong&gt;Start quorum disk daemon&lt;/strong&gt;&lt;br /&gt;The daemon is also one of daemons automatically started by cman&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: monospace; white-space: pre;"&gt;service qdiskd start&lt;/span&gt;&lt;br /&gt;&lt;strong&gt;Check quorum disk information&lt;/strong&gt;&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ mkqdisk -L -d&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;mkqdisk v0.6.0&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/dev/disk/by-id/scsi-1IET_00010002:&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/dev/disk/by-uuid/55fbf858-df75-493b-a764-5640be5a9b46:&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/dev/sdc:&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Magic:                eb7a62c2&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Label:                myqdisk&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Created:              Sat May  7 05:56:35 2011&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Host:                 station2.example.com&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Kernel Sector Size:   512&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Recorded Sector Size: 512&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Status block &lt;span style="color: blue;"&gt;for&lt;/span&gt; node 1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Last updated by node 1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Last updated on Sat May  7 15:09:37 2011&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;State: Master&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Flags: 0000&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Score: 0/0&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Average Cycle speed: 0.001500 seconds&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Last Cycle speed: 0.000000 seconds&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Incarnation: 4dc4d1764dc4d176&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Status block &lt;span style="color: blue;"&gt;for&lt;/span&gt; node 2&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Last updated by node 2&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Last updated on Sun May  8 01:09:38 2011&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;State: Running&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Flags: 0000&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Score: 0/0&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Average Cycle speed: 0.001000 seconds&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Last Cycle speed: 0.000000 seconds&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Incarnation: 4dc55e164dc55e16&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Status block &lt;span style="color: blue;"&gt;for&lt;/span&gt; node 3&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Last updated by node 3&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Last updated on Sat May  7 15:09:38 2011&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;State: Running&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Flags: 0000&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Score: 0/0&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Average Cycle speed: 0.001500 seconds&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Last Cycle speed: 0.000000 seconds&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Incarnation: 4dc4d2f04dc4d2f0&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;strong&gt;The cluster is still running with last node standing&lt;/strong&gt;&lt;br /&gt;Please note Total votes=quorum votes=5=2+3, if quorum disk vote is less than&amp;nbsp; (node votes+1), the cluster&amp;nbsp; wouldn’t have&amp;nbsp; survived&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$cman_tool status&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;..&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Nodes: 1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Expected votes: 9&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Quorum device votes: 3&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Total votes: 5&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Quorum: 5  &lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;..&lt;/pre&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1822605347830719087-1979843398346145118?l=honglus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://honglus.blogspot.com/feeds/1979843398346145118/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://honglus.blogspot.com/2011/05/rhcsred-hat-cluster-suite-quorum-disk.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/1979843398346145118'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/1979843398346145118'/><link rel='alternate' type='text/html' href='http://honglus.blogspot.com/2011/05/rhcsred-hat-cluster-suite-quorum-disk.html' title='RHCS(Red Hat Cluster Suite) quorum disk'/><author><name>honglus</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1822605347830719087.post-5160954238532425876</id><published>2011-05-02T23:05:00.005+10:00</published><updated>2011-05-07T17:19:38.302+10:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><category scheme='http://www.blogger.com/atom/ns#' term='Cluster'/><title type='text'>RHCS(Red Hat Cluster Suite) I/O fencing using SNMP IFMIB</title><content type='html'>RHCS&amp;nbsp; is comparable to HP MC/Service Guard, IBM HACMP, SUN Cluster etc. The free open source version is available in Centos/Fedora &lt;br /&gt;Fencing is the act of isolating a cluster node from its storage when the node is not responding,   &lt;br /&gt;otherwise, when the node is recovered, the shared file system may be corrupted when written by more than 1 node at the same time. &lt;br /&gt;RHCS supports following Fencing methods: &lt;br /&gt;&lt;strong&gt;Power fencing:     &lt;br /&gt;&lt;/strong&gt;Forcefully Power Cycle, just like pull out the power Cord &lt;br /&gt;- Internal Power fencing&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Lights-out management Card ( HP iLO, IBM RSA, SUN iLOM, DELL DRAC, IPMI etc)    &lt;br /&gt;- External Power fencing    &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SMART Power Switch (APC Switched Rack PDU etc) &lt;br /&gt;&lt;strong&gt;Network port fencing:     &lt;br /&gt;&lt;/strong&gt;Shutdown the storage network port&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; - IP Switch for iSCSI     &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; - SAN Switch for FC SAN &lt;br /&gt;&lt;strong&gt;SCSI 3 Persistent Reservation &lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;Virtual Guest     &lt;br /&gt;&lt;/strong&gt;shutdown VM guest by VM host    &lt;br /&gt;- Xen, Vmware or any guest managed by libvirt tools&lt;br /&gt;full list :&lt;br /&gt;&lt;a href="http://www.redhat.com/cluster_suite/hardware/" title="http://www.redhat.com/cluster_suite/hardware/"&gt;http://www.redhat.com/cluster_suite/hardware/   &lt;br /&gt;&lt;/a&gt;  &lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Each fence type above has its own fence agent, which is Python/Perl script.&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ls /sbin/fence*&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/sbin/fence_ack_manual   /sbin/fence_drac     /sbin/fence_mcdata     /sbin/fence_tool&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/sbin/fence_apc          /sbin/fence_drac5    /sbin/fence_node       /sbin/fence_virsh&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/sbin/fence_apc_snmp     /sbin/fence_egenera  /sbin/fence_rhevm      /sbin/fence_vixel&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/sbin/fence_bladecenter  /sbin/fence_ifmib    /sbin/fence_rps10      /sbin/fence_vmware&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/sbin/fence_brocade      /sbin/fence_ilo      /sbin/fence_rsa        /sbin/fence_vmware_helper&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/sbin/fence_bullpap      /sbin/fence_ilo_mp   /sbin/fence_rsb        /sbin/fence_wti&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/sbin/fence_cisco_mds    /sbin/fence_ipmilan  /sbin/fence_sanbox2    /sbin/fence_xvm&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/sbin/fence_cisco_ucs    /sbin/fence_lpar     /sbin/fence_scsi       /sbin/fence_xvmd&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/sbin/fenced             /sbin/fence_manual   /sbin/fence_scsi_test&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Power fencing agent (fence_ilo,fence_apc etc) typically use telnet/ssh to IP of LOM card or external Powerswitch to turn off the power.&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;fence_ifmib is today's subject, it use SNMP write permission to shutdown a network port of&amp;nbsp; iSCSI storage Server&lt;br /&gt;&lt;strong&gt;LAB Setup&lt;/strong&gt;&lt;br /&gt;Virtual Box with 3 VMS&lt;br /&gt;filer: Cluster management Server Luci and iSCSI filer.&lt;br /&gt;node1: Cluster node1 with Luci agent ricci&lt;br /&gt;node2: Cluster node2 with Luci agent ricci&lt;br /&gt;filer, node1, and node2 are connected in separate LAN, LAN1 is for application traffic, LAN2 is for iSCSI stroage traffic, So filer has 3 NICs, each Cluster node has 2 NICs.&lt;br /&gt;&lt;br /&gt;Using fence_ifmib, the node1 can fence off node2 by issuing snmpset via LAN1 interface to shutdown filer's one of LAN2 NICs, where node2 is connected and vice versa. &lt;br /&gt;&lt;strong&gt;Setup Cluster&lt;/strong&gt;&lt;br /&gt;on each node, yum install ricci; service ricci restart &lt;br /&gt;on filer, yum install luci;&amp;nbsp; "luci_admin init" to set admin password; service luci resart&lt;br /&gt;login to Luci web interface on port 8084&lt;br /&gt;create a new cluster and add cluster node members&lt;br /&gt;&lt;strong&gt;Setup fence_ifmib fence device&lt;/strong&gt;&lt;br /&gt;- &lt;strong&gt;on filer&lt;/strong&gt;, set up snmpd&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ cat /etc/snmp/snmpd.conf &lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;createUser fence_admin   MD5 "&lt;span style="color: darkred;"&gt;Pass1234&lt;/span&gt;"&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;authuser   read,write -s usm  fence_admin  authnopriv .1.3.6.1.2.1.2.2.1&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;I use SNMP V3 USM because Luci requires SNMP username/password. I think, other Cluster management tools: system-config-cluster, ccs_tool accept SNMP V2c and V1&lt;br /&gt;further info on setup snmpV1/V2c/V3&lt;br /&gt;&lt;a href="http://honglus.blogspot.com/2009/03/setup-net-snmp-on-linux-centos-52.html" title="http://honglus.blogspot.com/2009/03/setup-net-snmp-on-linux-centos-52.html"&gt;http://honglus.blogspot.com/2009/03/setup-net-snmp-on-linux-centos-52.html&lt;/a&gt;&lt;br /&gt;&lt;a href="http://honglus.blogspot.com/2011/03/setup-snmp-v3-usm-with-encryption.html"&gt;http://honglus.blogspot.com/2011/03/setup-snmp-v3-usm-with-encryption.html&lt;/a&gt;&lt;br /&gt;- &lt;strong&gt;on cluster node&lt;/strong&gt; , install&amp;nbsp; snmpagent and assign a&amp;nbsp; shared&amp;nbsp; fence device for each node&lt;br /&gt;yum install netsnmp-utils&lt;br /&gt;The port is the interface index numer in filer, since interface starts with loopback, eth0 index num=2, eth1 index num=3.&amp;nbsp; It is not hardcoded in fence_device, so each node can share the same fence device but different port&lt;br /&gt;&lt;a href="http://lh5.ggpht.com/_qxt-z_N__2s/Tb6sA8EvJlI/AAAAAAAAAIk/6fKfJKV-Z-M/s1600-h/image%5B8%5D.png"&gt;&lt;img alt="image" border="0" height="484" src="http://lh5.ggpht.com/_qxt-z_N__2s/Tb6sCFa2UuI/AAAAAAAAAIo/hpxaDBIDL6Y/image_thumb%5B2%5D.png?imgmax=800" style="border-bottom: 0px; border-left: 0px; border-right: 0px; border-top: 0px; display: inline;" title="image" width="638" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Test&lt;/strong&gt;&lt;br /&gt;On any node, run "fence_node the-other-node-name", then go to filer to check if one of the filer's storage NICs is down&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1822605347830719087-5160954238532425876?l=honglus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://honglus.blogspot.com/feeds/5160954238532425876/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://honglus.blogspot.com/2011/05/rhcsred-hat-cluster-suite-io-fencing.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/5160954238532425876'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/5160954238532425876'/><link rel='alternate' type='text/html' href='http://honglus.blogspot.com/2011/05/rhcsred-hat-cluster-suite-io-fencing.html' title='RHCS(Red Hat Cluster Suite) I/O fencing using SNMP IFMIB'/><author><name>honglus</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_qxt-z_N__2s/Tb6sCFa2UuI/AAAAAAAAAIo/hpxaDBIDL6Y/s72-c/image_thumb%5B2%5D.png?imgmax=800' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1822605347830719087.post-2925814250770137689</id><published>2011-04-26T17:54:00.003+10:00</published><updated>2011-04-27T14:56:58.557+10:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Storage'/><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><category scheme='http://www.blogger.com/atom/ns#' term='Linux Internals'/><title type='text'>Do we really need to set partition type to fd(Linux auto raid) for Linux software RAID?</title><content type='html'>Almost all Linux RAID documents mandate that partition type must be fd(Linux auto raid)&amp;nbsp; before building Linux software RAID. Actually, this step is optional, it helps a little if your RAID device is /dev/md0 in Centos. &lt;br /&gt;&lt;strong&gt;What is fd(Linux auto raid)?     &lt;br /&gt;&lt;/strong&gt;As the name implies, it is for auto detection of&amp;nbsp; raid&amp;nbsp; when OS boots. If you have created /dev/md0 but didn't put it&amp;nbsp; in configuration file /etc/mdadm.conf, OS is able to detect the partitions and assemble /dev/md0.&lt;br /&gt;&lt;strong&gt;But, this way of assembling RAID device only works for /dev/md0 in Centos by default.&lt;/strong&gt;    &lt;br /&gt;It is because Centos only enable raidautorun for /dev/md0 by default. Any other md will be assembled by reading /etc/mdadm.conf&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;[Centos 5 ] $grep -A 3 raidautorun  /etc/rc.sysinit &lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;[ -x /sbin/nash ] &amp;amp;&amp;amp; echo "&lt;span style="color: darkred;"&gt;raidautorun /dev/md0&lt;/span&gt;" | nash --quiet&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: blue;"&gt;if&lt;/span&gt; [ -f /etc/mdadm.conf ]; &lt;span style="color: blue;"&gt;then&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;/sbin/mdadm -A -s&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;fi&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#The auto detecting behavior is logged in kernel buffer&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ dmesg | grep -i auto&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;md: Autodetecting RAID arrays.&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;md: autorun ...&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;md: ... autorun DONE.&lt;/pre&gt;&lt;/pre&gt;&lt;strong&gt;fd VS&amp;nbsp; RAID superblock&lt;/strong&gt;&lt;br /&gt;Don't confuse fd with RAID superblock,&amp;nbsp; fd is an optional flag recognized by&amp;nbsp; nash raidautorun command. But RAID superblock is, in every RAID device member, an essential piece of information, which contains RAID level, state and parent&amp;nbsp; MD device UUID (man 4 md).&lt;br /&gt;&lt;pre&gt;&lt;span class="Apple-style-span" style="color: #38761d;"&gt;#Examine superblock on logical device will encounter an error&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #38761d;"&gt;#It is expected because superblock only exist in RAID member device&lt;/span&gt;&lt;br /&gt; $ mdadm --examine /dev/md0&lt;br /&gt;mdadm: No md superblock detected on /dev/md0.&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: #38761d;"&gt;#Examine  superblock on RAID member&lt;/span&gt;&lt;br /&gt;$ mdadm --examine /dev/sdb2&lt;br /&gt;/dev/sdb2:&lt;br /&gt;          Magic : a92b4efc&lt;br /&gt;        Version : 0.90.00&lt;br /&gt;           UUID : a31e6699:4360a3b7:38c544fa:f4e6faa9&lt;br /&gt;  Creation Time : Wed Apr 27 11:19:34 2011&lt;br /&gt;     Raid Level : raid1&lt;br /&gt;  Used Dev Size : 104320 (101.89 MiB 106.82 MB)&lt;br /&gt;     Array Size : 104320 (101.89 MiB 106.82 MB)&lt;br /&gt;   Raid Devices : 2&lt;br /&gt;  Total Devices : 2&lt;br /&gt;Preferred Minor : 0&lt;br /&gt;&lt;br /&gt;    Update Time : Wed Apr 27 12:51:58 2011&lt;br /&gt;          State : clean&lt;br /&gt;Internal Bitmap : present&lt;br /&gt; Active Devices : 2&lt;br /&gt;Working Devices : 2&lt;br /&gt; Failed Devices : 0&lt;br /&gt;  Spare Devices : 0&lt;br /&gt;       Checksum : 58c72673 - correct&lt;br /&gt;         Events : 20&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Scan  partitions superblock to find existing raid device.&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ mdadm --examine --brief --scan --config=partitions&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;ARRAY /dev/md1 level=raid1 num-devices=2 UUID=da55e1e2:c781a461:73d6dfa6:8c7cf6d6&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##The above output can be saved to /etc/mdadm.conf; then mdadm -A -s will activate the RAID device.&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;##DEVICE member list is optional, because default is “DEVICE partitions”.&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br /&gt;Partition type FD is a way of assembling raid used by nash raidautorun command and it only works for /dev/md0 in Centos by default.&lt;br /&gt;If you use /etc/mdadm.conf&amp;nbsp; to assemble RAID, the FD flag is optional.&amp;nbsp; But setting this flag can help you to recognize RAID members from “fdisk -l”.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1822605347830719087-2925814250770137689?l=honglus.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://honglus.blogspot.com/feeds/2925814250770137689/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://honglus.blogspot.com/2011/04/do-we-really-need-to-set-partition-type.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/2925814250770137689'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1822605347830719087/posts/default/2925814250770137689'/><link rel='alternate' type='text/html' href='http://honglus.blogspot.com/2011/04/do-we-really-need-to-set-partition-type.html' title='Do we really need to set partition type to fd(Linux auto raid) for Linux software RAID?'/><author><name>honglus</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1822605347830719087.post-2286069989178782589</id><published>2011-04-21T22:50:00.003+10:00</published><updated>2011-04-21T22:52:46.992+10:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Security'/><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><title type='text'>Setup Postfix SMTP password authentication with SASL</title><content type='html'>Simple Authentication and Security Layer(SASL) is a framework for authentication and data security in Internet protocols.    &lt;br /&gt;Postfix can relay the SASL framework to provide SMTP password authentication.     &lt;br /&gt;SMTP password authentication is suitable for roaming users who are outside of trusted network. They are still allowed to send email without relaxing SMTP restrictions , which could introduce spam emails.&amp;nbsp; &lt;br /&gt;Postfix version 2.3 onwards&amp;nbsp; supports two SASL implementations(This post will discuss cryus)&lt;br /&gt;&lt;pre&gt;[Centos 5.5 ] $ postconf -a&lt;br /&gt;cyrus&lt;br /&gt;dovecot &lt;/pre&gt;&lt;strong&gt;SASL Mechanisms&lt;/strong&gt;&lt;br /&gt;- SASL mechanisms: DIGEST-MD5 CRAM-MD5 use encrypted password , but they are only supported in saslauthd mechanism:sasldb,sql,ldapdb&lt;br /&gt;cyrus-sasl-md5 package provides library for DIGEST-MD5 CRAM-MD5&lt;br /&gt;- SASL mechanisms: PLAIN LOGIN use clear&amp;nbsp; text password,&amp;nbsp; it is supported saslauthd mechanism: pam, but the clear text can be protected by TLS&lt;br /&gt;cyrus-sasl-plain package provides library for&amp;nbsp; PLAIN LOGIN&lt;br /&gt;&lt;em&gt;NOTE:&lt;/em&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;- This post only discuss SASL&amp;nbsp;&amp;nbsp;&amp;nbsp; PLAIN LOGIN&amp;nbsp;&amp;nbsp;&amp;nbsp; in saslauthd&amp;nbsp;&amp;nbsp;&amp;nbsp; PAM&lt;br /&gt;&amp;nbsp;&amp;nbsp;- make sure&amp;nbsp; you already have a basic working Postfix before continue next steps&lt;br /&gt;&lt;strong&gt;1. Install and configure&amp;nbsp; saslauthd&lt;/strong&gt;&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$rpm -qa | grep sas&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;cyrus-sasl-2.1.22-5.el5_4.3&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;cyrus-sasl-plain-2.1.22-5.el5_4.3                &lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;cyrus-sasl-lib-2.1.22-5.el5_4.3&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#saslauthd should be configured to use pam mechanism &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ grep MECH /etc/sysconfig/saslauthd&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;MECH=pam&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#start /etc/init.dd/saslauthd and test it&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#smtp is service name /etc/pam.d/smtp&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$testsaslauthd -u guest01 -&lt;span style="color: darkblue;"&gt;p&lt;/span&gt; Pass001  -s smtp&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;0: OK "&lt;span style="color: darkred;"&gt;Success.&lt;/span&gt;"&lt;/pre&gt;&lt;/pre&gt;&lt;strong&gt;2. Enable SASL in postfix&lt;/strong&gt;&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$cat /etc/postfix/main.cf&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;smtpd_sasl_auth_enable = yes&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;broken_sasl_auth_clients = yes&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;smtp_sasl_security_options = noanonymous&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;smtpd_recipient_restrictions =   permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;strong&gt;3.Restart postfix and test the authentication&lt;/strong&gt;&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#First test:  telnet to check if   PLAIN LOGIN   is shown&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$(echo "&lt;span style="color: darkred;"&gt;ehlo localhost&lt;/span&gt;"; &lt;span style="color: darkblue;"&gt;sleep&lt;/span&gt; 2; echo "&lt;span style="color: darkred;"&gt;quit&lt;/span&gt;") | telnet localhost 25&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;250-AUTH PLAIN LOGIN DIGEST-MD5 CRAM-MD5&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;## you can limit  mechanism  type &lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$cat /usr/lib64/sasl2/smtpd.conf&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;pwcheck_method: saslauthd&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;mech_list: plain login&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;&lt;span style="color: green;"&gt;#Second test: test username and password by converting them to base64&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ &lt;span style="color: darkblue;"&gt;printf&lt;/span&gt;  "&lt;span style="color: darkred;"&gt;\0guest01\0Pass001&lt;/span&gt;" |openssl base64&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;AGd1ZXN0MDEAUGFzczAwMQ==&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$ (echo "&lt;span style="color: darkred;"&gt;AUTH PLAIN AGd1ZXN0MDEAUGFzczAwMQ==&lt;/span&gt;"; &lt;span style="color: darkblue;"&gt;sleep&lt;/span&gt; 2 )| telnet localhost 25&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Trying 127.0.0.1...&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Connected to localhost (127.0.0.1).&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Escape character is '^]'.&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;220 mail.example.com ESMTP Postfix&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;235 2.0.0 Authentication successful&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;Connection closed by foreign host.&lt;/pre&gt;&lt;/pre&gt;&lt;strong&gt;4. Enable TLS (Optional) to protect clear text password in PLAIN LOGIN&lt;/strong&gt;&lt;br /&gt;&lt;pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;"&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;$cat /etc/postfix/main.cf&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;smtpd_use_tls = yes&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;smtpd_tls_CAfile =  /etc/postfix/certs/ca.pem&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;smtpd_tls_cert_file = /etc/postfix/certs/postfix.pem&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;smtpd_tls_key_file = /etc/postfix/certs/postfix.key&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #fbfbfb; font-family: consolas,'Courier New',courier,monospace; font-size: 12px; margin: 0em; width: 100%;"&gt;smtpd_tls_loglevel = 1&lt;/pre&gt;&lt;/pre&gt;&lt;div class="
