Page 1 of 6 (112 posts)

  • talks about »

Last update:
Thu Apr 17 17:00:10 2014

A Django site.

QGIS Planet

FOSSGIS 2014 slides

Neues in QGIS 2.2

Nach dem lange erwarteten Release von QGIS 2.0 im September 2013, sind ab diesem Jahr neue Versionen im Viermonatszyklus geplant. Es werden die neuen Funktionen in QGIS 2.2, wie z.B. DB-Relationen mit verschachtelten Formularen, die erweiterten Methoden zur Transformierung geographischer Koordinatensysteme, zahlreiche Verbesserungen im Print Composer und ein komplett überarbeiteter DXF Export vorgestellt. Zusätzlich wird eine Vorschau auf das multithreaded Rendering gegeben und die neuen Mitglieder im Project Steering Committee vorgestellt

Links:

Mobile Kartenviewer mit Openlayers 3

Mit OpenLayers 3 steht eine komplette Neuentwicklung der funktionsreichen OpenLayers-Bibliothek zur Verfügung. Die verbesserte Unterstützung mobiler Geräte war ein primäres Ziel der neuen Version. Dieser Vortrag stellt den JQuery Mobile basierten OL3 Mobile Viewer vor, der erweiterte Funktionen wie automatische Kartenausrichtung oder Positionsnachführung bietet. Es wird auch ein Vergleich mit anderen Viewern, wie der auf Bootstrap und AngularJS aufbauenden Neuentwicklung von Swisstopo angestellt.

Links:

AGIT 2013: QGIS Cloud - Karten einfach ins Netz

Noch nie war es so einfach individuelle Web Map Services mit ansprechenden Karten, Geodatenbank und Web Client zu erstellen, wie mit QGIS Cloud. Der am 5. Juli an der AGIT 2013 in Salzburg präsentierte Vortrag kann hier herunter geladen werden.

Präsentation

Multithreaded rendering with QGIS

Nowadays, most computers have several processor cores. However, most computer programs are still designed to only use one processing unit. As a convenient and portable way of writing software using all the available processing power, Qt provides the excellent QtConcurrent framework.

In 2010, a Google Summer of Code project examined the suitabilty of using Qt concurrent for rendering the map image in QGIS using several processor cores. Following that approach, each layer renders its image in a separate thread. Once all layer threads are finished, the layer images are composited into one map image and the labels are drawn on top of it. Despite providing good results, that code was unfortunately never merged into the main development branch.

QGIS Enterprise 13.05 will provide the capability of multithreaded rendering. A screencast of the new functionality shows that not only the render time is shorter using multiple cores. More important is to have the possibility to cancel the render progress and the labeling any time, thus achieving a much more responsive user interface when navigating maps.

NTv2 transformations with QGIS

Datum transformations with grid shift files are used in several countries to convert coordinates between different datums. In Switzerland, datum transformation using the NTv2 method is important because of the upcoming conversion between the LV03 system and the new LV95 system. Up to now, doing coordinate transformations with grid shift files was possible in QGIS, but unconvenient.

To use an NTv2 transformation in QGIS, the grid shift file needs to be placed in a directory where proj4 can find it (usually /usr/share/proj on Linux and OSGeo4W\share\proj on Windows). Alternatively, the environment variable PROJ_LIB can be set to point to the directory with the grid shift file(s). Then we have to enable the setting Options->CRS->’Ask for datum transformation when no default is defined’.

The next time we use a coordinate transformation which involves a datum transformation, a dialog shows up and presents the available options.

Now it is possible to select the NTv2 transformation file ‘chenyx06a.gsb’ to convert between LV03 and LV95. It is also possible to select the datum transformation as default to avoid being asked again. Default transformation settings can be changed / added / delted in the options tab (or set during installation by an administrator).

To use an NTv2 based transformation which is not yet in the projection database of QGIS, a new entry has to be added to the datum transformation table in srs.db. If you add a transformation which is widely used in your country, please send the changes back to the project so that those entries can be included by default.

