2015年9月29日 星期二

在 Mac mini (PowerPC) 上面安裝 Lubuntu 15.10

我有一台 1.42GHz Mac mini,這幾天台灣颱風天沒事做就試著將 Debian/Ubuntu 安裝上去,試了許多方法,最後選擇了安裝 Lubuntu 15.10 最小安裝。

首先是到 http://ports.ubuntu.com/ubuntu-ports/dists/wily/main/installer-powerpc/current/images/powerpc/netboot/ 下載 mini.iso 燒錄到一張可覆寫光碟上面,然後在啟動 Mac mini (PowerPC) 時按住鍵盤上的 C 鍵讓系統從光碟開機,開機後會看到停在 Yaboot 的 boot: 提示字元,此時直接按下 Enter 鍵就可以進入安裝介面,或者是輸入 install radeon.tv=0 進入安裝介面。

只是過程中間手動設定使用 free.nchc.org.tw 的 Ubuntu 檔案鏡像站,目錄則是維持使用 /ubuntu-ports/ 這樣。


之後的安裝過程跟一般的 Debian/Ubuntu netboot 安裝方式相同,如同之前分享過的 Lubuntu 14.04 的最小安裝 來安裝系統。

安裝完成後要自己調整一下系統,首先是顯示的部份,要修改 /etc/yaboot.conf 在 Kernel 參數加上 radeon.tv=0,這樣才能夠將沒有在使用的 S-video 輸出關掉,修改完後需要執行一下 sudo ybin -v 更新開機設定。

接下來是音效的部份,要將 /etc/modprobe.d/blacklist.local.conf 整個移除掉,或是將裡面的內容都註解掉。

# Local module settings
# Created by the Debian installer

#blacklist snd-aoa-codec-tas
#blacklist snd-aoa-fabric-layout
#blacklist snd-aoa-i2sbus
#blacklist snd-aoa-soundbus
#blacklist snd-aoa

然後是修改 /etc/modules 將 snd-powermac 註解掉,然後加上其它需要載入的 kernel modules。

#snd-powermac
snd_aoa_i2sbus
snd_aoa_fabric_layout
snd_aoa_codec_tas
snd_aoa_codec_onyx

最後是 WiFi 的部份要手動安裝 linux-firmware-nonfree_1.14ubuntu1_all.deb,並且鎖住版號不要更新。

echo "linux-firmware-nonfree hold" | sudo dpkg --set-selections

主要是需要下面列出的軔體檔案。

/lib/firmware/b43/ucode5.fw
/lib/firmware/b43/pcm5.fw
/lib/firmware/b43/b0g0initvals5.fw
/lib/firmware/b43/b0g0bsinitvals5.fw

如果是使用 Ubuntu 15.10 之前的版本,則會有 X Window System freezing 的問題,需要使用 radeon.agpmode=-1 來避開問題。

就這樣顯示、音效跟無線網路都可以運作了,只是用 Firefox 來播放 YouTube 影片會很頓很頓這樣。

2015年9月17日 星期四

從 git repository 自行製作上游軟體的 snapshot tarball

在 Linux 系統上面的軟體開發,偶而會遇到需要直接從 git repository 取出尚未正式釋出的版本,以下分享一下我在參加 DebConf15 後,學會的使用流程。

以下以 http://www.freedesktop.org/wiki/Software/libmbim/ 為例子。

首先要找到 git repository 的位置,然後使用 git 指令 clone 到本地端。

$ git clone git://anongit.freedesktop.org/libmbim/libmbim

然後在該目錄底下,找出最後 commit 的日期。

$ git log -1 --format=%cd --date=short . | sed 's/-//g'
20150910

找出目前的版本號碼,libmbim 的版本號碼在寫作這篇文章時寫在 configure.ac 裡面。

dnl Process this file with autoconf to produce a configure script.                                                                                                                                                                             
AC_PREREQ([2.68])

dnl The libmbim version number
m4_define([mbim_major_version], [1])
m4_define([mbim_minor_version], [13])
m4_define([mbim_micro_version], [0])
m4_define([mbim_version],
          [mbim_major_version.mbim_minor_version.mbim_micro_version])

版本號碼也就是 1.13.0 這樣。

然後檢查一下有沒有 .gitignore,如果有的話要先另建一個文字檔 .gitattributes 放入下面的內容。

.gitattributes export-ignore
.gitignore export-ignore

然後就可以使用 git 跟 xz 指令來產生 tarball 檔案。

$ git archive --worktree-attributes --format=tar --prefix=libmbim-1.13.0+20150910/ HEAD | xz > ../libmbim-1.13.0+20150910.tar.xz

