Monday, March 28, 2016

Repair Win 8 Boot / migrate to SSD

I've spent a lot of time trying to get my Windows 8 PC to boot again after cloning to a new SSD and try to summarise how I finally got it all working -
Firstly, boot from a UEFI Windows 8 recovery disk (CD/DVD/USB) - I found that the automated recovery process didn't find the correct Windows partition, nor when I managed to add it to BCD settings would it make it reliably bootable e.g. using BCDEDIT I got it to find and launch the Windows partition but it refused to cold boot or would not "keep" the settings after a 2nd reboot or power off.
Go into the Advanced options and run the Command Prompt.
Enter diskpart to use the DiskPart tool to ensure you have all the right partitions and to identify your EFI partition - the key thing here is that your EFI partition is formatted as FAT32:
DISKPART> sel disk 0

Disk 0 is now the selected disk.

DISKPART> list vol

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
  Volume 0     E                       DVD-ROM         0 B  No Media
  Volume 1     C                NTFS   Partition    195 GB  Healthy    Boot
  Volume 2         WINRE        NTFS   Partition    400 MB  Healthy    Hidden
  Volume 3                      FAT32  Partition    260 MB  Healthy    System
Then assign a drive letter to the EFI partition:
DISKPART> sel vol 3

Volume 3 is the selected volume.

DISKPART> assign letter=b:

DiskPart successfully assigned the drive letter or mount point.
Exit DiskPart tool by entering exit and at the command prompt run the following:
cd /d b:\EFI\Microsoft\Boot\

bootrec /fixboot
Delete or rename the BCD file:
ren BCD BCD.bak
Use bcdboot.exe to recreate BCD store:
bcdboot c:\Windows /l en-gb /s b: /f ALL
The /f ALL parameter updates the BIOS settings including UEFI firmware/NVRAM, /l en-gb is to localise for UK/GB locale. The localisation defaults to US English, or use en-US.
Reboot and cross your fingers.
This gave me headaches. I was going in circles for a long while. There isn't a lot of reliable info about fixing UEFI/Windows 8 at the time of writing.
[EDIT]
To re-enable Hyper-V, I also had to run the following from an Administrator Command Prompt within Windows after rebooting:
bcdedit /set {default} hypervisorlaunchtype Auto
bcdedit /set {default} nx OptIn
http://superuser.com/questions/460762/how-can-i-repair-the-windows-8-efi-bootloader

Wednesday, November 26, 2014

Monday, June 30, 2014

OpenWRT - Mount rootfs on External Storage

Unable to install more software on OpenWRT ? Below is how to extend the storage using USB drive.

1. What is need :
-OpenWRT Router with USB port
-Any USB Storage

2. opkg update
opkg install kmod-fs-ext4 kmod-usb-storage-extras block-mount

3. Create new partition on USB storage using gparted, 1st partition is Swap partition 64M ( size is depend on your router model, usually mem size x2), 2nd partition is ext3 partition.

4. Duplicate the rootfs to USB storage
root@OpenWrt:/etc/config# mkdir /mnt/usb
root@OpenWrt:/etc/config# mount /dev/sda2 /mnt/usb/
root@OpenWrt:/etc/config# mkdir /tmp/root
root@OpenWrt:/etc/config# mount -o bind / /tmp/root
root@OpenWrt:/etc/config# cp /tmp/root/* /mnt/usb -a
root@OpenWrt:/etc/config# umount /tmp/root/
root@OpenWrt:/etc/config# ls /mnt/usb/


5. Edit the fstab using ssh terminal / putty and add configs below.
# vi /etc/config/fstab
config 'mount'
        option 'target' '/mnt/usb'
        option 'device' '/dev/sda2'
        option 'fstype' 'ext3'
        option 'options' 'rw,sync'
        option 'enabled' '1'
        option 'is_rootfs' '1'
        option 'enabled_fsck' '1'
           
config 'swap'                    
        option 'device' '/dev/sda1'
        option 'enabled' '1'


6. reboot & verify


Friday, June 27, 2014

OpenVPN Server with ACS SmartCard

This is note on how to configure OpenVPN server with smartcard (PKCS11), with window client.

1. Install OpenVPN server, please refer HERE

