Notis

lördag 2 februari 2019

Lördagsfika i 10 år

Tiden går fort, det har redan gått 10 år sen vi hade vårat första lördags fika, vissa saker har förändrats vissa saker är lika, men vi har hållit igång traditionen med lördags fika som vi har kört första lördagen i månaden, möjligtvis formen har förändrats något, nuförtiden så har vi haft standard att börja "fikat" med en pizza innan vi kör vanligt fika, men vi har hållit kvar i att första lördagen i månaden samlas utanför City konditori kl 13:00 med en akademisk kvart för att samla oss, även om vi skulle få för oss att ta fikat någon annan stans, man kan kolla på vår e-postlista några dagar innan om man vill vara helt säker på att datumet inte blivit flyttat, men det är inte ofta vi flyttar fikat.
Det händer att vi också fikar eller tar en pizza någon annan dag också när någon känner för det, då brukar det skrivas ett meddelande på e-postlistan angående detta.

Var inte rädd att kontakta oss eller bara dyka upp första lördagen i månaden utanför City konditori, vare sig du är ung eller gammal, vad vi pratar om är ganska brett, men vi brukar generellt prata om teknik iaf, vare sig det är mekanik, programming eller hur teknik används i samhället, det händer att vi pratar om populär kultur också.

Men jag är lite stolt över att vi hållt igång dessa lördagsfika så länge med få undantag och hoppas det iaf blir minst 10 år till.

Men kom ihåg "sharing is caring", så har du något du vill dela med dig av så var inte rädd att kontakta oss, vi är alla genuint intresserade av nya saker, vare sig de är små eller stora :)

onsdag 29 maj 2013

Bad capacitor in a Dell PowerEdge 860

The title says it all, but I'd like to share the whole story if someone else stumbles over a Dell server with a bad capacitor.

This server was brought to work by my boss, it was meant to be put in our rack here and do the work it previously did at the first location.

But he told me that he tested it before he left and then it didn't start. it had been running fine 2 hours earlier and had not been shut down in a long time before that.

So I began looking at the server, when I plugged the power cable I could hear the fans started in idle mode,
power led was blinking as in idle mode. no problems so far.
I pressed the power button and I could hear the hard-drives starting up, the power led had a steady light, hard-drive led steady too and the "i" led (System status indicator) was blinking/flashing.
There was nothing else, no lights in the Diagnostic indicators, as you can see from this picture:


I took a copy of the data from the hard-drive before doing anything else.

Then I started to debug, removed the fans to CPU and a few plastic pieces and saw the bad cap right next to the CPU, suspecting that was the problem but I did some troubleshooting on a few other parts first, because I didn't want to solder on the motherboard before I had checked everything else possible to check.
* removed the Raid-controller
* removed the CD drive
* removed RAM
Not much more I could do because I didn't have a spare power supply.
Found an other blog-post about a bad capacitor in a poweredge so I guess its not that uncommon http://parkyjimbo.blogspot.se/2011/02/dell-poweredge-2950-failure.html and Dell had bad reputation about their bad caps a few years back.

Here is the motherboard with the CPU fans removed, and a red arrow pointing at the bad cap


Two close up pictures of the cap:



I solder it away but just heating the pins on the other side and pulling the cap away.
Here you can see that the bottom side of the cap has been pulled out a little too:
(my blue hands is because of the work I did on my 1957 Chrysler, painting the dashboard http://chrysler1957.blogspot.se/)

I actually had a few new 6.3V 1500µF capacitors at work, it wasn't the same shape but close enough removed the CPU heat-sink too and put in some new thermal compound.

Cleaned out all dust and old bugs with "air in a can",
put everything in place and tested and it booted just fine!


fredag 3 februari 2012

Bash script to backup data to magnetic tape

This is a bash script I wrote in 2010 and have been using ever since.
It backups data from a network storage to a magnetic tape.
I don't backup much data every time so this script will continue the backup on the same tape, I backup about 600MB and the tape I use is 72GB so I dont need to erase the tape very often.
I guess doing like this wont tear out the tape as fast as if I would write the same data to the beginning of the tape every time I'm doing a backup.

I have looked at some other scripts I found on the web, e.g. Vivek Gite's version, but it wasn't what I needed. I hope other people looking for this backup-method will find my script useful.

I run this script on debian stable and guess all the commands I use in this script is in debian stable by default.

Edit: I've put the script here: https://github.com/DomeDan/magnetic-tape-backup

onsdag 26 oktober 2011

MTR - My Traceroute

Det hela började för cirka ett år sen när jag hade lite problem med brandväggen på jobbet (pfSense), helt plötsligt bröts anslutning till internet och brandväggen förlorade alla paket från WAN.

Efter att ha pratat med supporten hos internetleverantören och jag gjort några ändringar i brandväggen så sa han att han skulle använda MTR över natten för att kolla svarstiden på ping och antal förlorade paket, han tipsade mej om att pröva programmet om jag får nätverksproblem.

Så jag kollade upp det och såg att det fanns i ubuntu/debian repository:
domedan@Pavilion0:~$ aptitude search mtr
p   mtr      - Full screen ncurses and X11 traceroute tool
p   mtr-tiny - traceroute-fullskärmsverktyg baserat på ncurses
Installerade det och prövade, det första paketet "mtr" var jag inte så nöjd över, det var ett grafiskt gränssnitt som inte funkade riktigt som det skulle vill jag minnas.
Testade sedan "mtr-tiny" och blev riktigt nöjd! Prövade det lite men hade inte så mycke riktig användning för det.

Tiden gick och jag glömde bort programmet, men så plötsligt idag så kom det till användning.
Det var till en avlägsen plats som några paket skulle skickas, men anslutningen var väldigt dålig och svarstiden (på de paket som kom fram) ca 600ms, när jag pingade några minuter så förlorades 95% av paketen.
Med traceroute kunde ja inte se så mycket, på de ställen som svarstiden drog iväg så fick jag inte samma svarstid vid ping försök.
Då kom jag att tänka på programmet som supporten tipsade om, efter lite googlade så kom ja på vad det hette.

Jag körde igång det och kunde lokalisera problemet direkt, här är en skärmdump på just vad jag såg (dock censurerad på källa och mål-adress): Som ni kan se så ser det ut som en traceroute, det speciella är att man kan se svarstiden på de olika platser paketet går genom och antal paketförluster i procent.

Bilden visar när jag har skickat nästan 100 paket, i ett tidigt skede (vid ams-core-1.pos0-1-3-0.tele2.net) så förloras 75% av paketen som kommer dit, då förstår man att nånting är galet... att det är mycke paketförluster längre ner är ju förståligt men när paketet förtfarande är inom sverige så är det lite konstigt...

Jag ringde supporten och frågade vad det var för fel, de började kika på det och tyckte också det var konstigt så de skulle kolla närmare på det och höra av sej när de löst problemet (de har inte hört av sej än).

Här är ännu en skärmdump när jag valt det andra visningsalternativet (ändras med bokstaven d): Här kan man se hur det gick för de senaste 102 (i mitt fall) paketen på alla stället det skickades till. På rad 5 kan man se ams-core-1.pos0-1-3-0.tele2.net och få en liten uppfattning om vad som händer, det verkar ju inte vara i intervaller utan snarare ganska slumpvis som paket förloras.

I första visningsläget kan man även ändra vilken information som ska visas (med bokstaven o), jag ändrade till att bara se det jag behövde för att enkelt följa med i vad som hände.


Men i vilket fall, jag skrev detta för att tipsa er om detta verktyg för jag själv tycker det är väldigt bra att ha i de få tillfällen man kan tänkas behöva det, hoppas ni tyckte det var intressant om ni orkat läsa ända ner hit.

onsdag 28 september 2011

Linksys WRT54GL with SD-card

Denna guide skrev jag hösten 2010 och nyligen ville David att jag skulle slänga upp den här, det lät som en bra ide så här är den:



A guide of how to add a SD-card to your WRT54GL router and use it as root filesystem.


Add the card

I use a A-Data 2GB sd-card (cost me 59 sek 2010-10-21) and it works good, write speed about 600kb/s.
This is how the card should be wired:
WRT54GL SD map source: http://www.adamkowalewski.com/linksys-wrt54gl/wrt54gl-sd-mod.html (404'ed last i checked: 2011-09-28)
I wont go into details about the soldering, for info about that i recommend to search around in forums and wikies in the WRT-community, if someone want to add that part to this guide your very welcome!


Configuration

I use openwrt kamikaze 8.09.2 brcm-2.4 (linux 2.4 kernel becaus of better performance with mmc sd-card driver)
http://downloads.openwrt.org/kamikaze/8.09.2/brcm-2.4/openwrt-wrt54g-squashfs.bin-file to flash with tftp or webui
http://downloads.openwrt.org/kamikaze/8.09.2/brcm-2.4/openwrt-brcm-2.4-squashfs.trx-file to flash with mtd command-line tool
more info can be found here: http://wiki.openwrt.org/toh/linksys/wrt54g

When thats done, connect to the router using the webinterface and set a new root password.
Then connect with ssh and type:
opkg update
opkg install kmod-broadcom-mmc kmod-fs-ext2 e2fsprogs fdisk
That will install the SD-card driver mmc, support for ext2 filesystem, programs to create ext2 filesystem and fdisk to manage partitions.
Next take a look with dmesg, you will probably get "error -1' and so on, then you need an other mmc driver.
I use 1.3.4 gpio2 http://programmingstuff.free.fr/files/openwrt/whiterussian/mmc/1_3_4/gpio2/mmc.o
source to info about the driver: https://forum.openwrt.org/viewtopic.php?id=9653
I got the driver source code here: mmc_1.3.4_src.tar.gz and a the compiled one here: mmc.o.tar.gz if the programmingstuff.free.fr site goes down
rmmod mmc
wget http://programmingstuff.free.fr/files/openwrt/whiterussian/mmc/1_3_4/gpio2/mmc.o -P /lib/modules/2.4.35.4/
echo 0x9c > /proc/diag/gpiomask
insmod mmc
and then check with dmesg, if should be something like:
[INFO] mmc_card_init: card inited successfully in 21 tries (647733 CPU cycles).
[INFO] mmc_init: MMC/SD Card ID:
03 53 44 53 44 30 32 47 80 03 fa 94 b9 00 a2 ad [INFO] Manufacturer ID   : 03
[INFO] OEM/Application ID: SD
[INFO] Product name      : SD02G
[INFO] Product revision  : 8.0
[INFO] Product SN        : 03fa94b9
[INFO] Product Date      : 2010-2
[INFO] mmc_card_config: size = 1931264, hardsectsize = 1024, sectors = 1931264
[WARN] mmc_init: hd_sizes=1931264, hd[0].nr_sects=3862528
[INFO] mmc_card_init: set_blocklen (CMD16) succeeded !
Partition check:
mmca: p1
If it's somehing like "mmc_init got error calling mmc_card_init" then it probably short circuit or bad contact with the SD-card


Use the card as root filesystem

I have tested a lot of guides and failed on them till i found this old wiki: http://oldwiki.openwrt.org/OpenWrtDocs(2f)KamikazeConfiguration(2f)BootFromExternalMediaHowTo.html (does not exist last i checked: 2011-09-28)
But i needed to do some changes and ugly hack to make it work
First, if you haven't created a ext2-partition on your SD-card you should now, I don't recommend doing it on the router, I failed when doing it but I think it was because i forgot to write 0x9c to /proc/diag/gpiomask
Use fdisk to create a partition if you don't got one already, then create the filesystem, this is how to do it:
fdisk /dev/mmc/disc0/disc
mkfs.ext2 /dev/mmc/disc0/part1
mount /dev/mmc/disc0/part1 /mnt # mounting it to check if it works
Recursive copy the root to the SD-card:
mkdir /tmp/orig mount -o bind / /tmp/orig   # this is necessary to prevent duplicating /proc /dev and so forth
tar -c -C /tmp/orig -f - . | tar -xv -C /mnt -f -
umount /tmp/orig
rmdir /tmp/orig
rm -r /mnt/etc/*   # we don't need a duplicate /etc tree
umount /mnt
and here the /etc/init.d/bootext script, copy and paste or wget it ./bootext
#!/bin/sh /etc/rc.common

START=11
STOP=91

echo 0x9c > /proc/diag/gpiomask
insmod mmc

bootext_cleanup() { # [cleanup_level]
[ "$1" -ge 3 ] && grep -q '^[^ ]* /rom ' /proc/mounts && mount -o move /rom $putold/rom
[ "$1" -ge 2 ] && { . $putold/bin/firstboot ; pivot $putold $target ; }
[ "$1" -ge 1 ] && umount -l $target/etc
return 0
}

bootext_fail() { #  [cleanup_level]
echo "$1" >&2
[ ! "$2" ] || bootext_cleanup $2
exit 1
}

bootext_quit() { # 

echo "$1" >&2
exit 0
}

bootext_start() {
! grep -q "^$device / " /proc/mounts || bootext_quit "$name already on /"

if ! grep -q "^$device $target " /proc/mounts
then
 ! grep -q "^$device " /proc/mounts || bootext_fail "$name already mounted"

 for module in $modules
 do
  if ! grep -q "^$module " /proc/modules
  then
   [ $module != mmc ] || [ ! "$gpiomask" ] || echo "$gpiomask" > /proc/diag/gpiomask || bootext_fail "could not set gpiomask"
   insmod $module || bootext_fail "could not insert $module module"
  fi
 done

 while [ ! -b $device ]
 do
  [ "$waitdev" -gt 0 ] || bootext_fail "$device does not exist"
  waitdev=$(( $waitdev - 1 ))
  sleep 1
 done

 [ -d $target ] || mkdir $target || bootext_fail "could not create mountpoint $target"
 mount ${filesys:+-t $filesys} ${mountopt:+-o $mountopt} $device $target || bootext_fail "could not mount $name on $target"
fi

[ -d $target$putold ] || mkdir $target$putold || bootext_fail "could not create mountpoint $putold"
[ -d $target/etc ] || mkdir $target/etc || bootext_fail "could not create mountpoint /etc"
mount -o bind /etc $target/etc || bootext_fail "could not bind mount /etc"

. /bin/firstboot
pivot $target $putold || bootext_fail "could not pivot to $target" 1

! grep -q "^[^ ]* $putold/rom " /proc/mounts || { [ -d /rom ] || mkdir /rom && mount -o move $putold/rom /rom ; }

return 0
}

bootext_stop() {
grep -q "^$device / " /proc/mounts || bootext_quit "$name not on /"

bootext_cleanup 999
}

bootext_config() { # 
local section=$1 local action=$2 local enabled device name target putold modules gpiomask waitdev filesys mountopt config_get_bool enabled $section enabled 1 [ "$enabled" -gt 0 ] || return 0 config_get device $section device [ "$device" ] || bootext_fail "external boot device not configured" config_get name $section name config_get target $section target config_get putold $section putold config_get modules $section modules config_get gpiomask $section gpiomask config_get waitdev $section waitdev config_get filesys $section filesys config_get mountopt $section mountopt [ "$name" ] || name="$device" [ "$putold" ] || putold="${target:-/old}" [ "$target" ] || target="/${filesys:-new}" bootext_$action } start() { config_load bootfromexternalmedia config_foreach bootext_config bootfromexternalmedia start } stop() { config_load bootfromexternalmedia config_foreach bootext_config bootfromexternalmedia stop }
The only difference is that i added: echo 0x9c > /proc/diag/gpiomask insmod mmc and dont forget to chmod a+x /etc/init.d/bootext

and the /etc/config/bootfromexternalmedia ./bootfromexternalmedia
config bootfromexternalmedia
       option enabled  '1'
       option device   '/dev/mmc/disc0/part1'
       option name     'mmc'
       option target   '/mnt'
       option putold   '/mnt'
       option modules  'mmc ext2'
       option gpiomask '0x9c'
       option waitdev  '0'
       option filesys  'ext2'
       option mountopt 'noatime'
Don't need jbd (its the module for journaling) as in the original
Testing:
/etc/init.d/bootext stop    # should report that device is not on /
/etc/init.d/bootext start   # should perform the switch without producing any output

df -h          # chould get somehting like:
Filesystem                Size      Used Available Use% Mounted on
rootfs                    1.8G     29.8M      1.7G   2% /
/dev/root                 1.6M      1.6M         0 100% /rom
tmpfs                     7.0M    732.0k      6.3M  10% /tmp
/dev/mtdblock/4           1.7M    420.0k      1.3M  24% /jffs
mini_fo:/jffs             1.6M      1.6M         0 100% /mnt
/dev/mmc/disc0/part1      1.8G     29.8M      1.7G   2% /
mini_fo:/jffs             1.6M      1.6M         0 100% /etc
Enable it at boot:
/etc/init.d/bootext enable

To be able to use the space on the SD-card for applications, comment out this line:
option overlay_root /jffs
in /etc/opkg.conf


Webserver

To be able to use php i followed this guide: http://www.rabinovich.org/ymheebcex/
in short:
opkg update
opkg install lighttpd lighttpd-mod-simple-vhost lighttpd-mod-status lighttpd-mod-cgi
mkdir /www0


# in /etc/lighttpd.conf:
# ----------------
"mod_status",
"mod_simple_vhost",
"mod_cgi"

simple-vhost.server-root = "/www0/"
simple-vhost.default-host = "www.0.com"
simple-vhost.document-root = "/"

cgi.assign = ( ".php" => "/usr/bin/php" )

server.indexfiles = ( "index.html", "index.htm", "index.php")

#### status module
status.status-url = "/status"
status.config-url = "/config"
# ----------------
# "Status" gives you the pages you can see in http://your_router_ip/status and http://your_router_ip/config once we get as far as to get the server stated.




opkg install php4 php4-cgi php4-mod-gd

# change a few things in /etc/php.ini:
# ------------------
doc_root = /www0
extension_dir = "/usr/lib/php"
# ------------------


#try it out:

echo "" > /opt/www/phpinfo.php
/etc/init.d/lighttpd start
Update time:
echo "CET-1CEST,M3.5.0,M10.5.0/3" > /etc/TZ #-1 is Europe/Stockholm
opkg install ntpclient
ntpclient -h 0.se.pool.ntp.org -s
Now you got a webserver that runs on 14W, at least mine does :)

All sources:
Much info about wrt54g/gl/gs: http://wiki.openwrt.org/toh/linksys/wrt54g
Pictues and info about SD-card mod: http://www.adamkowalewski.com/linksys-wrt54gl/wrt54gl-sd-mod.html (404'ed last i checked: 2011-09-28)
Forum thread about SD-card driver: https://forum.openwrt.org/viewtopic.php?id=9653
Howto root in external drive: http://oldwiki.openwrt.org/OpenWrtDocs(2f)KamikazeConfiguration(2f)BootFromExternalMediaHowTo.html (does not exist last i checked: 2011-09-28)
Use php on Openwrt: http://www.rabinovich.org/ymheebcex/

Created: 2011-01-05
Updated: 2011-09-28 (changed links and stuff)
Feel free to use, distribute and modify this documentation /DomeDan

måndag 19 september 2011

Htop - en interaktiv processövervakare

Htop är en aktivitetshanterare skriven för Linux (men funkar också på FreeBSD genom att emulera Linux procfs).

Vad är fördelen med htop jämfört med top, htop startar snabbare, du kan skrolla i listan av processer och ändra sorteringsalternativ snabbt och enkelt, du kan snabbt döda processer direkt i htop eller ändra processprioritet(nice), stöd för mus och färg.

Så här skriver du för att installera htop i ubuntu/debian.
sudo apt-get install htop
Längst ner på bilden så ser man de kommandon man kan utföra antingen genom Fx-tangenterna eller så kan du klicka med musen för att aktiver dem.
Du kan navigera htop med piltangenterna, PgUP, PgDn, Home, End, och markera processer med mellanslag för att göra någon åtgärd (ex. kill, nice), sedan avmarkera alla genom att trycka 'U'(shift+u), man kan också visa processer endast från en användare genom att trycka 'u' och välja i en lista.

För att ta del av alla kommandon så kan du skriva
man htop
Htop är praktiskt om man inte har ett fungerande X installerat, men jag brukar köra htop även om X funkar :)

Länkar:
Htop officiella hemsida: http://htop.sourceforge.net
Wikipedia artikel: http://en.wikipedia.org/wiki/Htop

söndag 11 september 2011

Kompilera senaste wine

Ska gå igenom hur jag kompilerade wine och installerar det på ett alternativt ställen och hur jag kör wine med alternativa inställningar.

Först så såg jag till att jag hade kompilerings verktygen installerade
sudo apt-get install build-essential automake checkinstall git-core

Sen så installerade jag alla dependecies, i Ubuntu så gör man det lättast genom att skriva följade i kommado promten:
sudo apt-get build-dep wine1.3

Sen så laddade jag ner senaste wine med git
git clone git://source.winehq.org/git/wine.git ./wine-git

Sedan så är det dags för ställa in wine så det installeras i /opt/wine/
cd wine-git
./configure --prefix=/opt/wine

Sen så var det dags för själva kompileringen (det här kommer ta ett tag)
make depend && make

Och när det var färdigt så installerade jag wine
sudo make install

Sådär nu var wine installerat i /opt/wine

då var det dags för att testa det med alternativa inställningar
env WINEPREFIX="/home/user/.wine_opt" /opt/wine/bin/wine eve.exe

Vad betyder raden ovan då?
jo det första env WINEPREFIX="/home/user/.wine_opt" ställer in wine att läsa och spara alla inställningar i "/home/user/.wine_opt" vilket man kan ändra till vart man nu vill ha de alternativa inställningarna.

Och "/opt/wine/bin/wine" är ju sökvägen till den alternativa wine som sen kör windows programmet "eve.exe"

Men som sagt det är inte alltid den senaste versionen fungerar felfritt, då får man backa tillbaka tills man hittar en version som fungerar, som i mitt fall ovan så visade det sig att det inte fungerade med eve så jag fick backa till den senaste stabila versionen.

Ifall kompileringen misslyckas av någon skum anledning kan ni testa att köra
make clean && make distclean
Som tar bort alla inställningar/temporära filer/binärer, och sen så får du börja om vid configure, så ska det förhoppningsvis fungera denna gången.

En del av det är kan användas när man kompilerar andra saker men inte vill installera på det vanliga ställena :)