Archive for the 'Linux' Category

Use wget in cron with no output

When you use wget in a cron to run a php script at a specific interval the home directory of the user this cron is running as is filled with files containing the output.
You can make cron output everything to stdout to make this stop:

/usr/bin/wget -O - -q http://www.whatever.com/cron.php

No Comments »

Set network interface to 100 mbit full duplex (eth0) in CentOS

Add this line to /etc/sysconfig/networking/devices/ifcfg-eth0
(or any other nic if you need to)

ETHTOOL_OPTS=”autoneg off speed 100 duplex full”

Make sure your switch also has this configured this way.

No Comments »

VMware 6.5.4 and Ubuntu vmnet compile problems and cursor flaw fix

VMware seems to go the Microsoft way of doing things; They create a flawed installer and no KB to fix this.
Fortunately there are some smart dudes who know their stuff and place it on the www. I was lazy to find out this time myself so this is some sort of “placeholder” for the next time when I run into this, or when VMware has sorted their stuff out with a new version, or fix.

Thanks to digital-scurf blog author; Sorry to copy this but this really makes sense. Short and clear:

I recently updated vmware on my desktop to workstation 6.5.4 having previously upgraded the machine to Ubuntu 10.04. This resulted in interesting issues so I thought I’d collate them all here.

1. vmware’s installer remains flawed wrt. output generated during module compile—to fix this, create a gcc wrapper script which removes the -W flags, e.g.

#!/usr/bin/python
import sys
import copy
import os
argv = copy.copy(sys.argv)
i = len(argv)
for i in range(i-1, 0, -1):
if len(argv[i]) > 4 and argv[i][:2] == "-W" and argv[i][3] != ",":
del argv[i]
argv[0] = "/usr/bin/gcc"
os.execv(argv[0], argv)

2. Pop that somewhere like /tmp/gcc and chmod +x it.
3. Run sudo env PATH=/tmp:$PATH sh /wherver/VMware-Installer.bundle
4. When the installer finishes, cd into /etc/vmware and add export VMWARE_USE_SHIPPED_GTK=”force” to the bootstrap file. (This fixes the mouse-broken in fullscreen mode, two pointers visible, vmware losing grab blahblahblah problem)
5. cd into /usr/lib/vmware/modules/source
6. untar the vmci and vmnet tarballs
7. in vmci-only/include/pgtbl.h add compat_sched.h to the includes
8. in vmnet-only/vnetUserListener.c add compat_sched.h to the includes
9. tar those up again
10. run sudo vmware-modconfig—console—install-all
11. Assuming all is well, vmware will now work properly.

No Comments »

SVN and Mac OSX hidden .DS_Store ._ .AppleDouble files

If you work on a mac (as i do) your directories get poluted with .DS_Store, ._ and .AppleDoubel files. Apple (this is THE missing Finder feature!) has no option to turn this crap off.
Now when you use svn, you will also import all these useless files.

Thank god there is a option in svn to globally ignore specific files.
Just edit the file:

~/subversion/config

Find the line global-ignores, uncomment it and make it something like this:

global-ignores = *.o *.lo *.la #*# .*.rej *.rej .*~ *~ .#* .DS_Store .AppleDouble ._*

Whoot!

No Comments »

Iptables active and passive FTP in CentOS

This is how to make sure active AND passive FTP work flawlessly with IPtables, in this case, on CentOS. In this case it was for a DirectAdmin server.
You have to look up in your ftpd config which passive FTP ports your daemon uses and use those. In my case the portrange was 35000-35999.

This is /etc/sysconfig/iptables

