Saturday, April 16, 2016

How to enable nested VM in KVM

1. Uncomment below line in /etc/modprobe.d/kvm.conf
options kvm_intel nested=1


[root@localhost ~]# cat /etc/modprobe.d/kvm.conf 
###
### This configuration file was provided by the qemu package.
### Feel free to update as needed.
###

###
### Set these options to enable nested virtualization
###

options kvm_intel nested=1
#options kvm_amd nested=1


2. Remove and Add the kvm_intel module

modprobe -r kvm_intel
modprobe  kvm_intel


3. Verify whether the change has been applied or not,

cat /sys/module/kvm_intel/parameters/nested
Y

4.Use 'Copy host CPU configuration' in VM's CPU configurations

Sunday, March 13, 2016

My first experience with beaglebone serial port

Yesterday, I received beaglebone and PL2303HX USB to TTL serial cable I ordered few weeks a go. First thing I tried to do with the beaglebone was to try it's serial port.

So I connected the serial cable with the beaglebone and PC. I use fedora on my PC, so I used screen program to communicate with the serial port.

Then I powered up the beaglebone using the mini USB port and was waiting for the messages to be printed in the serial console.

Well, the good news was that messages were printed. but there were bad news.
sometimes it showed garbled messages. Also when it showed messages correctly, I wasn't able to type. It was simply a read only screen session.

What went wrong? I started googling and couldn't find any clue. finally I landed on a page where it lists beaglebone HW faults and it listed a similar scenario described as a HW fault. But it was a very old issue and cannot believe it still exists in new boards.

So I started diagnosing the issue.
First I tried to check whether it is an issue with the PC. Therefore I connected the beaglebone and the serial cable setup with my windows laptop. I did't get garbled messages on my screen session this time (I used Putty) but still I couldn't type.

So this must be an issue with either the beaglebone or the serial cable. If it's an issue with the beaglebone, I do not have any option. So I decided to diagnose the serial cable. I opened the USB side of the cable to check the circuit. the USB side can be easily opened since it was not sealed.

Huh, Found the issue!!!. The green wire was detached from the PCB due to a bad soldering job.
I soldered the green wire to the PCB again and reconnected the setup with the PC.

voila, screen session is bidirectional now. :)


Sunday, January 10, 2016

How to fix Unibeast's "Selected Mac OS X Installer is Incomplete" error

Selected Mac OS X Installer is Incomplete

Your selected Mac OS X Installer is incomplete. Please delete all copies of the installer from all mounted volumes and redownload it again from the Mac App Store.

Do you receive above error message when you try to prepare a bootable USB  using Unibeast and a OS X installer downloaded from another machine, or a torrent? and you are 100% sure the downloaded installer is genuine copy?

Actually you can resolve this by doing either,
1. Simply changing the system time or
2. Patching Unibeast to remove a validation. 
(Changing 0000000100003262         je         0x1000032a2 to a NOP in Unibeast 6.1.1)

Both can be done easily. But I'm going to describe only the first option here. 

First let me explain few validations which are done by Unibeast before it allows you to create the bootable USB.

1. First validation it does is the Installer name and the path. Installer should be available at the /Applications directory with the correct name.

E.g.: 
/Applications/Install OS X Yosemite.app
/Applications/Install OS X El Capitan.app

2. Second validation is that,

If the installer is for Yosemite, then it checks for the string "com.apple.InstallAssistant.Yosemite" in the /Applications/Install OS X Yosemite.app/Contents/_MASReceipt/receipt file using "grep -q" command.

If the installer is for El Capitan, then it checks for "
com.apple.InstallAssistant.ElCapitan" in the /Applications/Install OS X El Capitan.app/Contents/_MASReceipt/receipt file using "grep -q" command.

3. The third validation is that it validates the signature of the receipt. This is the moment you get the "Installer is Incomplete" error message. This can happen either your receipt file is actually changed by someone or the certificates included in the receipt file are expired.

You can view the certificate information executing below command, (first change directory to /Applications/Install OS X xxx.app/Contents/_MASReceipt/ directory)

openssl pkcs7 -inform der -in receipt -print_certs -text

