Monday, December 15, 2014

Ubuntu server 14.04 - Auto mount network Drive Issue

Recently, due to maintanance upgrade I have to reboot my Server and notice that it stuck at boot screen waiting for external Network drive to mount. Previous article ubuntu-server-auto-mount-iscsi-storage

The message is "the disk drive for /backupdata is not ready or not presented". 2 things I can do:

Remount network drive with UUID instead of /dev/blah..blah in /etc/fstab
#> blkid
/dev/mapper/datavg-backupdata: UUID="85e81bbc-2c86-4bef-b1e9-f77d21929de5" TYPE="xfs" 

Add nobootwait option into mount target in /etc/fstab
UUID=85e81bbc-2c86-4bef-b1e9-f77d21929de5 /backupdata xfs auto,rw,user,nobootwait 0 0

Then reboot my system and It work!

Thursday, December 11, 2014

Backuppc add administrator account

Adding a CGI Administrator

as root privilege open up /etc/backuppc/ and go to line 2020
$Conf{CgiAdminUserGroup} = 'backuppc';
$Conf{CgiAdminUsers} = 'backuppc, admin';

Reload Backuppc service
service backuppc reload

Adding Administrator to htpasswd for Apache basic authentication

htpasswd /etc/backuppc/htpasswd admin

Restart Apache service
service apache2 restart

Tuesday, December 9, 2014

Ubuntu server auto mount iSCSi storage

Install Open-iSCSI initiator
apt-get install open-iscsi

configuration file could be located at /etc/iscsi/iscsid.conf or ~/.iscsid.conf.
node.startup = automatic
node.session.auth.username = MY-ISCSI-USER
node.session.auth.password = MY-ISCSI-PASSWORD
discovery.sendtargets.auth.username = MY-ISCSI-USER
discovery.sendtargets.auth.password = MY-ISCSI-PASSWORD

Discover iSCSi Target
iscsiadm -m discovery -t sendtargets -p

Login to target
iscsiadm --mode node --targetname --portal --login

Note: remember login to your iSCSi server (SAN) then allow your server connection
Make sure you auto connect to iSCSi server target when server start up
vi /etc/iscsi/nodes/\:cx.fcnma082600013.b1/\,3260\,3/default

node.startup = automatic

Restart service
/etc/init.d/open-iscsi restart

Format and mount the iSCSi volume

dmesg or fdisk -l, or look at /var/log/messages to find new devices
You can use LVM or partition your disk now
fdisk /dev/sde

Format a partition ext4 or xfs or brtfs
mkfs.ext4 /dev/sde1

Mount file system
mkdir /backupdata
mount /dev/sde1 /backupdata

Add mount point to /etc/fstab 
/dev/sde1  /backupdata ext4 defaults 0 0

Monday, December 8, 2014

Bonding Network Card Ubuntu 14.04

Make sure your Cisco Switch support 802.3ad, then group 2 interface ports together
Router> enable
Router# configure terminal
Router(config)# interface port-channel 1
Router(config-if)# interface g1/0/24
Router(config-if)# channel-group 1 mode active
Router(config-if)# exit
Router(config)# interface g1/0/23
Router(config-if)# channel-group 1 mode active
Router(config-if)# end
Router# copy run start

Bonding mode:
802.3ad or 4 : IEEE 802.3ad Dynamic link aggregation. Creates aggregation groups that share the same speed and duplex settings. Utilizes all slaves in the active aggregator according to the 802.3ad specification.

Bonding network card on Ubuntu Server
apt-get install ifenslave-2.6
echo "bonding" >> /etc/modules
modprobe bonding

vi /etc/network/interface
auto em1
iface em1 inet manual
bond-master bond0
bond-primary em1

auto em2
iface em2 inet manual
bond-master bond0

auto bond0
iface bond0 inet static
bond-slaves none
bond-mode 4
bond-miimon 100

Reboot server and wait a little bit for the bond interface become active

Thursday, December 4, 2014

Ubuntu - 3 tricks to copy DVD into iso file

Built in command

cat /dev/sr0 > /home/Documents/mydisk.iso
dd if=/dev/sr0 of=/home/Documents/mydisk.iso

If both cat, and dd not work because of '/dev/sr0': Input/output error
If I run dmesg, I recieve a lot of Buffer I/O error on device sr0

Try ddrescue in Ubuntu the package is gddrescue
sudo apt-get install gddrescue
ddrescue --direct --block-size=2048 --no-split /dev/sr0 /home/Documents/mydisk.iso

Now you can open iso file with VLC

Tuesday, December 2, 2014

Linux find command for files or folders older than .....

Find files and folders in current working directory older than 60 days
find ./* -maxdepth 0 -mtime +60

Find only folders in /mnt/media -> child folder -> grandchild exclude these folder notme, dtran, xXXx older than 3 years
find /mnt/media -maxdepth 2 -mtime +1095 -type d -not \( -path "./notme*" -o -path "./dtran*" -o -path "./xXXx*" \) > ~/Folder2Backup.txt

Remove all files that have xxx in names and older than 2 years
find ./ -type f -name "*xxx*.*" -mtime +730 -exec rm "{}" \;

Windows not a big deal, install Cygwin and Finding Nemoooo
find /cygdrive/f -maxdepth 2 -type d -mtime +730 > ~/dir_older_than_2years.txt

Find directory older than 2 years and list its size
find /cygdrive/f -maxdepth 1 -type d -mtime +730 -exec du -sh "{}" \; 

Apple flush DNS cache

Open Terminal and run this command

dscacheutil -flushcache

TTL and DNS cache

Time to Live (TTL) is used to renew the DNS records on all the DNS servers around the world to the set TTL value. 

The units used are seconds. The older common TTL value for DNS was 86400 seconds, which is 24 hours. A TTL value of 86400 would mean that, if a DNS record was changed on the authoritative name server, the DNS servers around the world could still be showing the old value from their cache for up to 24 hours after the change.

Why change the TTL value

If you want to make quick DNS changes, it is a good practice to place a low TTL value. The TTL values can be changed by logging in to the the Self Service Center.
If you change the TTL, you have to wait for the current TTL to pass before the new TTL will be active. This means that if you change the TTL to 1 hour instead of 24 hours, you have to wait the 24 hours first before the 1 hour TTL wil be active.

Setting a TTL value lower than 12 hours is not recommended, and should only be used during a short period for special cases. By default, the TTL value is 24 hours.