# Firewall configuration written by system-config-securitylevel
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:RH-Firewall-1-INPUT - [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

#active and passiev ftp
-A RH-Firewall-1-INPUT -p tcp --syn --dport 21 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp --syn --dport 20 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp --syn --dport 35000:35999 -j ACCEPT

#ssh only for me
-A RH-Firewall-1-INPUT -s 1.2.3.4 -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT

#other useful ports available to the public
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 25 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 110 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 2222 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT

Now we have to make sure some iptables modules are loaded.
Edit /etc/sysconfig/iptables-config
Make sure this line is looking like this:

IPTABLES_MODULES="ip_conntrack_netbios_ns ip_nat_ftp ip_conntrack_ftp"

Restart your iptables and test your ftp connection. It should work as expected.

3 Comments »

ClamAV 0.94 not working anymore in MailScanner

I had this issue, clamav worked perfectly on command line, but within MailScanner it seemed to stop working. I could not find out why. I checked every configuration file, everything seemed normal.

Today i was upgrading ClamAV from 0.94 to 0.94.1, and suddenly i saw these lines in my maillog:


Nov 12 09:01:39 mx02 MailScanner[26358]: WARNING: Ignoring deprecated option --unzip
Nov 12 09:01:39 mx02 MailScanner[26358]: WARNING: Ignoring deprecated option --jar
Nov 12 09:01:39 mx02 MailScanner[26358]: WARNING: Ignoring deprecated option --tar
Nov 12 09:01:39 mx02 MailScanner[26358]: WARNING: Ignoring deprecated option --tgz
Nov 12 09:01:39 mx02 MailScanner[26358]: WARNING: Ignoring deprecated option --deb
Nov 12 09:01:39 mx02 MailScanner[26358]: WARNING: Ignoring deprecated option --unrar
Nov 12 09:01:39 mx02 MailScanner[26358]: WARNING: Ignoring deprecated option --arj
Nov 12 09:01:39 mx02 MailScanner[26358]: WARNING: Ignoring deprecated option --lha
Nov 12 09:01:39 mx02 MailScanner[26358]: WARNING: Ignoring deprecated option --unzoo
Nov 12 09:01:39 mx02 MailScanner[26358]: WARNING: Ignoring deprecated option --max-ratio
Nov 12 09:01:39 mx02 MailScanner[26358]: WARNING: Ignoring deprecated option --unrar

Hmmmm.. weird. I started googling and found this bug:
https://wwws.clamav.net/bugzilla/show_bug.cgi?id=1213

They did this: Instead of hardfailing, clamd will print warnings.

Glad it is resolved now..

2 Comments »

VMware linux vmdk-file mount from linux host with LVM filesystems

Pheeew, long title this time…

I’ve been a VCP for a while now and working with VMware products. Since Linux on VMware is becomming pretty ordinary right now, you can still see that there are some missing features left to implement. Especially VCB is not there yet completely for Linux (it does do the complete Linux vmdk file, but not the files inside the vmdk like it does with Windows filesystems). Since IBM’s p-Series Power virtualisation rules more than VMware, you can see that the Unix-part will be more integrated to a VMware w/ Linux sollution due to the hardware- and license costs. Also the Virtual Center Server/Client combination is very intuitive to work with, compared to the IBM’s HMC/VIO combination.

Here is a little howto to mount a Linux vmdk file within a host (e.g. Linux host or Service console) and mount the vmdk to a directory. With a regular filesystem, this seems to be no problem, BUT if you have equipped the Linux partitions with LVM, you need to do some extra commands to alter, change and view the filesystems under LVM.

#
# mount a Linux vmdk file with LVM partitions on a Linux host:
#
1. Existing Linux vmdk file: RHES4-i386-clean.vmdk, mount as a flat file:

[root@linux-1 RHES4-i386-clean]# vmware-mount -p RHEL4-U2-i386-ES_thin.vmdk
Nr Start Size Type Id Sytem
-- ---------- ---------- ---- -- ------------------------
1 63 208782 BIOS 83 Linux
2 208845 20755980 BIOS 8E Unknown

2. Mount the second partition to a directory using the -f flag:

[root@linux-1 RHES4-i386-clean]# vmware-mount -f RHEL4-U2-i386-ES_thin.vmdk test
[root@linux-1 RHES4-i386-clean]# cd test
[root@linux-1 test]# ls
flat

3. Search for the offset in the sectors:
[root@linux-1 test]# sfdisk -luS ./flat
last_lba(): I don't know how to handle files with mode 81b0
Disk ./flat: cannot get geometry

Disk ./flat: 1305 cylinders, 255 heads, 63 sectors/track
Units = sectors of 512 bytes, counting from 0

Device Boot Start End #sectors Id System
./flat1 * 63 208844 208782 83 Linux
./flat2 208845 20964824 20755980 8e Linux LVM
./flat3 0 - 0 0 Empty
./flat4 0 - 0 0 Empty

Look for the used sectors of /flat1 (=208782) and multiply with 512. That’s the offset we are going to use.

[root@linux-1 test]# bc
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
208782*512
106896384

4. Connect the second partition (Linux LVM) to a loopdevice, using the offset:
[root@linux-1 test]# losetup -o 106928640 /dev/loop0 flat

5. Look for the volumegroup inside the newly created /dev/loop0
[root@linux-1 test]# vgscan
Reading all physical volumes. This may take a while...
WARNING: Duplicate VG name rootvg: Existing
jY02R5-g1Ds-HoTy-2r5E-4hza-I1GC-HoYAOE (created here) takes precedence over
54wLuw-w8An-IfGL-ACKV-lK1B-0sx3-q1sX36
Found volume group "rootvg" using metadata type lvm2
Found volume group "rootvg" using metadata type lvm2

[root@linux-1 test]# pvdisplay
WARNING: Duplicate VG name rootvg: Existing
jY02R5-g1Ds-HoTy-2r5E-4hza-I1GC-HoYAOE (created here) takes precedence over
54wLuw-w8An-IfGL-ACKV-lK1B-0sx3-q1sX36
--- Physical volume ---
PV Name /dev/sda2
VG Name rootvg
PV Size 74.43 GB / not usable 22.62 MB
Allocatable yes
PE Size (KByte) 32768
Total PE 2381
Free PE 445
Allocated PE 1936
PV UUID ZHjhkC-No2D-M2jI-erME-ypxC-hw8R-Op8suu

--- Physical volume ---
PV Name /dev/loop0
VG Name rootvg
PV Size 9.90 GB / not usable 26.02 MB
Allocatable yes
PE Size (KByte) 32768
Total PE 316
Free PE 60
Allocated PE 256
PV UUID MMZAx8-EU7Q-z36V-SJ8L-vh7O-n9y2-3rz6mp

I’m using the rootvg as default naming scheme for all my LVM system partitions. This has been detected and I have to rename my LVM of the vmdk to e.g. rootvgtemp instead of rootvg.

[root@linux-1 test]# pvscan
WARNING: Duplicate VG name rootvg: Existing
jY02R5-g1Ds-HoTy-2r5E-4hza-I1GC-HoYAOE (created here) takes precedence over
54wLuw-w8An-IfGL-ACKV-lK1B-0sx3-q1sX36
PV /dev/sda2 VG rootvg lvm2 [74.41 GB / 13.91 GB free]
PV /dev/loop0 VG rootvg lvm2 [9.88 GB / 1.88 GB free]
Total: 2 [84.28 GB] / in use: 2 [84.28 GB] / in no VG: 0 [0 ]

6. Change, if necessary the rootvg name (check the warnings). Make sure you use the correct UUID and remember that number when changing it back to the correct name (rootvgtemp -> rootvg):
Check that with vgdisplay:

[root@linux-1 test]# vgrename jY02R5-g1Ds-HoTy-2r5E-4hza-I1GC-HoYAOE rootvgtemp

[root@linux-1 test]# vgscan
Reading all physical volumes. This may take a while...
Found volume group "rootvg" using metadata type lvm2
Found exported volume group "rootvgtemp" using metadata type lvm2

8.
[root@linux-1 test]# lvscan
ACTIVE '/dev/rootvg/rootlv' [1.00 GB] inherit
ACTIVE '/dev/rootvg/homelv' [18.00 GB] inherit
ACTIVE '/dev/rootvg/optlv' [3.00 GB] inherit
ACTIVE '/dev/rootvg/tmplv' [512.00 MB] inherit
ACTIVE '/dev/rootvg/usrlv' [5.00 GB] inherit
ACTIVE '/dev/rootvg/varlv' [1.00 GB] inherit
ACTIVE '/dev/rootvg/swaplv' [2.00 GB] inherit
ACTIVE '/dev/rootvg/datalv' [30.00 GB] inherit
inactive '/dev/rootvgtemp/rootlv' [512.00 MB] inherit
inactive '/dev/rootvgtemp/homelv' [1.00 GB] inherit
inactive '/dev/rootvgtemp/optlv' [512.00 MB] inherit
inactive '/dev/rootvgtemp/tmplv' [512.00 MB] inherit
inactive '/dev/rootvgtemp/usrlv' [4.00 GB] inherit
inactive '/dev/rootvgtemp/varlv' [1.00 GB] inherit
inactive '/dev/rootvgtemp/swaplv' [512.00 MB] inherit

9. Activate a LV and mount the directory:
[root@linux-1 test]# lvchange -ay /dev/rootvgtemp/rootlv

10. Mount:
[root@linux-1 test]# mkdir /home/user/vmware/RHES4-i386-clean/dir
[root@linux-1 test]# mount /dev/rootvgtemp/rootlv /home/user/vmware/RHES4-i386-clean/dir

11. Now you can change to that directory and do your things.

To disable the directory/filesystems and restart the virtual with this vmdk.file:

Disconnect:
[root@linux-1 test]# cd ..
[root@linux-1 RHES4-i386-clean]# umount /dev/rootvgtemp/rootlv
[root@linux-1 RHES4-i386-clean]# lvchange -an /dev/rootvgtemp/rootlv

[root@linux-1 RHES4-i386-clean]# vgchange -an rootvgtemp

Change the VG-name back to the original. You must do this when you had to change the vgname due to duplicate names. After that, disconnect the disk:

[root@linux-1 RHES4-i386-clean]# vgchange -yn rootvgtemp

copieer de vgcfg van de laatst werkende, b.v.
Look for the latest backup of the LVM definitions with “lvcfgrestore -l” or look inside the /etc/lvm/archive directory. Copy the file and change the rootvgtemp name inside the file to the correct one, in our example it’s rootvg :

[root@linux-1 RHES4-i386-clean]# cp /etc/lvm/archive/rootvgtemp_00009.vg .

Change the rootvgtemp to rootvg inside the file:

Restore the LVM definitions:
[root@linux-1 RHES4-i386-clean]# vgcfgrestore -f ./rootvgtemp_00000.vg
rootvg
WARNING: Duplicate VG name rootvg: Existing
54wLuw-w8An-IfGL-ACKV-lK1B-0sx3-q1sX36 (created here) takes precedence over
jY02R5-g1Ds-HoTy-2r5E-4hza-I1GC-HoYAOE
Restored volume group rootvg
[root@linux-1 RHES4-i386-clean]# vgscan
Reading all physical volumes. This may take a while...
WARNING: Duplicate VG name rootvg: Existing
jY02R5-g1Ds-HoTy-2r5E-4hza-I1GC-HoYAOE (created here) takes precedence over
54wLuw-w8An-IfGL-ACKV-lK1B-0sx3-q1sX36
Found volume group "rootvg" using metadata type lvm2
Found volume group "rootvg" using metadata type lvm2
[root@linux-1 RHES4-i386-clean]# lvscan
WARNING: Duplicate VG name rootvg: Existing
jY02R5-g1Ds-HoTy-2r5E-4hza-I1GC-HoYAOE (created here) takes precedence over
54wLuw-w8An-IfGL-ACKV-lK1B-0sx3-q1sX36

Disconnect the loop device:
[root@linux-1 RHES4-i386-clean]# losetup -d /dev/loop0

[root@linux-1 RHES4-i386-clean]# lvscan
WARNING: Duplicate VG name rootvg: Existing
jY02R5-g1Ds-HoTy-2r5E-4hza-I1GC-HoYAOE (created here) takes precedence over
54wLuw-w8An-IfGL-ACKV-lK1B-0sx3-q1sX36
ACTIVE '/dev/rootvg/rootlv' [512.00 MB] inherit
ACTIVE '/dev/rootvg/homelv' [1.00 GB] inherit
ACTIVE '/dev/rootvg/optlv' [512.00 MB] inherit
ACTIVE '/dev/rootvg/tmplv' [512.00 MB] inherit
ACTIVE '/dev/rootvg/usrlv' [4.00 GB] inherit
ACTIVE '/dev/rootvg/varlv' [1.00 GB] inherit
ACTIVE '/dev/rootvg/swaplv' [512.00 MB] inherit

Remove the loopdevice and the flat file:
[root@linux-1 RHES4-i386-clean]# losetup -d /dev/loop0

[root@linux-1 RHES4-i386-clean]# vmware-mount -X

Cool shit or what???

6 Comments »

IBM T41 with Fedora Core 5 and Xorg problems

I’ve installed my work laptop with Fedora Core 5 last week. Everything went very well but it always takes time before it’s perfectly running for your needs. My previous OS was Fedore Core 4 and before that it was installed with Gentoo.
I must say that it has become pretty easy lately, especially with a kickstart server on my side and PXE booting goes quite quick. Within 10 minutes your system is ready to run.

Continue Reading »

No Comments »

Font size of Gnome2 apps in KDE with no Gnome2 installed

To set the font type and size for the gnome applications used under KDE3 and no Gnome2 installed, you don’t have the gnome-control-centre.

Edit the following file:

$ vi ~/.kde3.3/share/config/gtkrc

Add the font_name parameter to the default style section:

style “default”
{
font_name = “Cursor 8”
}

In the style “default” section there might be lots of other stuff, just add the font_name at the end. Any new started gnome application now uses this font as a system font.

No Comments »

Gentoo 1.4 with Apache2 and PHP 4 error

When i tried to upload a file larger than 580Kb i got the following error in apache’s error_log:

Requested content-length of 670955 is larger than the configured limit of 524288

After googling for quite a while i found the following solution and it works:

Problem noted on Gentoo 1.4 with Apache 2.0.x, the error “Requested content-length of 670955 is larger than the configured limit of 524288” was occuring under Apache and a “Page not found” would appear in the browser. Trying the above settings made no change with PHP, but on Gentoo there is an additional PHP config file, /etc/apache2/conf/modules.d/70_mod_php.conf, and increasing the number on the line “LimitRequestBody 524288” solves the issue.

The same problem also exists on RedHat 8.0/9.0.

No Comments »

Next »