If your machine time is not within the validity period of the certificates, the signature validation is failed and Unibeast prompts the "Installer is Incomplete" error message.

e.g.:
openssl pkcs7 -inform der -in receipt -print_certs -text | egrep 'Not Before|Not After'
            Not Before: Nov 11 21:58:01 2010 GMT
            Not After : Nov 11 21:58:01 2015 GMT
            Not Before: Feb 14 18:56:35 2008 GMT
            Not After : Feb 14 18:56:35 2016 GMT
            Not Before: Apr 25 21:40:36 2006 GMT
            Not After : Feb  9 21:40:36 2035 GMT

In this case, the lowest "Not After time" is Nov 11 21:58:01 2015 GMT and the highest "Not Before time" is Nov 11 21:58:01 2010 GMT. Therefore the time of your machines should be within Nov 11 21:58:01 2010 GMT and Nov 11 21:58:01 2015 GMT.

Therefore if you change the machine time appropriately, let's say 2015/01/01 then Unibeast will proceed without prompting the  "Installer is Incomplete" error message. :)

Note: I think above validation was introduced by Unibeast developers to address a legal issue rather than making sure you have a genuine copy, because you can still have a modified installer files even when the receipt validation is passed.  So if you download the MAC OS X Installer from a torrent site or any other place, check the MD5 or SHA1 of the InstallESD.dmg file.

For Further reads about apple receipts,

Sunday, January 3, 2016

Building a hackintosh

First you need to read a lot about working builds before going in to building a hackintosh.
tonymacx86 is a very good resource on this subject and the community is very helpful.

I had only few options selecting motherboard and processes due to the availability in local computer market. Online purchasing was not an option due to the shipping cost.

Finally I decided to go with ASUS H97M-E and Intel i3-4330 haswell processor with integrated intel graphics (Intel HD 4600)
Make sure that the keyboard and mouse are USB and the monitor supports digital input (i.e. DVI-D or HDMI).

First you need to create a bootable USB with the target OS X. If you don't have a mac, you can prepare the USB using a VM. If you have a mac, then you can create the bootable USB easily.

Please note that this is not a step by step guide to build a hackintosh. However I have mentioned links which have the step by step guides useful in this process.

Download VMware Workstation

I was using Fedora 21, so I downloaded "VMware Workstation 12 Pro for Linux 64-bit".
Link: http://www.vmware.com/products/workstation/workstation-evaluation

Make sure that the version of the kernel and the version of the kernel-headers of your system are same. Otherwise the VMware installer will complain that it is unable to find the proper header files.

In my case they had different versions. So I updated the kernel.

[root@desktop9 ~]# rpm -q kernel-headers
kernel-headers-4.1.13-100.fc21.x86_64

[root@desktop9 ~]# uname -r
4.0.4-201.fc21.x86_64

[root@desktop9 ~]# yum update kernel

Unlock VMWare Workstation

You need to "unlock" VMware workstation to use your target OS X.

Download unlocker from here,
Link: http://www.daveparsons.net/downloads/unlocker207.zip

Run the unlocker script,
[root@desktop9 unlocker208]# ./lnx-install.sh 

Now it's the time to start the VMware workstation. Unfortunately VMware workstation threw errors and it was unable to start.

