[en] Fixing Ubuntu boot process after restoring tar backups to newly formatted disk (with UUID changed)

Mostly note to my self for futu­re reference.

What they don’t tell You in the tar bac­kup tuto­rial is that it’s not eno­ugh to edit /etc/fstab (and the­ir instruc­tions for grub are for grub-legacy).

Becau­se after resto­ring you pro­ba­bly have new par­ti­tion UUIDs, you must:

  • boot livecd
  • mount your root fs
  • mount -B /dev /rootfs/dev, etc. (with proc and sys at least) to be able to chro­ot from livecd to your root fs
  • chroot /rootfs
  • edit /etc/fstab and chan­ge UUIDs the­re (new ones you can get using blkid
  • do sudo dpkg-reconfigure -plow grub-pc to auto­ma­ti­cal­ly upgra­de grub con­fig files, just let it install to the drive(s) it was on
  • do update-initramfs -u so UUID sto­red insi­de ini­tramfs get upda­ted, too

Then you sho­uld be able to boot it.

[en] Fix PNG images dark in IE

IE can’t do any­thing right. If you save some gra­phi­cal ele­ments to PNG, and try to put them on an area with CSS-defi­ned color, the­re will be a dif­fe­ren­ce even if you used the same color in the PNG — IE ren­ders PNGs dar­ker than it sho­uld. The reason for this is misin­ter­pre­ta­tion of gAMA fra­me saved in PNGs that makes it possi­ble to bet­ter color-match pic­tu­res. The fix is to remo­ve this fra­me, and doing it on Ubun­tu is as easy as:

aptitude install pngcrush
cd your-graphics-directory
mkdir fixed
find . -type f -exec pngcrush -d fixed -rem cHRM -rem gAMA -rem iCCP -rem sRGB {} \;

Now you have a „fixed” direc­to­ry whe­re you have PNGs that will work pro­per­ly in IE (and are a bit smal­ler which is a nice side effect). If you’re sure they­’re ok, just do

mv fixed/* ./
rmdir fixed

Tha­t’s all.

[en] Fix irregularity of Java Timer and ScheduledThreadPoolExecutor

Using Java Timer class one can sche­du­le a task for recur­ring exe­cu­tion. Even tho­ugh Sche­du­led­Th­re­ad­Po­olE­xe­cu­tor makes it possi­ble to cre­ate timers with nano­se­cond reso­lu­tion (but bewa­re of under­ly­ing ope­ra­ting sys­tem clock pre­ci­sion!), regu­la­ri­ty of task exe­cu­tion is by default awful.

I have run into this once and had to expla­in the custo­mer that it’s not fixa­ble. When I measu­red the delay betwe­en timer exe­cu­tions, etc. it tur­ned out that doing as much as new Thread(runnable).start() usu­al­ly takes 1 – 5 mil­li­se­conds, but at times it takes two orders of magni­tu­de lon­ger: even half a second!

Same custo­mer, other pro­ject and this time I tho­ught of a reason for this beha­vio­ur: gar­ba­ge col­lec­tion. I star­ted with cal­ling System.gc() expli­ci­tly insi­de measu­red code and it takes 200 – 500 mil­li­se­conds! So it must be it.

Is the­re a solu­tion? Of cour­se the­re is. It’s cal­led The Con­cur­rent Low Pau­se Col­lec­tor and has been in Java sin­ce ver­sion 5. Read the lin­ked artic­le for many, many deta­ils, but shor­tly just add:

-XX:+UseConcMarkSweepGC

to the usu­al java ‑jar com­mand and the gar­ba­ge col­lec­tion will be done in paral­lel with your code exe­cu­tion. Of cour­se it’s no gol­den bul­let, it makes ove­rall per­for­man­ce wor­se (now inste­ad of 1 – 5 mil­li­se­conds, a sin­gle loop pass takes 4 – 10 mil­li­se­conds), but for this par­ti­cu­lar use, it makes Timer regu­la­ri­ty bet­ter by two orders of magnitude.

[en] Solution to SIL3124‑2 „no valid device”

SIL3124 is a PCI (as in old PCI, not PCI express) SATA-II con­trol­ler which I had to buy becau­se my NAS’ old Giga­by­te mother­bo­ard sup­ports (down­spe­eded) SATA-II dri­ves only to 750GB size. Of cour­se I got to know this AFTER buy­ing 1,5TB drive 😉

Any­way, it’s always uphill and even tho­ugh SIL3124 card sees the dri­ve and I’ve instal­led Ubun­tu Server with no pro­blems to it, I could­n’t boot the card. It kept say­ing „no valid devi­ce”. Turns out it has a RAID-only BIOS by default so if some­one — like me — wants to use it as an JBOD (Just a Bunch Of Disks) con­trol­ler, BIOS upgra­de is needed. How user frien­dly not to men­tion it in a — Czech-lan­gu­age — manual.

Of cour­se, being main­ly a Linux user with no CD- or DVD-dri­ve, I have it even more uphill. BIOS fla­shing tools are ava­ila­ble for Win­dows and DOS. Soooo the solu­tion is:

  1. Use HP USB Disk Sto­ra­ge For­mat Tool to cre­ate boota­ble DOS pen­dri­ve, here­’s Polish lan­gu­age tuto­rial: http://​forum​.purepc​.pl/​D​y​s​k​i​-​t​w​a​r​d​e​-​c​d​r​o​m​y​-​d​v​d​-​p​e​n​d​r​i​v​e​-​i​n​n​e​-​p​a​m​i​e​c​i​-​f​5​5​/​B​o​o​t​-​P​e​n​d​r​i​v​e​-​t​2​5​4​0​0​5​.​h​tml if You don’t spe­ak Polish, just google „boot pen­dri­ve dos”, in the tuto­rial is a link to Win98 boot files You might use.
  2. Down­lo­ad UPDFLASH and the newest BIOS zip from http://​www​.sili​co​ni​ma​ge​.com/​s​u​p​p​ort
  3. The zip file has more than one BIOS insi­de, read the README and see which one is „IDEBIOS or „non-RAID” BIOS. Copy the file toge­ther with UPDFLASH to the pendrive.
  4. Boot the PC with the PCI SATA Con­trol­ler from the pendrive.
  5. Run „upd­flash biosfile.bin”
  6. If you don’t have a UPS, pray to Athe­ist’s God™ that the­re­’s no blac­ko­ut during fla­shing process.
  7. Use mother­bo­ar­d’s (not SATA con­trol­le­r’s) BIOS to set Hard Dri­ve as first boot prio­ri­ty, make sure the­re­’s „Boota­ble Add-In Cards” ena­bled somewhere.
  8. Reset and enjoy boota­ble lar­ge drives.

Note: Dri­ve­’s UUIDs chan­ge becau­se of that so it’s best to do it BEFORE instal­ling Ubun­tu, other­wi­se You get a main­ta­nan­ce console.