VirtualBox guestcontrol

VirtualBox 可以用 vboxmanage guestcontrol 來有限度的控制 VM 裡的 GuestOS。

GuestOS 是 Ubuntu 的話,得安裝 virtualbox-guest-utils, virtualbox-guest-dkms ,安裝完以後,重新開機。

在 HostOS 裡,就可以用 vboxmanage guestcontrol 指令了。

# VirtualBox 5.x
vboxmanage --nologo guestcontrol "Ubuntu 16.04" run --exe /sbin/ifconfig --username ubuntu --passwordfile password.txt --wait-stdout --wait-stderr --verbose

參考資料:

anbox 與 snappy

Anbox 是一個以 container 來摹擬 Android 的技術,如此一來,就可以在 Ubuntu 裡執行 Android app。

按照 Anbox 的說明,得先安裝 snappy,snappy 是 Canonical 推的新的套件機制,軟體以類似 container 的方式安裝進去,不過這個技術推行快兩年了,用的人好像還是不怎麼多。安裝 snappy 的方法很簡單,只要安裝 snapd 就可以了:

sudo apt-get install snapd

安裝 snappy 以後,你還得要先登入 Ubuntu one 的帳號 (用法):

sudo snap login your_email

,之後才能依照 Anbox 的說明,進行安裝:

snap install --classic anbox-installer

。如果不先 login ,snap install 時,會不給安裝。

安裝 anbox-installer 以後,再執行

anbox-installer

就會啟動安裝程序了。

不過我還是安裝失敗了,anbox 說 Ubuntu 14.04 應該是可以安裝,但是實際狀況是有問題,我沒深究,就算了。

LTS Enablement Stacks – trusty to utopic

要把 trusty 的 kernel 跟 xserver 升級到目前 utopic ,可以參考這篇 Kernel/LTSEnablementStack – Ubuntu Wiki

其實就是 apt-get install 相關的 package 而已:sudo apt-get install –install-recommends linux-generic-lts-utopic xserver-xorg-lts-utopic libgl1-mesa-glx-lts-utopic libegl1-mesa-drivers-lts-utopic

伺服器版的話,因為沒有 xserver 的牽絆,只要 sudo apt-get install –install-recommends linux-generic-lts-utopic 就可以。

要特別注意的,就是在安裝過程會移除掉某些 package,這裡要特別留意,在安裝前 apt 會有事先提示。以我來說,skype 、google earth 跟 wine 都被移除掉,所以在安裝完重開機以後,要記得把這些軟體裝回去。

這次升級的意外發現是 Google earth 不需要額外處理就有中文顯示了,終於啊…

更換 Ubuntu 開機過程的佈景主題

Ubuntu 開機過程其實是可以更換圖片的,甚至已經提供了不少佈景主題可以使用:apt-cache search plymouth-theme

plymouth-theme-ubuntu-logo - graphical boot animation and logger - ubuntu-logo theme
plymouth-theme-ubuntu-text - graphical boot animation and logger - ubuntu-logo theme
mythbuntu-default-settings - default settings for Mythbuntu
plymouth-theme-edubuntu - Plymouth is an application that runs very early
plymouth-theme-fade-in - graphical boot animation and logger - fade-in theme
plymouth-theme-glow - graphical boot animation and logger - glow theme
plymouth-theme-kubuntu-logo - graphical boot animation and logger - kubuntu-logo theme
plymouth-theme-kubuntu-text - graphical boot animation and logger - kubuntu-text theme
plymouth-theme-lubuntu-logo - plymouth theme for Lubuntu
plymouth-theme-lubuntu-text - plymouth text theme for Lubuntu
plymouth-theme-sabily - plymouth theme for Sabily (graphical theme)
plymouth-theme-sabily-text - plymouth theme for Sabily (text theme)
plymouth-theme-script - graphical boot animation and logger - script theme
plymouth-theme-solar - graphical boot animation and logger - solar theme
plymouth-theme-spinfinity - graphical boot animation and logger - spinfinity theme
plymouth-theme-text - graphical boot animation and logger - text theme
plymouth-theme-ubuntu-gnome-logo - graphical boot animation and logger - ubuntu-gnome-logo theme
plymouth-theme-ubuntu-gnome-text - graphical boot animation and logger - ubuntu-gnome-text theme
plymouth-theme-ubuntustudio - Ubuntu Studio Plymouth theme
plymouth-theme-xubuntu-logo - graphical boot animation and logger - xubuntu-logo theme
plymouth-theme-xubuntu-text - graphical boot animation and logger - xubuntu-text theme

你可以使用 apt-get install 來安裝,這些佈景主題會被安裝到 /lib/plymouth/themes/ 目錄下,安裝以後,該如何使用呢? 可以用 update-alternative 來替換,在 terminal 輸入 sudo update-alternative default.plymouth 以後,就可以選擇你喜愛的佈景主題了。

網路上也有人自行去修改 theme,調整字的位置、圖形等等的,用 ubuntu plymouth 去找,就可以找到相關的資訊了。

Grub symbol ‘grub_term_highlight_color’ not found

把筆電的 Ubuntu 13.10 升級到 14.04,想不到卻中了招,重開機時,出現 symbol ‘grub_term_highlight_color’ not found 的錯誤。

網路上一找,果然 launchpad 上已經有人回報了,網路上也有不少人分享解法。大致上有兩類解法:

  1. 設法用 livecd/liveusb 重新 chroot 進去,然後用 grub-install 重新安裝 grub
  2. 用 livecd/liveusb 開機,安裝 boot-repair ,利用 boot-repair 來解。

這兩類解法對我都無效,後來是在 launchpad 的那篇裡,看到 downgrade grub ,就想說來試試看。主要的步驟,還是 boot-repair,所以先用 Ubuntu 14.04 的 liveusb 開機,安裝 boot-repair,執行 boot-repair 。boot-repair 的過程裡,會有一些提示,以及需要手動下指令的部份,第一次會是要移除 grub 以及相關的套件;到了第二次時,會要你重新安裝 grub,這邊的指令要改變一下,先裝指定版本的 grub,再執行 boot-repair 提供的指令:sudo apt-get install grub-common=2.00-19ubuntu2 grub-efi-amd64=2.00-19ubuntu2 grub-efi-amd64-bin=2.00-19ubuntu2 grub-efi-amd64-signed=1.22+2.00-19ubuntu2 grub2-common=2.00-19ubuntu2

接著就是讓 boot-repair 做完就可以了。

備註:

  • 如果你不知道有哪些版本可以用,要找某 package 之前的版本,可以用 apt-cache show package | grep Version 來看。
  • 用 LiveCD/LiveUSB 開進去以後,自行掛載並 chroot 的方法,就是先用 sudo parted -l 或 sudo fdisk -l 確認分割區,接著做掛載的動作,大致是這樣 (分割區請自行替換,不要照抄):
    sudo mount /dev/sda5 /mnt
    sudo mount /dev/sda4 /mnt/boot
    sudo mount /dev/sda7 /mnt/home
    for i in /dev /dev/pts /sys /proc /run; do sudo mount $i /mnt$i; done
    sudo chroot /mnt
    hostname your_host
    export HOME=/root

debian package 的相依性圖形

找了半天找不到適當的指令顯示套件的相依套件,想起之前無意找到的 apt-cache dotty,就想說用圖形來看套件的相依性還是最快的。

產生圖形的方法:

  • apt-cache:apt-cache 本身就有提供 dotty command 可以產生,用法是 apt-cache dotty your_package > out.dot
  • debtree:debtree 需要另外安裝,好處是有提供更多額外的參數來產生圖形,用法是 debtree your_package > out.dot

接著就可以利用 dot 指令來產生圖形了,dot 是 graphviz 套件提供的指令,可以根據 dot 語法來產生圖形,用法是 dot -T png -o out.png out.dot。用 apt-cache dotty 產生的 dot 語法,會讓 dot 產生圖形的速度變得非常慢;而 debtree 所產生出來的 dot 語法,就不會如此。我猜想是 debtree 有預先排除掉 libc6, libstdc++6 與 zlib1g 的關係吧。

systemd

最近 Debian 宣佈以後改用 systemd,Canonical 也隨之跟進,所以之後衍生的 distribution 應該也都會跟進。Arch 是已經改用 systemd 了,CentOS/RHEL 應該是到 7 以後才會可能會用 systemd。

看到這兒就想到目前在用的 Ubuntu 12.04 應該也可以改用 systemd 吧~目前先找到這兩篇:

基本上都是要特定 ppa (上面這兩篇提到的 ppa 還都不同,到時候再來看那邊比較新就用哪個),安裝 systemd 以後,然後改 grub ,大概就這樣。可能遇到的問題是 /etc/mtab 問題以及一些服務可能會無法啟動。從 Ubuntu Wiki 對 systemd 的說明裡 看起來缺的東西不少,我想最好是先拿 VM 的機器來試驗,不要拿工作機來試驗,免得把自己搞得焦頭爛額。

extundelete

之前一直以為在 Linux 上反刪除是很麻煩的,直到過年前自己誤刪了檔案,去 Google 解法之後,才知道現在有 extundelete 這工具。

根據 extundelete 的網站說明,在反刪除之前,第一要先卸載,如果是系統分割區,那最好就是趕緊重開機,以 LiveCD 開機;第二就是用 extundelete 進行搜索被刪除的檔案。

我自己的情況是不小心移除了系統分割區上的檔案,所以我趕緊重新開機以 Ubuntu 12.04 LiveCD 開機。重開機以後,去系統設定裡的 “Software & Updates” ,把 main, universe, restricted, multiverse 都勾選起來,接著到 terminal 裡執行 sudo apt-get udpate && sudo apt-get install extundelete ,安裝 extundelete。安裝完成後,執行 sudo extundelete –restore-all –restore-directory /home/user –after 1390881600 /dev/sda1 就會開始進行反刪除的動作,反刪除後的檔案會放置在當前目錄下的 RECOVERED_FILES 資料夾下。”–after” 表示只拯救指定日期後的檔案,而其後的數字,是用 date -d “2014-01-28 12:00” +%s 取得,extundelete 不接受日期時間字串,只能透過 date 指令取得數字來使用,這部份可以在 extundelete 的 man page 裡看到。

只是 Ubuntu 12.04 的 extundelete 有問題,我後來再用 Ubuntu 13.10 的 LiveCD,才能正常使用。但最後還是拯救失敗,因為從刪除到重開機,我還是做了太多動作,導致一些檔案已經被覆蓋掉,殘念,只能安慰自己說那些檔案其實不重要。

參考資料: