Sign Håvard Rast Blok

Blog

Undelete files on FAT with Linux

  • May. 9th, 2009 at 7:48 PM
It happens to everybody: You make a small mistake, and there go all your holiday pictures. Luckily, all memory cards and cameras share a few features: JPG files on FAT/FAT32. This makes it especially easy to recover deleted files using standard tools on Linux.

Key points to remember:
  • Once the disaster is a reality, keep the card away from both computer and camera.
  • Do not work with card directly, but instead make an image copy. See below.
  • If you don't have it already, install the forensic tool foremost.
    yum install foremost
  • Before you start, make sure the card is not mounted.

The commands:

umount /media/disk
dd if=//dev/sdb1 of=/tmp/card.img bs=4096 conv=sync,notrunc
mkdir /tmp/recover
foremost -v -t jpg -i /tmp/card.img -o /tmp/recover

Candid in London: "Where are you?"

  • Apr. 6th, 2009 at 9:44 PM
Towards the end of March 2009 I strolled the streets of London, shooting random people and random faces. After a few dozen shoots, I realiased the theme of the day: mobile phones. They would stand or walk, mostly unaware of their surroundings, absorbed in the most important topic of all: "Where are you?"


See the rest of the pictures here.

Mounting OBEX over Bluetooth on Linux

  • Mar. 21st, 2009 at 9:18 PM
Mounting the memory card on your mobile phone over Bluetooth is now really smooth under Fedora. Thanks to topyli's post and David's HOWTO, all you need is the one-liner below. Once you've paired the devices, and have installed obexfs, and fuse-utils, run this, and your read to copy files:


NAME="MY PHONE NAME"; MAC=`hcitool scan | \
grep $NAME | tr '\t' ' ' | cut -f 2 -d ' '`; \
CHANNEL=`sdptool search --bdaddr $MAC FTP | \
grep "Channel" | tr -s ' ' | cut -f 3 -d ' '`; \
obexfs -b$MAC -B$CHANNEL /mnt/phone


To unmount:
fusermount -u /mnt/phone

Multi IM client for Symbian

  • Jan. 16th, 2009 at 11:46 AM
With Android out of the door, IM chat over IP on the mobile will soon be a staple. Paying for SMS text messaging will soon be a thing of the past. However, what about all those other devices which hasn't caught up yet? fring saves the day!

Fring supports text chat for Skype, MSN, Google Talk, ICQ, SIP, Twitter, Yahoo! and AIM. Furthermore, it supports Skype and SIP voice over IP, which should be a welcome service. Finally, it can connect to Facebook, Gmail Notifier, Vtap Video Streaming, Orkut Social Network, Yandex Push Email, and more.

From your phone, you can download fring by pointing it to m.fring.com. On my N80, two applications were installed, and fring started up automatically. You'll have to sign up for an account, and then add the IM networks you already use. Your friends will automatically appear in a searchable list.

Modifying SELinux port for SSHD

  • Jan. 5th, 2009 at 1:59 PM
Recently I wanted to change the port for the SSH daemon (running on a Fedora 10 install), however, SELinux got in the way. After looking at these posts, I found that the following would allow me to run sshd on port 222.

semanage port -m -t ssh_port_t -p tcp 222

On my rather slow server, it took about three minutes to update. To confirm that the change was made, I ran the following command:

semanage port -l | grep ssh

Fedora 10

  • Nov. 30th, 2008 at 10:38 PM
Fedora 10 was released this week, and you can get your copy here. True to form, I post my notes of what I usually have to do to after a fresh install.