2. Generate cert for client :
# ./build-key-pkcs12 client2
Generating a 1024 bit RSA private key
........................++++++
....................................++++++
writing new private key to 'client2.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [MY]:
State or Province Name (full name) [KL]:
Locality Name (eg, city) [Petaling Jaya]:
Organization Name (eg, company) [Test]:
Organizational Unit Name (eg, section) [server]:
Common Name (eg, your name or your server's hostname) [client2]:
Name [server]:
Email Address [me@test.com]:

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
Using configuration from /etc/openvpn/easy-rsa/openssl-1.0.0.cnf
Check that the request matches the signature
Signature ok
The Subject's Distinguished Name is as follows
countryName           :PRINTABLE:'MY'
stateOrProvinceName   :PRINTABLE:'KL'
localityName          :PRINTABLE:'Petaling Jaya'
organizationName      :PRINTABLE:'Test'
organizationalUnitName:PRINTABLE:'server'
commonName            :PRINTABLE:'client2'
name                  :PRINTABLE:'server'
emailAddress          :IA5STRING:'me@test.com'
Certificate is to be certified until Jun 21 13:06:42 2024 GMT (3650 days)
Sign the certificate? [y/n]:y


1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated
Enter Export Password:
Verifying - Enter Export Password:

copy all client2* file to window that installed ACS Cert Management Utility.

3. Import the client cert
3.1 plug the smartcard reader and login
3.2 Action  > Certificate Manager
3.3 Click import , select file that you copy just now. e.g client2.p12
3.4 When prompt to enter export password, enter the password enter during generate the cert, DO NOT LEAVE BLANK.


4. Install and Configure OpenVPN client.(without install gui)
4.1 download http://ovpnppc.ziggurat29.com/files/openvpn-gui-1.0.3-pkcs11.src.zip gui, this version will prompt  the pkcs11 pin where the official site verion won't.

4.2 Locate the middleware by the smartcard provider, my case is :
"C:\Program Files\Advanced Card Systems Ltd\ACOS5-CryptoMate Admin Client Kit\Mid dleware\x86\PKCS\>acospkcs11.dll"

4.2 Find the Serialized id.
openvpn --show-pkcs11-ids C:\Program Files\Advanced Card Systems Ltd\ACOS5-CryptoMate Admin Client Kit\Mid
dleware\x86\PKCS\acospkcs11.dll

The following objects are available for use.
Each object shown below may be used as parameter to
--pkcs11-id option please remember to use single quote mark.

Certificate
       DN:             C=MY, ST=KL, L=Petaling Jaya, O=Test, OU=server, CN=xp3,
name=server, emailAddress=me@test.com
       Serial:         04
       Serialized id:  Advanced\x20Card\x20Systems\x20Ltd\x2E/CTM64/603868942
/ACS\x20Card\x20OS\x205/F8892A3678F75A7E586BFBEF805F3CA80DD2



4.3  Add PKCS provider to openvpn config file

pkcs11-providers C:\Program Files\Advanced Card Systems Ltd\ACOS5-CryptoMate Admin Client Kit\Mid
dleware\x86\PKCS\acospkcs11.dll
pkcs11-id     'Advanced\x20Card\x20Systems\x20Ltd\x2E/CTM64/603868942
/ACS\x20Card\x20OS\x205/F8892A3678F75A7E586BFBEF805F3CA80DD2'


5. Run openvpn-gui and connect.



Wednesday, June 25, 2014

FB Invite all friends js script


elms=document.getElementById('fbpage_invite_audience_action_finch').getElementsByTagName('button');for(var fid in elms){if(typeof elms[fid] === 'object'){(elms[fid]).click();}}


Steps:

1. Launch Mozilla and load the Pages.

2.  Under invite friend click "See all friends"

3. Press F12 on keyboard > click on "Console" tab.

4. Paste the script above to console >>

5. Scroll down the friends list and repeat step 4.

Wednesday, June 11, 2014

Bluetooth module for old multimedia speaker


This is about how to adding Bluetooth feature to your old multimedia speaker.


Old phone charger with 5v output.


This AC-DC converter

Connect the phone charger board to 220AC on the speaker board

USB Bluetooth module


Connect the 5v output to Bluetooth USB input (pin 1(+) and pin 4 (-).

Connect the Bluetooth Aux out to speaker Aux input, above is Edifier R202 board.


Manually iron the AC input to phone charger board


Wrap the high voltage circuit for safely!!


Glue the charger board to panel


Glue the Bluetooth beside the charger board

Bluetooth speaker!!


Note: your speaker aux will not function properly because the bluetooth module will draw the power from it, if you want have both work you need extra switch to switch between Aux or bluetooth.

NiMh Charger Disassemble


This post is to dissemble NiMH charger to inspect the build quality, I only have 3 units, 2 from GP and 1 from unknown china brand. 

GP Fast Charge

China brand cheap charger

China brand cheap charger overview



Below 3 pictures is GP 4 position charger.