Monday, January 28, 2013

Windows on SSD

Made a new computer for my work place. It's not an upgrade, because the old one was not touched and completely replaced. I've got an ASUS motherboard (P8H77V-LE), an IvyBridge i7 CPU, plenty of memory, an Intel 520 series SSD for the system boot and a WD Black HDD for active work data.

To reduce the number of writing operation to the SSD, I moved some folders including my user profile to the HDD, and also instructed the system to create all new profiles there.

The latter is the most easy part, just change the registry value
HKLM\SOFTWARE\Microsoft\Windows NT\Current Version\ProfileList\ProfilesDirectory

To redirect all the other folders you need to create a junction between the expected location and the actual one. The full list of the folders which were moved to be located on the HDD:

C:\Users\%myname%\
C:\ProgramData\
C:\Windows\Logs\
C:\Windows\System32\winevt\
C:\Windows\ServiceProfiles\LocalService
C:\Windows\SoftwareDistribution\DataStore\

To move a folder I need to boot to the recovery console (reboot, F8, repair (if F8 does notwork, try F5))
In the repair console the drive letters are changed. The drive C: becomes E:

Important! If there more than two drives in the system, the target HDD could also change the letter. Make sure it's letter is the same in the recovery mode as in the normal operation mode! Unplug or disable (in the BIOS setup) all other drives.

Use the robust copy command which carefully copies all the directory structure:
robocopy /copyall /mir /xj E:\ProgramData\ D:\ProgramData\

after the command above successfully creates a directory mirror, rename the source directory (delete it if you are brave enough) and then make a junction (a link), using the following command:

mklink /J E:\ProgramData\ D:\ProgramData\

make sure, the ACL remains the same for the original and the junction, use the icacls command as follows (assume the current dir is E:\):


icacls E:\ProgramData\ /save ProgramData.acl
- before you put the original away

icacls . /restore ProgramData.acl
- after you have created the junction

Directories like the following can't be safely moved, windows does not even boot:

C:\Windows\System32\config
C:\Windows\security

 Also do the following:

1. Direct the %TEMP% and %TMP% environment variable to a HDD folder.
2. Make the page file on the HDD as well. Even if you have a lot of RAM, the page file is still required.

Use windows' Resource Monitor to check, that most of writes now go to the D: drive (HDD). Use the Sysinternals' ProcMon to collect a statistic about file operations and make decision what could be also moved to the HDD.

Sunday, December 30, 2012

MacBook Pro

Well, I've got a MacBook Pro. Let's see.
13" Core i5 2.5GHz, 4GB, 500GB - $1200
$400 more expensive as a windows notebook with the same hardware.
Does it worth the money?
Let's see…

Bad things:

Hardware:
The whole piece aluminum case rather bad than good. Too sharp edges. But I like that I can hold the book by only one hand not being afraid that it will bend and broke.

My home network was not recognized during the setup. It was found later, though.
USB mouse did not work after the book woke up from sleep.

OS X:
I hate the way which the open window icons piles on each other. Looks disgusting. Found how to change that, likely!
The only way to install an app to drag it?

Phonetic keyboard layout is the most stupiedst possible. I hate those who made it.


What I like:

Hardware:
Keyboard work smoothly and fine to touch
There are no speakers in sight, but the sound is clear, nice.
The display is good quality (Not the best, though.). Shows almost the same quality being observed from different angles.

OS X:
I absolutely like that almost every command has a shortcut. Sometimes the key combinations are quite difficult to remember, but still. Would be nice to have shortcuts on the menus as well.


Thursday, November 22, 2012

Speed up virtual android

To run the android emulator fast and smooth - use an x86 image with hardware visualization enabled.
To enable the virtualization: on windows, simple just install the "Intel x86 Emulator Accelerator (HAZM)". The install package could be downloaded using the Android SDK Manager.

On Linux (Debian) make sure the following packages are installed:
qemu-kvm, libvirt-bin

To run the emulator as a kernel-based virtual machine, execute:

emulator-x86 -avd -kernel android-sdk-linux_x86/system-images/android-16/x86/kernel-qemu -qemu -m 512 -enable-kvm

Wednesday, November 21, 2012

Endianness

How to memorize what the Big-endian is and what the Little-endian is?
(The decision to use that meaningless names only in favor of J. Swift talent was quite stupid in the first place.)

So, here's a "simple" rule:
Let's say that the "end" is the starting byte of the memory word (lowest address).
Then "Little" will mean the less-significant, i.e. little part of the number is located at that first byte end.
In contrary, "Big" will mean the most-significant, i.e. biggest part of the number is located at the end  (the first byte).

How to memorize which architecture uses which notation?
The PC which costs a little is based on the x86 architecture which is Little-endian.
Workstations, like SPARC, SGI cost big money, and also they are Big-endian.

Crypted Jelly Bean fix

Android v4.2 changed default provider for SecureRandom. Because of that the Cipher throws this exception on v4.2: BadPaddingException: pad block corrupted.

The solution is quite simple. Just add explicitly specified provider as the second parameter of the SecureRandom.getInstance() method:

 SecureRandom sr = SecureRandom.getInstance( "SHA1PRNG", "Crypto" );

Read more here

Tuesday, November 20, 2012

Depricate an IP address

Say, a server has a number of IP addresses, but we don't want some addresses to be used as outbound.

ipconfig /all   gives us which address is preferred:

 Autoconfiguration Enabled . . . . : Yes
 IPv4 Address. . . . . . . . . . . : 2.68.18.2(Preferred)
 Subnet Mask . . . . . . . . . . . : 255.255.255.248
 IPv4 Address. . . . . . . . . . . : 2.68.18.3(Preferred)
 Subnet Mask . . . . . . . . . . . : 255.255.255.248


To make an address not preferred, remove it from the interface and recreate it again using the netsh:
 
interface ipv4 add address LAN 2.68.18.2 mask=255.255.255.248 preferredlifetime=0


keyboard switching utility

Updated the language switching utility
This utility assigns mostly unused the right "windows" key to switch between the system's languages.