Default user in WSL

The Windows Subsystem for Linux (WSL) defaults to running as the “root” user. In order to change that behavior, just create a Linux user.Let’s imagine this user is named “jdoe”. To have WSL start the session as “jdoe” instead of “root”, just run the following command from a “cmd.exe” window:

C:\Users\JohnDoe> lxrun /setdefaultuser jdoe

Take into account that running any running WSL will be killed inmmediately.

Turn Caps Lock into an additional Control key in Windows

I can’t remember when it was the last time I needed the Caps Lock key on my keyboard. For ages, I have been using support in Linux and Mac OS X to make Caps Lock behave as an additional Control key.

Windows doesn’t seem to have built-in support for doing this so I had to resort to an external utility named Ctrl2Cap by Mark Russinovich, available at http://technet.microsoft.com/en-us/sysinternals/bb897578.aspx. Ctrl2cap is a kernel-mode device driver that filters the system’s keyboard class driver in order to convert caps-lock characters into control characters. People like myself that migrated to NT from UNIX are used to having the control key located where the caps-lock key is on the standard PC keyboard, so a utility like this is essential for our editing well-being.

Another option which does not require installing any drivers (that might potentially cause harm) consists of applying a change to the Windows registry. I learnt about this technique from http://blog.horie.to/2012/06/make-capslock-additional-ctrl-in.html:

Modifying registries may cause system failures. Please take full responsibility for your actions.

  1. Run regedit.exe
  2. Create a new binary entry named “Scancode Map” under “HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlKeyboard Layout”
  3. Input following binary code and close regedit.exe
  4. 00 00 00 00 00 00 00 00
    03 00 00 00 1D 00 3A 00
    00 00 00 00 00 00 00 00

  5. Sign out, then sign in

Reverse scrolling direction in Windows

If you are used to Mac OS X Lion “natural” scrolling behavior, you might be interested in to how to emulate such behavior in Windows.

There is a registry setting named FlipFlopWheel that does allow reversing the scrolling direction, both vertical and horizontal. The exact name of the registry key depends on the HID of the mouse devices and, in computers with multiple input devices, there might be multiple entries.

Look for a key under HKEY_LOCAL_MACHINE that is named like SYSTEMCurrentControlSetEnumHID????????Device Parameters. Change the value for FlipFlopWheel from 0 to 1 to reverse vertical scrolling. In Windows 8, there’s an additional FlipFlopHScroll that allows reversing horizontal scrolling.

IPv6 stateless address configuration in Windows 7 uses randomization by default

Stateless autoconfiguration of IPv6 addresses in Windows 7 (and also Windows Vista) uses, by default, randomization. This is against section 4 of RFC 2464 that mandates that the network identifier part of the IPv6 address is derived from the 48-bit MAC address for Ethernet (and Wireless) interfaces:

4. Stateless Autoconfiguration

The Interface Identifier [AARCH] for an Ethernet interface is based on the EUI-64 identifier [EUI64] derived from the interface’s built-in 48-bit IEEE 802 address. The EUI-64 is formed as follows. (Canonical bit order is assumed throughout.)

The OUI of the Ethernet address (the first three octets) becomes the company_id of the EUI-64 (the first three octets). The fourth and fifth octets of the EUI are set to the fixed value FFFE hexadecimal. The last three octets of the Ethernet address become the last three octets of the EUI-64.

The Interface Identifier is then formed from the EUI-64 by complementing the “Universal/Local” (U/L) bit, which is the next-to-lowest order bit of the first octet of the EUI-64. Complementing this bit will generally change a 0 value to a 1, since an interface’s built-in address is expected to be from a universally administered address space and hence have a globally unique value. A universally administered IEEE 802 address or an EUI-64 is signified by a 0 in the U/L bit position, while a globally unique IPv6 Interface Identifier is signified by a 1 in the corresponding position. For further discussion on this point, see [AARCH].

For example, the Interface Identifier for an Ethernet interface whose built-in address is, in hexadecimal,

34-56-78-9A-BC-DE

would be

36-56-78-FF-FE-9A-BC-DE.

A different MAC address set manually or by software should not be used to derive the Interface Identifier. If such a MAC address must be used, its global uniqueness property should be reflected in the value of the U/L bit.

An IPv6 address prefix used for stateless autoconfiguration [ACONF] of an Ethernet interface must have a length of 64 bits.

The fact that Windows 7 doesn’t seem to adhere to this by default might create interoperability problems in networks where section 4 of RFC 2464 is assumed to be true. Linux, *BSD and Solaris map adhere to RFC 2464 by default, and hence many administrators statically create DNS AAAA RRs for such hosts. However, randomization in Windows makes this unfeasible.