First of all, have a look at
"Personal Fedora 10 Installation Guide" by Mauriat Miranda
(http://www.mjmwired.net/resources/mjm-fedora-f10.html)


Here's my quick summary, tailored to my needs:


yum -y update

rpm -ivh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm
rpm -ivh http://linuxdownload.adobe.com/adobe-release/adobe-release-i386-1.0-1.noarch.rpm
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-rpmfusion-*

yum -y install AdobeReader_enu ant OpenEXR OpenEXR_Viewers amarok arj autopano-sift-C azureus bash-completion bittorrent-gui colordiff digikam dosbox dvdauthor dvgrab easytag emacs enblend flash-plugin gimp glipper gnome-mplayer gnome-volume-manager gnucash gqview gstreamer-ffmpeg gstreamer-plugins-ugly gtkpod htop hugin k3b-extras-freeworld kdegraphics kdiff3 kino kover kqemu lame-mp3x libcddb libdvdcss liberation-fonts mencoder mjpegtools mozplugger mp3gain ncftp obexfs java-1.6.0-openjdk java-1.6.0-openjdk-javadoc java-1.6.0-openjdk-plugin java-1.6.0-openjdk-src openoffice.org-calc openoffice.org-writer pidgin-otr python-psyco qemu-launcher qtpfsgui rdesktop samba subversion thunderbird thunderbird-lightning transcode ufraw ufraw-gimp unrar vcdimager vdr-mp3 vlc w3m wine wireshark-gnome xine xine-lib-extras xine-lib-extras-freeworld xmms xmms-faad2 xmms-mp3 xmms-pulse

wget -O /tmp/skype_fc.rpm http://www.skype.com/go/getskype-linux-fc7
yum --nogpgcheck localinstall /tmp/skype_fc.rpm

wget -O /tmp/libdvdcss.rpm http://livna-dl.reloumirrors.net/fedora/9/i386/libdvdcss-1.2.9-5.lvn9.i386.rpm
OR
wget -O /tmp/libdvdcss.rpm ftp://ftp.pbone.net/mirror/rpm.livna.org/fedora/archive/9/x86_64/libdvdcss-1.2.9-5.lvn9.x86_64.rpm
yum --nogpgcheck localinstall /tmp/libdvdcss.rpm

wget -O /tmp/all-20071007.tar.bz2 http://www.mplayerhq.hu/MPlayer/releases/codecs/all-20071007.tar.bz2
mkdir -p /usr/lib/codecs
tar -jxvf /tmp/all-20071007.tar.bz2 --strip-components 1 -C /usr/lib/codecs/

Finally, if SELinux is enabled, you might have to run:
chcon -t textrel_shlib_t '/usr/lib/sse2/libpostproc.so.51.2.0'
chcon -t textrel_shlib_t '/usr/lib/sse2/libswscale.so.0.6.1'


This should take care of most media players, flash and pdf plugins, Skype, and iPod support through gtkpod, and other useful programs.

dd, mount, loop and other device image tricks

  • Sep. 14th, 2008 at 11:06 AM
Lately I have been looking into virtualization, and all the fun stuff which comes with that. Here is a collection of links related to virtual devices; how to copy block devices, partition, format, mount, etc.

Creating and using disk images mini-howto

DD Tutorial

Learn The DD Command

Running Microsoft Windows inside Debian: qemu

Copying Windows to a new drive, using linux - How-to/Guide


The most interesting tutorial, was the second, which creates a virtual block device, which later can be used with Qemu. Here's a quick summary:
dd if=/dev/zero of=win_e.img bs=1024 count=1000000
losetup /dev/loop0 win_e.img
fdisk -ul /dev/loop0  # Create a W95 FAT32 partition
losetup -o 32256 /dev/loop1 /dev/loop0
mkfs.vfat -v /dev/loop1
mount -o uid=myuser,gid=myuser /dev/loop1 tmp
I just installed a new and bigger harddisk in my mum's laptop, and wanted to preserve the dual boot setup, with Windows XP and Fedora. Actually, it was enough to keep the Windows partition, since the Fedora was lagging behind a few updates.

Using a generic, but extremely useful IDE-to-USB adapter, I could copy the full Windows partition over to the new drive, without having to reinstall or change anything. Credit goes to Ed Anderson for putting together this guide to help with that task. To summarise the gist of it:

The internal drive was on /dev/hda, while the new and temporarily external was /dev/sda.

  1. The first step was to examine hda, and record the old partition details, system ID, and START and END in sectors:
    fdisk -l -u /dev/hda

  2. Then run fdisk on the new disk, also working in sectors:
    fdisk /dev/sda

    u (for sectors)
    n, p, 1, START, END (new partition, with same START and END sectors)
    a, 1 (set boot flag)
    t, ID (set same ID as old partition)
    w (write and quit)

  3. Now we're ready to copy the data. First the Master Boot Record (MBR), and then the Windows partition:

    dd if=/dev/hda of=/dev/sda bs=446 count=1
    dd if=/dev/hda1 of=/dev/sda1 bs=4096


  4. Then insert the new drive at the location it should live in.

  5. Install Fedora using your favourite method, making sure you create a grub boot loader which has the Windows partition as an option.

Jul. 28th, 2008

  • 11:00 AM
Here's a repeat of a previous entry on Fedora installation, this time for version 9:

"Personal Fedora 9 Installation Guide" by Mauriat Miranda
(http://www.mjmwired.net/resources/mjm-fedora-f9.html)


For the quick version:

yum -y update

rpm -ivh http://rpm.livna.org/livna-release-9.rpm
rpm -ivh http://linuxdownload.adobe.com/adobe-release/adobe-release-i386-1.0-1.noarch.rpm

yum -y install thunderbird gqview glipper gstreamer-plugins-ugly vcdimager dvdauthor mjpegtools mencoder gnome-mplayer mplayer-fonts kino xine libdvdcss amarok xmms-mp3 kdemultimedia-extras k3b-extras-nonfree kover libcddb azureus bittorrent-gui mozplugger gtkpod hugin digikam enblend easytag pidgin-otr bash-completion obexfs flash-plugin AdobeReader_enu amarok-extras-nonfree vlc gnome-volume-manager qt4-x11 emacs kdiff3 kdegraphics gnucash

wget http://www.skype.com/go/getskype-linux-beta-fc7
rpm -ivh /tmp/skype-2.0.0.43-fc5.i586.rpm

wget -O /tmp/all-20071007.tar.bz2 http://www.mplayerhq.hu/MPlayer/releases/codecs/all-20071007.tar.bz2
mkdir -p /usr/lib/codecs
tar -jxvf /tmp/all-20071007.tar.bz2 --strip-components 1 -C /usr/lib/codecs/


This should take care of most media players, flash and pdf plugins, Skype, and iPod support through gtkpod, and other useful programs.

Windows infected in five minutes

  • Jul. 15th, 2008 at 11:15 PM
Slashdot is reporting on a study from SANS Institute's Internet Storm Center which shows that an unpatched Windows XP box will be infected after about five minutes on the Internet. German researchers found that it took slightly longer, however the conclusion still holds:

"While the survival time varies quite a bit across methods used, pretty much all agree that placing an unpatched Windows computer directly onto the Internet in the hope that it downloads the patches faster than it gets exploited are odds that you wouldn't bet on in Vegas."

Flight photos over Sarpsborg

  • Jul. 10th, 2008 at 8:27 PM
During my last trip to Norway, I used the new Moss/Rygge airport and flew via Copenhagen. During both flights we crossed right over Sarpsborg, Fredrikstad and Sandbakken, and I also had a beautiful view of Svinesund and Koster. I've updated the picture section we some flight photos:

http://hblok.net/pictures/public/misc/flights


The Max Planck Institute for Software Systems brings you a test to see if your ISP is throttling BitTorrent traffic from your computer. At the end of the tests, it also gives some nice statistics on your upload and download speeds.

http://broadband.mpi-sws.mpg.de/transparency/bttest.php

Encryption

  • Jun. 19th, 2008 at 10:37 PM
In the wake of the recent internet traffic monitoring law passed in Sweden, it is highly overdue to get serious about encryption. First off, e-mail encryption, focusing on PGP/GPG. Below are a some useful links:

Enigmail: PGP/GPG extension for Mozilla Thunderbird.

FireGPG: GPG extension for Mozilla Firefox. Brings e-mail encryption to Gmail, and any other website with GPG content.

GpgOL is a plugin for Microsoft Outlook 2003, by the maintainers of GnuPG.

GPGoe is a GPG plug-in for the Microsoft Outlook Express.


For even more links about PGP/GPG and related tools, see Folkert van Heusden's collection of information.

WINE, DOSBox, Doom and Hero's Quest

  • Jun. 17th, 2008 at 10:55 PM
WINE version 1.0 was announced today, and this got me thinking maybe I could run some of the old games I used to play some 15 years ago. Well, at that time, Windows wasn't needed at all, so I turned to another great project: DOSBox, an excellent MS-DOS emulator, focusing primarily on games.

So I had to dig out some old games then. Doom seemed like a natural first choice, and after a bit of shifting through various groups, it ran fine. In fact, below you can see a screenshot of Doom, Doom II and Hero's Quest all running at the same time under Fedora 9.





Installation


yum install dosbox

Today, this gave me dosbox.i386 0.72-4.fc9.

Configuration


* Start up by simply typing: dosbox
* In the DOS-terminal, type: CONFIG -writeconf dosbox.conf
* Exit the terminal by typing "exit"
* You will now find the file dosbox.conf in your current directory.
* Move and rename this file: mv dosbox.conf ~/.dosboxrc
* Next time you start DOSBox, it should say: "CONFIG:Loading primary settings from config file /home/username/.dosboxrc"

Sound


On the initial start up, DOSBox gave the following error messages, which many people have reported:

MIXER:Can't open audio: No available audio device , running in nosound mode.
ALSA:Can't subscribe to MIDI port (65:0) nor (17:0)


To start with the last issue, the MIDI port. This was easily fixed by updating the midi-section in the .doxboxrc config file created above. Theses settings works for my onboard "VIA Technologies, Inc. VT8233/A/8235/8237 AC97 Audio Controller"

[midi]
mpu401=intelligent
device=alsa
config=128:0


The second issue required the PulseAudio server to be started. Simply typing pulseaudio will take care of that. You can verify that it is working correctly by runnging paplay /usr/share/sounds/generic.wav, and you should hear a small sound.

After this DOSBox reported no more errors, and would play both MIDI and sound effects. For some games, you need to "install.exe"/"setup.exe" to set the sound properties. Make sure the IRQ, DMA and port settings match the settings in your .dosboxrc. (Had you also almost forgotten your favourite IRQ/DMA setting? :D )

Heli Invasion 2 - addictive Flash game

  • Jun. 13th, 2008 at 2:52 PM
Try out this super cool Flash game:
http://www.spudmud.com/games/23-Heli-Invasion-2/

Also, make sure you download Firefox 3, so you can increase the Flash app by pressing CTRL++
http://www.mozilla.com/firefox/

Automatic Login on Fedora 9

  • Jun. 8th, 2008 at 9:59 PM
After updating to Fedora 9 today, Autologin was disabled. It seems it has been deliberately taken out. The current fix for Gnome is as follows:

Edit /etc/gdm/custom.conf
[daemon]
# http://live.gnome.org/GDM/2.22/Configuration
TimedLoginEnable=true
TimedLogin=yourusername
TimedLoginDelay=0


You might want to set the delay to a few seconds. More information here:
http://dnmouse.webs.com/autologin.html
Stefan Grothkopp has put out a very slick, and fun, command line interface to Google, running in your browser. http://goosh.org

Things to try:
> w street parade
...
> 1

> p zurich

Along the same lines, Surfraw and the likes of Links, Lynx, and w3m will do about the same, in your console.
$ sudo apt-get install surfraw w3m
...
$ sr google test

(Note: the Debian/Ubuntu packages work fine, however Fedora's repositories hold an older, broken version of Surfraw.)

Fedora 9 relesed

  • May. 13th, 2008 at 7:09 PM
Fedora 9 has been released. Get your copy here! Release notes can be found here. From Slashdot:

"Some of the more interesting new features include a new package management system, which can be used as an alternative to yum, known as PackageKit. This release also includes GNOME 2.22 and/or KDE 4.0.3, and Firefox 3 beta 5. Overall, there are a lot of improvements worth looking at, and the Bittorrent seeds are already feeding the release fairly effectively."



Fuel crisis...

  • Apr. 28th, 2008 at 10:27 PM
...or just a price peek?

Here are some of today's headlines from The Guardian, as the crude oil price almost hits $120/barrel:

Cost of fuelling aircraft has soared
Gas flow to Britain slows despite high prices
Opec warns of $200 oil as price hits new high