Tuesday, November 10, 2009

bash script to delete users directorys older then 14 days

#!/bin/bash

### Declare array ###
ARRAY=( `ypcat passwd | awk -F: '{print $1}'` )

### Get number of elements in the array ###
ELEMENTS=${#ARRAY[@]}

### Delete folders older then 14 days in users directory ###
for (( i=0;i<$ELEMENTS;i++)); do
/usr/bin/find /nas/data/accelrys/pp/web/jobs/"${ARRAY[${i}]}" -mtime +14 -exec rm -rf {} \;
done

Resizing a VMWare Virtual Hard Disk - Linux and Windows OS

http://hagaycarmi.wordpress.com/

*** As this procedure is risky DON’T forget to create a backup of the VM ***

Stage 1 – resizing the VMDK file

On windows:

1. Shutdown the VM.

2. Open CMD and browse to C:\Program Files\VMware\VMware Server

3. From the command prompt, run the command: vmware-vdiskmanager -x 20Gb -t 3 "C:\Users\Marcus\test-OS\ubuntu_test-0001.vmdk"
The last command will set the vmdk file to 20 GB.

On Linux:

1. Shutdown the VM.

2. Open console and browse to the VM directory (Usually under /vmfs/volumes/vol_name/VM_directory)
3. Execute the same command (vmware-vdiskmanager)






Stage 2 – Expanding VM OS File System

On Windows:

1. Boot the OS
2. Open CMD and run diskpart.exe to expand the NTFS File System: http://support.microsoft.com/kb/325590
3. Reboot the OS.
You can also boot the VM OS using Live CD with Gparted: http://gparted.sourceforge.net/livecd.php

On Linux:

1. Reboot with Live CD
2. Check FS integrity: fsck -n /dev/sda1
3. Drop the Journaling from the ext3 FS: tune2fs -O ^has_journal /dev/sda1
4. Use fdisk or parted command to expand the partition.
5. Reboot into Live CD once more.
6. Check FS: e2fsck -f /dev/sda1
7. Resize the ext2 to "fit" the partition: resize2fs /dev/sda1
8. Check FS again: fsck -n /dev/sda1
9. Create the Journal : tune2fs -j /dev/sda1
10. reboot

EMC Celerra IP Replication via CLI

EMC Celerra IP Replication via CLI

PROD
Name: SALMON
DRP Name: PERCH
Create the trust (run on PROD & DRP):
[root@SALMON nasadmin]# nas_cel -create PERCH -ip 172.17.0.22 -passphrase nasadmin
[root@PERCH nasadmin]# nas_cel -create SALMON -ip 172.17.0.27 -passphrase nasadmin
Check the trust:
[root@SALMON nasadmin]# nas_cel -list
id name owner mount_dev channel net_path CMU
0 SALMON 0 172.17.0.27 CK2000646000870000
2 PERCH 0 172.17.0.22 CK2000646004010000
[root@PERCH nasadmin]# nas_cel -list
id name owner mount_dev channel net_path CMU
0 PERCH 0 172.17.0.22 CK2000646004010000
2 SALMON 0 172.17.0.27 CK2000646000870000
[root@SALMON nasadmin]# nas_cel -info id=2
id = 2
name = PERCH
owner = 0
device =
channel =
net_path = 172.17.0.22
celerra_id = CK2000646004010000
passphrase = nasadmin
[root@PERCH nasadmin]# nas_cel -info id=2
id = 2
name = SALMON
owner = 0
device =
channel =
net_path = 172.17.0.27
celerra_id = CK2000646000870000
passphrase = nasadmin
Create FileSystem Checkpint on the PROD Source file system:
[root@SALMON nasadmin]# fs_ckpt Figaro_Groups -Create
[root@SALMON nasadmin]# fs_ckpt Figaro_Users -Create
Create the new destination file system on the DRP Celerra (must be the same size):
[root@PERCH nasadmin]# nas_fs -name Figaro_Users_REP -type rawfs -create samesize=Figaro_Users:cel=SALMON pool=clar_r5_performance
[root@PERCH nasadmin]# nas_fs -name Figaro_Groups_REP -type rawfs -create samesize=Figaro_Groups:cel=SALMON pool=clar_r5_performance
Create mount points for the new file system on the celerra DRP:
[root@PERCH nasadmin]# server_mountpoint server_2 -create /dst_users Figaro_Users_REP
server_2 : done
[root@PERCH nasadmin]# server_mountpoint server_2 -create /dst_groups Figaro_Groups_REP
server_2 : done
Mount the file system (read only):
[root@PERCH nasadmin]# server_mount server_2 -option ro Figaro_Users_REP /dst_users
server_2 : done
[root@PERCH nasadmin]# server_mount server_2 -option ro Figaro_Groups_REP /dst_groups
server_2 : done
Copy the CheckPoint from the Celerra Prod source to the Celerra DRP destination:
[root@SALMON nasadmin]# fs_copy -start Figaro_Users_ckpt1 Figaro_Users_REP:cel=PERCH -option convert=no,monitor=off
[root@SALMON nasadmin]# fs_copy -start Figaro_Groups_ckpt1 Figaro_Groups_REP:cel=PERCH -option convert=no,monitor=off
Verify the File transfer:
[root@SALMON nasadmin]# fs_copy -list
Local Source Filesystems
Id Source Destination Status %Remaining CommState
219 Figaro_Users_ck Figaro_Users_RE started 100 transferring
221 Figaro_Groups_c Figaro_Groups_R started 100 transferring
Begin replication:
[root@SALMON nasadmin]# fs_replicate -start Figaro_Groups Figaro_Groups_REP:cel=PERCH
[root@SALMON nasadmin]# fs_replicate -start Figaro_Users Figaro_Users_REP:cel=PERCH

Check replication FileSystem:
[root@PERCH nasadmin]# nas_fs -info -size Figaro_Groups_REP
id = 86
name = Figaro_Groups_REP
acl = 0
in_use = True
type = rawfs
worm = off
volume = v232
pool = clar_r5_performance
member_of = root_avm_fs_group_3
rw_servers=
ro_servers= server_2
rw_vdms =
ro_vdms =
backup_of = Figaro_Groups:SALMON
auto_ext = no,virtual_provision=no
size = total = 488800 (sizes in MB) ( blockcount = 1001062400 )
stor_devs = CK200064600401-0011
disks = d22
disk=d22 stor_dev=CK200064600401-0011 addr=c16t1l1 server=server_2
disk=d22 stor_dev=CK200064600401-0011 addr=c0t1l1 server=server_2
[root@PERCH nasadmin]# nas_fs -info -size Figaro_Users_REP
id = 88
name = Figaro_Users_REP
acl = 0
in_use = True
type = rawfs
worm = off
volume = v235
pool = clar_r5_performance
member_of = root_avm_fs_group_3
rw_servers=
ro_servers= server_2
rw_vdms =
ro_vdms =
backup_of = Figaro_Users:SALMON
auto_ext = no,virtual_provision=no
size = total = 412766 (sizes in MB) ( blockcount = 845344768 )
stor_devs = CK200064600401-0010
disks = d21
disk=d21 stor_dev=CK200064600401-0010 addr=c0t1l0 server=server_2
disk=d21 stor_dev=CK200064600401-0010 addr=c16t1l0 server=server_2