A workaround consists of running the following command, with administrator privileges:

netsh interface ipv6 set global randomizeidentifiers=disabled

I’ve sent feedback to Microsoft asking if this is deliberate and why this decision was made in the first place. (Not sure if they will ever reply, though).

Do any of you have any insight on this?

Windows 7 Beta 1 + Apple = no sound

While testing Windows 7 on an Apple MacBook Pro system, I noticed that sound didn’t work at all. Of course, this was after I installed BootCamp drivers and everything was working (more or less as expected) except the sound.

What’s the solution? I found it here. In essence, the solution consists of running the RealTekSetup.exe binary from the Leopard DVD using “Troubleshoot Compatibility“, telling it that “The program worked in earlier versions of Windows” and that it worked fine in “Windows Vista“. After it has been installed no reboot it’s even needed!

Top 10 new features in Windows Server 2008

These are the Top 10 new features in Windows Server 2008: Is this innovation? Maybe. Let me go through them all:

  1. The self-healing NTFS file system:

    A self-healing NTFS file system sounds like a cool feature, but any modern journaling filesystem is pretty good at recovering from errors by replaying the journal (usually at mount time).

  2. Parallel session creation:

    Parallel session creation sounds like a minor improvement to Terminal Services in Windows. Basically, the fact that a Terminal Server can’t concurrently create new user sessions seems like a big deficiency to me. NoMachine’s NX and the old and good X11 system allow for concurrent user session creation since basically there is no writable, shared state between users/sessions. X11 authorization cookies are created in the user’s home directory and the session itself is abstracted by processes and some IPC resources.

  3. Clean service shutdown:

    To be honest here, a malfunctioning daemon could potentially slow down the shutdown of a UNIX system, so improving on this front sounds like a good idea. On the other side, how many times do you have to reboot a UNIX server? Hint: uptime.

  4. Kernel Transaction Manager:

    I’m not entirely familiar with Windows kernel internals, but this sounds like a cool feature. I’m not sure what UNIX systems already implement this, if at all.

  5. SMB2 network file system:

    It’s glad to know that the old, insecure and not very efficient SMB/CIFS network filesystem is being revamped. However, I am wondering what kind of changes is Microsoft introducing and how will they affect open source implementations like SAMBA. I don’t foresee any patent issues on this, though, since file system development (either local or networked) has stalled considerably during the last years, and even ZFS and Reiser4 only bring concepts but I wouldn’t call them revolutionary.

  6. Address Space Load Randomization (ASLR):

    I don’t see anything fascinating here. The Linux kernel has been sporting this with the introduction of Exec Shield.

  7. Windows Hardware Error Architecture (WHEA):

    This seems very Windows-centric, so I don’t see any real innovation here. I would call this another privative feature of an already privative operating system.

  8. Windows Server Virtualization:

    Nothing to see here. Xen support is extremely well integrated in Linux (read as in Red Hat Enterprise Linux, CentOS or SUSE Novell Enterprise) and NetBSD, and it offers support for paravirtualized and HVM-based virtualization. Xen has proven mature enough for production use, has lots of cool features and it’s open and free and has an exceptional performance. In fact, hypervisor-based virtualization had been in used by IBM’s POWER architecture for quite some time — IIRC starting with VM/370 — so no innovation here.

  9. PowerShell:

    Although a nice addition to Windows, UNIX has always had powerful shells like tcsh, zsh, bash or even PERL for years and also new scripting languages like Python or Ruby are starting to be used to develop more complex scripts.

    A powerful shell scripting environment has proven useful for automating tasks and administering systems. PowerShell sounds like the same tune to me.

  10. Server Core:

    Finally, it seems Microsoft starts to understand that useless and insecure features, like Windows Media Player, are only meant for desktop systems and not for servers. They cripple the operating system, increase complexity and bring nothing, so removing them completely is a good idea. It’s a pity, however, that it took Microsoft more than 10 years to realize what UNIX already had 40 years ago.

Conclusion

While many of the ideas and features commented here are good, I can’t seem to see much innovation here. I’m wondering how many patents did Microsoft file for such simple, tried-and-true ideas.

Windows Vista (y IV)

Definitivamente, tras unos cuantos intentos de conseguir mantener un sistema usable con Windows Vista Beta 2, he decidido desinstalarlo. La mayoría de las aplicaciones que necesito no funcionan:

  • NX client
  • Cygwin
  • VMware Server

