Le blog de Jean David TECHER, un Réunionnais à Saint-Priest/Lyon

Aller au contenu | Aller au menu | Aller à la recherche

1 2 3 4 5 6 7 8 9 10 11 12 13 14 >

vendredi 5 octobre 2018

[Ubuntu] Fixed issue for mlocate by building it from sources

Whatever you Ubuntu version is, one day you might meet some issues with mlocate/updatedb.mlocate.
  • huge I/O on disk
  • OOMkiller will kill it
  • and so on

I found a recent mlocate version with instruction to build it. So let give it a try! We will build it first

It is listed in my daily crontab (file = /etc/cron.daily/mlocate )

I found a PKGBUILD from https://gitea.artixlinux.org/artix/packages/src/branch/master/mlocate/trunk/PKGBUILD and wanted to give it a try

Translating its content to my own needs, I did
export srcdir=$PWD/mlocate-build

# Create some folder to download sources
mkdir mlocate-build && cd $srcdir

git clone https://pagure.io/mlocate.git && cd mlocate/ && git checkout c98bf6595703456558a6f9c163c746cdaa9e591f

cd $srcdir
git clone git://git.savannah.gnu.org/gnulib.git && cd gnulib/ && git checkout 5861339993f3014cfad1b94fc7fe366fc2573598

cd $srcdir/mlocate
#sed -i '/^groupname /s/mlocate/locate/' Makefile.am # I will not run this one because mlocate group exists on my computer. No need to replace it with a new group
../gnulib/gnulib-tool --import
autoreconf --install
# Configure
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var/lib
# Build

# Time to prepare package
make DESTDIR=/tmp/mlocate-build install

# 111 = Group ID for mlocate group on my PC
chgrp 111 /tmp/mlocate-build/usr/bin/locate
chmod 2755 /tmp/mlocate-build/usr/bin/locate
# Create a symbolic link
ln -s /tmp/mlocate-build/usr/bin/updatedb /tmp/mlocate-build/usr/bin/updatedb.mlocate

Test it before installing it

  1. As a simple user -- from a terminal session -- , write some random file
    echo "hello world" > /TMP_MinGW32/sources/Nabilla.txt
  2. As root -- from a terminal session --, launch it and monitoring it. Below command is taken from /etc/cron.daily/mlocate on my computer
    flock --nonblock /run/mlocate.daily.lock /usr/bin/ionice -c3 /tmp/mlocate-build/usr/bin/updatedb
    Important: Stay in front of your computer, open your monitoring tool to check: CPU, I/O, RAM and so on. This is important to check that consumption is low!!! On my computer it took 3 minutes to refresh database /var/lib/mlocate/mlocate.db
  3. Query locate to see if it can find your new file
    /tmp/mlocate-build/usr/bin/locate Nabilla
    . It returned my new random file as expected. (/TMP_MinGW32/sources/Nabilla.txt)
Let's destroy the symbolic link now
rm -vf /tmp/mlocate-build/usr/bin/updatedb.mlocate

Install it!

  • First we need to destroy the symbolic link /usr/bin/updatedb -> /etc/alternatives/updatedb. We just need to delete the symbolic link
    rm -vf  /usr/bin/updatedb
  • Time to copy our binaries
    cp -avf  /tmp/mlocate-build/usr/* /usr/
  • Let's create the new link
    ln -s /usr/bin/updatedb /usr/bin/updatedb.mlocate
  • We just need to add some rights
    chgrp 111 /usr/bin/locate 
    chmod 2755 /usr/bin/locate

jeudi 29 janvier 2015

Ubuntu 14.10 - Upgrade Linux kernel from 3.18.1 to 3.18.4 (incremental patches)

My sources for 3.18.1 are located at /opt/linux-3.18.1. Kernel 3.18.1 is my current kernel. I wanted to upgrade because I read important notes in ChangeLog-3.18.4. This way my kernel will be up-to-date.
  • Go to this folder
    cd /opt/linux-3.18.1
  • Download incremental patches
    mkdir tmp_patch
    cd tmp_patch/
    wget https://www.kernel.org/pub/linux/kernel/v3.x/incr/patch-3.18.1-2.xz
    wget https://www.kernel.org/pub/linux/kernel/v3.x/incr/patch-3.18.2-3.xz
    wget https://www.kernel.org/pub/linux/kernel/v3.x/incr/patch-3.18.3-4.xz
  • Decompress these patches
    xz -d patch-3.18.1-2.xz
    xz -d patch-3.18.2-3.xz
    xz -d patch-3.18.3-4.xz
  • Apply these patches
    cd ..
    patch -p1 < tmp_patch/patch-3.18.1-2
    patch -p1 < tmp_patch/patch-3.18.2-3
    patch -p1 < tmp_patch/patch-3.18.3-4
  • The usual commands to build kernel
    • Nothing to change using command below (I will just click 'Yes' since all my options are already checked)
      make menuconfig
      Notice: Just run make mrproper before command above to keep your kernel folder clean -- if required !--
    • Build everything
      make -j4 bzImage modules
      Notice: If you have a DVD or a film to watch then ....Command above should take a while
    • Install
      make -j4 INSTALL_MOD_STRIP=1 modules_install
      make -j4 INSTALL_MOD_STRIP=1 install
      make -j4 INSTALL_MOD_STRIP=1 headers_install
      Notice: INSTALL_MOD_STRIP=1 is pretty useful. This flag helps to install binaries with a smaller size :)

lundi 26 janvier 2015

Ubuntu 14.10: Upgrade from libxext-dev 1.3.2 to 1.3.3 (build packages .deb manually)

Using libxext-dev 1.3.2 on Ubuntu 14.10 I got this fucking error

_xgeWireToEvent: Unknown extension 148, this should never happen

This error has been fixed for libxext-dev 1.3.3. Unfortunately this version is not available. So I have to rebuild .deb manually

Instructions below help to build packages .deb
mkdir Xext-1.3.3

cd Xext-1.3.3

apt-get build-dep libxext-dev

wget http://ftp.de.debian.org/debian/pool/main/libx/libxext/libxext_1.3.3-1.dsc \
        http://ftp.de.debian.org/debian/pool/main/libx/libxext/libxext_1.3.3.orig.tar.gz \

dpkg-source -x libxext_1.3.3-1.dsc

cd libxext-1.3.3/

dpkg-buildpackage -rfakeroot -b

cd ..

dpkg -i libxext6_1.3.3-1_i386.deb \
           libxext6-dbg_1.3.3-1_i386.deb  \
           libxext-dev_1.3.3-1_i386.deb  \

lundi 8 avril 2013

Useful links