2019年11月20日 星期三

When execute sh script under linux, /bin/sh^M:bad interpreter:No such file or directory

When execute sh script under linux, /bin/sh^M:bad interpreter:No such file or directory

Root Cause:
The file has been modify under windows.
#vim file name
:set ff
Check if fileformat=dos

Fixed:
:set ff=unix
:wq

Run script again.

2019年11月17日 星期日

Commad line flash BIOS/BMC fw

Commad line flash BIOS/BMC fw

/Flash
Method
Command line (Local)
 
EFI Shell 
Windows
BIOS

AfuEfix64.efi BIOS.bin /b /p /n /x
afuwinx64.exe  BIOS.bin /b /p /n /x
BMC

socflash -s BMC.bin
yafuflash.exe -cd


FW /Flash
Method
Command line (Local)
Linux
BIOS./afulnx_64 BIOS.bin /b /p /n /x
BMC./yafuflash -cd BMC.ima -vyes
FW /Flash
Method
Command line (Remote)
Windows Client
BIOS
Grantley:
yafuflash.exe -nw -ip [BMC_IP] -u username -p password -bios BIOS.bin
Purley:
yafuflash.exe -d 2-nw -ip [BMC_IP] -u username -p password  BIOS.bin
BMCyafuflash.exe -nw -ip  [BMC_IP] -u username -p password -full BMC.ima

2019年11月13日 星期三

Windows remote shutdown/reboot

Windows remote shutdown/reboot

Reboot:
net use \\Remote IP /user:administrator password
shutdown -m \\\\Remote IP -r -f -t 3

Shutdown
net use \\Remote IP /user:administrator password

shutdown -m \\\\Remote IP -s -f -t 3

2019年11月12日 星期二

How to enable/disable ethernet by command under windows

How to enable/disable ethernet by command under windows


disable
netsh interface set interface "Ehternet" disabled

enable

netsh interface set interface "Ethernet" enabled

2019年11月11日 星期一

Reset BMC username/password by ipmitool locally

Reset BMC username/password by ipmitool locally


ipmitool raw 0x6 0x45 0x02 0x72 0x6F 0x6F 0x74 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
ipmitool raw 0x6 0x47 0x02 0x02 0x70 0x77 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
ipmitool raw 0x6 0x47 0x02 0x01
ipmitool raw 0x6 0x43 0x93 0x02 0x04 0x00
ipmitool raw 0x6 0x40 0x03 0x82 0x84
ipmitool raw 0x6 0x40 0x03 0x42 0x44


User will set to "root"

Password is "pw"

2019年11月6日 星期三

How to write a linux script with loop

How to write a linux script with loop


While true
do

XXXX (Command1)

sleep 2 
XXXX (Command2)


done

------------------------------------------
Add count with color


While true
do

XXXX (Command1)

sleep 2 
XXXX (Command2)

echo -e "\033[40;32m  "This is $count times." \033[0m"
count =$(($count+1))


done

2019年10月30日 星期三

Hwo to make HDD IO on linux system


Hwo to make HDD IO on linux system

dd if=/dev/sdb of=/dev/null

This is to read disk, and you can check HDD LED behavior.

2019年10月23日 星期三

How to write a batch file script with "administrator" permission

How to write a batch file script with "administrator" permission

Add your batch file after "::START" , your cmd command will run with administrator permission.
::START

::::::::::::::::::::::::::::
------------------------

@echo off
CLS
ECHO.
ECHO =============================
ECHO Running Admin Shell
ECHO =============================

:init
setlocal DisableDelayedExpansion
set "batchPath=%~0"
for %%k in (%0) do set batchName=%%~nk
set "vbsGetPrivileges=%temp%\OEgetPriv_%batchName%.vbs"
setlocal EnableDelayedExpansion

:checkPrivileges
NET FILE 1>NUL 2>NUL
if '%errorlevel%' == '0' ( goto gotPrivileges ) else ( goto getPrivileges )

:getPrivileges
if '%1'=='ELEV' (echo ELEV & shift /1 & goto gotPrivileges)
ECHO.
ECHO **************************************
ECHO Invoking UAC for Privilege Escalation
ECHO **************************************

ECHO Set UAC = CreateObject^("Shell.Application"^) > "%vbsGetPrivileges%"
ECHO args = "ELEV " >> "%vbsGetPrivileges%"
ECHO For Each strArg in WScript.Arguments >> "%vbsGetPrivileges%"
ECHO args = args ^& strArg ^& " "  >> "%vbsGetPrivileges%"
ECHO Next >> "%vbsGetPrivileges%"
ECHO UAC.ShellExecute "!batchPath!", args, "", "runas", 1 >> "%vbsGetPrivileges%"
"%SystemRoot%\System32\WScript.exe" "%vbsGetPrivileges%" %*
exit /B