The new datum transformation handling will be available in the upcoming QGIS 2.2 and QGIS Enterprise 13.05. The development has been funded by the Swiss cantons Basel-Landschaft and Solothurn. I also want to thank Fabio Di Pietro, Stefan Ziegler and Frank Warmerdam for answering all my questions about datums, coordinate transformations and proj4.

Sourcepole Kursprogramm Frühling 2014

Im Mai 2014 bietet Sourcepole wieder sein kompetentes Kursprogramm rund um alle GDI Komponenten an. Zu allen Kursen gehört umfangreiches Kursmaterial, Mittagessen und Kaffepausen. Bei Buchung eines Grundkurses und den darauf folgenden Aufbaukurs erhalten die Teilnehmer Rabatt auf den Kurspreis.

Geo-Datenbank:

  • PostgreSQL / PostGIS Einführung (5. - 6. Mai 2014)
  • PostgreSQL / PostGIS für Fortgeschrittene (7. Mai 2014)

Desktop GIS

  • QGIS 2.0 / Enterprise Desktop Grundkurs (12. - 13. Mai 2014)
  • QGIS 2.0 / Enterprise Desktop für Power User (14. Mai 2014)

Web GIS / OWS-Services

  • QGIS 2.0 / Enterprise Server und QGIS Web Client (22.Mai 2014)

QGIS Programmierung

  • QGIS 2.0 / Enterprise Plugin Entwicklung mit PyQt4 und PyQGIS (19. - 20. Mai 2014)

Informationen zu den Kursen und die Online Anmeldung finden Sie im Kursprogramm

Wir freuen uns darauf Sie in Zürich begrüssen zu können.

New Mapfish Appserver site with OL3 mobile viewer is online

The city of Winterthur recently launched their new public map portal, based on Mapfish Appserver. Some of the features are outlined in the online help (in German).

Mobile users are redirected to the OL3 Mobile Viewer, which is based on OpenLayers 3 and jQuery Mobile. To have a look at it from your desktop browser follow this link.

In contrary to the desktop version, most of the background layers are delivered as tiles and only topic layers are full size WMS requests. The interesting thing is, that instead of using a tile protocol like WMTS, TMS, etc., an OL3 tiled WMS datasource does multiple WMS requests in a tile scheme. The usual tiling problems (labels, etc.) do not apply for the used raster layers and Varnish serves as cache for on-the-fly generated WMS tiles. In contrary to file based tile caching, much less disk space and more important, no update process is needed.

@PirminKalberer

INTERGEO 2013

Der OpenSource-Park auf der Intergeo wächst weiter! In diesem Jahr findet die Intergeo vom 8. bis 10. Oktober in Essen statt. Der OpenSource-Park befindet sich in Halle 1, Stand Nr. H1.033. Das OpenStreetMap Projekt ist mit dem Stand H1.040 gleich neben dem OpenSource-Park vertreten..

Auch auf der diesjährigen Hauptmesse der Geo-Informatik-Branche, der Intergeo, wird es wieder eine zentrale Anlaufstelle für alle Besucher geben, die sich über professionelle OpenSource-Anwendungen informieren wollen. Die Zahl der ausstellenden Firmen auf dem OpenSource-Park ist gegenüber dem Vorjahr nochmals um 50% angewachsen. Damit spiegelt die Messebeteiligung auch den über die Jahre stetig anwachsenden Marktanteil quelloffener Lösungen wieder. “Die Bedeutung von OpenSource-Software steigt nach unseren Beobachtungen von Jahr zu Jahr an”, bestätigt Projektleiter Daniel Katzer von der HINTE GmbH, die die INTERGEO für den DVW ausrichtet.

In diesem Jahr sind Firmen aus ganz Deutschland und der Schweiz auf dem OpenSource-Park vertreten. Die Schwerpunkte der ausstellenden Firmen liegen bei den Themen Performance-Optimierung für große Datenmengen, schnelle und umfassende Suchfunktionen über verteilte Datenbestände, Lösungen für die Ver- und Entsorgungsbranche, Geoportale für Unternehmen und Behörden, und natürlich im Bereich spezialisierter Beratungsleistungen.

