Monday, April 23, 2012

Do not buy Intel's Ivy Bridge CPU!

Intel just launched new CPU line - Ivy Bridge family. There is a problem however. With shiny new CPU you will buy a back-door for your PC. Intel calls the back-door "Intel Insider". 
Intel Insider is DRM. More precisely it allows third-parties to remotely control your PC when the third-parties wish to.
This anti-feature first arose in Sandy Bridge family. It was warmly greeted by Intel customers. In fact it was so warm that many Intel customers become AMD customers.
Returning to Ivy Bridge. Intel listened to MAFFIA and not to its customers. Intel Insider is still present in those new CPUs.
So, If you want to control your PC, do not buy Ivy Bridge!

Wednesday, April 4, 2012

Aligning partitions, lvm and encrypted volumes on SSD

The disk: OCZ Vertex3 120GB
The goals:
  • partition disk with GPT
  • prepare disk to host multiple Linux-es (multiboot)
  • setup an LVM
  • make a few encrypted logical volumes
  • make the whole stack work fast, namely align all :)
The tool: sysresccd (on USB stick)

The main idea is to make sure every layer aligns to SSD erase block.
If there is any error on any level the whole work is probably wasted. I'm not an expert, so, I can be wrong :)

Erase block size is probably 2 MiB. The post on forum states 2 MB, but I assume they actually mean 2 MiB. This is very important number. Every step must take it into account. As extra caution measure I would align everything to 4 MiB.

1. Creating GPT partition table
Warning! This destroys all data on the drive!
Boot from our sysresccd, and load gui.
Start GRparted.
Device > Create Partition table... > Advanced > select "gpt" > Apply

2. Creating aligned partitions
We are still using GParted.
2.1. Unallocated space at the beginning of the drive. The purpose of this space is to hold partition table. I'm giving it 8 MiB (dividable by 4 MiB). To create such space you need to create the first partition which starts at 8 MiB. I'm not sure if this step is need, I've read different opinions about this. But I don't worry too much about this, it's just 8 MiB after all :)
2.2. Bios boot partition. 32 MiB (dividable by 4 MiB), fat32, flagged as "bios_grub" (this is important). Wikipedia article states a few MiBs should be fine, but Sabayon howto recommends 32MiB. I'm not greedy, so I choose the latter. Again, it must be flagged as "bios_grub". It might be good idea to add labels to partitions. I named this one "groob_boot".
2.3. Multiple partitions for /boot volumes of multiple Linux-es (each Linux will have its own /boot). 400 MiB (dividable by 4 MiB), ext2 each. This is where grub2 will put its staff. I'm labeling them like "ubuntu_boot", "sabayon_boot", etc. I created 5 such partitions, which is probably a little bit overkill. But who knows :)

3. Creating physical volumes (which will host my logical volume group)
Physical volume contains metadata  area at the beginning of the volume followed by actual data area. Here it's important to start your data area aligned. So, we use --dataalignment option with value 4m (which is 4 MiB):
pvcreate --dataalignment 4m /dev/sda7
--dataalignment option means that data area will start to a multiple of its value. 
Following command will show you where the data area starts.
pvs -o +pe_start

4. Creating logical volume group
Due to physical volumes were created with  --dataalignment option, we need set physical extent size for volume group. To do so we pass -s option to vgcreate. As you can see I'm passing the same 4 MiB:
vgcreate -s 4m vg_main /dev/sda7

5. Creating logical volumes
Nothing special here. E.g.:
lvcreate -L 10G -n lv_ubuntu_root vg_main

6. Creating encrypted containers
Next we setup an encrypted volume above logical volume. According to this mail the encrypted container also should be aligned. To do so we pass --align-payload option which value is in 512 bytes sectors. To align to 4 MiB we do:
cryptsetup luksFormat --align-payload=8192 /dev/vg_main/lv_ubuntu

7. Creating file systems
The post in OCZ  forum states that tuning ext3 and ext4 "probably won't effect performance". One of benchmarks I've found shows questionable effect from such tuning. Arch wiki page omits the tuning also. So, I'm not using it :)

Monday, March 26, 2012

Idea 11 does not supprot TestNG 6.4

In one of my project I've started using TestNG as unit testing framework. The project itself is Maven based. So, obviously I added appropriate dependency to my pom file:
        <dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.4</version>
<scope>test</scope>
</dependency>
As you can see I've used the latest TestNG version available at this time, which is 6.4.
But when I was trying to run any test from Idea, I saw following error:
java.net.SocketException: Broken pipe
    at java.net.SocketOutputStream.socketWrite0(Native Method)
    at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
    at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
    at java.io.ObjectOutputStream$BlockDataOutputStream.drain(ObjectOutputStream.java:1838)
    at java.io.ObjectOutputStream$BlockDataOutputStream.setBlockDataMode(ObjectOutputStream.java:1747)
    at java.io.ObjectOutputStream.(ObjectOutputStream.java:226)
    at org.testng.remote.strprotocol.SerializedMessageSender.sendMessage(SerializedMessageSender.java:24)
    at org.testng.remote.strprotocol.MessageHub.sendMessage(MessageHub.java:44)
    at org.testng.remote.RemoteTestNG$RemoteSuiteListener.onFinish(RemoteTestNG.java:248)
    at org.testng.SuiteRunner.invokeListeners(SuiteRunner.java:200)
    at org.testng.SuiteRunner.run(SuiteRunner.java:243)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:87)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1170)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1095)
    at org.testng.TestNG.run(TestNG.java:1007)
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:109)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:202)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:173)
    at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:106)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
The error is strange and there is no my code in the stack trace. Also, test was finishing fine if run by maven. This hints that there is something wrong. And this something is IDE-related.
I used a linux answering machine to find out what is wrong. The answer was found very quickly: Idea 11 does not support TestNG 6.4. The workaround is to downgrade TestNG version to 6.3.1. I did just that and the problem vanished :)

P.S. I'm still confident that Idea is the best java IDE :p

Friday, January 27, 2012

Downgrade svn from 1.6 to 1.7

I'm using a Sabayon as my primary OS now. It's a rolling distro. And it fairly quickly incorporates latest changes from mainline projects.
Few weeks ago among other updates subversion was upgraded from 1.6 to 1.7. At first there were no problems, because I mainly used command line svn client. I upgraded my working copies to 1.7 and was happy.
The problem started to arise when I tried to work with upgraded working copy from my IDE - Idea. The first problem was that Idea does not support subversion 1.7. And will not support it for a few more month. 
So, I tried to downgrade subversion package on my OS. This failed, because 1.6 was removed from repository. 
There was a chance to build 1.6 from sources. But I prefer not to mix binary and compiled from sources packages. 
I ended up with solution suggested on stackoverflow. I used another OS (Ubuntu) on my multi-boot machine which still has subversion 1.6. From there I deleted a subversion folders from my projects. Which is easy in subversion 1.7 ;) Then I made a checkout to existing projects. This allowed me to not loose any changes. Then I rebooted to my primary OS and used subversion from IDE only.

Saturday, September 3, 2011

Fixing UI font in Idea

Recently I switched my Linux OS from Ubuntu to Sabayon. And I've noticed the UI fonts of Idea (many java developers would agree IntelliJ Idea is the best IDE) are bad. Probably something related to anti-aliasing went wrong. The fix is easy, just add following line to your {idea-installation-directory}/bin/idea.vmoptions:
-Dawt.useSystemAAFontSettings=on

Thursday, July 21, 2011

Updating versionCode and versionNumber in Android manifest via Gradle

I'm working on Android project which has multiple builds for different customers.
Each build is organized as separate project and is build via Ant script. The problem is that building all those builds and updating versionCode and versionNumber is all manifest files takes a lot of time. So, I decided to use some tool to this for me. Yes, I'm a bit lazy :)
I've chosen Gradle. It leverages the power of Groovy and is able to call Ant scripts.
Groovy has great tools to work with XML, like XmlSlurper. So, updating versionCode and versionNumber in Android manifest files seemed easy. Unfortunately after significant amount of time all I got was ugly formatted Android manifest with tag0 namespaces :(
Then I put XmlSlurper aside and used String.replaceAll(Pattern pattern, String replacement) method. It took me about 5 minutes to do all replacements :)

Sunday, July 4, 2010

Goodbye to Firefox Sync and welcome back to Xmarks

Some time ago I was using Xmarks for bookmark synchronization. Then I switched to Firefox Sync. I used only Firefox and only on Linux powered machines. Firefox Sync worked perfectly and is synchronized not only bookmarks, but also other useful things like history.
But with starting from Firefox Sync 1.2.3 (it was called Weave Sync back then) it failed to synchronize bookmarks on x64 Linux. The problem was still present in 1.3 as well as in latest 1.4.
So, I gave up and switched back to Xmarks. The latter doesn't have many fancy features. But at least it works.