如果本來就沒有 .gitignore 的話,就可以不需要使用參數 --worktree-attributes,這樣產生出來的 tarball 檔案就不會包含 .gitignore 在裡面,在使用 Debian 上的一些 git based 的管理工具,會因為 .gitignore 的存在而產生問題。

最後檢查一下 libmbim-1.13.0+20150910.tar.xz 的內容,看看是否沒有那些不應該存在的 .git 開頭的檔案在裡面。

$ tar tf libmbim-1.13.0+20150910.tar.xz
libmbim-1.13.0+20150910/
libmbim-1.13.0+20150910/AUTHORS
libmbim-1.13.0+20150910/COPYING
libmbim-1.13.0+20150910/COPYING.LIB
libmbim-1.13.0+20150910/Makefile.am
libmbim-1.13.0+20150910/NEWS
libmbim-1.13.0+20150910/README
libmbim-1.13.0+20150910/autogen.sh
libmbim-1.13.0+20150910/build-aux/
libmbim-1.13.0+20150910/build-aux/Makefile.am
libmbim-1.13.0+20150910/build-aux/mbim-codegen/
libmbim-1.13.0+20150910/build-aux/mbim-codegen/Makefile.am
libmbim-1.13.0+20150910/build-aux/mbim-codegen/Message.py
libmbim-1.13.0+20150910/build-aux/mbim-codegen/ObjectList.py
libmbim-1.13.0+20150910/build-aux/mbim-codegen/Struct.py
libmbim-1.13.0+20150910/build-aux/mbim-codegen/mbim-codegen
libmbim-1.13.0+20150910/build-aux/mbim-codegen/utils.py
libmbim-1.13.0+20150910/build-aux/templates/
libmbim-1.13.0+20150910/build-aux/templates/Makefile.am
libmbim-1.13.0+20150910/build-aux/templates/mbim-enum-types-template.c
libmbim-1.13.0+20150910/build-aux/templates/mbim-enum-types-template.h
libmbim-1.13.0+20150910/build-aux/templates/mbim-error-quarks-template.c
libmbim-1.13.0+20150910/build-aux/templates/mbim-error-types-template.c
libmbim-1.13.0+20150910/build-aux/templates/mbim-error-types-template.h
libmbim-1.13.0+20150910/configure.ac
libmbim-1.13.0+20150910/data/
libmbim-1.13.0+20150910/data/Makefile.am
libmbim-1.13.0+20150910/data/mbim-service-auth.json
libmbim-1.13.0+20150910/data/mbim-service-basic-connect.json
libmbim-1.13.0+20150910/data/mbim-service-dss.json
libmbim-1.13.0+20150910/data/mbim-service-ms-firmware-id.json
libmbim-1.13.0+20150910/data/mbim-service-ms-host-shutdown.json
libmbim-1.13.0+20150910/data/mbim-service-phonebook.json
libmbim-1.13.0+20150910/data/mbim-service-proxy-control.json
libmbim-1.13.0+20150910/data/mbim-service-sms.json
libmbim-1.13.0+20150910/data/mbim-service-stk.json
libmbim-1.13.0+20150910/data/mbim-service-ussd.json
libmbim-1.13.0+20150910/data/pkg-config/
libmbim-1.13.0+20150910/data/pkg-config/Makefile.am
libmbim-1.13.0+20150910/data/pkg-config/mbim-glib.pc.in
libmbim-1.13.0+20150910/docs/
libmbim-1.13.0+20150910/docs/Makefile.am
libmbim-1.13.0+20150910/docs/libmbim-icon.svg
libmbim-1.13.0+20150910/docs/libmbim-logo.png
libmbim-1.13.0+20150910/docs/libmbim-logo.svg
libmbim-1.13.0+20150910/docs/man/
libmbim-1.13.0+20150910/docs/man/Makefile.am
libmbim-1.13.0+20150910/docs/reference/
libmbim-1.13.0+20150910/docs/reference/Makefile.am
libmbim-1.13.0+20150910/docs/reference/libmbim-glib/
libmbim-1.13.0+20150910/docs/reference/libmbim-glib/Makefile.am
libmbim-1.13.0+20150910/docs/reference/libmbim-glib/libmbim-glib-common.sections
libmbim-1.13.0+20150910/docs/reference/libmbim-glib/libmbim-glib-docs.xml
libmbim-1.13.0+20150910/docs/reference/libmbim-glib/version.xml.in
libmbim-1.13.0+20150910/gtester.make
libmbim-1.13.0+20150910/m4/
libmbim-1.13.0+20150910/m4/compiler-warnings.m4
libmbim-1.13.0+20150910/src/
libmbim-1.13.0+20150910/src/Makefile.am
libmbim-1.13.0+20150910/src/libmbim-glib/
libmbim-1.13.0+20150910/src/libmbim-glib/Makefile.am
libmbim-1.13.0+20150910/src/libmbim-glib/generated/
libmbim-1.13.0+20150910/src/libmbim-glib/generated/Makefile.am
libmbim-1.13.0+20150910/src/libmbim-glib/libmbim-glib.h
libmbim-1.13.0+20150910/src/libmbim-glib/mbim-cid.c
libmbim-1.13.0+20150910/src/libmbim-glib/mbim-cid.h
libmbim-1.13.0+20150910/src/libmbim-glib/mbim-compat.c
libmbim-1.13.0+20150910/src/libmbim-glib/mbim-compat.h
libmbim-1.13.0+20150910/src/libmbim-glib/mbim-device.c
libmbim-1.13.0+20150910/src/libmbim-glib/mbim-device.h
libmbim-1.13.0+20150910/src/libmbim-glib/mbim-enums.h
libmbim-1.13.0+20150910/src/libmbim-glib/mbim-errors.h
libmbim-1.13.0+20150910/src/libmbim-glib/mbim-message-private.h
libmbim-1.13.0+20150910/src/libmbim-glib/mbim-message.c
libmbim-1.13.0+20150910/src/libmbim-glib/mbim-message.h
libmbim-1.13.0+20150910/src/libmbim-glib/mbim-proxy-helpers.c
libmbim-1.13.0+20150910/src/libmbim-glib/mbim-proxy-helpers.h
libmbim-1.13.0+20150910/src/libmbim-glib/mbim-proxy.c
libmbim-1.13.0+20150910/src/libmbim-glib/mbim-proxy.h
libmbim-1.13.0+20150910/src/libmbim-glib/mbim-utils.c
libmbim-1.13.0+20150910/src/libmbim-glib/mbim-utils.h
libmbim-1.13.0+20150910/src/libmbim-glib/mbim-uuid.c
libmbim-1.13.0+20150910/src/libmbim-glib/mbim-uuid.h
libmbim-1.13.0+20150910/src/libmbim-glib/mbim-version.h.in
libmbim-1.13.0+20150910/src/libmbim-glib/test/
libmbim-1.13.0+20150910/src/libmbim-glib/test/Makefile.am
libmbim-1.13.0+20150910/src/libmbim-glib/test/test-cid.c
libmbim-1.13.0+20150910/src/libmbim-glib/test/test-fragment.c
libmbim-1.13.0+20150910/src/libmbim-glib/test/test-message-builder.c
libmbim-1.13.0+20150910/src/libmbim-glib/test/test-message-parser.c
libmbim-1.13.0+20150910/src/libmbim-glib/test/test-message.c
libmbim-1.13.0+20150910/src/libmbim-glib/test/test-proxy-helpers.c
libmbim-1.13.0+20150910/src/libmbim-glib/test/test-uuid.c
libmbim-1.13.0+20150910/src/mbim-proxy/
libmbim-1.13.0+20150910/src/mbim-proxy/76-mbim-proxy-device-ownership.rules.in
libmbim-1.13.0+20150910/src/mbim-proxy/Makefile.am
libmbim-1.13.0+20150910/src/mbim-proxy/mbim-proxy.c
libmbim-1.13.0+20150910/src/mbimcli/
libmbim-1.13.0+20150910/src/mbimcli/Makefile.am
libmbim-1.13.0+20150910/src/mbimcli/mbimcli-basic-connect.c
libmbim-1.13.0+20150910/src/mbimcli/mbimcli-completion
libmbim-1.13.0+20150910/src/mbimcli/mbimcli-dss.c
libmbim-1.13.0+20150910/src/mbimcli/mbimcli-helpers.c
libmbim-1.13.0+20150910/src/mbimcli/mbimcli-helpers.h
libmbim-1.13.0+20150910/src/mbimcli/mbimcli-ms-firmware-id.c
libmbim-1.13.0+20150910/src/mbimcli/mbimcli-ms-host-shutdown.c
libmbim-1.13.0+20150910/src/mbimcli/mbimcli-phonebook.c
libmbim-1.13.0+20150910/src/mbimcli/mbimcli.c
libmbim-1.13.0+20150910/src/mbimcli/mbimcli.h
libmbim-1.13.0+20150910/utils/
libmbim-1.13.0+20150910/utils/Makefile.am
libmbim-1.13.0+20150910/utils/mbim-network.in

