[en] How to mount LVM VG and restore data from it when one of its PV drives has failed

However great LVM is in Linux, allowing one to span single „partition” over several hard drives, if the underlying „drives” are real hard drives and not RAID volumes, You can get pretty fucked when one of those disks fails.

It took me several hours of googling around and trials to find out how to recover as much data as is possible (meaning: all the data that is on remaining disks, the data on failed drive is obviously lost). So let’s try to add a short and working recipe to Google.

  1. You do NOT have to pvcreate any bogus empty PVs with fake UUIDs to replace the failed drive. LVM2 can be used in „partial” mode without all the drives.
  2. To use partial mode, You need to create /dev/ioerror device like this (I use Ubuntu, in other distros it might be different):
    • nano filename to create a text file where a single line „0 9999999999 error” sans quotes should be placed
    • dmsetup create ioerror filename to create a device LVM will read instead of missing PV
    • ln -s /dev/mapper/ioerror /dev/ioerror so it’s just where LVM will look for it
  3. After ioerror is created, just activate your volume group in partial mode using vgchange -P -ay VOLNAME
  4. Mount it (it will mount in read only mode) and copy your precious data

Cheers to these guys who finally written something I could use instead of pvcreate and bogus hard drives discussions.

Virtualmin on Ubuntu 8.04 Server

Notes to myself and Googlers on installing a virtual hosting control panel Virtualmin (a great add-on to Webmin) on Ubuntu server:

  • wget http://software.virtualmin.com/gpl/scripts/install.sh
    chmod 755 install.sh
    ./install.sh
    — installs Virtualmin automatically with all dependencies, with a nice skin which is also used by Webmin (which I remember used to be quite ugly by default)
  • chmod 711 /var/spool/postfix/var/run/saslauthd — fixes login failure when trying to send mail through virtual server
  • it seems apache vhost, ftp, e-mail and DNS is properly configured automatically, will add more info here as I move on with my hosting migration to Virtualmin probably

dostaje automatycznie „display: none” w Firefoksie?

Straciłem nad tym więcej czasu niż chcę się przyznać; miałem dodać mały element graficzny o nazwie pliku zspon.png do strony jednego z Klientów i jakimś cudem nie pojawiał się on nigdy na stronie, a Firebug pokazywał że ma on „display: none”, choć żadnego CSSa nie przypisywałem.

Okazało się, że Adblock z filtrami Filterset.g wycina mi obrazki które mają w nazwie „spon” :> Wyłączenie Adblocka na czas developmentu to dobry pomysł, choć ja zostawiam włączony – jak ktoś będzie go używał to wolę zawczasu wiedzieć co mu zniknie i zmienić nazwę pliku 🙂 zs-pon.png się wyświetla 😀

[en] How to word wrap text in Graphics2D.drawString in Java

Google wasn’t awfully helpful while I was searching for solution to word wrapping a text when drawing in Java, so let’s teach Google this: 😉

    private void drawStringRect(Graphics2D graphics, int x1, int y1, int x2, int y2, 
        float interline, String txt) {
        AttributedString as = new AttributedString(txt);
        as.addAttribute(TextAttribute.FOREGROUND, graphics.getPaint());
        as.addAttribute(TextAttribute.FONT, graphics.getFont());
        AttributedCharacterIterator aci = as.getIterator();
        FontRenderContext frc = new FontRenderContext(null, true, false);
        LineBreakMeasurer lbm = new LineBreakMeasurer(aci, frc);
        float width = x2 - x1;

        while (lbm.getPosition() < txt.length()) {
            TextLayout tl = lbm.nextLayout(width);
            y1 += tl.getAscent();
            tl.draw(graphics, x1, y1);
            y1 += tl.getDescent() + tl.getLeading() + (interline - 1.0f) * tl.getAscent();
            if (y1 > y2) {
                break;
            }
        }
    }