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

Howe­ver gre­at LVM is in Linux, allo­wing one to span sin­gle „par­ti­tion” over seve­ral hard dri­ves, if the under­ly­ing „dri­ves” are real hard dri­ves and not RAID volu­mes, You can get pret­ty fuc­ked when one of tho­se disks fails.

It took me seve­ral hours of googling aro­und and trials to find out how to reco­ver as much data as is possi­ble (meaning: all the data that is on rema­ining disks, the data on failed dri­ve is obvio­usly lost). So let’s try to add a short and wor­king reci­pe to Google.

  1. You do NOT have to pvcre­ate any bogus emp­ty PVs with fake UUIDs to repla­ce the failed dri­ve. LVM2 can be used in „par­tial” mode witho­ut all the drives.
  2. To use par­tial mode, You need to cre­ate /dev/ioerror devi­ce like this (I use Ubun­tu, in other distros it might be different): 
    • nano filename to cre­ate a text file whe­re a sin­gle line „0 9999999999 error” sans quotes sho­uld be placed
    • dmsetup create ioerror filename to cre­ate a devi­ce LVM will read inste­ad of mis­sing PV
    • ln -s /dev/mapper/ioerror /dev/ioerror so it’s just whe­re LVM will look for it
  3. After ioer­ror is cre­ated, just acti­va­te your volu­me gro­up in par­tial mode using vgchange -P -ay VOLNAME
  4. Mount it (it will mount in read only mode) and copy your pre­cio­us data

Che­ers to the­se guys who final­ly writ­ten some­thing I could use inste­ad of pvcre­ate and bogus hard dri­ves discussions.

Virtualmin on Ubuntu 8.04 Server

Notes to myself and Googlers on instal­ling a vir­tu­al hosting con­trol panel Vir­tu­al­min (a gre­at add-on to Webmin) on Ubun­tu server:

  • wget http://software.virtualmin.com/gpl/scripts/install.sh
    chmod 755 install.sh
    ./install.sh
     — installs Vir­tu­al­min auto­ma­ti­cal­ly with all depen­den­cies, with a nice skin which is also used by Webmin (which I remem­ber used to be quite ugly by default) 
  • chmod 711 /var/spool/postfix/var/run/saslauthd  — fixes login failu­re when try­ing to send mail thro­ugh vir­tu­al server
  • it seems apa­che vhost, ftp, e‑mail and DNS is pro­per­ly con­fi­gu­red auto­ma­ti­cal­ly, will add more info here as I move on with my hosting migra­tion to Vir­tu­al­min probably

dostaje automatycznie „display: none” w Firefoksie?

Stra­ci­łem nad tym wię­cej cza­su niż chcę się przy­znać; mia­łem dodać mały ele­ment gra­ficz­ny o nazwie pli­ku zspon.png do stro­ny jed­ne­go z Klien­tów i jakimś cudem nie poja­wiał się on nigdy na stro­nie, a Fire­bug poka­zy­wał że ma on „display: none”, choć żad­ne­go CSSa nie przypisywałem.

Oka­za­ło się, że Adblock z fil­tra­mi Filterset.g wyci­na mi obraz­ki któ­re mają w nazwie „spon” :> Wyłą­cze­nie Adbloc­ka na czas deve­lop­men­tu to dobry pomysł, choć ja zosta­wiam włą­czo­ny — jak ktoś będzie go uży­wał to wolę zawcza­su wie­dzieć co mu znik­nie i zmie­nić nazwę pli­ku 🙂 zs-pon.png się wyświetla 😀

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

Google wasn’t awful­ly help­ful whi­le I was sear­ching for solu­tion to word wrap­ping a text when dra­wing 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;
            }
        }
    }