Insgesamt steht damit auf dem OpenSource-Park ein Wissenspool zur Verfügung, der nicht nur alle gängigen Bereiche der räumlichen Datenverarbeitung umfasst, sondern daneben auch zahlreiche spezifische Themen und Branchenlösungen bereithält.

Der FOSSGIS e.V. versorgt Sie gerne mit Informationen rund um freie Software aus dem GIS Bereich und freie Geodaten. Zahlreiche Projekte sind über die OSGeo (Open Source Geospatial Foundation) vertreten. Es liegt Informationsmaterial für Sie bereit. Wir beraten Sie gerne!

Vortragsprogramm auf dem OpenSource-Park

Ein Highlight wird wie jedes Jahr das umfangreiche Vortragsprogramm an allen drei Tagen sein. Es erwarten Sie u.a. Vorträge zu OpenStreetMap, QGIS, INSPIRE, D115, ALKIS, Cloud-Diensten, Bürgerbeteiligungssystemen, diversen Fachschalen und vielen weiteren Neuerungen und Best-Practice-Beispielen.

Das Vortragsprogramm wird vom FOSSGIS e.V. organisiert.

Ausstellende Firmen

Ausstellende Firmen auf dem diesjährigen OpenSource-Park der Intergeo:

  • Mapwebbing
  • Metaspatial
  • norBIT GmbH
  • Omniscale GmbH & Co. KG
  • rasdaman GmbH/ Jacobs University Bremen
  • Sourcepole AG
  • terrestris GmbH & Co. KG
  • WebGis - in medias res GmbH
  • WhereGroup GmbH & Co. KG

OSM Stand

Das OpenStreetMap Projekt ist in diesem Jahr mit einem eigenen Stand auf der Intergeo vertreten. Dieser grenzt direkt an den OSGeo Park an und befindet sich in Halle 1, Stand Nr. H1.040. Schauen Sie doch vorbei und informieren Sie sich über die neusten Entwicklungen im OpenStreetMap-Projekt.

Rahmenprogramm

OSM Stammtisch im Unperfekthaus

Im Rahmen des Engagements des FOSSGIS e.V. auf der INTERGEO 2013 findet am 08.10.2013 ab 19 Uhr der OSM Stammtisch im Unperfekthaus , Essen statt.

FOSSGIS e.V. Vollversammlung

Am 09.10.2013 trifft sich der FOSSGIS e.V. zur Vollversammlung auf der Intergeo.

Wir freuen uns auf Ihren Besuch auf der Intergeo. Schauen Sie doch auf dem OpenSource-Park vorbei!

Kursprogramm Herbst 2013

Sourcepole bietet Grundlagen- und Aufbau-Kurse für den Betrieb von Geodaten-Infrastrukturen auf der Basis von PostgreSQL/PostGIS und Quantum GIS an. Detaillierte Informationen zu den Kursen, die wieder im November 2013 stattfinden, entnehmen Sie bitte http://www.sourcepole.ch/kurse Die Anmeldung ist online möglich. Wir freuen uns darauf Sie in Zürich begüssen zu können.

PDF reports with embedded maps

Printing is always one of the more difficult parts in a web mapping application. There are solutions like the MapFish Print module or the built-in QGIS WYSIWYG PDF printing. But very often users do not want only a map on their print output, but collected information stored in a database with images, etc. - and a matching map. This is the domain of database reporting tools like JasperReports. They provide desktop tools for designing complex reports with texts, graphics, images, tables, etc. and server software for web applications. But how to include a matching map - a map with application parameters like the bounding box or a list of active layers, etc.?

Sourcepole is releasing the missing link between high-quality map printing and database reports, an extension for JasperReports/iReport. This extension makes it easy to embed maps served with the standardized Web Map Service (WMS) protocol.

With this extension installed as plugin for iReport Designer, you have all the reporting features of JapserReports plus a new toolbox component for embedding maps.

This allows you to create multi-page reports with embedded maps using parameters from your web mapping application and complex Jasper expressions.

Source and documentation of the WMS map extension for Jasper Reports is available on Github and binaries as Github downloads

Many thanks to Mika from Panter for implementing the Java stuff and the Canton of Zurich for sponsoring this useful piece of Open Source software.