2015年9月13日 星期日

製作 Ubuntu 安裝用的 USB 隨身碟

分享一下我經常在使用的步驟,以下假設該 USB 隨身碟的 device node 在 /dev/sdb。

首先把 MBR 區域清成零。

$ sudo dd if=/dev/zero of=/dev/sdb bs=1M count=1
輸入 1+0 個紀錄
輸出 1+0 個紀錄
複製了 1048576 個位元組 (1.0 MB), 0.193325 s, 5.4 MB/s

再來用 fdisk 建立磁碟分割區

$ sudo fdisk /dev/sdb
裝置不含有效的 DOS 分割表,也不含 Sun、SGI 或 OSF 磁碟標籤
以磁碟識別碼 0xf6805fe6 建立新的 DOS 磁碟標籤。
變更將僅存於記憶體之中,直到您決定寫入它們。
在此之後,前一個內容當然將無法回復。

警告:分割表 4 的無效旗標 0x0000 將由 w(rite) 所修正

命令 (m 以獲得說明): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
分割區編號 (1-4, 預設 1): 
使用預設值 1
起初 磁區 (2048-7908470, 預設 2048): 
使用預設值 2048
最後 磁區, +磁區 或 +大小{K,M,G} (2048-7908470, 預設 7908470): 
使用預設值 7908470

