2017年8月28日 星期一

USB compatibility between 2.0 & 3.x


(Hikey Board)                             (USB 3.x Hub)      
Hikey LEMAKER USB 2.0 --> DigiFusion USB 3.0 --> Win 10, USB 3.0  sometimes no response

Hikey LEMAKER USB 2.0 --> Win 10, USB 3.0 : USB Device not recognized



Hikey LEMAKER USB 2.0 --> Win 10, USB 2.0 :  OK

PS: Sony XPERIA XZs (G8232, Android 7.1.1) has similar symptoms.


Ref: 





2017年8月22日 星期二

Optimization on SSD

Refer to:
  1. https://www.leaseweb.com/labs/2013/07/5-crucial-optimizations-for-ssd-usage-in-ubuntu-linux/
  2. https://askubuntu.com/questions/325283/how-do-i-check-the-health-of-a-ssd

Optimization on SSD
1. Buy more than enough RAM
2. Use the default partition layout
3. Avoid using swap
echo -e "vm.swappiness=0" | sudo tee -a /etc/sysctl.conf
4. Disable access time logging
sudo nano /etc/fstab
   Now change “errors=remount-ro” to “noatime,errors=remount-ro”. Save the file and reboot.
5. Enable TRIM
echo -e "#\x21/bin/sh\\nfstrim -v /" | sudo tee /etc/cron.daily/trim
sudo chmod +x /etc/cron.daily/trim

monitor the expected life-time (This may not wok on VM)
1. install smartmontools
sudo apt-get install smartmontools
2.
sudo smartctl -data -A /dev/sda

2017年8月19日 星期六

crontab usage

一般若要某 user 定時執行某件事情, 就以那個 user 的帳號執行 crontab -e 就可以建立定時要執行的事情. 注意: 不要直接 edit crontab  檔案, 而是執行 crontab -e.

For Ubuntu
Method A: crontab -e
  1. as "user" login
  2. crontab -e
  3. # m h dom mon dow command
      0,20,40 * * * * /home/fae/git_repo/git_pull.sh >> /home/fae//Logs/git/git-"$(date +\%F_\%T)".log 2>&1

Method B: edit crontab file. This method doesn't work for CentOS.
  1. as root
  2. vim /etc/crontab
  3. as user "fae" to execute command
      # m h dom mon dow command
      0,20,40 * * * *   fae  /home/fae/git_repo/git_pull.sh >> /home/fae//Logs/git/git-"$(date +\%F_\%T)".log 2>&1
  4. restart cron service
      sudo service cron reload
      or
      /etc/init.d/cron reload

Method C: sudo crontab -e
  1. as "user" login
  2. sudo crontab -e
  3. # m h dom mon dow command

      0,20,40 * * * * /home/fae/git_repo/git_pull.sh >> /home/fae/Logs/git/git-"$(date +\%F_\%T)".log 2>&1
      10 3 * * 1-5 /home/fae/Tools/trim/trim_ssd.sh >> /home/fae/Logs/trim/trim-"$(date +\%F_\%T)".log 2>&1


觀察 crontab 執行結果
1.  sudo cat /var/log/syslog | grep CRON
2.  cat log.txt

Solved CRON no MTA install
  message ---- "CRON[8380]: (CRON) info (No MTA installed, discarding output)"

sudo apt-get install postfix

Example: git_pull.sh
#! /bin/bash

echo -e " "
echo -e "###############################################################"
echo -e "# SYNC start" `date +%Y_%m%d_%H:%M:%S`
echo -e " ---- git pull jmt_driver ---- "
cd /home/fae/git_repo/jmt_driver
git reset --hard HEAD
git pull

echo -e " ---- git pull jmt_docs ---- "
cd ../jmt_docs
git reset --hard HEAD
git pull

Example: crontab -e

0,20,40 * * * *      /home/fae/git_repo/git_pull.sh >> /home/fae/pull_log/git_pull_log.txt

For CentOS
Method A: crontab -e
  1. as "user" login
  2. crontab -e
  3. # m h dom mon dow command
      0,20,40 * * * * /home/fae/git_repo/git_pull.sh >> /home/fae//Logs/git/git-"$(date +\%F_\%T)".log 2>&1

Method B: edit crontab file. This method doesn't work for CentOS.
  1. as root
  2. vim /etc/crontab
  3. as user "fae" to execute command
      # m h dom mon dow command
      0,20,40 * * * *   fae  /home/fae/git_repo/git_pull.sh >> /home/fae//Logs/git/git-"$(date +\%F_\%T)".log 2>&1
  4. restart cron service
      sudo service cron reload
      or
      /etc/init.d/cron reload

