Archive

Archive for the ‘hardware’ Category

CPU flags explained (linux)

April 16th, 2010 No comments

i had to find some cpu flags and their descriptions, so i wrote a little utility script that explains what features your CPU has. It uses your kernel's cpuinfo includes to gather the descriptions and /proc/cpuinfo to get the actual flags. For example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$ ./cpufeatures.py
                 fpu : Onboard FPU
                 vme : Virtual Mode Extensions
                  de : Debugging Extensions
                 pse : Page Size Extensions
                 tsc : Time Stamp Counter
                 msr : Model-Specific Registers
                 pae : Physical Address Extensions
                 mce : Machine Check Exception
                 cx8 : CMPXCHG8 instruction
                apic : Onboard APIC
                 sep : SYSENTER/SYSEXIT
                mtrr : Memory Type Range Registers
                 pge : Page Global Enable
                 mca : Machine Check Architecture
                cmov : CMOV instructions
                 pat : Page Attribute Table

cpufeatures.py :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/env python
import re

cpuflag_descriptions = {
   # filled during runtime, see readLinuxKernelCPUFeatures
}

def readLinuxKernelCPUFeatures():
   f = open('/usr/src/linux/arch/x86/include/asm/cpufeature.h', 'r')
   lines = f.readlines()
   f.close()
   for line in lines:
      m = re.search('#define X86_FEATURE_([A-Za-z0-9_]*).*\/\* (.*)\*\/', line)
      if m is None:
         continue
      cpuflag_descriptions[m.group(1).lower()] = m.group(2)

def readCPUInfo():
   f = open('/proc/cpuinfo')
   lines = f.readlines()
   f.close()
   return lines

def getCPUInfo():
   result = {}
   lines = readCPUInfo()
   proc = -1
   for line in lines:
      args = map(lambda arg: arg.strip(), line.split(':'))
      if len(args) != 2:
         continue
      if args[0] == 'processor':
         proc = int(args[1])
         result[proc] = {}
         continue
      if args[0] == 'flags':
         args[1] = args[1].split()
      result[proc][args[0]] = args[1]
   return result

def processCPUFlags(cpuinfo, cpu=0):
   flags = cpuinfo[0]['flags']
   for f in flags:
      if not f in cpuflag_descriptions:
         print "%20s : unkown" % (f)
      else:
         print "%20s : %s" % (f, cpuflag_descriptions[f])

def explainCPUFlags():
   cpuinfo = getCPUInfo()
   processCPUFlags(cpuinfo)

readLinuxKernelCPUFeatures()
#print cpuflag_descriptions
explainCPUFlags()
Categories: coding, hardware Tags:

munin alternative

May 28th, 2009 No comments

just started a new project called 'monitordatasink' (im kind of uncreative in such naming things...).
Jut hop over to http://code.google.com/p/monitordatasink/ and have a look yourself. happy monitoring! :)

Categories: coding, funstuff, hardware, python, server, website Tags:

clone discs over the network

April 1st, 2009 No comments

its easy if you know how:
A is the computer we want to clone, B is the target.
1) download and burn two gentoo installation CDs and boot them on both systems.
2) give the root user a password and start sshd:

1
2
passwd
/etc/init.d/sshd start

3) clone discs via dd and ssh: (execute this on A)

1
dd if=/dev/hda bs=512 | ssh root@<IP of B> "dd of=/dev/hda"

4) thats all. You can view the status of the operation via:

1
kill -SIGUSR1 `ps | grep dd | awk '{ print $1 }'`

EDIT: better solution (with compression over the network):
on B:

1
netcat -l -p 11000 | bzip2 -d | dd of=/dev/sda

on A:

1
bzip2 -c /dev/sda | netcat <IP of B> 11000
Categories: gentoo, hardware Tags:

logical volume manager & backups

January 2nd, 2008 No comments

LVM is really cool to use, but two features are lacking in my opinion:
1. a nice backup feature
2. a volume merge feature (could be combined with the backup feature)

the best backup process to date possible which i found is that: http://tldp.org/HOWTO/LVM-HOWTO/snapshots_backup.html

Thats in short:
1. create a backup logical volume:

lvcreate -L20G -s -n backup /dev/vg/webserver

(be sure that the size is more or equal the target volume size!

2. mount the backup volume:

mount /dev/vg/backup /mnt/

3. create a backup using the famous tar tool:

tar -cfvj /backup.tar.bz2 /mnt/

4. unmount the backup volume and remove it:

umount /mnt/ops/dbbackup
lvremove /dev/ops/dbbackup

not very comfortable.

EDIT: ah btw happy new year ;)

Categories: hardware, server Tags:

(hacking) the netgear router

December 8th, 2006 No comments

the newest version of the netgear DG834B router blocks the windows filesharing ports through VPN Connections. This is a small tutorial how to re-enable them:

download the official sources:

http://kbserver.netgear.com/kb_web_files/n101238.asp

(for me DG834Bv3 Version 4.01.06. )
(never ever install a version prior 4 when your device is shipped with version 4.)
just try to download the same version that is actually running on it.

tar xvfj DG834Bv3_DG834GBv3_4_01_06_src.tar.bz2
cd DG834B\(G\)V3.V4.01.06_src

# follow the README

patch -p0 < patch-apps
patch -p0 < patch-knl
su
tar jxf target.tar.bz2

# hexedit the file target/usr/sbin/rc and replace 137 with 147, 138 with 148, 139 with 149 and 445 with 455.
khexedit target/usr/sbin/rc

#go on with the README

./build.sh "DG834V3B_V4.01.06.img" target newimage.img

#upload newimage.img to your router. 
#windows directory sharing should now work over the vpn :) 
Categories: hardware Tags: