前置作業
1. in Win 10: 控制台\所有控制台項目\電源選項
-> 選擇蓋上螢幕時的行為 -> 將“開啟快速啟動”關閉
2. in BIOS setup menu: disable "secure boot"
安裝Ubuntu
1. Partition 分割 (三個就好,無需/boot)
- /
- /home
- swap
2. 啟動引導器位置選安裝的Drive代號 (example: /dev/sda),不要選到partition
==========
3.裝完後重開機若無GRUB開機選單出現而直接開進Win 10:
把EFI磁區掛到G槽 (代號隨意,找個沒在用的就好)
#mountvol g: /s
進G槽
#g:
#bcdedit /set {bootmgr} path \EFI\ubuntu\grubx64.efi
or (secure boot沒關的話)
#bcdedit /set {bootmgr} path \EFI\ubuntu\shimx64.efi
4. 進Ubuntu LiveCD => try ubuntu
連上網路
#sudo add-apt-repository ppa:yannubuntu/boot-repair && sudo apt-get update
#sudo apt-get install -y boot-repair && (sudo boot-repair &)
會跳出一視窗,點擊Recommended repair
5. 重開機,會出現GRUB開機選單
==========
設定開機順序 (Set boot sequence)
#update-grub
#/gedit etc/default/grub
修改GRUB_DEFAULT=saved
#grep menuentry /boot/grub/grub.cfg
(index從0開始)
#grub-set-default X <- (not work for UEFI OS)
# update-grub
==========
6. Disable UTC, 避免 Ubuntu 和 Windows 時間不同而錯亂
# timedatectl set-local-rtc 1 --adjust-system-clock
2019年1月31日 星期四
2017年5月22日 星期一
Get administrator privilege in windows command line
@echo off
:: BatchGotAdmin
:-------------------------------------
REM --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
set params = %*:"=""
echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
exit /B
:gotAdmin
pushd "%CD%"
CD /D "%~dp0"
:--------------------------------------
:startA
setlocal enableextensions enabledelayedexpansion
CD /D "%~dp0"
::Disabl UAC
reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 0 /f
::Reboot
shutdown -r
exit /b 0
goto :eof
:: BatchGotAdmin
:-------------------------------------
REM --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
set params = %*:"=""
echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
exit /B
:gotAdmin
pushd "%CD%"
CD /D "%~dp0"
:--------------------------------------
:startA
setlocal enableextensions enabledelayedexpansion
CD /D "%~dp0"
::Disabl UAC
reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 0 /f
::Reboot
shutdown -r
exit /b 0
goto :eof
2016年7月8日 星期五
Robocopy backup example
SET /P _inputname= Start backup(y/n):
IF "%_inputname%"=="y" GOTO :go_backup
ECHO Don't backup!
GOTO :end
:go_backup
Robocopy D:\Documents F:\000_Backup\Documents /R:3 /e /xo /purge /xf *.tmp *.bak Thumbs.db *.pst
:end
IF "%_inputname%"=="y" GOTO :go_backup
ECHO Don't backup!
GOTO :end
:go_backup
Robocopy D:\Documents F:\000_Backup\Documents /R:3 /e /xo /purge /xf *.tmp *.bak Thumbs.db *.pst
:end
2016年6月15日 星期三
Linux, Use dd command to backup system
Backup:
# dd if=/dev/hdx bs=1M conv=sync,noerror | gzip > /path/to/image.gz
Hdx could be hda, hdb etc. In the second example gzip is used to compress the image if it is really just a backup.
Restore:
# gzip -dc /path/to/image.gz | dd of=/dev/hdx bs=1M conv=sync,noerror
###################################################
將映像檔依照檔案大小作分割
# dd if=/dev/hdx bs=4k conv=sync,noerror | gzip -c | split -b 2000m - /path/to/backup.img.gz
The - option tells split to read from stdin. Otherwise, split would interpret the /mnt/hdc1... as the file to be split.
# cat /mnt/hdx/backup.img.gz.* | gzip -dc | dd of=/dev/hda1 bs=4k conv=sync,noerror
# dd if=/dev/hdx bs=1M conv=sync,noerror | gzip > /path/to/image.gz
Hdx could be hda, hdb etc. In the second example gzip is used to compress the image if it is really just a backup.
Restore:
# gzip -dc /path/to/image.gz | dd of=/dev/hdx bs=1M conv=sync,noerror
###################################################
將映像檔依照檔案大小作分割
# dd if=/dev/hdx bs=4k conv=sync,noerror | gzip -c | split -b 2000m - /path/to/backup.img.gz
The - option tells split to read from stdin. Otherwise, split would interpret the /mnt/hdc1... as the file to be split.
# cat /mnt/hdx/backup.img.gz.* | gzip -dc | dd of=/dev/hda1 bs=4k conv=sync,noerror
2016年6月6日 星期一
Bash - sdiff, compare two file
# sdiff -s file1 file2
< 代表file1有file2沒有
> 代表file1沒有file2有
| 代表file1有file2有,但是不相同
> 代表file1沒有file2有
| 代表file1有file2有,但是不相同
其他參數
-w 30 限定輸出字元30個
-s 只顯示不同的行
-s 只顯示不同的行
Ref. http://note.tc.edu.tw/943.html
CentOS - Upgrade kernel
Option 1.
# rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm (external link)
# yum install --enablerepo=elrepo-kernel install kernel-ml
# yum remove kernel-{firmware,headers,devel}
# yum install --enablerepo=elrepo-kernel kernel-ml-{firmware,headers,devel}
Option 2. Recommend
http://www.thegeekstuff.com/2013/06/compile-linux-kernel/
You can ignore “make menuconfig” (which may require extra libs) by using current
kernel config file like this:
change folder to kernel src folder
# cp /boot/config-3.10.0 .config
# make olddefconfig
# make
# make modules
# make modules_install
# make install
# rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm (external link)
# yum install --enablerepo=elrepo-kernel install kernel-ml
# yum remove kernel-{firmware,headers,devel}
# yum install --enablerepo=elrepo-kernel kernel-ml-{firmware,headers,devel}
Option 2. Recommend
http://www.thegeekstuff.com/2013/06/compile-linux-kernel/
You can ignore “make menuconfig” (which may require extra libs) by using current
kernel config file like this:
change folder to kernel src folder
# cp /boot/config-3.10.0 .config
# make olddefconfig
# make
# make modules
# make modules_install
# make install
訂閱:
文章 (Atom)