Wednesday 19 July 2017

Convert Windows 7 ISO/Disk to another version and/or OEM

You have a laptop that had Windows preinstalled and still has a sticker on it with the Product key for that OEM installation. You want to install it again on a new SSD (for example).

You need an OEM version of Windows 7 Home/Professional/Ultimate/... but you have only an ISO/Disk from other Windows 7 version and/or not OEM.

The following procedure can be used for any Windows 7 to Windows 7 conversion be it Ultimate,Professional,HomePremium,HomeBasic,Starter and Retail or OEM. I am not sure about the x86 vs x64, that's why I just took care that the Windows 7 kit I started from is for the same architecture as I needed.


On Ubuntu: (FAILED ! - just adapted ImgBurn's parameters given here: http://forum.imgburn.com/index.php?/topic/11194-how-to-create-a-windows-vista-7-8-installation-disc-bootable-using-imgburn/, but DVD did not boot, so I expect it has to do with the hexadecimal notation needed in k3b. As the process of building a DVD is quite lengthy, I did not try tweaking the parameters and burn again.)

Windows 7 installation DVDs are UDF and the very intuitive ISO Master under Ubuntu (as per ver. 16.04) does not support it. Therefore we need to use more cumbersome (personal opinion, of course :-) k3b (install it from Ubuntu software).
Steps:
- extract the files out of the Windows 7 iso using archive manager. If you have the dvd, copy them from the Windows dvd to a directory.
- modify the sources/ei.cfg as needed. For example, for a Windows 7 Professional OEM retail, my ei.cfg looked like this:

[EditionID]
Professional
[Channel]
OEM
[VL]
0
Other options for your particular case can be seen here: http://www.askvg.com/how-to-choose-desired-windows-7-edition-version-during-setup/


- repack the file in a iso using k3b. Very important is to have the boot options right. Here is how mine looked:


- create the iso (or burn cd) and get to the Windows installation



On Windows:

- use 7zip to extract the files from the Windows iso
- modify the sources/ei.cfg as needed. For example, for a Windows 7 Professional OEM retail, my ei.cfg looked like this:

[EditionID]
Professional
[Channel]
OEM
[VL]
0
Other options for your particular case can be seen here: http://www.askvg.com/how-to-choose-desired-windows-7-edition-version-during-setup/

- repack the file as an iso (or directly burn it on disk) using ImgBurn (free!). As for the boot options, here they are, explained much better:
http://forum.imgburn.com/index.php?/topic/11194-how-to-create-a-windows-vista-7-8-installation-disc-bootable-using-imgburn/
-  create the iso (or burn cd directly) and get to the Windows installation


Final notes:
- in my case, I had to do the Windows activation over the phone, no operator, just entering a lot of numbers and getting back a bunch. As the COE label on the laptop was genuine, everything went smooth.
I don't know however how many times one can do this reactivation... I suppose it is limited.

Friday 9 September 2016

Installing megatools on CentOS 6

In case you wanted to install the megatools command line client for Mega.co.nz and you've run into this error:

checking for GLIB - version >= 2.32.0... no
*** Could not run GLIB test program, checking why...
*** The test program failed to compile or link. See the file config.log for the
*** exact error that occured. This usually means GLIB is incorrectly installed.
configure: error: Glib 2.32.0 or later is required to build megatools


this is what you need to do (kudos should go to: Mike Miao) :

1. Make sure you have all the dependencies needed for MegaTools installed:

yum install gcc make  libcurl-devel openssl-devel gmp-devel tar libffi-devel gettext-devel



2. Install the 2.32 version of the glib:

1:  mkdir glib-source  
2:  cd glib-source/  
3:  wget http://ftp.gnome.org/pub/GNOME/sources/glib/2.32/glib-2.32.4.tar.xz  
4:  tar zxf glib-2.32.4.tar.xz  
5:  cd glib-2.32.4/  
6:  ./configure --prefix=/usr/local/glib-2.32
8:  make  
9:  make install  

As you can see, I preferred to install Glib 2.32 all in one directory, to avoid any mixing with the main Glib version that is shipped with CentOS. So, all files belonging to this library were installed in /usr/local/glib-2.32

3. Then, retry configuring and installing megatools, as follows:

1:  cd megatools-source  
2:  export LD_LIBRARY_PATH=/usr/local/glib-2.32/lib/  
3:  export PKG_CONFIG_PATH=/usr/local/glib-2.32/lib/pkgconfig  
4:  ./configure  
5:  make  
6:  make check  
7:  make install  



You are all set !

More instructions in the help pages of the command tools or even on: Mike Miao's page that inspired this )

Tuesday 23 February 2016

Ubuntu linux: how to restrict a graphic tablet to only one monitor (in a dual monitor setup ;)



I have 2 monitors that are placed on top of each other, like this:

My graphical tablet (Genius EasyPen i405X) is covering by default the entire (summed-up) area, which means that only about half of the tablet is usable for a MyPaint drawing that is opened only on the Benq monitor.


What I want to do is to restrict the tablet movement only to Benq, ie: tablet's physical margins should correspond to Benq ones.

Let's get the needed parameters. The monitors resolution and offset can be seen by launching xrandr in command line:

optimus:~$ xrandr
Screen 0: minimum 320 x 200, current ...
LVDS connected (normal left inverted right x axis y axis)
   1366x768      60.02 +
   1280x720      59.86 
   ... 

480 x 1142, maximum 16384 x 16384HDMI-0 connected primary 1920x1080+338+1080 (normal left inverted right x axis y axis) 598mm x 336mm
   1920x1080     60.00*+  50.00    59.94 
   1920x1080i    60.00    50.00    59.94 
   1680x1050     59.88 
   ...
VGA-0 connected 2560x1080+0+0 (normal left inverted right x axis y axis) 673mm x 284mm
   2560x1080     59.98*+
   1920x1080     60.00 
   1680x1050     59.95 
   ... 
The first screen is laptop's one that is inactive. Then, each monitor can be found based on the cable/socket it's on. In my case Benq is on HDMI and AOC is on VGA.

Xrandr displays all possible resolutions for each monitor but we need only the one that is active, marked with * (btw, the "+" means it is the recommended resolution). I have trimmed many of those for brevity and in fact we need only the first line of each, the long one where we have the resolution and also the offset.
As you can see (see also the picture) AOC (on VGA) has a resolution of 2560x1080 and it has offset 0 and 0 (it's top left corner is in the zero of the axis system).
More interesting for me, BenQ has resolution of 1920x1080 and horizontal offset 338, while the vertical one is 1080, i.e. Benq is lower that the 0 axis point with exactly the height of AOC.
(There are some distances in reality between monitor margins, but obviously these are not taken into account.)

So, let's write all down:


TotalHsize: 2560 (i.e. the Horizontal resolution of AOC, that "includes" BenQ)
TotalVsize: 2160 (i.e. the summed up Vertical resolution of both, as they are stacked: 1080+1080)
BenqHsize: 1920
BenqVsize: 1080
BenqHoffset: 338
BenqVoffset: 1080

These are all the input data we need. Now, let's calculate the proportions (or relative values):

BenqRelHsize = BenqHsize / TotalHsize = 1920 / 2560 = 0.75
BenqRelVsize = BenqVsize / TotalVsize = 1080 / 2160 = 0.5
BenqRelHoffset = BenqHoffset / TotalHsize = 338 / 2560 = 0.13203125
BenqRelVoffset = BenqVoffset / TotalVsize = 1080 / 2160 = 0.5


So, finally, the command we should launch looks like this:

xinput set-prop "Tablet name as detected by xinput --list" --type=float "Coordinate Transformation Matrix" RelHsize 0 RelHoffset 0 RelVsize RelVoffset 0 0 1

which in my case, for Benq, is:

xinput set-prop "Genius EasyPen i405X" --type=float "Coordinate Transformation Matrix" 0.75 0 0.13203125 0 0.5 0.5 0 0 1

Launch it and it's working!

This will not survive a reboot so you should do something about it if you care. Personally, I have just added the above line in a script that I run each time I use the tablet (which is quite rare in my case).

For more info see the sources I used:


http://ubuntuforums.org/showthread.php?t=1656089&s=ca2da10a736e5ce13dcd20da11fdd854&p=10330180#post10330180

http://ubuntuforums.org/archive/index.php/t-1571365.html 






Friday 13 February 2015

Micro$oft's contribution to the world (the pictures are taken by me, the films are on youtube)

Everything started here:




... then, it spread throughout the world, because "Nobody was fired for buying Microsoft".

So now it is in tram stations (Bucharest, Romania)...




... ATMs (ING, Bucharest, Romania)...



 ... Ikea (Palo Alto, California) ...



... elevators (Palo Alto, California)....



... restaurants (Budapest, Hungary)...



... airports (Budapest, Hungary) ...




Then, another memorable moment when they launched their tablet:




But the marketing and brainwashing machine is working:



... so, happy windows-ing!

Tuesday 21 October 2014

MAC based licensing in VMWare and cloud

The problem:

The requirement: To move a linux software product licensed by MAC, from the physical machine into the virtualized environment or the cloud and to have it still running.

Solutions:

1. Contact the software vendor and get a new license based on the new MAC address in the virtualized environment. 

That's the perfect solution in case the software vendor is NOT a mother-fu***r, as hungry for money as a fat kid for chocolate (this is not mine, it is from a song :)

In my case, I wasn't lucky and they asked for money for this operation "not covered by the license".
Just a small piece of info: the software I talk about costs ~20,000 euro and the support for it is "just" 16% from the cost, per year. Define greediness...


2. Change the MAC address of your main network card in VMWare

This can be done in Linux by adding (or modifying) the HWADDR=aa:bb:cc:... / MACADDR=aa:bb:cc:.. configuration options in /etc/sysconfig/network-scripts/ifcfg-eth0 as to indicate the new MAC address.

I added them both but in my VMWare Workstation 10 environment, this didn't work until I modified the advanced parameters of the network interface and put there the new MAC too.

On my Ubuntu host having VMWare 10 and CentOS as guest VM, this is done in:
VM Settings->Hardware->Network Adapter->Advanced->MAC Address

Then it worked perfect.

3. Create a dummy interface with the needed MAC address

Then I moved to the cloud, where things were not totally in my control. The cloud guys didn't know how (or didn't bother) to set the MAC for me, saying that OnApp virtualization doesn't accept this. Maybe they are actually right, but wat to do wat to do...

I followed this tutorial: http://www.question-defense.com/2012/11/26/linux-create-fake-ethernet-interface but it doesn't work because it has some typos and wrong indications, so I thought I should re-publish it here, edited. So: how to create a dummy interface on your CentOS machine, just to use its MAC address for licensing purposes:

Assumptions:

- you will create a new fake / dummy interface, named eth1 with MAC address: aa:bb:cc:dd:ee:ff . If you need another interface number, please modify in the code below. Also replace aa:bb:cc.... with your own MAC address you need to clone.

Step 1

Add the following lines to /etc/rc.d/init.d/network , on top if the file.
/sbin/modprobe dummy
/sbin/ip link set name eth1 dev dummy0
/sbin/ifconfig eth1 hw ether AA:BB:CC:DD:EE:FF

Notes:

  • the tutorial linked above, indicates you should put this in /etc/rc.local to work, which is WRONG. /etc/rc.local is executed after /etc/rc.d/init.d/network, and so, you'll get an error at boot time, saying: device eth1 does not seem to be present, delaying initialization
  • I know that altering /etc/rc.d/init.d/network it is not ok in case of upgrades, etc. In my case it is ok because I have no intention to upgrade it ever (the software works anyway only on CentOS 5 so I need to keep it 5 and not upgraded it to the latest 7). Still, if you know about a script similar to /etc/rc.local that executes before the others in /etc/rc.d/init.d/, I'd like to hear from you!

Step 2

Add to /etc/sysconfig/network-scripts a new file named ifcfg-eht1. Actually, just copy ifcfg-eth0 with the new name, then edit the ifcfg-eth1:
cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth1

After editing it, my ifcfg-eth1 looks like:
DEVICE="eth1"
ONBOOT="yes"

So only a couple of things were mentioned: that is named eth1 and that it should be brought up when system starts. Nothing else, since it will be unused for networking; just to have it in the system with a MAC. The tutorial linked above, misses this step.

Step 3

Reboot the system or reload networking. Then, issue a ifconfig at command prompt and admire your new MAC faked interface.

Notes:

  • If you follow the boot messages you'll see that there is a warning though when it tries to bring up eth1: RTNETLINK answers: no such device
    Fortunately, it is just a warning and the eth1 is present in ifconfig afterwards. Still, if anyone knows how to get rid of this warning too, I'd be happy to update this post.

4. Fake your MAC dynamically, per request

Instead of doing something definitive like creating a new network interface or so, what about reporting a fake MAC to those apps that are known to ask for it?


All are some type of wrappers that launch the executable and intercepts any calls to the SIOCGIFHWADDR (the low level C function returning the real MAC Address), replacing it with the one we want.

It happens that I've liked fakeuname that allows for faking also hostname, so that's the one I tried (not that the others are not ok!). To make it work you need to:

Step 1

Download the fakeuname.c file and save it somewhere.

Step 2

Compile the fakeuname.c program into a dynamic libfakeuname.so library, as instructed in the .c file itself:

gcc -o fakeuname.o -c -fPIC -Wall fakeuname.c
gcc -o libfakeuname.so -shared -W1,export-dynamic fakeuname.o -ldl

Step 3

Prepare the environment a bit, before launching your command that takes into account the MAC address, like this:

export LD_PRELOAD=/tmp/libfakeuname.so
export FAKEMACADDR=AA:BB:CC:DD:EE:FF

Step 4

Launch your command and you'll see that magically it takes the new MAC address from the FAKEMACADDR environment variable.

Step 5

Make the exports of the above variable part of your bashrc, profile,... whatever init script you use for launching your server (automatically or manually). Maybe even the /etc/rc.local is now very good to be used for this.