Fixing Grub in Debian Rescue Mode

December 15th, 2009

Today Grub experienced a hiccup which left me with crippled Grub rescue mode complaining about “symbol ‘grub_printf_’ not found“. Searching Google gave me just one hit — an German forum page from yesterday bearing no solution yet.

After trying many known things I eventually created a satisfiable solution — bootable system. Not knowing how to fix Grub I decided to downgrade Grub 2 to Grub 1 and the only way to do this is using rescue mode on Debian install disc. The procedure goes as follows:

  • Boot from Debian install disc for architecture you use (i.e. amd64). In the boot menu choose help option as it offers you the option to use the “old-style” command line boot options. The default rescue-mode shell lacks some variables needed for installing/removing packages form the system, so it is useful to start rescue-mode with the following boot option (it enables the user input needed during some instal/remove processes): rescue debian-installer/framebuffer=false
    It is also possible to do this later by running TERM=vt100; export TERM in command-line.
  • Follow the procedure that looks pretty much as installation procedure, but after certain point it offers you the option to choose the partition to use as a root system. At this point it is good if you know which one is it. Next menu lets you enter the command line in which you can alter your system.
  • Using apt-get I first removed the Grub 2 installation (just in case leaving behind configuration files) and then installed the grub-legacy package. After some configuring
    #grub
    grub> find /boot/grub/stage1
    (hd0,1)
    (hd1,0)
    grub>root (hd1,0)
    grub>setup (hd1)
    grub>quit

    and

    #update-grub

    the new “good-old” Grub 1 installation was ready for reboot.

Java plugin on 64 bit Debian

April 3rd, 2009

Well, finaly I did it. After installing everything I could imagine it might help and trying out all possible solutions I have Java plugin finally working in Iceweasel.

The solution was found on Java bug #4802695 first reported on 14-JAN-2003. The helpful comment #514 made by cava on 14-DEC-2008 said:

It works finally !!! Just need to link java-6-sun-1.6.0.12/jre/lib/amd64/libnpjp2.so in the Firefox plugins directory and we have it !!!!!!!!!!!!!!!!!!!

The command needed was:
ln -s /usr/lib/jvm/java-6-sun-1.6.0.12/jre/lib/amd64/libnpjp2.so ~/.mozilla/plugins/libjavaplugin.so

Flash player for 64 bit Debian

March 23rd, 2009

Quoting Frederik Kriewitz’s reply on debian-user mailing list:

Download the 64 Bit plugin from
http://labs.adobe.com/downloads/flashplayer10.html
extract it and copy and copy libflashplayer.so to /usr/lib/iceweasel/plugins/

Update (11/25/2009):
The new link to 64-bit version is:
http://labs.adobe.com/technologies/flashplayer10/64bit.html

Synchronizing Google Calendar on Linux

November 5th, 2008

I’ve first done it after reading an Linux.com article and at that time the sync was just one way street – from Google to KDE. As I needed two-way sync I didn’t use it much till today when I remembered to try out the things once more and after a little bit of setup I found it working on KDE’s KOrganizer and Thunderbird’s extension Lightning

The basic setup layout is presented on Terminally Incoherent blog and extended with links to file-based and HTTP-based installaton on GCALDaemon’s web page.

UPDATE (24.12.2008)

As Google’s tools are constantly evolving, now there is another option available. To sync Google Calendar with your Thunderbird/Icedove with Lightning extension you can now use CalDAV. The setup is very simple and it also works with Google Apps.

Reblog this post [with Zemanta]

Port scanning with nmap

October 23rd, 2008

Nmap is an useful tool for checking the security of a server. Since I don’t use it very often I’ve made a list of useful resources to check when in need.

The first advice, also praised by nmap authors, I got from Trinity from The Matrix Reloaded film.

nmap -v -sS -O 10.2.2.2

-v – verbose output (try -vv for even more verbose)
-sS – “the default and most popular scan option for good reasons”*
-O – OS discovery

Since my server is behind (hope) a good firewall I had to add -P0 option.

nmap portscanner howto

Describing the basic nmap scans

Nmap – Free Security Scanner For Network Exploration & Security Audits

Nmap official page

Nmap reference guide

Nmap manual

Insecure.Org – Nmap Free Security Scanner, Tools & Hacking resources

News and links

Google Earth on 64-bit Debian GNU/Linux

August 12th, 2008
Image representing Google Earth as depicted in...Image via CrunchBase, source unknown

Today I finally decided that it’s about time to try to install Google Earth on my new computer, running an 64-bit version of Debian Testing. I’ve said before and I’ll say it again: “I love Debian!”