命令 (m 以獲得說明): t
已選分割區 1
十六進位編碼 (輸入 L 以列出編碼): c
分割區 1 的系統類型已變更為 c (W95 FAT32 (LBA))

命令 (m 以獲得說明): p

磁碟 /dev/sdb: 4049 MB,4049137152 位元組
125 磁頭,62 磁區/磁軌,1020 磁柱,總計 7908471 磁區
單位 = 磁區 之於 1 * 512 = 512 位元組
磁區大小 (邏輯/實體):512 位元組 / 512 位元組
I/O 大小 (最小/最佳化):512 位元組 / 512 位元組
磁碟識別碼:0xf6805fe6

所用裝置 開機      開始         結束      區塊   識別號  系統
/dev/sdb1            2048     7908470     3953211+   c  W95 FAT32 (LBA)

命令 (m 以獲得說明): w
分割表已變更!

呼叫 ioctl() 以重新讀取分割表。

警告:如果您已建立或修改任何 DOS 6.x
分割區,請參看 fdisk 線上手冊以獲得額外
資訊。
同步磁碟。

使用 partprobe 指令讓系統重新讀取分割表。

$ sudo partprobe 

製作 FAT32 檔案系統,並且使用 UbuntuStick 的名稱。

$ sudo mkfs.vfat -n UbuntuStick /dev/sdb1
mkfs.fat 3.0.26 (2014-03-07)
mkfs.fat: warning - lowercase labels might not work properly with DOS or Windows

掛載 FAT32 檔案系統。

$ gvfs-mount -d /dev/sdb1
/dev/sdb1 已掛載於 /media/fourdollars/UbuntuStick

最後再使用 usb-creator-gtk 來選擇使用 Ubuntu ISO 製作 Ubuntu 安裝用的 USB 隨身碟

$ usb-creator-gtk -n

當然也可以直接使用 usb-creator-gtk 就可以了,這只是我個人的小小潔癖。

2015年9月8日 星期二

在 Ubuntu 14.04 上面使用 pyenv 搭配 virtualenv 建立 Django 的開發環境。

pyenv 是一套管理同時使用不同版本 Python 的工具,也可以搭配 virtualenv 使用。

首先依照 Common build problems 安裝一些套件,由於等一下也會使用到 git 所以一併安裝。

$ sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev git

然後執行官方建議的安裝方式。

$ wget https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer -O - | bash

然後我不是很喜歡每次啟動 shell 就會自動載入使用 pyenv,所以我自己寫了一個 ~/bin/pyenv 的腳本程式來使用。

#!/bin/bash

export PATH="$HOME/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
export PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h(python)\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
bash --noprofile -l

每次當我要使用 pyenv 時,就要先執行一次 pyenv,接下來我就可以看到 (python) 的提示出現,代表我正在使用 pyenv。

fourdollars@ubuntu(python):~$

接下來來找找看,有哪些 Python 版本可以安裝使用。

$ pyenv install -l
Available versions:
  ...
  2.7.10
  ...
  3.4.3
  ...

我選擇安裝最新(寫這篇文章時)的 Python 2 的穩定發行版本。