Method C: sudo crontab -e
  1. as "user" login
  2. sudo crontab -e
  3. # m h dom mon dow command

      0,20,40 * * * * /home/fae/git_repo/git_pull.sh >> /home/fae/Logs/git/git-"$(date +\%F_\%T)".log 2>&1
      10 3 * * 1-5 /home/fae/Tools/trim/trim_ssd.sh >> /home/fae/Logs/trim/trim-"$(date +\%F_\%T)".log 2>&1


Crontab tack effect
  For Ubuntu

sudo service cron reload
or
/etc/init.d/cron reload


  For CentOS

sudo systemctl start crond.service



觀察 crontab 執行結果
1.  sudo cat /var/log/cron | grep -i corn
2.  cat log.txt

Example: git_pull.sh
#! /bin/bash

echo -e " "
echo -e "###############################################################"
echo -e "# SYNC start" `date +%Y_%m%d_%H:%M:%S`
echo -e " ---- git pull jmt_driver ---- "
cd /home/fae/git_repo/jmt_driver
git reset --hard HEAD
git pull

echo -e " ---- git pull jmt_docs ---- "
cd ../jmt_docs
git reset --hard HEAD
git pull

Example: trim_ssd.sh
#! /bin/bash

sudo fstrim  -v /ssd1
sudo fstrim  -v /ssd2


Example: crontab -e

0,20,40 * * * *      /home/fae/git_repo/git_pull.sh >> /home/fae/pull_log/git_pull_log.txt





2017年8月17日 星期四

VMware is running extremely slow


   找到 VMware guest OS 變慢的原因了,
A. Don't run any P2P
因為在 chrome browser 開了 Radiotunes 的 Audio streaming, 這應該是個 P2P, 他會侵蝕頻寬占用 CPU time, 使用約 1 小時, 會讓 chrome & VMware 變得很慢

症狀: 剛開始執行 VMware guest OS 與 播放 Radiotunes, 前面 40 分鐘都算順暢, 約一小時後, Chrome & VMware 變得慢到不行.已經到了無法使用的狀態.

處理方法:
  1. 從 Win10 叫出 Task Manager 讓 VMware 停止執行
  2. 從 Chrome 關閉 Radiotunes 網頁
  3. 重新啟動 VMware
  4. 經過兩小時後, 若沒特別讓 VM 做甚麼事, 則 CPU time 應該接近 0, 如圖所示



B. Host OS to Trim SSD
VM 卡卡的另一個因是 win10 SSD 沒有 Trim, 處理之後, 雖然不是非常順, 至少, 不會卡住不動
Refer to: https://www.howtogeek.com/257196/how-to-check-if-trim-is-enabled-for-your-ssd-and-enable-it-if-it-isnt/

  1. Run Administrator Command Prompt
  2. Enable Trim
fsutil behavior set DisableDeleteNotify 0
  3. Search "Optimize Drive" & run




C. ADB Server
adb server   造成 Window 10 吃很多 CPU 資源, VM 未開 adb 時, CPU 平均 0%, 開 ADB 之後, CPU 立刻飆到 12~15%, 這樣應該算抓到 VM 變慢的原因了, 以後不用的時候就砍掉 adb server 就可以了

D. Moving VMware to CentOS 7
將 VMware 移動到 CentOS7 之後, VM 上的 adb 開起來之後, 放數小時都不會有任何拖慢速度的感覺, 超穩的




2017年8月8日 星期二

Samba installation and configuration

Prepared
$  sudo apt update

Samba Server packages:
  1. samba
  2. samba-client
  3. samba-common

$ sudo apt install samba samba-client samba-common
$ sudo pdbedit --list
$ sudo pdbedit -a account_name -f"Account Fullname"
$ sudo smbpasswd -e account_name

$ sudo service --status-all
$ sudo service smbd restart
$ sudo service nmbd restart

Samba configuration: /etc/samba/smb.conf
    [global]
        workgroup = MYGROUP
            server string = Samba Server Version %v
            hosts allow = 127. 192.168.0.
            netbios name = server-name
            interfaces = eno1    # check your setting
            log file = /var/log/samba/log.%m
            max log size = 50
            security = user
            passdb backend = tdbsam
            dns proxy = no
            printing = cups
            printcap name = cups
            load printers = no
            cups options = raw
    [homes]
            comment = Home Directories 
            browseable = yes
            writable = yes
            guest ok = no
