sandip's blog

Disable auto fsck

I have a huge external usb drive set to be auto-mounted during backup processes and did not want to run fsck on every mount. With the below setting it would completely turn off the auto fsck check.

# tune2fs -c 0 -i 0 </dev/partition>

However, I would highly suggest atleast doing a regular 6 months check if not doing manual fscks.

# tune2fs -c 0 -i 6m </dev/partition>

PostgreSQL 8.3 install on CentOS

# wget http://yum.pgsqlrpms.org/reporpms/8.3/pgdg-centos-8.3-6.noarch.rpm
# rpm -Uvh pgdg-centos-8.3-6.noarch.rpmr /># yum install postgresql-server
# service postgresql initdb
# service postgresql start

vzdump LVM snapshots kernel errors

On running daily lvm snapshot backups via vzdump on OpenVZ servers, I noticed the below Kernel errors in logwatch reports.


WARNING:  Kernel Errors Present
    Buffer I/O error on device dm-4,  ...:  22 Time(s)
    EXT3-fs error (device dm-4): e ...:  60 Time(s)
    lost page write due to I/O error on dm-4 ...:  22 Time(s)

This would show up on busy servers only, probably caused due to lvm snapshot running out of space.

I edited "/usr/bin/vzdump" and increased the size from 500m to 1000m which seems to have resolved the issue for now.


run_command (\*LOG, "$lvcreate --size 1000m --snapshot --name vzsnap /dev/$lvmvg/$lvmlv");

svn checkout via shell script

Very often development servers only have self-signed certificate for ssl connection. I've recently had to create a script that would checkout from a https svn repository that would fail with "Server certificate verification failed: issuer is not trusted..." . Below is a workaround used to temporarily trust the certificate.

svn --username $SVN_USER --password $SVN_PASS --no-auth-cache checkout ${REPO_URL}/${REPO_PATH} $REPO_PATH <<EOF 2>/dev/null
t
EOF

Testing zipped archives

If you've got a lot of zip files and need to test it, here's a one liner that can be used to quickly validate the archives:

for x in `ls` ; do zip -T $x ; done | tee /tmp/archive_test.log

comparing files line by line

Here's a way to compare two files that have common lines in both files:

sort file1.txt > file1_sorted.txt
sort file2.txt > file2_sorted.txt
comm -12 file1_sorted.txt file2_sorted.txt

Note: files need to be sorted first prior to comparing.

cofigure phplist spellcheck for firefox

PHPList comes with FCKeditor as the gui default editor. However, by default it is setup so that the spellcheck is only available to IE users. To enable for other browsers such as Firefox, follow the below directions:

  1. Edit admin/fckphplist.php:
  2. Replace all instances of:
    FCKConfig.SpellChecker &nbsp;    = 'ieSpell' ;

    with:

    FCKConfig.SpellChecker &nbsp;    = 'SpellerPages' ;

  3. Edit admin/.htaccess and add "spellchecker.php" to the list of files to allow access to.
  4. If this is a linux box, then make sure aspell is installed. Edit "admin/FCKeditor/editor/dialog/fck_spellerpages/spellerpages/server-scripts/spellchecker.php" and update the aspell program path:

    $aspell_prog    = '/usr/bin/aspell';

That should do it.

Backup, restore and cloning of partition table

To backup partition table:

sfdisk -d /dev/sda > sda.table

To restore the partition table:

sfdisk /dev/sda < sda.table

To clone partition table:

sfdisk -d /dev/sda | sfdisk /dev/sdb

set_loginuid failed opening loginuid

If this file doesn't exist:

/proc/<pid of crond>/loginuid

It's because the kernel doesn't have AUDIT enabled. So you get a bunch of errors in "/var/log/secure" with "set_loginuid failed opening loginuid".

Recompile kernel with audit support:

CONFIG_AUDIT=y
CONFIG_AUDITSYSCALL=y

If recompiling of kernel is not an option then:

Comment the below lines from all pam.d files.

session required   &nbsp;    pam_loginuid.so

Find files via:

# grep -l pam_loginuid.so /etc/pam.d/*
/etc/pam.d/atd
/etc/pam.d/crond
/etc/pam.d/login
/etc/pam.d/remote
/etc/pam.d/sshd

Loss in network connectivity on OpenVZ host

I was seeing loss in network connectivity when an OpenVZ container is stopped and noticed that the bridge mac address was taking the mac address of an existing containers virtual network interface instead of the physical interface.

The solution was to set the bridge mac address to the physical interface:

/sbin/ifconfig br0 hw ether $(ifconfig eth0 | awk '{print $5; exit}')

Here is what my "/etc/sysconfig/vz-scripts/vps.umount" looks like which is used to remove routes to container with veth-bridge from bridge.

Comment