How to Shrink/Resize a VMDK file in ESXi

** Use this technique at your own risk. I do not and will not take responsibility for your corrupted vmdk’s as a result of following this process, whether correctly or incorrectly **

If you have ever taken a look at the descriptor file for a vmdk file, you will the “Extent description” section:

# Extent description
RW 52428800 VMFS “foo-flat.vmdk”

The value between ‘RW’ and ‘VMFS’ is the size of disk when divided by 512 and is in bytes:

52428800 * 512 = 26843545600 (25G)

-rw——- 1 root root 26843545600 Sep 18 19:10 foo-flat.vmdk
-rw——- 1 root root 370 Sep 18 19:11 foo.vmdk

If you want to shrink (or increase) the size of your vmdk file, alter this value in the descriptor file to reflect your new desired size*. You can do with this ‘vi’ or ‘nano’:

* For this example we will to shrink the disk to 12.5G

# Extent description
RW 26214400 VMFS “foo-flat.vmdk”

After making this change you can use ‘vmkfstools -i’ to clone this disk:

# vmkfstools -i foo.vmdk -d thin foo_1.vmdk
Destination disk format: VMFS thick
Cloning disk ‘foo.vmdk’…
Clone: 100% done.

You will discover that the cloned disk now reflects the new size of 12.5G:

-rw——- 1 root root 13421772800 Sep 18 19:13 foo_1-flat.vmdk
-rw——- 1 root root 372 Sep 18 19:13 foo_1.vmdk
-rw——- 1 root root 26843545600 Sep 18 19:10 foo-flat.vmdk
-rw——- 1 root root 370 Sep 18 19:11 foo.vmdk

the -d parameter defines the disk type: zerothick, thin etc.

source: http://professionalvmware.com/2009/09/how-to-shrink-a-vmdk-file-in-esx/

NTP time sync to external time server in Windows 2008

Time synchronization is an important aspect for all computers on the network. By default, the clients computers get their time from a Domain Controller and the Domain Controller gets his time from the domain’s PDC Operation Master. Therefore the PDC must synchronize his time from an external source. There are servers listed at the NTP Pool Project website. Before you begin, don’t forget to open the default UDP 123 port (in- and outbound) on your firewall. 

  1. First, locate your PDC Server. Open the command prompt and type: C:\>netdom /query fsmo
  2. Log in to your PDC Server and open the command prompt.
  3. Stop the W32Time service: C:\>net stop w32time
  4. Configure the external time sources, type: C:\> w32tm /config /syncfromflags:manual /manualpeerlist:”0.pool.ntp.org, 1.pool.ntp.org, 2.pool.ntp.org”
  5. Make your PDC a reliable time source for the clients. Type: C:\>w32tm /config /reliable:yes
  6. Start the w32time service: C:\>net start w32time
  7. The windows time service should begin synchronizing the time. You can check the external NTP servers in the time configuration by typing: C:\>w32tm /query /configuration
  8. Check the Event Viewer for any errors.

source: http://defaultreasoning.wordpress.com/2009/11/16/synchronize-time-with-external-ntp-server-on-windows-server-2008-r2/

LDAP/PDC on CentOS5

Hi,

 

after reading several tutorials and howtos for building a ldap-pdc i decided to write this small howto build on three different tutorials. Each one of them had it's small "bugs" so here is what worked for me:

 

1. Building LDAP Server

install openldap, set ldap password and edit slapd.conf:

 

~# yum install openldap-servers openldap-clients
~# slappasswd -h {SSHA}
~# vim /etc/openldap/slapd.conf

 

change some lines:

 

suffix  "dc=DOMAIN,dc=LOCAL"
rootdn  "cn=Manager,dc=DOMAIN,dc=LOCAL"
rootpw  {SSHA}PASSWORD -> generated with slapppasswd

 

add this to the file:

 

include /etc/openldap/schema/samba.schema
access to attrs=userPassword,sambaLMPassword,sambaNTPassword
    by self write
    by dn="cn=Manager,dc=DOMAINdc=LOCAL" write
    by anonymous auth
    by * none

access to *
    by dn="cn=Manager,dc=DOMAIN,dc=LOCAL" write
    by self write
    by * read

 

copy database

 

~# cp /etc/openldap/DB_CONFIG.example /var/lib/ldap/DB_CONFIG

 

now start the ldap server and add it to startup:

 

~# /etc/init.d/ldap start
~# chkconfig ldap on

 

2. Add initial and exisitng users/groups

change some lines in the migration script:

 

~# vim /usr/share/openldap/migration/migrate_common.ph

 

$DEFAULT_MAIL_DOMAIN = "DOMAIN.LCOAL";
$DEFAULT_BASE = "dc=DOMAIN,dc=LOCAL";

 

after that fill the ldap database

 

~# /usr/share/openldap/migration/migrate_base.pl > base.ldif
~# ldapadd -x -W -D "cn=Manager,dc=DOMAIN,dc=LOCAL" -f base.ldif
~# grep "x:[5-9][0-9][0-9]" /etc/passwd > passwd
~# grep "x:[5-9][0-9][0-9]" /etc/group > group
~# /usr/share/openldap/migration/migrate_passwd.pl passwd > passwd.ldif
~# /usr/share/openldap/migration/migrate_group.pl group > group.ldif
~# ldapadd -x -W -D "cn=Manager,dc=DOMAIN,dc=LOCAL" -f passwd.ldif
~# ldapadd -x -W -D "cn=Manager,dc=DOMAIN,dc=LOCAL" -f group.ldif

 

3. Setup SAMBA

to keep it short: check here and here.