#            valid users = %S
           valid users = %S, %D%w%S
           inherit acls = Yes

Manage Samba account:
  1. List Samba account
  # sudo pdbedit --list
  2. Add Samba account by pdbedit
  # sudo pdbedit -a account_name -f"Account Fullname"
  3. Add Samba account
  # sudo smbpasswd -a account_name -f"Account Fullname"
  4. Enable Samba account
  # sudo smbpasswd -e account_name
  5. Disable Samba account
  # sudo smbpasswd -d account_name
  6. Delete Samba account
  # sudo smbpasswd -x account_name
  7. Change Samba password
  # sudo smbpasswd account_name

Restart Samba:
  1. for Ubuntu
        a. # sudo service --status-all
        b. # sudo service smbd restart
        c. # sudo service nmbd restart
  2. for CentOS
        a. # sudo systemctl list-units | grep smb
        b. # sudo systemctl list-units | grep nmb
        c. # sudo systemctl restart smb.service
        d. # sudo systemctl restart nmb.service
        e. # sudo systemctl status smb.service
        f. # sudo systemctl status nmb.service


Auto Start Samba:
  1. for Ubuntu
        a. # sudo update-rc.d samba defaults
        b. # sudo /var/log/samba/log.smbd
        c. # sudo /var/log/samba/log.nmbd
  2. for CentOS
        # sudo chkconfig smb on


Test Samba:
   1. Test your own computer's samba function, using GUI -- connect to server   smb://127.0.0.1/account_name
   2. Connection from other linux computer
   3. Connection from Windows computer


 

2017年8月4日 星期五

Wine crashing with NVIDIA GeForce GTX 750 Ti

Unknown Why,

Guest OS ,Ubuntu 1604LTS, will crash if you installed wine.
Detail description:
1. Host OS: Win10 64bit
2. Display adapter: NVIDIA GeForce GTX 750 Ti
3. VMware Workstation 11
4. Guest OS: Ubuntu 1604LTS 64bit
5. Wine installed on Ubuntu

You will get the following messages if you had just installed wine and reboot.



It will also crash if you copy vmdk to another PC or NB to run.

2017年8月3日 星期四

Add a new hard drive to CentOS 7

Refer to 1. https://www.server-world.info/en/note?os=CentOS_7&p=add_hd
              2. https://www.tecmint.com/add-new-disk-to-an-existing-linux/

Step 1. Open a terminal and change to root
Step 2. Goto /dev to see which one is going to be added
    # cd /dev
    # ls -l sd*
Step 3: Fdisk it and change partition id to 0x8E (Linux LVM)
    # fdisk /dev/sdb
Step 4. show new drive partition status
    # sfdisk -l /dev/sdb
Step 5. format a new hard drive with ext4
    # mkfs.ext4 /dev/sdb1




Step 6. mount a new hard drive
    # mkdir /data; mount /dev/sdb1 /data
Step 7. Modified /etc/fstab, added
    /dev/sdb1    /data    ext4    defaults    0  0

備份LINE電腦版的歷史訊息與聊天記錄

Refer to : http://kaedeknowledge.blogspot.tw/2017/04/line-pc-message-backup.html

 所有訊息包含文字, 圖片, 影像都成功轉移到新的電腦. 前提是不要與 windows app store 的版本搞混. 這裡的 Line 不是用 windows app store 的版本, 而是傳統的版本.

Step 1. 在舊電腦上, 開始->執行->輸入 %USERPROFILE%\AppData\Local\, 切換到該目錄, 並將 Line 資料檔壓縮起來
Step 2. 在新電腦上, 下載 Line 並安裝, 安裝完之前, 先不要按下關閉 Line
Step 3. 在新電腦上解壓縮之前備份的 Line 資料檔,
Step 4. 在舊電腦上, 開始->執行->輸入 %USERPROFILE%\AppData\Local\, 切換到該目錄並將 解壓縮的 Line 資料檔複製到此目錄
Step 5. 關閉 Line

2017年8月1日 星期二

Change computer name (Ubuntu)

Refer to https://askubuntu.com/questions/9540/how-do-i-change-the-computer-name

Step 1: Edit /etc/hostname
    # vim /etc/hostname
Step 2: Edit /etc/hosts
    # vim /etc/hosts
Step 3:
    # hostnamectl set-hostname 'new-hostnam'
Step 4: Restart Terminal