Mi experiencia con Vista ha sido francamente desagradable. No sólo la instalación es horriblemente lenta, sino que el sistema es inestable, la mayoría de las aplicaciones no funcionan o no se instalan, consume una barbarie de recursos hardware, y el rendimiento del sistema es francamente penoso.

Por ello, vuelvo a ocupar los dos discos duros con un RAID-0 y Ubuntu Linux.

Quizá en otra ocasión, cuando Vista deje de ser algo más que una Beta de exhibición, vuelva a instalarlo para probar cómo se comporta con una carga de trabajo real. A día de hoy, para mí, es francamente inútil.

Windows Vista (III)

Con respecto al arranque dual, me ha costado un poco conseguir que funcionase correctamente, pero al final para haber quedado bastante bien. La idea consiste en instalar Windows Vista en el primer disco duro. No he conseguido convencerle de que se instale en una partición, y pretende abarcar la totalidad del disco duro. Una vez instalado, tras casi 1 hora, instalé SUSE 10.1 en el segundo disco duro, indicando al instalador YaST2 que colocase GRUB en el MBR del primer disco duro. Después sólo basta con añadir la siguiente entrada el fichero de configuración de GRUB:

title Windows Vista
   rootnoverify (hd0,0)
   makeactive
   chainloader +1

Otra de las peculiaridades que he encontrado es la desaparición del antiguo cargador de Windows, y su reemplazo por Boot Configuration Data (BCD), supuestamente un cargador renovado compatible con EFI. Sinceramente, no me parece nada del otro mundo, sobre todo si se compara con GRUB, máxime cuando las modificaciones a este cargador se deben realizar a través de la herramienta bcdedit.exe.

Como buen fan de los sistemas UNIX y GNU/Linux, he intentado instalar CygWin bajo Windows Vista Beta 2, aunque sin éxito. Para quien no lo sepa, CygWin es una colección de herramientas y librerías que permiten disfrutar de un entorno similar al intérprete de comandos de GNU/Linux:

Cygwin is a Linux-like environment for Windows. It consists of two parts:

  • A DLL (cygwin1.dll) which acts as a Linux API emulation layer providing substantial Linux API functionality.
  • A collection of tools, which provide Linux look and feel.

CygWin hace disponible el intérprete de comandos bash, el editor vim, el editor emacs, herramientas de gestión de procesos, como el comando ps, herramientas de manipulación de archivos, como ls, less, cat, grep o tail, etc.

Desgraciadamente, parece que el ejecutable bash.exe sufre los mismos problemas que el cliente NX de NoMachine, es decir, resulta imposible ejecutarlo sin obtener un error grave, y creo que el culpable es nuevamente el Address Space Layout Randomization. Curiosamente, esta característica se ha anunciado a bombo y platillo, pero es una facilidad que otros sistemas operativos y entornos llevan implementando bastante tiempo, como OpenBSD, PAX o las extensiones Exec Shield que, si no recuerdo mal, fueron los núcleos de Red Hat los primeros en incorporar.

Una de las aplicaciones que sí he conseguido hacer funcionar correctamente sobre Windows Vista es Synergy, una aplicación multiplataforma que permite compartir un teclado y un ratón entre varias máquinas. Synergy está disponible para Mac OS X, para GNU/Linux y para Windows, lo que me permite usar el teclado y el ratón del PowerBook G4 de 17″ para controlar el PowerBook G4 12″, el NEC Chrom@ de 15″, el Pentium IV y el Pentium III, sin tener que moverme del sitio.

Curiosamente, cuando se ejecuta una aplicación bajo la identidad de otro usuario (por ejemplo, el Administrador), Synergy deja de funcionar hasta que dicha aplicación no termina. Entiendo que al cambiar el contexto de ejecución a otro usuario, y dado que Synergy se ejecuta con las credenciales de un usuario y no como servicio, los eventos de teclado y ratón que genera Synergy no afectan a la nueva aplicación.

Windows Vista (II)

El administrador de dispositivos es prácticamente inutilizable: la lista de dispositivos se refresca casi constantemente, y en los momentos más inorportunos, por lo que casi siempre acabo haciendo clic derecho sobre la entrada incorrecta. Parece como si Windows no fuera capaz de detectar correctamente todos los dispositivos de mi equipo, y por ello la lista se refresca casi constantemente.

Ha sido necesario instalar el controlador de vídeo de nVidia para conseguir algo más de rendimiento en el apartado gráfico, pero a pesar de ello, el rendimiento sigue siendo poco óptimo, teniendo en cuenta que se trata de una nVidia GeForce 5200FX con 256MB de memoria. En este aspecto, el controlador de nVidia de Linux saca mejor rendimiento al subsistema gráfico, sobre todo con Xgl y aplicaciones OpenGL.