@PirminKalberer

FOSSGIS 2013: Performance optimised wms services with QGIS server

Performance is usually a top priority for a WMS service. A recent talk at the FOSSGIS (held by Sourcepole) shows what a WMS administrator can do to optimise QGIS server performance. Finally, the performance of QGIS server is compared with UMN mapserver in two production scenarios.

Slides from FOSSGIS 2013 in Rapperswil (in german).

FOSSGIS 2013: Qualitätssicherung von Geodaten auf der Basis von Web Processing Services (WPS)

Bevor neue Daten in eine Geodaten-Infrastruktur überführt werden, müssen sie Qualitätssicherungs-Verfahren durchlaufen. Diese Prozesse können sowohl generisch, als auch speziell für ein bestimmtes Datum konfektioniert sein. Um Sicher zu stellen, dass diese Prozesse langlebig und verfügbar sind, bietet es sich an OGC-Konforme Services zu diesem Zweck zu nutzen. Deshalb werden im Vortrag die Vor- und Nachteile OGC-Konformer Web Processing Services (WPS) als Basis der Qualitätssicherung von Geodaten diskutiert.

Präsentation

FOSSGIS 2013: Mapfish Appserver

Mapfish Appserver is a platform for building web mapping applications using OGC standards and the Mapfish REST protocol.

Slides from FOSSGIS 2013 in Rapperswil (in german).

FOSSGIS 2013: GeoPackage, das Shapefile der Zukunft

Der GeoPackage-Standard ist im Januar 2013 vom OGC als Draft veröffentlicht worden. Er vereint die Speicherung von Vektor- und Rasterdaten im verbreiteten SQLite DB-Fileformat. Vektoren werden im SpatiaLite-Format und Rasterdaten wie MBTiles gespeichert.

Präsentation

QGIS Enterprise – Open Source GIS with LTS Support

Quantum QGIS, a user-friendly and full featured Open Source GIS suite, is used in a wide range of professional enterprise infrastructures. Sourcepole, located in Zurich, Switzerland, now fills the last gap, which has prevented many organizations from the use of QGIS in enterprise infrastructures so far - they offer professional support directly from QGIS core developers. With QGIS Enterprise long term support and maintenance, the customer gets a professionally supported and maintained GIS infrastructure based on QGIS.

QGIS is an official project of the Open Source Geospatial Foundation (OSGeo). It is developed since 2002 by a very active developer community and runs on Linux, Mac OSX, Windows and Android. It provides all features required for a desktop GIS in enterprise use. This includes interfaces to many data formats, extensive analysis functionality, support of main specifications of the Open Geospatial Consortium, numerous styling options, production of ready to print maps and extenddability via Python interface.

The upcoming QGIS Release 2.0 is the basis of the QGIS Enterprise Suite consisting of QGIS Desktop, QGIS Server and QGIS Web Client. These components are maintained by Sourcepole apart from the QGIS community project. Backward compatibility to QGIS 1.8 (Lisboa) plays a major role, because most existing plugins, will not be compatible with the upcoming QGIS community version 2. QGIS Enterprise is currently available for Ubuntu / Debian, RedHat 6, Windows 32bit and Windows 64bit.

Since 2003 Sourcepole is significantly involved in the development of QGIS and supports organizations from 2 to 140,000 employees in the use of QGIS. As an official committer to several OSGeo projects, Sourcepole is able to integrate customer specific extensions into the main software repositories. Improvements of QGIS Enterprise, if possible, will always go back into the QGIS community development.

www.qgisenterprise.com

QGIS Enterprise - Open Source GIS mit LTS Support

Das benutzerfreundliche und funktionsreiche Quantum GIS (QGIS) bewährt sich seit mehreren Jahren im professionellen Einsatz. Die Firma Sourcepole aus Zürich füllt jetzt eine letzte Lücke, die Organisationen davon abgehalten hat QGIS in Unternehmens-Infrastrukturen einzusetzen – der professionelle Support direkt von den Kernentwicklern. Mit dem QGIS Enterprise Long Term Support- und Wartungsvertrag erhält der Kunde die Sicherheit, eine professionell unterstützte und betriebsbereite GIS Infrastruktur auf der Basis von QGIS zu betreiben.