Could not open /dev/vmmon: No such file or directory.
Please make sure that the kernel module `vmmon' is loaded.

So I tried to load the required kernel module manually using modprobe.

[root@desktop9 ~]# modprobe vmmon
modprobe: ERROR: could not insert 'vmmon': Required key not available

After doing a google search I found out that the real reason for this error was the BIOS option "Secure Boot". I set the value for this bios option to "Other OS". After that the VMware workstation started.

Prepare ISO

Now you need an iso of the target OS X. I had Appstore copies of Mountain Lion and Yosemite operating systems. The original OS X comes as a dmg file. So you need to convert the dmg file to an iso.

I used dmg2img to convert Mountain Lion dmg file to an iso since the iso generated by the dmg2img for the Yosemite dmg didn't work with VMware workstation.

yum install dmg2img
dmg2img InstallESD.dmg InstallESD.iso

After that you will be able to use the iso on VMware workstation to create a new VM. Then you can use the VM to prepare a bootable USB with Yosemite or El Capitan using Unibeast.

Step by step instructions for preparing a Mac OS X VM on VMware workstation are available in this blog,
Link: https://mizitechinfo.wordpress.com/2014/07/13/installing-mac-osx-10-8-on-vmware-workstation/

Prepare the bootable USB using Unibeast

Unibeast seems very sensitive when it comes to finding the OS X from /Applications directory with correct names and files. It does not support to load an OS X installer from a user provided location.

If you already have a downloaded OS X installer, you need to copy that to the /Applications directory. However sometimes it complains that it couldn't locate the installer or the "installer is incomplete" if you copy the installer manually to /Applications directory.

If OS selection is greyed out in Unibeast, make sure that the OS X installer has the correct name and copied to the correct location.
e.g.: "Install OS X Yosemite.app" in /Applications directory.

Sometimes it still does not work even though the OS X installer is placed correctly. Try setting the system time to a previous year, e.g.: 2010 and rerunning the Unibeast in such a scenario.

Update: Please read this blog post if you are unable to make the OS X Installer recognized by Unibeast.
http://swapoff.blogspot.com/2016/01/how-to-resolve-unibeasts-selected-mac.html

Install the OS X

Once you have prepared the bootable USB, you should be able to use it to install the OS X on your build.

Step by step instructions on preparing the USB and installing it on your build using Unibeast and Multibeast are available in tonymacx86 site.



Saturday, September 5, 2015

Disable automatic package metadata update in Fedora

Sometimes my internet speed becomes slow when I use Fedora after a system reboot. Once this happens, I experienced the effect even though all the network related applications are closed. My internet connection is not a super fast, so it annoyed me a lot. I wanted to find out the reason behind this issue.

Step 1: use netstat to identify the PID/applications which have opened TCP connections,

[root@desktop9 ~]# netstat -anp -t
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 192.168.0.1:53          0.0.0.0:*               LISTEN      1252/dnsmasq        
tcp       13      0 192.168.1.9:48208       192.168.1.50:445        CLOSE_WAIT  6776/gvfsd-smb      
tcp        0      0 192.168.1.9:44632       137.189.4.14:80         ESTABLISHED 10934/python        
tcp        0      0 192.168.1.9:44635       137.189.4.14:80         CLOSE_WAIT  10934/python        
tcp        0      0 192.168.1.9:44690       137.189.4.14:80         CLOSE_WAIT  10934/python        
tcp       13      0 192.168.1.9:36304       192.168.1.50:139        CLOSE_WAIT  6769/gvfsd-smb-brow

The output shows that the process 10934/python has a established connection with destination 137.189.4.14:80.

Step 2: Use ps command to find out more information of this process

[root@desktop9 ~]# ps -efw | grep 10934
root     10934     1  0 18:56 ?        00:00:00 /usr/bin/python -OO /usr/bin/dnf -v makecache timer
root     11204 11153  0 19:02 pts/0    00:00:00 grep --color=auto 10934

The output shows the culprit. it was "/usr/bin/dnf -v makecache timer"

The man page of dnf describes makecache downloads and caches in binary format metadata for all known repos available in the system.

Man page output:

       dnf [options] makecache
              Downloads and caches in binary format metadata for all known repos. Tries to avoid downloading whenever possible (e.g. when the local  metadata
              hasn't expired yet or when the metadata timestamp hasn't changed).

       dnf [options] makecache timer
              Like  plain  makecache but instructs DNF to be more resource-aware, meaning will not do anything if running on battery power and will terminate
              immediately if it's too soon after the last successful makecache run (see dnf.conf(8), metadata_timer_sync).


It seems that the dnf makecache is scheduled to run after every reboot. I decided to disable this and do manual metadata updates whenever it's required.

Command to disable dnf-makecache.service:

systemctl disable dnf-makecache.service 

Update 1: Disable the dnf-makecache.timer as well. Otherwise the service will be restarted.

systemctl disable dnf-makecache.timer

Update 2: I started using Fedora 29 Server edition and noted packagekit is also involved in this.
Therefore I disabled them as well,

systemctl disable packagekit.service
systemctl disable packagekit-offline-update.service