First I’ve done a Google search and found solution at SysAdmin’s Diary. Just for my own information I’ll list the steps here, for details take a look at SysAdmin’s Diary blog.

As simple as:

1. Install the googleearth-package

2. Run make-googleearth-package to build the googleearth Debian package

3. See the googleearth_4.3.7284.3916+0.5.4-1_amd64.deb !!! Now, install it.

4. Run googleearth, voila!

If Google Earth complains about error 29 you should also install the lib32nss-mdns package. It might also help to delete the ~/.googleearth folder.

Reblog this post

BackTrack Security Audit LiveCD

June 24th, 2008
Backtrack 2.0 screenshot

Image via Wikipedia

I’ve came across BackTrack today on linux.com RSS feed. I’ll give it a try this summer when I plan to thouroughly test my servers security.

I’ll report on my findings.

Zemanta Pixie

Internet Explorer on Debian Etch

March 18th, 2008

Source: WikipediaI’ve already wrote about installing IE on Debian, but since then things changed a bit and today I finally succeeded to make it run on my Etch box. While the first time round I installed IE due to web-design issues, this time it was IE-only pages that forced me to search for the solution.

The first and most important step is to fetch the latest-greatest Wine version. The whole process is explained at Wine home page so I’ll mention just the necessary commands:

wget -q http://wine.budgetdedicated.com/apt/387EE263.gpg -O- | sudo apt-key add -

and

sudo wget http://wine.budgetdedicated.com/apt/soces.list.d/etch.list -O /etc/apt/sources.list.d/winehq.list

Now we can start following the installation procedure described at IEs4Linux web page. Since the procedure mentioned there is for Sarge, I’ll copy the necessary commands below:

apt-get update
apt-get install wine libxxf86dga1 libxxf86vm1 cabextract

and

wget http://www.tatanka.com.br/ies4linux/downloads/ies4linux-latest.tar.gz
tar zxvf ies4linux-latest.tar.gz
cd ies4linux-*
./ies4linux

While this should usually work, I encountered a problem – missing mfc42.cab file. Googling around I found it here and downloaded it into ~/.ies4linux/downloads/ie6/EN-US/ folder.

cd ~/.ies4linux/downloads/ie6/EN-US/
wget http://activex.microsoft.com/controls/vc/mfc42.cab

And after that the install script worked without flaws.

Installing Alternative PHP Cache (APC) on Debian Etch

January 9th, 2008

Obtaining and installing APC

Alternative PHP Cache (APC) is a free, open, and robust framework for caching and optimizing PHP intermediate code. It’s an PECL extension which shares the packaging and distribution system with its sister, PEAR.

Provided that you have PEAR (php-pear) package installed on your system, the procedure is as simple as pecl install apc. Alternatives.

meglohvat:# pecl install apc
downloading APC-3.0.16.tgz ...
Starting to download APC-3.0.16.tgz (114,298 bytes)
.............done: 114,298 bytes
45 source files, building
running: phpize
Configuring for:
PHP Api Version:         20041225
Zend Module Api No:      20060613
Zend Extension Api No:   220060519
Use apxs to set compile flags (if using APC with Apache)? [yes] :

As probably corectly guessed by PECL package managers, you are runing an Apache web server so you should confirm by typing yes or hitting Enter key.

Errors which you may (I did) encounter

checking for re2c... no
configure: WARNING: You will need re2c 0.9.11 or later if you want to \
regenerate PHP parsers.

The re2c package was missing on my system ›› apt-get install re2c.

checking for gawk... no
checking for nawk... nawk
checking if nawk is broken... no

I had no gawk or nawk but mawk pattern scanning and processing language installed on system ›› apt-get install gawk.

checking whether apc needs to get compiler flags from apxs...

Sorry, I was not able to successfully run APXS.  Possible reasons:

1.  Perl is not installed;
2.  Apache was not compiled with DSO support (--enable-module=so);
3.  'apxs' is not in your path.  Try to use --with-apxs=/path/to/apxs
The output of apxs follows
/tmp/tmpJQuZdD/APC-3.0.16/configure: line 3846: apxs: command not found
configure: error: Aborting
ERROR: `/tmp/tmpJQuZdD/APC-3.0.16/configure --with-apxs' failed

Missing APache eXtenSion (APXS) tool for building and installing extension modules for the Apache HyperText Transfer Protocol (HTTP) server. APXS is found in apache2-threaded-dev package. The command apt-get install apache2-threaded-dev will also install a long chain of dependencies.

Setting up APC

A good place to start is Alternative PHP Cache chapter in PHP manual. There it’s written that the default configuration is sutable for most instalations, but they single out two settings: apc.shm_size and apc.stat.

apc.shm_size
Here you should enter the size of each shared memory segment in MB, the default value being 30MB. By default, the maximum size of shared memory segment in Debian is 33554432 or 33MB. You can check it by cat /proc/sys/kernel/shmmax command. If you want to know more about shared memory segments, read this forum thread.
UPDATE: “Of course you can always raise the maximum size of a shared memory segment, using sysctl. Do this only when you know what you are doing. Run “man sysctl” for more information.” (source).
UPDATE: I’ve increased the apc.shm_size to 256MB without changing any kernel setting and it works fine.
apc.stat
From PHP manual:
Be careful if you change this setting. The default is for this to be On which means that APC will stat (check) the script on each request to see if it has been modified. If it has been modified it will recompile and cache the new version. If you turn this setting off, it will not check. That means that in order to have changes become active you need to restart your web server. On a production server where you rarely change the code, turning stats off can produce a significant performance boost.

For included/required files this option applies as well, but note that if you are using relative path includes (any path that doesn’t start with / on Unix) APC has to check in order to uniquely identify the file. If you use absolute path includes APC can skip the stat and use that absolute path as the unique identifier for the file.

If you change these settings or not, the next step is to move the /usr/share/php/apc.php script into your webserver path and access it with browser. It provides a detailed look at what is happening with your cache and, with GD enabled in PHP, also shows you graphs of the situation of your cache.

After checking if caching actualy works, you should point your eyes to the Cache full count value (on the left tables under File Cache Information). The number tells you how many times the cache filled up the allocated memory and had to be cleared of entries not accessed within number of seconds set up with apc.ttl setting. “You should configure your cache to minimize this number if not the resulting cache churn is going to hurt performance. You should either set more memory aside for APC, or use apc.filters to cache fewer scripts.”*

Updates

When I tried to replicate the above installation process on my production server running on minimum required software I encountered some additional problems/missing packages.

    meglohvat:# pecl install apc
    downloading APC-3.0.16.tgz ...
    Starting to download APC-3.0.16.tgz (114,298 bytes)
    .........................done: 114,298 bytes
    45 source files, building
    running: phpize
    sh: phpize: command not found
    ERROR: `phpize' failed

phpize is a shell script to prepare PHP extension for compiling. It is a part of php5-dev package ›› apt-get install php5-dev

Upgrade

To upgrade the APC extension run the command:

meglohvat:# pecl upgrade apc
downloading APC-3.0.19.tgz ...
Starting to download APC-3.0.19.tgz (115,735 bytes)
.........................done: 115,735 bytes
47 source files, building
running: phpize
Configuring for:
PHP Api Version:         20041225
Zend Module Api No:      20060613
Zend Extension Api No:   220060519
Use apxs to set compile flags (if using APC with Apache)? [yes] :

And if everything went well you should see something like this in the end.

Build process completed successfully
Installing '/var/tmp/pear-build-root/install-APC-3.0.19//usr/lib/php5/20060613/apc.so'
upgrade ok: channel://pecl.php.net/APC-3.0.19
You should add "extension=apc.so" to php.ini
meglohvat:#

Setting up SSL with Apache2 on Debian Etch

December 21st, 2007

For more detailed instructions, pleae follow the link below and do read the comments too, since the solution I used is mentioned in the comments.

1. Create folder

        # mkdir /etc/apache2/ssl

2. Create SSL certificate (you should have openssl package installed)

        openssl req -new -x509 -days 365 -nodes -out /etc/apache2/ssl/apache.pem \
	-keyout /etc/apache2/ssl/apache.pem

3. Enable SSL Apache module

        klopotec:~# a2enmod ssl
	Module ssl installed; run /etc/init.d/apache2 force-reload to enable.

4. Tell Apache to accept connections on port 443 by adding the line below into /etc/apache2/ports.conf

        Listen 443

5. Configure virtual host adding:

        SSLEngine on
        SSLCertificateFile /etc/apache2/ssl/apache.pem

i.e.

NameVirtualHost *:443
NameVirtualHost *:80
<VirtualHost *:80>
    ServerName earth.my.flat    DocumentRoot /var/www/

ErrorLog /var/log/apache2/error.log    CustomLog /var/log/apache2/access.log combined

</VirtualHost>
<VirtualHost *:443>    ServerName earth.my.flat

DocumentRoot /var/www/    ErrorLog /var/log/apache2/error.log

CustomLog /var/log/apache2/access.log combined    SSLEngine on

    SSLCertificateFile /etc/apache2/ssl/apache.pem</VirtualHost>

6. Restart/reload Apache

        /etc/init.d/apache2 reload

This walkthrough created on the basis of:
Setting up an SSL server with Apache2