QGIS ist ein Projekt der Open Source Geospatial Foundation (OSGeo). Es läuft unter Linux, Mac OSX, Windows und Android und unterstützt zahlreiche Vektor-, Raster- und Datenbankformate und Funktionen. QGIS wird seit 2002 von einer sehr aktiven Entwickler-Gemeinschaft entwickelt. Es verfügt über alle Funktionen, die ein Desktop GIS für den Unternehmenseinsatz benötigt. Dazu gehören Schnittstellen zu vielen Datenformaten, umfangreiche Analysefunktionen, Unterstützung der wichtigsten Spezifikationen des Open Geospatial Consortiums, vielfältige Darstellungsoptionen, die Produktion druckfertiger Karten und die Erweiterbarkeit über eine Python Schnittstelle.

Die Grundlage von QGIS Enterprise ist die QGIS Suite Version 2.0 bestehend aus QGIS Desktop, QGIS Server und QGIS Web Client. Diese Komponenten werden, unabhängig vom QGIS Community Projekt, durch die Sourcepole AG gepflegt, gewartet und erweitert. Dabei spielt die Kompatibilität zur QGIS Version 1.8 Lisboa eine grosse Rolle, denn eine Vielzahl Erweiterungen existieren, die mit der kommenden QGIS Version 2.0 der Community, nicht mehr betrieben werden können. QGIS Enterprise steht zur Zeit für Ubuntu/Debian, RedHat 6, Windows 32bit und Windows 64bit zur Verfügung.

Sourcepole ist seit 2003 an der Entwicklung von QGIS massgeblich beteiligt und betreut Organisationen von 2 bis 140’000 Mitarbeitern die QGIS im produktiven Einsatz betreiben. Als offizielle Committer in mehreren OSGeo-Projekten kann die Firma auch direkt in den Original-Code eingreifen und Kundenanforderungen flexibel erfüllen. Verbesserungen in QGIS Enterprise werden, wenn immer möglich, dem QGIS Community Projekt zur Verfügung gestellt.

www.qgisenterprise.com

Faster maps with progressive WMS

The good old OGC WMS has many advantages compared to tiled maps:

  • Continious zoom levels
  • Support for different projections
  • Combination of multiple layers in one request
  • Higher resolutions for printing
  • Better labelling
  • No maintenance needed when updating data

Well known disadvantages are scalability issues for high-traffic sites and a slower response time for complex maps.

The second point can be significantly improved by using a technique known from the progressive JPEG format. Before loading a map with full resolution, a map image with a lower resolution is requested from the server. This results in a better response time, because rendering and transmitting of the low resolution image is significantly faster. The biggest effect on rendering time is in combination with raster layers, but also for vector layers the improvement can be substantial.

High resolution:

Low resolution:

The technique can be easily applied to any WMS using this basic OpenLayers implementation.

There is much room for improvements. The low resolution layer could be tiled, limited to certain zoom levels or having a larger extend for smoother panning.

QGISCloud has this optimization built into the QGIS Web-Client viewer, which helps collecting experience with a wide range of datasets.

QGIS Cloud and Sourcepole are sponsoring Öcher-Safari

QGIS Cloud and Sourcepole are proud to be official sponsors of the team Öcher-Safari, attending the Allgäu-Orient-Rallye. One of the last adventures in the world of cars. Sourcepole serves the team with know how, infrastructure and more. Information about the team and the charity ideas of this event you can find on Öcher-Safari and the official web site of the Allgäu-Orient-Rallye.

Serving multiple WFS-T with TinyOWS

Our favorite WFS-T server complement of UMN Mapserver is TinyOWS. We like the simplicity of it so much, that we packaged it for Ubuntu and added it to OSGeoLive. Installation is easy:

sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update
sudo apt-get install tinyows

The simplicity is a little bit too much, when it comes to serve multiple WFS-T on the same server. There is only one configuration file, but we want a configuration for each service. There are solutions for that, but I never saw a documentation of the most elegant solution we found. It uses Apache rewrite capabilities to set the TINYOWS_CONFIG_FILE environment variable according to the called URL:

# URL rewriting
RewriteEngine On

# Forbid direct access
RewriteRule ^/cgi-bin/.*$ - [F]

# Rewrite /xxx to /cgi-bin/tinyows with TINYOWS_CONFIG_FILE=/etc/tinyows/xxx.xml
RewriteRule ^/(.+)$ /cgi-bin/tinyows [QSA,PT,L,E=TINYOWS_CONFIG_FILE:/etc/tinyows/$1.xml]

This configuration included in a virtual host declaration (wfs.example.com) serves your WFS-T on wfs.example.com/servicename.

installing Postgis 2.0 under Debian wheezy

We’ll be using Postgis2.0 from UbuntuGIS, which has packages for a number of recent Ubuntu releases. Since Ubuntu precise has libc6 2.14 and Debian wheezy only 2.13 we fall back on Ubuntu oneiric for packages, which also has libc6 2.13.

However Postgis 2.0 in UbuntuGIS depends on a lot of llibraries which were in squeeze but live in wheezy under a higher version. Therefore we’ll install a lot of packages from Debian squeeze. Fortunately the libraries are versioned themselves and thus can be installed along the libraries from Debian wheezy.

Let’s go. Add the Debian squeeze sources:

# SRC="deb http://ftp.ch.debian.org/debian/ wheezy main"
# echo "$SRC" >> /etc/apt/sources.list

We’ll also add the security source, in case Debian releases a security update.

# SRC="deb http://ftp.ch.debian.org/debian/ wheezy main"
# echo "$SRC" >> /etc/apt/sources.list

You may want to replace ftp.ch.debian.org by a debian mirror nearer to you.

Now add the UbuntuGIS sources:

# SRC="deb http://ppa.launchpad.net/ubuntugis/ubuntugis-unstable/ubuntu oneiric main"
# echo "$SRC" > /etc/apt/sources.list.d/ubuntugis.list

Now update and try to install postgis:

# apt-get update
# apt-get install postgresql-9.1-postgis

Create your database:

# sudo su
# su - postgres
$ psql postgres
postgres=# CREATE DATABASE your_db OWNER your_preferred_user:

Now add the postgis features to that database:

$ psql -d your_db -f /usr/share/postgresql/9.1/contrib/postgis-2.0/
$ psql -d your_db -f /usr/share/postgresql/9.1/contrib/postgis-2.0/spatial_ref_sys.sql

That should be it. Let’s hope it works.

A final warning: you are mixing multiple distributions here. This can lead to problems. Due to version conflicts upgrading packages can become very difficult.

Tomáš Pospíšek tpo_hp@sourcepole.ch

Howto shrink a remote root ext3 filesystem on Debian wheezy

This howto describes how to resize a root ext3 filesystem on a remote Debian wheezy server.

This howto is not an original work but only an update of an older howto by Stefan @ https://thunked.org/. This version is specifically adapted to a server running Debian wheezy.

DISCLAIMER:

THERE IS A DECENT CHANCE THAT IF YOU FUCK THIS UP YOUR
REMOTE SYSTEM SIMPLY WONT BOOT AT ALL.  I URGE YOU TO TEST
THIS LOCALLY BEFORE USING THIS METHOD ON A PRODUCTION
SYSTEM. ESPECIALLY IF YOUR SYSTEM IS NOT DEBIAN WHEEZY,
SINCE THAT'S THE ONLY ONE I HAVE TESTED.

THE QUICK WAY:

If you don't want to read the whole thing you can only
execute the commands I run and probably skip the
explanations.

I’ve only done this on Debian Wheezy. If you’re using another distro the initrd layout and init scripts may be a bit different. However, I suspect it looks very similar on almost every distro out there. On Debian my root partition is an ext3 partition.

The general idea is pretty simple: you can’t shrink a mounted partition and it’s impossible to unmount or replace your root partition in a live system, so we have to resize the partition before it is mounted. What we’ll do to accomplish this is change the initrd image to make the init scripts resize the root partition before mounting it. This is by far the most flexible and easy method to resize your root partition I could think of. Most suggestions I found on google required you to create separate OS on a new root partition and boot into that, but I did not have any space to create a new root partition on my remote machine.