Aunque Windows Vista permite cambiar la resolución de las fuentes del sistema de 96ppp a 120ppp, el cambio requiere reiniciar el sistema, lo cual me resulta incomprensible, y algunas aplicaciones no se muestran bien, como el cliente NX: los tipos de letra de estas aplicaciones se amplian con respecto a su tamaño original, pero en lugar de verse de forma bien definida como en Mac OS X o Linux, se observan de forma borrosa, por lo que he optado por devolver la resolución de las fuentes nuevamente a 96ppp.

Con respecto al tema de la seguridad, casi cualquier cambio que hago en las preferencias del sistema provoca que aparezca un cuadro de diálogo solicitando mi permiso para llevar a cabo dicha operación. Lo que resulta curioso es que operaciones que requieren privilegios administrativos, como la reconfiguración de la red, se realizan sin preguntarme la contraseña del administrador, incluso aún cuando estoy trabajando con un usuario no privilegiado.

Parece que el cliente NX no funciona correctamente, y no sólo termina inesperadamente, sino que provoca que aparezca una miríada de ventanas indicándome sobre el error, e intentando buscar una solución (no sé muy bien cómo). Creo que el problema se debe a la introducción de Address Space Layout Randomization (ASLR) en la Beta 2 de Windows Vista, aunque no puedo estar totalmente seguro. De lo que sí estoy seguro es de que no está relacionado con Data Execution Prevention (DEP) ya que está habilitado para algunos servicios de Windows, y mi procesador no tiene soporte de NX por hardware.

Windows Vista (I)

Hace unos días que Microsoft me ha invitado a participar en la Beta 2 de Windows Vista en Español, a fin de ayudar a que la traducción de los mensajes, textos de ayuda, etc., sea lo más correcta posible.

Una famosa frase dice, “mantén a tus amigos cerca, y a tus enemigos más cerca aún”. Si bien es cierto que no soy un entusiasta de ninguno de los productos de Microsoft, empiezo a sentir interés en comprobar en primera persona exactamente qué novedades trae Windows Vista. Después de leer innumerables artículos, la impresión que tengo es que no hay absolutamente nada que Windows Vista implemente que no haya sido ya implementado en Linux o en Mac OS X. La mejor forma de comprobarlo es experimentarlo en primera persona.

Para ello, he tenido que deshacer mi configuración RAID-0 de mis dos discos duros y eliminar Linux, aunque sólo temporalmente, ya que no había forma alguna de convencer al instalador de Windows Vista de que intentara coexistir con el esquema de particiones que Linux utiliza. Una vez instalado Windows Vista, pienso volver a instalar SUSE Linux 10.1 con Xgl, aunque sea sólo para disfrutar de su escritorio espacial en 3D completamente acelerado mediante OpenGL.

La instalación de Windows Vista Beta 2 es un proceso extremadamente lento, y ligeramente engorroso, sobre todo en el aspecto del particionado: no ha habido forma de conseguir que Windows Vista se instalase en una partición de 32GB que tenía preparada para él, y he tenido que eliminar absolutamente todas las particiones del disco. Aunque es algo típico de Microsoft suponer que nadie nunca querrá usar otra cosa que no sea Windows o alguno de sus productos, no esperaba un comportamiento tan rígido y dictatorial, y es que versiones anteriores son mucho más tolerantes al respecto.

Una vez finalizada la instalación, el tiempo que empleado desde la pantalla de inicio hasta obtener un escritorio plenamente funcional llega casi al minuto, y es que la barra lateral, además de consumir demasiados recursos, enlentece aún más el proceso.

Una vez estable el sistema, veo que Windows Vista consume 591MB de memoria, aproximadamente el triple que lo que consume mi escritorio GNOME en Linux. La apariencia es realmente preciosa, y los efectos de transparencia quedan muy vistosos. Probaré a instalar los controladores de nVidia específicos porque no me puedo creer que la composición sea tan extremadamente lenta cuando con Xgl soy capaz de tener más de veinte ventanas abiertas, con transparencia, y con Windows Vista, cuando hay más de dos, el movimiento de las ventanas sobre el escritorio no es fluido. Por ejemplo, mover en Windows Vista una sola ventana a través del escritorio, dispara el consumo de procesador hasta el 80%, mientras que lo mismo con Xgl en Linux apenas hace que el consumo de CPU roce el 20%.