Thursday, April 7, 2016

Resizing an UFS2 filesystem on FreeBSD

List all block devices:
# gpart show

If this doesn't show the correct size for the resized device, then reboot. During reboot ignore any warnings about invalid GPT headers
Error eg: gpart: table 'ada0' is corrupt: Operation not permitted

Fix the invalid GPT header (replace ada0 by your actual block device):
$ gpart recover ada0

Allow write access to GEOM providers:
$ sysctl -w kern.geom.debugflags=16

Resize the third partition (again, replace 3 and ada0): 
$ gpart resize -i 3 ada0
p/s: i value is depand on /dev/ada0p3 (value after p)

Resize the filesystem:
$ growfs ada0p3
Enter Yes (case-sensitive!) when asked

Disallow write access to GEOM providers (just as a security measure):
$ sysctl -w kern.geom.debugflags=0
This even works for a mounted root filesystem.

Friday, April 1, 2016

Add New Hard Disk Freebsd 10.2


Nowadays you should use gpart to partition the disk (fdisk/disklabel are being overtaken by gpart since it supports GPT), newfs to format UFS[2] partitions and zpool to create ZFS filesystems.

#gpart create -s gpt /dev/da1
#gpart add -t freebsd-ufs /dev/da1
#newfs -U /dev/da1p1
#mkdir /data
#mount -t ufs /dev/da1p1 /data 

Add in fstab
# nano /etc/fstab
/dev/da1p1 /data ufs rw 2 2

Ref: https://www.freebsd.org/doc/handbook/disks-adding.html
https://amitabhkant.com/2012/03/26/adding-new-disk-in-freebsd/

Friday, November 27, 2015

My bash script doesn't work in crontab

........Continuing to bash script yesterday..

I got a problem where it doesn't work when it is running using the crontab.

Here is some tips:
1. You can troubleshoot by keep the log of your cron
eg: 10 02 * * * /home/aminah/script.sh  >> /home/aminah/cronscripts.log 2>&1

So, you can tail the cronscripts.log once it is running.

2.  Path of you script.
Make sure you put the full path so that the script will understand where you put the script.

3. If your script is download the files, it will download it at home of your running bash file.
eg: run as root.. the download file will located at /root/


It is really good experience for me... Thanks to Allah swt....

Wednesday, November 25, 2015

Playing with bash file

This is my first command of bash file.. Usually i'm only adding few command which is already there (who already wrote by my SIFU)..

What I'm going to do is.. transfering file from sftp server A to server B and send to S3 amazon. The tricky is sftp part.. :) .. I'm creating 2 file here sftpcommand.txt and script.sh


sftpcommand.txt
+++++++++++++++++++
mget data-2015_11_24*
bye

+++++++++++++++++++


script.sh
++++++++
#!/bin/bash
now="$(date)"         
printf "Current date and time %s\n" "$now"      #date of the day     

now="$(date +'%Y_%m_%d')"
printf "Current date in yyyy_mm_dd format %s\n" "$now"   

#.......
echo "try command"
#echo "data-$(date -d "3 day ago" +'%Y_%m_%d')"
now="data-$(date -d "1 day ago" +'%Y_%m_%d')*"   #1day before current date with wildcard*

echo "startfilename=""$now"  #show the output of $now

echo "changing sftp command"
sed -i "1s/.*/mget $now/" sftpcommand.txt    #changing sftpcommand.txt at 1st line same value with $now

echo "sftp is running"
sftp -b sftpcommand.txt -v -P 9878 -i cthroot.pem root@sftp.server.com:   #sftp bash command of sftpcommand.txt

echo "list"
find /home/aminah/data/ -name "$now" -print  #work
echo "send to s3"
find /home/aminah/data/ -name "$now" -exec aws s3 cp '{}' s3://pathbucket/folder/ \;   #work #sending the same value to s3.. 

echo "end"
+++++++

To check the command run bash  #bash -x script.sh ; it will show the output and easy to troubleshoot. 

And its working like charm.. horey...

Wednesday, July 1, 2015

Exchange 2010: Unable to open Exchange Management Console - Initialization Failed

Problem: (Error once to open EMC) The attempt to connect to http://exchange.contoso.com'/powershell using 'Kerberos' authentication failed: Connecting to the remote server failed with the following error message : WinRM cannot process the request. The following error occurred while using Kerberos  authentication: The network path was not found.


Resolutions:

Method 1:

Close all MMC/EMC instances before proceeding.
Open Registry Editor (regedit) as the user you run the EMC under.
Go to
HKEY_CURRENT_USER\SOFTWARE\Microsoft\ExchangeServer\v14\AdminTools
Look for value NodeStructureSetting.
If it is there, back it up and then remove it.

Method 2:

Close all MMC/EMC Instances before proceeding.
Open Powershell or Powershell IDE as the user you run the EMC under and execute the following command:.
Remove-ItemProperty -Path HKCU:\Software\Microsoft\ExchangeServer\v14\AdminTools\ -Name NodeStructureSettings
Close Powershell
After performing either of the methods above to remove the registry entry you should be able to open the Exchange Management Console and it will discover another Exchange server and connect.

Monday, April 13, 2015

Hardisk full - enter full pathname of shell or return for /bin/sh; ERROR

First thing you can do is, run Fsck manually

#Fsck -y 

then reboot.

Sometimes, we only fsck to that directory only

#fsck -y /dev/da01
# reboot

Sunday, February 22, 2015

Server 2008R2 Standard giving "This copy of windows is not genuine" error, cannot run windows activation

I was wonder why my old server giving error to windows is not genuine... Some how this old server was activate with licence.

Here is the problem:
There is few services which is not started:

• Software Protection

• SPP Notification Service