Unpacking the initrd image is fairly straight forward:

$ mkdir ~/initrd; cd ~/initrd
$ gunzip -c /boot/initrd.img-3.2.0-3-amd64 | cpio -i --make-directories
62631 blocks
$ ls -l
total 40
drwxr-xr-x 2 root root 4096 Sep 11 20:23 bin
drwxr-xr-x 3 root root 4096 Sep 11 20:23 conf
drwxr-xr-x 6 root root 4096 Sep 11 20:23 etc
-rwxr-xr-x 1 root root 6797 Sep 11 20:23 init
drwxr-xr-x 7 root root 4096 Sep 11 20:23 lib
drwxr-xr-x 2 root root 4096 Sep 11 20:23 lib64
drwxr-xr-x 2 root root 4096 Sep 11 20:23 run
drwxr-xr-x 2 root root 4096 Sep 11 20:23 sbin
drwxr-xr-x 6 root root 4096 Sep 11 20:23 scripts

First, we have to copy all the programs we need to resize our partition onto the initial ram disk. For my ext3 file system I need e2fsck and resize2fs. The programs are depending on a few libraries, so you’ll need to copy those to the new initrd image too. Libraries can also depend on other libraries, make sure you recursively check dependencies until you don’t have any missing dependencies anymore.

$ ldd /sbin/e2fsck
    linux-vdso.so.1 =>  (0x00007fff3594c000)
    libext2fs.so.2 => /lib/x86_64-linux-gnu/libext2fs.so.2 (0x00007f7cdddd5000)
    libcom_err.so.2 => /lib/x86_64-linux-gnu/libcom_err.so.2 (0x00007f7cddbd1000)
    libblkid.so.1 => /lib/x86_64-linux-gnu/libblkid.so.1 (0x00007f7cdd9a9000)
    libuuid.so.1 => /lib/x86_64-linux-gnu/libuuid.so.1 (0x00007f7cdd7a4000)
    libe2p.so.2 => /lib/x86_64-linux-gnu/libe2p.so.2 (0x00007f7cdd59c000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f7cdd214000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f7cdcff8000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f7cde01e000)
$ ldd /sbin/resize2fs
    linux-vdso.so.1 =>  (0x00007fffa216a000)
    libe2p.so.2 => /lib/x86_64-linux-gnu/libe2p.so.2 (0x00007fa01f7a2000)
    libext2fs.so.2 => /lib/x86_64-linux-gnu/libext2fs.so.2 (0x00007fa01f55f000)
    libcom_err.so.2 => /lib/x86_64-linux-gnu/libcom_err.so.2 (0x00007fa01f35a000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fa01efd3000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fa01edb7000)
    /lib64/ld-linux-x86-64.so.2 (0x00007fa01f9b0000)

We only copy the libraries that are not yet present in the initramfs. Fortunately in our case there are no recursive dependencies of those libraries.

$ for i in libext2fs.so.2.4 libcom_err.so.2.1 libe2p.so.2.3; do \
     cp -i /lib/x86_64-linux-gnu/$i lib/x86_64-linux-gnu/; \
  done
$ cd lib/x86_64-linux-gnu/
$ ln -s libcom_err.so.2.1 libcom_err.so.2
$ ln -s libext2fs.so.2.4 libext2fs.so.2
$ ln -s libe2p.so.2.3 libe2p.so.2
$ cd ~/initrd/

$ cp /sbin/e2fsck ~/initrd/bin/
$ cp /sbin/resize2fs ~/initrd/bin/

Next, we need to edit the init script. Debian uses busybox in its initrd image so the init script will be interpreted by a bourne shell. If you look through the init script file you’ll find the moment where the script mounts the root file system:

$ cat scripts/local
...
    # FIXME This has no error checking
    # Mount root
    if [ "${FSTYPE}" != "unknown" ]; then
            mount ${roflag} -t ${FSTYPE} ${ROOTFLAGS} ${ROOT} ${rootmnt}
    else
            mount ${roflag} ${ROOTFLAGS} ${ROOT} ${rootmnt}
    fi