$ pyenv install 2.7.10
Downloading Python-2.7.10.tgz...
-> https://yyuu.github.io/pythons/eda8ce6eec03e74991abb5384170e7c65fcd7522e409b8e83d7e6372add0f12a
Installing Python-2.7.10...
patching file ./Lib/site.py
Installed Python-2.7.10 to /home/fourdollars/.pyenv/versions/2.7.10

然後先切進 2.7.10 的環境,更新一下套件。

$ pyenv global 2.7.10
$ pip list --outdated | awk '{print $1}' | xargs pip install --upgrade
You are using pip version 6.1.1, however version 7.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
You are using pip version 6.1.1, however version 7.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting setuptools
  Downloading setuptools-18.3.1-py2.py3-none-any.whl (462kB)
    100% |████████████████████████████████| 462kB 666kB/s 
Collecting pip
  Using cached pip-7.1.2-py2.py3-none-any.whl
Installing collected packages: setuptools, pip
  Found existing installation: setuptools 15.2
    Uninstalling setuptools-15.2:
      Successfully uninstalled setuptools-15.2
  Found existing installation: pip 6.1.1
    Uninstalling pip-6.1.1:
      Successfully uninstalled pip-6.1.1
Successfully installed pip-7.1.2 setuptools-18.3.1

接下來要搭配使用 virtualenv 建立一個獨立的 Python 環境。

$ pyenv virtualenv 2.7.10 watchdog
Collecting virtualenv
  Downloading virtualenv-13.1.2-py2.py3-none-any.whl (1.7MB)
    100% |████████████████████████████████| 1.7MB 345kB/s 
Installing collected packages: virtualenv
Successfully installed virtualenv-13.1.2
New python executable in /home/fourdollars/.pyenv/versions/watchdog/bin/python2.7
Also creating executable in /home/fourdollars/.pyenv/versions/watchdog/bin/python
Installing setuptools, pip, wheel...done.
Ignoring indexes: https://pypi.python.org/simple
Requirement already satisfied (use --upgrade to upgrade): setuptools in /home/fourdollars/.pyenv/versions/watchdog/lib/python2.7/site-packages
Requirement already satisfied (use --upgrade to upgrade): pip in /home/fourdollars/.pyenv/versions/watchdog/lib/python2.7/site-packages

接下來要建立一個 watchdog 專案目錄,並且在裡面設定使用這個獨立的 Python 環境。

$ mkdir ~/watchdog && cd ~/watchdog
$ pyenv local watchdog
$ pyenv local
watchdog

也就是說在這個目錄底下,pyenv 會自動切進跟專案目錄名稱相同的 virtualenv 環境。

接下來總算可以安裝 Django 來開發了。

$ pip install Django
Collecting Django
  Downloading Django-1.8.4-py2.py3-none-any.whl (6.2MB)
    100% |████████████████████████████████| 6.2MB 110kB/s 
Installing collected packages: Django
Successfully installed Django-1.8.4

安裝完 Django 後要重新登入一下,才可以使用 django-admin 的指令來建立這個新專案。

fourdollars@ubuntu(python):~/watchdog$ django-admin startproject watchdog .

然後就是 Django 的初始化跟啟動開發用的伺服器。

$ python manage.py migrate
Operations to perform:
  Synchronize unmigrated apps: staticfiles, messages
  Apply all migrations: admin, contenttypes, auth, sessions
Synchronizing apps without migrations:
  Creating tables...
    Running deferred SQL...
  Installing custom SQL...
Running migrations:
  Rendering model states... DONE
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying sessions.0001_initial... OK
fourdollars@ubuntu(python):~/watchdog$ python manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).
September 08, 2015 - 09:50:59
Django version 1.8.4, using settings 'watchdog.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

2015年8月17日 星期一

在 Ubuntu 14.04 上面使用 git-pbuilder 來編譯 Debian packages 給 sid 使用

在使用

$ DIST=sid ARCH=amd64 git-pbuilder create
之前,可以先編輯 ~/.pbuilderrc 檔案,加上下面的內容。

MIRRORSITE=http://ftp.debian.org/debian
DEBOOTSTRAPOPTS=( '--keyring' '/usr/share/keyrings/debian-archive-keyring.gpg' )

然後安裝 debian-archive-keyring cowbuilder git-buildpackage 這幾個套件。

 $ sudo apt-get install debian-archive-keyring cowbuilder git-buildpackage

然後就可以使用

$ DIST=sid ARCH=amd64 git-pbuilder create
來產生 /var/cache/pbuilder/base-sid-amd64.cow 這個目錄。

