Thursday, February 8, 2018

Here is how you move an individual user's profile folder in Windows 7+

In Windows 7 and higher, all users' profile folders (similar to users' home folders in UNIX systems) are located under `C:\Users\` (similar to `/home/`).
There are many articles talking about how you can move the entire "Users" folder to a different drive other than `C:`.

However, it has been hard for me to figure out how to move only one specific user's profile folder out of `C:\Users\` without touching those of other users.
This could be useful when I want to separate the profiles of certain users from the others.
For example, on a lab machine, I want to encrypt the system drive with BitLocker. This will also encrypt the user profile of my own account which is an administrator.
However, at the same time I would like to leave the profiles of some other users (e.g. a customized guest account with persistent settings) unencrypted so they can retrieve their data later from the hard drive without me, even using a different machine.

This is very straight forward in UNIX systems because the home folder location information is part of `/etc/passwd`.

Therefore the first thing that I tried was "Local Users and Groups" in "Computer Management". It appears to be promising -- basically I can find my user in the list of local users:

(Image expired...)

And there are two text-boxes in the user's properties:

(Image expired...)

However, as I annotated in the figure, none of these actually servers the purpose.
If I fill in any or both (yes, I tried all three combinations) of these two text-boxes with the desired path (e.g. `C:\desired\profile\folder\path\`), the next time the target users logs in he receives a warning that Windows could not find his profile folder hence is using a temporary one.
At the same time, an empty folder named with the desired path string plus ".V6" is created (e.g. `C:\desired\profile\folder\path.V6\`), and I have to first gain ownership of that folder before I could delete it.
This does not work even if I have moved the user's original profile folder from `C:\Users\` to that desired path.

Here is what actually works --
The profile path is stored in the system registry in `HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\S-1-5-*\ProfileImagePath`. That `S-1-5-*` is the internal user ID associated with the target user which I have to click on each to figure out which is the corresponding one.

(Image expired...)

Note that this key in registry only exists after the target user has logged in successfully for at least once (i.e. its user profile has been created under `C:\Users\`).
After I change the path to the desired path, I also need to use the "Administrator: Command Prompt" (i.e. run "Command Prompt" as Administrator), and move the user's profile folder from `C:\Users\` to the desired path. The syntax is `move SOURCE DESTINATION`, e.g.

move C:\Users\user_name C:\desired\profile\folder\path

As long as the destination is consistent with the one I set earlier in the registry, the migration is successful; the target user will log in with no hassle and use the new profile path from now on.

The complaint here is: Why in the hell does Windows have the two text-boxes in the management console for local users to confuse us?
Possible excuse: It is probably some backward compatible feature. Materials that I found seem to say those boxes are for users whose profiles are located on other machines in the local network.
I do not care though...

Import a VM on VMware ESXi server with vSphere Client 6.0

Okay, so this is the second post in the "funky design" series.
I am writing these down, just in case that I forget about them myself in the future.

With vSphere Client 6.0, creating a VM is relatively easy, just as easy as how you achieve it in VMware Player or VMware Workstation.

(Image expired...)

I would expect importing a VM to be done in the same way, but I was totally wrong on this. I searched the client UI for quite a while but did not find anything related to importing.
What is importing?
After I transfer the files of a VM from one ESXi server to the other, I need to be able to edit it and run it. There needs to be some way to let the new ESXi server know about its existence.

Later I learned this from Google --
First, I need to open the data-store browser by right-click on the data-store in the "summary" page, which is anti-intuition enough...

(Image expired...)

Second, I need to find the file that I copied to this ESXi server, manually select the ".vmx" file, and click the "add to inventory" button.

(Image expired...)

Good job...

Manage permissions of roles on VMware ESXi server with vSphere Client 6.0

First of all, VMware ESXi is at v6.5 at the time this post is composed. However, it seems that VMware has dropped the development of vSphere Client which has been a powerful tool to manage ESXi servers.
Now the latest version of vSphere Client one can get is v6.0 Update 3 (5112508), and the download link can be found in VMware KB: Download URLs for VMware vSphere Client (2089791).

Complaint 1: The web UI shipped with ESXi v6.5 does not work with Chrome (the latest version as of Jan 2018). I get an exception pop-up immediately after I log in. It prevents future interactions and only allows me to reload the log in page which will simply lead to the same exception again. No screen-shot for this because I do not have Chrome on the machine I am currently using, but I believe a lot of you might be using Chrome...

I really think vSphere Client is MUCH MORE stable than the web UI. So sad that they seem to have dropped the development of vSphere Client.
Note that vSphere Client v6.0 can edit the settings of a VM only if the VM was created compatible with v11 or lower.

Complaint 2: If you edit the settings of any virtual machine in the web UI for more than once, including when you create it, the form in the web UI will be filled up with garbage strings and integers (e.g. RAM size becoming some negative number) that you definitely do not want to risk continuing with the edit.

Of course, I totally understand that web-based management systems are much easier to design and maintain. Actually, vSphere Client only works for Windows systems -- those who use macOS or Linux will have to use the web UI or use another VM (to run Windows) to manage the VM host (ESXi server).

Fortunately, I have a Windows 10 machine, so I am still able to run vSphere Client v6.0.
However, I really had a hard time figuring out how to manage users and roles with the client.

(Image expired...)

Management of users and permission can be access in "inventory".
In "users", I can create/delete users;
In "permissions", I can assign roles to the users.
But wait -- how do I manage the roles?

I searched Google and here is what I found:
First, I need to go back to the "home" page which I do not even know about its existence before this; then click on "roles".

(Image expired...)

On the "roles" page, I can then add and edit roles if I have enough permissions to do so.

(Image expired...)

Complaint 3: I know this does not sound very complicated, but it is really anti-intuition to me, i.e. why this function is so far away from other related functions in the client software. I do not quite understand the thoughts of who designed this client. Honestly, I think some times it could be very helpful if the entrance of some function of the software appears multiple times in different places, so it is easier to find.

Anyway, more complaints are coming in the next post.

Think twice before you buy the Edimax EW-7811Un dongle

This is just a complaint...
I think everyone who is thinking of buying a tiny Wi-Fi dongle should really think twice, especially those who is planning to use it on a Linux machine.

Edimax EW-7811Un
During the past three years working with it I got mostly just headaches.
It is slow (approximately 20 Mbps in my case) and it creates a lot of compatibility issues with the built-in Wi-Fi driver of Raspbian, Ubuntu 14.04 LTS, Ubuntu 16.04 LTS, and CentOS 7.

You are worth a better dongle.

Wednesday, November 15, 2017

Linux built-in driver fails for Edimax EW-7811Un [Realtek RTL8188CUS]

It seems that I have been struggling with this small piece of hardware for years; and it has been giving me surprises all the time.

Yes, I am talking I about this Wi-Fi dongle again:

Edimax EW-7811Un
While it still appears to be one of the best sellers on Amazon, a lot of people have had problems with it when using with Linux systems.

Recently the critical problem is the intermittent connection issue which occurs on a lot of Wi-Fi adapters including some of the RTL models. https://www.google.com/search?q=ubuntu+intermittent+wifi&ie=utf-8&oe=utf-8 (a lot of complaints are from Ubuntu users, likely because a good part of Linux desktop users are using Ubuntu).
If many years later when you click on this link you do not see any sense making posts, that means the problem is probably solved -- which would be great.

Long story short, I am not writing to provide a full solution to this problem, because there is already one: GitHub - pvaret/rtl8192cu-fixes: Realtek 8192 chipset driver, ported to kernel 3.11.
It has very straight forward installation instructions in the GitHub repo's `README.md` file; I have been using this fixed driver for a lot of Ubuntu 16.04 LTS PCs and it solves the problem like a charm.
For example, it works on my desktop PC which runs Ubuntu 16.04.3 LTS (GNU/Linux 4.10.0-38-generic x86_64).

However, this simple solution did not work immediately when I tried it with a CentOS 7 desktop using kernel version 3.10.0-693.5.2.el7.x86_64.
During installation I had several problems:
  1. After installation my `dmesg` shows:

    8192cu: loading out-of-tree module taints kernel. / 8192cu: module verification failed: signature and/or required key missing - tainting kernel
  2. Once I blacklist the built-in driver (rtl8192cu) as I usually do with Ubuntu 16.04 LTS, no new driver is loaded for my Wi-Fi dongle. The device completely disappears from NetworkManager. While it is still there if I do `ifconfig -a`, there does not seem to be a way that I can start it.
Here are some experiences on how I finally made it work:

First, the "tainting kernel" message does not matter -- as long as the driver is still loaded as a kernel module. You can check whether it is using `lsmod` -- it should appear as "8192cu".

Second, it does not really matter if you see "used = 0" for "8192cu" in `lsmod`, because that is also the case on my Ubuntu 16.04 LTS desktop.

Third, I still do not know how to make it work with NetworkManager. Instead, I turned to use `wpa-supplicant` directly. This tool is very fundamental, and does not allow you to switch Wi-Fi access points based on your need or in any graphical way; it fits in my needs perfectly but may not fit in yours.

The instructions to disable NetworkManager and configure the Wi-Fi dongle to work with `wpa-supplicant` directly is here: HowTos/Laptops/WpaSupplicant - CentOS Wiki.
Some of the instructions are outdated -- in `prepnet`, you should probably use `systemctl start messagebus` instead of calling it from `init.d`, for example.

Note that, if you do not want to disable NetworkManager completely, you can just set you specific Wi-Fi dongle to be "unmanaged" for it: configuration - How can I make NetworkManager ignore my wireless card? - Ask Ubuntu.

One more thing is, I found that when using wpa_supplicant, the default driver `nl80211` does not work with the fixed driver aforementioned. However, I succeeded with "wext". This can be changed in `/etc/sysconfig/wpa_supplicant` where there is a place for users to specify the driver to use. I changed its first two sections into:

# Use the flag "-i" before each of your interfaces, like so:
#  INTERFACES="-ieth1 -iwlan0"
INTERFACES="-iwlp0s26f7u1"

# Use the flag "-D" before each driver, like so:
#  DRIVERS="-Dwext"
DRIVERS="-Dwext"


Now I have been using this desktop for a day and have not noticed any intermittent connection issue so far, which used to happen every several minutes.
It appears it has been resolved.

In summary:
  1. Use the fixed driver (rtl8192cu-fixes).
  2. Disable NetworkManager (at least for the problematic device) and use wpa_supplicant.
  3. Config wpa_supplicant to use the "wext" driver.
Good luck :-)