...

Simply add in the commands to resize the file system right before the the file system is mounted. Resize2fs in Debian does not want to resize the file system before it is forcefully checked. It may be wise to add the -p or -y flag to e2fsck. -y will answer yes to all questions, this could prevent a hung system but may cause more damage to your files or filesystem. The -p flag will only automatically answer yes to safe operations. resize2fs takes two parameters, the first is the block device that has the ext2 or ext3 file system and the second is the new size you want to give it. By default the size is in blocks, but you can append a unit to change that. ‘K’ for kilobytes, ‘M’ for megabytes, ‘G’ for gigabytes and ‘T’ for terabytes. If you don’t specify a size, it will enlarge the file system to the total size of the partition or logical volume. After adding the commands the init script will look something like this:

    #RESIZEROOTFS MODIFIED!!! DONT RUN MORE THAN ONCE
    _log_msg "Starting e2fsck"
    /bin/e2fsck -p -f -C 0 /dev/sda4 || true
    _log_msg "Starting resize2fs"
    /bin/resize2fs /dev/sda4 100G || true

    # FIXME This has no error checking
    # Mount root
    if [ "${FSTYPE}" != "unknown" ]; then
            mount ${roflag} -t ${FSTYPE} ${ROOTFLAGS} ${ROOT} ${rootmnt}
    else
            mount ${roflag} ${ROOTFLAGS} ${ROOT} ${rootmnt}
    fi

If you have access to the system’s console, you might want to add a “-C 0” to e2fsck’s parameters. That will show you the progress of the fscheck.

There’s one last thing we have to do before re-packing the initrd image. e2fsck and resize2fs will fail if there is no /etc/mtab file available so we’ll have to make sure /etc/mtab exists.

$ touch ~/initrd/etc/mtab
$ cd ~/initrd/
$ find ./ | cpio -H newc -o > /tmp/initrd.cpio
64097 blocks
$ gzip -c /tmp/initrd.cpio > /boot/initrd-resize.img

And lastly, we need to add a new default boot option in grub. In Debian grub’s configuration file is constructed from various bits under /etc/grub.d. The resulting total configuration file is put under /boot/grub/grub.cfg. Open up the grub.cfg file in your favorite text editor and look for the default entry. It’s usually the first one, but may vary. Add a copy of the original entry to /etc/grub.d/40_custom and change the initrd image to the one we just created.

$ cat /etc/grub.d/40_custom
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.

menuentry 'resize' --class debian --class gnu-linux --class gnu --class os {
        insmod gzio
        insmod part_gpt
        insmod ext2
        set root='(hd0,gpt1)'
        search --no-floppy --fs-uuid --set=root 0aa8bc27-17e3-4ae2-a9cf-497ab444970b
        echo    'Loading Linux 3.2.0-3-amd64 ...'
        linux   /vmlinuz-3.2.0-3-amd64 root=UUID=660f79dc-c152-4e15-ad61-7075b42de609 ro  quiet
        echo    'Loading initial ramdisk ...'
        initrd  /initrd-resize.img
}

Now make sure that it’s this entry that will be booted into by default. Set GRUB_DEFAULT in /etc/default/grub to the name of the entry you’ve just created:

$ cat /etc/default/grub
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
# info -f grub -n 'Simple configuration'

#GRUB_DEFAULT=0
GRUB_DEFAULT="resize"
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet"
GRUB_CMDLINE_LINUX=""
...

Finally, you can reboot the system. When it comes back online (if it comes back grin) your file system will be resized. Be aware that e2fsck and resizefs take a long time on big disks. On my system the two took 2 hours for a 1.5T filesystem. Thus don’t prematurely reboot your system if it doesn’t come up again quickly.

Don’t forget to remove the new grub entry, so your file system doesn’t get resized every time you boot.

Original howto at https://thunked.org/general/howto-shrink-a-remote-root-ext3-filesystem-t96.html

Original howto Written by Stefan @ https://thunked.org/

This version for Debian wheezy by Tomáš Pospíšek

  • Page 1 of 6 ( 112 posts )
  • >>

Back to Top

Sponsors