:gotPrivileges
setlocal & pushd .
cd /d %~dp0
if '%1'=='ELEV' (del "%vbsGetPrivileges%" 1>nul 2>nul  &  shift /1)

::::::::::::::::::::::::::::
::START

::::::::::::::::::::::::::::

2019年9月25日 星期三

How to run vmware workstation VN guest by CLI command


How to run vmware workstation VN guest by CLI command

C:\Program Files (x86)\VMware\VMware Workstation>vmrun -T ws start "D:\XXXX.vmx"

2019年8月23日 星期五

How to modify BMC MAC address by ipmitool


How to modify BMC MAC address by ipmitool


1.Enable BMC MAC SET mode:
/usr/bin/ipmitool raw 0x0c 0x01 0x01 0xc2 0x00
2.Write MAC to BMC (BMC MAC=d0:27:88:a4:e4:37):
/usr/bin/ipmitool raw 0x0c 0x01 0x01 0x05 0xD0 0x27 0x88 0xA4 0xE4 0x37

2019年8月5日 星期一

How to provision TPM2.0 for TXT environment

How to provision TPM2.0 for TXT environment

Please get tools "TPM2ProvTool_20150909" "Client_TXT_Debug_ToolKit_20180625"

1.Boot into BIOS
2.Disable TXT
3.Boot to UEFI shell
4.Execute    (In TPM2ProvTool_20150909\PRE_PROD\COMMON)
  a.Define_AUX.nsh
  b.Define_PS.nsh
  c.Define_SGX.nsh
  d.Lock_PS2.nsh
5.Exit,  back to BIOS
6.Enable TXT, save&exit
7.Boot to UEFI shell
8.Execute "TXTINFO64" (In Client_TXT_Debug_ToolKit_20180625\EFI\txtinfo64)
If pass, you will see "System is in TXT environment"




------------------------------------------------------------------------
Another way:

1.Power on SUT
2.Boot into BIOS
3.Disable TPM/TXT/VT-D
4.Boot into EFI Shell
5.Select TPM2 Prov files
6.Use Basic Provisioning using the sample SHA256 definitions
a)For TXT indexes run Tpm2TxtProv.nsh SHA256 Example
b)If you need to create the platform owner index run Tpm2PoProv.nsh SHA256 Example
c)For the SGX index run Tpm2SgxiProv.nsh SHA256 Example
d)For the PPI index run Tpm2PpiProv.nsh SHA256 Example
7.Boot into BIOS again.
8.Enable TPM/TXT/VT-D
9.Boot to OS,and install tboot,tpm-tools packages
10. Tboot kernel configuration added to grub
11. Reboot and select tboot kernel

2019年2月13日 星期三

How to enable Mellonax option rom in UEFI

How to enable Mellonax option rom in UEFI

1.mst start
2.cd /dev/mst/
  ls (Check device name, ex:mt4099_pci_cr0)

[Enable option rom in UEFI]
#mlxconfig -d /dev/mst/mt4099_pci_cr0 q
#mlxconfig -d /dev/mst/mt4099_pci_cr0 s UEFI_HII_EN=true
#mlxconfig -d /dev/mst/mt4099_pci_cr0 s EXP_ROM_UEFI_x86_ENABLE=true
#mlxconfig -d /dev/mst/mt4099_pci_cr0.1 s UEFI_HII_EN=true
#mlxconfig -d /dev/mst/mt4099_pci_cr0.1 s EXP_ROM_UEFI_x86_ENABLE=true


[Upgrade fw]  download from http://www.mellanox.com/page/firmware_table_ConnectX4LxEN
#flint -d /dev/mst/mt4099_pci_cr0 -i fw-4099-2_30_8000-MCX353A-FCB_ A1.bin burn
#Reboot

[Upgrade option rom] download from http://www.mellanox.com/page/products_dyn?product_family=257&mtag=UEFI
#mst start
#flint -d /dev/mst/mt4117_pci_cr0 --allow_rom_change brom 14_17_11_RELEASE_0x1015.efirom

Simple dd command to test HDD read/write performance under linux

Simple dd command to test HDD read/write performance under linux Read #dd oflag=direct if=/dev/zero of=/mnt/test bs=512k count=200...