之後就可以在有使用 gbp 管理的 Debian package 的 git repository 底下使用

$ gbp buildpackage --git-pbuilder --git-arch=amd64 --git-dist=sid --git-export-dir=../build-dir
來編譯 Debian package 了。

2015年7月21日 星期二

在 GNU/Linux 系統上使用指令來燒錄光碟的一些心得

首先是 dvd+rw-mediainfo 這個指令可以用來檢查光碟機裡面到底是放著哪一種光碟片。

$ sudo dvd+rw-mediainfo /dev/sr0
INQUIRY:                [HL-DT-ST][DVD+-RW GP60N   ][A300]
GET [CURRENT] CONFIGURATION:
 Mounted Media:         1Ah, DVD+RW
 Media ID:              RITEK/004
 Current Write Speed:   4.0x1385=5540KB/s
 Write Speed #0:        4.0x1385=5540KB/s
 Write Speed #1:        2.4x1385=3324KB/s
 Speed Descriptor#0:    00/2295103 R@8.0x1385=11080KB/s W@4.0x1385=5540KB/s
 Speed Descriptor#1:    00/2295103 R@8.0x1385=11080KB/s W@2.4x1385=3324KB/s
READ DVD STRUCTURE[#0h]:
 Media Book Type:       00h, DVD-ROM book [revision 0]
 Legacy lead-out at:    2295104*2KB=4700372992
READ DISC INFORMATION:
 Disc status:           blank
 Number of Sessions:    1
 State of Last Session: empty
 "Next" Track:          1
 Number of Tracks:      1
READ FORMAT CAPACITIES:
 unformatted:  2295104*2048=4700372992
 26h(0):  2295104*2048=4700372992
READ TRACK INFORMATION[#1]:
 Track State:           invisible incremental
 Track Start Address:   0*2KB
 Free Blocks:           2295104*2KB
 Track Size:            2295104*2KB
READ CAPACITY:          0*2048=0

看到 Mounted Media 這行寫著 DVD+RW 就是光碟片的規格了,另外是 Disc status 這行可以看到目前光碟片的內容是空白的。

另外使用 wodim 也可以看到光碟片的規格,不過更重要的是 wodim 可以看到光碟機的規格

$ sudo wodim dev=/dev/sr0 driveropts=help -checkdrive -v
TOC Type: 1 = CD-ROM
scsidev: '/dev/sr0'
devname: '/dev/sr0'
scsibus: -2 target: -2 lun: -2
Linux sg driver version: 3.5.27
Wodim version: 1.1.11
Driveropts: 'help'
SCSI buffer size: 64512
Device type    : Removable CD-ROM
Version        : 0
Response Format: 2
Capabilities   : 
Vendor_info    : 'HL-DT-ST'
Identification : 'DVD+-RW GP60N   '
Revision       : 'A300'
Device seems to be: Generic mmc2 DVD-R/DVD-RW.
Current: 0x001A (DVD+RW)
Profile: 0x0012 (DVD-RAM) 
Profile: 0x002B (DVD+R/DL) 
Profile: 0x001B (DVD+R) 
Profile: 0x001A (DVD+RW) (current)
Profile: 0x0016 (DVD-R/DL layer jump recording) 
Profile: 0x0015 (DVD-R/DL sequential recording) 
Profile: 0x0014 (DVD-RW sequential recording) 
Profile: 0x0013 (DVD-RW restricted overwrite) 
Profile: 0x0011 (DVD-R sequential recording) 
Profile: 0x0010 (DVD-ROM) 
Profile: 0x000A (CD-RW) 
Profile: 0x0009 (CD-R) 
Profile: 0x0008 (CD-ROM) 
Profile: 0x0002 (Removable disk) 
Driver options:
burnfree Prepare writer to use BURN-Free technology
noburnfree Disable using BURN-Free technology

像是我目前使用的燒錄機有支援 burnfree 的功能,wodim 如果加上 -prcap 來使用,可以看到更詳細的細節。

$ sudo wodim -prcap dev=/dev/sr0 driveropts=help -checkdrive -v
TOC Type: 1 = CD-ROM
scsidev: '/dev/sr0'
devname: '/dev/sr0'
scsibus: -2 target: -2 lun: -2
Linux sg driver version: 3.5.27
Wodim version: 1.1.11
Driveropts: 'help'
SCSI buffer size: 64512
Device type    : Removable CD-ROM
Version        : 0
Response Format: 2
Capabilities   : 
Vendor_info    : 'HL-DT-ST'
Identification : 'DVD+-RW GP60N   '
Revision       : 'A300'
Device seems to be: Generic mmc2 DVD-R/DVD-RW.

Drive capabilities, per MMC-3 page 2A:

  Does read CD-R media
  Does write CD-R media
  Does read CD-RW media
  Does write CD-RW media
  Does read DVD-ROM media
  Does read DVD-R media
  Does write DVD-R media
  Does read DVD-RAM media
  Does write DVD-RAM media
  Does support test writing

  Does read Mode 2 Form 1 blocks
  Does read Mode 2 Form 2 blocks
  Does read digital audio blocks
  Does restart non-streamed digital audio reads accurately
  Does support Buffer-Underrun-Free recording
  Does read multi-session CDs
  Does read fixed-packet CD media using Method 2
  Does not read CD bar code
  Does not read R-W subcode information
  Does read raw P-W subcode data from lead in
  Does return CD media catalog number
  Does return CD ISRC information
  Does support C2 error pointers
  Does not deliver composite A/V data

  Does play audio CDs
  Number of volume control levels: 255
  Does support individual volume control setting for each channel
  Does support independent mute setting for each channel
  Does not support digital output on port 1
  Does not support digital output on port 2

  Loading mechanism type: tray
  Does support ejection of CD via START/STOP command
  Does not lock media on power up via prevent jumper
  Does allow media to be locked in the drive via PREVENT/ALLOW command
  Is currently in a media-locked state
  Does not support changing side of disk
  Does not have load-empty-slot-in-changer feature
  Does not support Individual Disk Present feature

  Maximum read  speed: 11080 kB/s (CD  62x, DVD  8x)
  Current read  speed: 11080 kB/s (CD  62x, DVD  8x)
  Maximum write speed:  5540 kB/s (CD  31x, DVD  4x)
  Current write speed:  5540 kB/s (CD  31x, DVD  4x)
  Rotational control selected: CLV/PCAV
  Buffer size in KB: 768
  Copy management revision supported: 1
  Number of supported write speeds: 2
  Write speed # 0:  5540 kB/s CLV/PCAV (CD  31x, DVD  4x)
  Write speed # 1:  3324 kB/s CLV/PCAV (CD  18x, DVD  2x)

Supported CD-RW media types according to MMC-4 feature 0x37:
  Does write multi speed       CD-RW media
  Does write high  speed       CD-RW media
  Does write ultra high speed  CD-RW media
  Does not write ultra high speed+ CD-RW media

如果是從來都沒有使用過的 DVD+RW 片,可能會需要先格式化一次。

$ sudo wodim dev=/dev/sr0 -format
...
$ sudo dvd+rw-mediainfo /dev/sr0
INQUIRY:                [HL-DT-ST][DVD+-RW GP60N   ][A300]
GET [CURRENT] CONFIGURATION:
 Mounted Media:         1Ah, DVD+RW
 Media ID:              RITEK/004
 Current Write Speed:   4.0x1385=5540KB/s
 Write Speed #0:        4.0x1385=5540KB/s
 Write Speed #1:        2.4x1385=3324KB/s
 Speed Descriptor#0:    00/2295103 R@8.0x1385=11080KB/s W@4.0x1385=5540KB/s
 Speed Descriptor#1:    00/2295103 R@8.0x1385=11080KB/s W@2.4x1385=3324KB/s
READ DVD STRUCTURE[#0h]:
 Media Book Type:       00h, DVD-ROM book [revision 0]
 Legacy lead-out at:    2295104*2KB=4700372992
READ DISC INFORMATION:
 Disc status:           complete
 Number of Sessions:    1
 State of Last Session: complete
 Number of Tracks:      1
 BG Format Status:      in progress, 78.1% complete
READ FORMAT CAPACITIES:
 formatted:  2295104*2048=4700372992
 26h(0):  2295104*2048=4700372992
READ TRACK INFORMATION[#1]:
 Track State:           complete incremental
 Track Start Address:   0*2KB
 Free Blocks:           0*2KB
 Track Size:            2295104*2KB
FABRICATED TOC:
 Track#1  :             14@0
 Track#AA :             14@2295104
 Multi-session Info:    #1@0
READ CAPACITY:          2295104*2048=4700372992

DVD+RW 格式化完後 Disc status 會變成 complete。

如果使用的是已經有寫入資料的 DVD-RW 片,可能會需要先快速抹除光碟內容。

$ sudo wodim -v dev=/dev/sr0 blank=fast

如果快速抹除光碟片執行失敗,也許可以試試看強迫完整抹除光碟內容。

$ sudo wodim -v dev=/dev/sr0 blank=all -force

DVD-RW 抹除後會長像下面這樣。

$ sudo dvd+rw-mediainfo /dev/sr0
INQUIRY:                [HL-DT-ST][DVD+-RW GP60N   ][A300]
GET [CURRENT] CONFIGURATION:
 Mounted Media:         14h, DVD-RW Sequential
 Media ID:              RITEKW04    
 Current Write Speed:   4.0x1385=5540KB/s
 Write Speed #0:        4.0x1385=5540KB/s
 Write Speed #1:        2.0x1385=2770KB/s
 Speed Descriptor#0:    00/2298495 R@8.0x1385=11080KB/s W@4.0x1385=5540KB/s
 Speed Descriptor#1:    00/2298495 R@8.0x1385=11080KB/s W@2.0x1385=2770KB/s
READ DVD STRUCTURE[#10h]:
 Media Book Type:       00h, DVD-ROM book [revision 0]
 Legacy lead-out at:    2298496*2KB=4707319808
READ DVD STRUCTURE[#0h]:
 Media Book Type:       33h, DVD-RW book [revision 3]
 Last border-out at:    8390653*2KB=17184057344
READ DISC INFORMATION:
 Disc status:           blank
 Number of Sessions:    1
 State of Last Session: empty
 "Next" Track:          1
 Number of Tracks:      1
READ FORMAT CAPACITIES:
 unformatted:  2297888*2048=4706074624
 00h(800):  2297888*2048=4706074624
 10h(10):  2297888*2048=4706074624
 15h(10):  2297888*2048=4706074624
READ TRACK INFORMATION[#1]:
 Track State:           blank
 Track Start Address:   0*2KB
 Next Writable Address: 0*2KB
 Free Blocks:           2297888*2KB
 Track Size:            2297888*2KB
READ CAPACITY:          0*2048=0

有時候可能會想要指定最低倍速來燒錄光碟片,因為光碟機或光碟片的品質問題,會導致全速燒錄時的失敗,最低倍速的燒錄會相對保險一些。

$ sudo wodim -v -eject dev=/dev/sr0 speed=2 driveropts=burnfree Windows10_InsiderPreview_x64_ZH-TW_10162.iso

加上 -eject 是希望燒錄完成後將光碟片拖盤退出(如果光碟機真的有拖盤的話),加上 driveropts=burnfree 是因為光碟機有這個功能。

使用 DVD+RW 跟 DVD-RW 的不同點在於 DVD+RW 只要格式化一次,之後就可以重覆地直接將 ISO 寫進去,不需要像 DVD-RW 那樣,每次都要先抹除內容,然後才可以將 ISO 寫進去。

2015年7月10日 星期五

關於 Debian/Ubuntu 裡面的 foreign-architectures 這件事

Debian 跟 Ubuntu 都在某個版本後開始支援了 Multiarch 這樣的架構,主要的中心思想是要改善檔案系統的結構,讓它能夠共存多種不同 CPU 架構的應用程式跟檔案;然後如果使用者安裝的系統是 amd64 的話,Debian 跟 Ubuntu 都會自動加入 i386 來使用。

只不過也許有些人像筆者一樣有潔癖,不喜歡系統裡面存在著其它根本完全不會去使用的東西,於是在 Ubuntu 14.04 裡面就可以用下面的指令將 i386 給移除掉。

$ sudo dpkg --remove-architecture i386

如果哪天反悔了,也可以再加回來。

$ sudo dpkg --add-architecture i386

或者想要看看目前使用了哪些額外的架構。

$ dpkg --print-foreign-architectures
i386

或是想要看看目前主要使用的架構是什麼。

$ dpkg --print-architecture
amd64

或許想要試試看 i386 跟 amd64 以外的架構(P.S. Ubuntu 只有提供少部份的幾種,Debian 也不是每個 Mirror Site 都會包含所有部份)

$ dpkg-architecture -L
...
armhf
armel
mipsn32
mipsn32el
mips64
mips64el
powerpcspe
x32
lpia
i386
ia64
alpha
amd64
armeb
arm
arm64
avr32
hppa
m32r
m68k
mips
mipsel
powerpc
ppc64
ppc64el
s390
s390x
sh3
sh3eb
sh4
sh4eb
sparc
sparc64
...

最後是在 amd64 系統裡面將 i386 移除掉,也可以順便省下一些在 apt-get update 或是 apt update 的時間,搭配以前寫過的「在 Ubuntu 上面減少 apt-get update 的時間」使用效果最好。