over 5 years ago

Linux, Apache, MySQL, and PHP (LAMP) on Archlinux

  1. Install Apache
    pacman -Syy apache 
    vim /etc/httpd/conf/httpd.conf
    systemctl enable httpd
    systemctl start httpd
    
    Example httpd.conf
    ServerAdmin XXXXXX@gmail.com
    ServerName 127.0.0.1:80
    ...
    LoadModule rewrite_module modules/mod_rewrite.so
    ...
    DocumentRoot "/srv/http" //the default path of web file 
    <Directory "/srv/http">
    Options FollowSymLinks
    AllowOverride All
    Require all granted
    </Directory>
    
  2. Install php
    pacman -Syy php php-apache
    vim /etc/httpd/conf/httpd.conf
    systemctl restart httpd
    
    Example httpd.conf
    ...
    #LoadModule mpm_event_module modules/mod_mpm_event.so
    LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
    ...
    LoadModule dir_module modules/mod_dir.so
    LoadModule php7_module modules/libphp7.so
    ...
    Include conf/extra/php7_module.conf
    
  3. Testing
    sudo echo "<?php phpinfo(); ?>" > /srv/http/phpinfo.php
    //Open the web
    http://127.0.0.1/phpinfo.php
    
  4. *Install MariaDB (MySQL) *
    pacman -Syy mariadb
    mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
    systemctl enable mysqld.service
    systemctl start mysqld.service
    mysql_secure_installation
    vim /etc/php/php.ini
    
    
    



    Example /etc/php/php.ini
    extension=pdo_mysql.so
    extension=mysqli.so
    
    1. *Install phpmyadmin *
      pacman -Syy phpmyadmin php-mcrypt
      vim /etc/php/php.ini
      vim /etc/httpd/conf/extra/phpmyadmin.conf
      vim /etc/httpd/conf/httpd.conf
      sudo systemctl restart httpd
      
      Example php.ini
      extension=mysqli.so
      extension=mcrypt.so
      ...
      open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/:/etc/webapps/
      
      Example phpmyadmin.conf
      Alias /phpmyadmin "/usr/share/webapps/phpMyAdmin"
      <Directory "/usr/share/webapps/phpMyAdmin">
      DirectoryIndex index.php
      AllowOverride All
      Options FollowSymlinks
      Require all granted
      </Directory>
      
      Example httpd.conf
      # phpMyAdmin configuration
      Include conf/extra/phpmyadmin.conf
      
    2. Reference
 
over 5 years ago

Node.js installation with nvm

  1. Install
    sudo pacman -Syy nodejs npm
    
    Alternate Installations (Install on user dir not system, but it is useful to manage node.js version)
    git clone git://github.com/creationix/nvm.git ~/.nvm
    echo ". ~/.nvm/nvm.sh" >> .zshrc //bashrc or your shell rc
    source .zshrc
    nvm install v0.12.13 //use nvm ls-remote to look up version
    nvm use v0.12.13
    nvm alias default v0.12.13
    
  2. Reference
 
over 5 years ago

Server site
$ cd /opt/git
$ mkdir project.git
$ cd project.git
$ git --bare init

Project site
$ cd myproject
$ git init
$ git add .
$ git commit -m 'initial commit'
$ git remote add origin [username]@[hostname]:[Dir]
$ git push origin master

Git clone
$ git clone [username]@[hostname]:[Dir]
--Testing
$ cd project
$ echo "Testing add README" > README;
$ git commit -am 'Add the README file'
$ git push origin master

 
over 6 years ago

自行編譯的好處是可以自行修改核心,而且可以更了解ODL的專案開發方式,但ODL的開發使用了許多套件,並使用了maven來管理其相依性與編譯程式,對於不熟的人來說是個很大的麻煩。故以下提供一個較完善的流程,讓新手可以快速的編譯,但並沒有多加敘述,各個部分請自行參考來源或自行搜索相關資料。

  1. ntp setup http://blog.longwin.com.tw/2009/12/ubunut-linux-set-zone-ntp-time-2009/
  2. install java
    sudo add-apt-repository ppa:webupd8team/java
    sudo apt-get update
    sudo apt-get install oracle-java7-installer
    export JAVA_HOME=/usr/lib/jvm/java-7-oracle/     //you can add it to your bashrc.
    
  3. maven 3.1.1 download
    • 參考來源
      wget http://apache.spinellicreations.com/maven/maven-3/3.1.1/binaries/apache-maven-3.1.1-bin.tar.gz
      mkdir -p /usr/local/apache-maven
      sudo cp apache-maven-3.1.1-bin.tar.gz /usr/local/apache-maven/
      cd /usr/local/apache-maven/
      sudo tar -zxvf apache-maven-3.1.1-bin.tar.gz
      sudo ln -s /usr/local/apache-maven/apache-maven-3.1.1/bin/mvn /usr/local/bin/mvn
      
    • 安裝成功,輸入"mvn -v"會有像下面一樣的訊息
      Apache Maven 3.1.1 (NON-CANONICAL_2013-11-08_14-32_mockbuild; 2013-11-08 09:32:41-0500)
      Maven home: /usr/share/maven
      Java version: 1.7.0_55, vendor: Oracle Corporation
      Java home: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.60-2.4.7.0.fc20.x86_64/jre
      Default locale: en_US, platform encoding: UTF-8
      OS name: "linux", version: "3.13.10-200.fc20.x86_64", arch: "amd64", family: "unix"
      
  4. 設定及安裝基本環境
    mkdir .m2
    cp -n ~/.m2/settings.xml{,.orig} ; \wget -q -O - https://raw.githubusercontent.com/opendaylight/odlparent/master/settings.xml > ~/.m2/settings.xml
    apt-get install git vim curl htop screen
    install mininet
    git clone git://github.com/mininet/mininet
    ./mininet/util/install.sh -a
    
  5. 下載並編譯
    mkdir opendaylight
    for PROJECT in controller openflowjava openflowplugin l2switch; \
    do git clone ssh://${ODL_USERNAME}@git.opendaylight.org:29418/${PROJECT}.git; \
    done
    //編譯順序  controller > openflowjava > openflowplugin > l2switch
    export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=512m"
    cd ~/opendaylight/controller
    git checkout -b helium remotes/origin/stable/helium
    git checkout -b helium-SR3 61e8ebd4fe43fc54b1bf54570e44bc1e20e26378
    mvn clean install 
    cd ~/opendaylight/openflowjava
    git checkout -b helium remotes/origin/stable/helium
    git checkout -b helium-SR3 2de4abf0a55b509879f9b88213ed61ed9bb0e947
    mvn clean install 
    cd ~/opendaylight/openflowplugin
    git checkout -b helium remotes/origin/stable/helium
    git checkout -b helium-SR3 c3c4614e0533c08a73a659320927bf8fdea06368
    mvn clean install 
    cd ~/opendaylight/l2switch
    git checkout -b helium remotes/origin/stable/helium
    git checkout -b helium-SR3 46b2a0167aa3e70d662478e3cb7d5d00b75f5d57
    mvn clean install 
    
    • 編譯過程中的錯誤解決
    • 目前遇到過兩種狀況
      1. 直接出現某某jar在 nexus.opendaylight.org/content/repositories/public/ 下無法存取
        解決方法
        請照著網址手動下載那個檔案,並放置.m2/repositoy中,按照網頁中一樣的目錄順序即可存取
      2. 只有出現錯誤,只有說明要到那個專案裡的 surefire-reports裡面查看 report
        然後到錯誤的專案裡,並依提示路徑找到 ~/opendaylight/controller/features/base/target/surefire-reportsTEST-org.opendaylight.yangtools.featuretest.SingleFeatureTest.xml 像這樣的檔案
        找到後可以更深入的知道什麼問題,例如我遇到的又是缺少檔案
        我缺少的是 apache 和 maven的官網某個東西無法下載,此時就依第一個解決方法一樣放入
    • 如果都不是上兩種情況,請對照一下您 maven的版本,專案的編譯順序,基本上就可以編過
  6. 執行方式
    cd ~/opendaylight/controller/opendaylight/distribution/opendaylight-karaf/target/assembly/bin/
    ./karaf
    (開過一次後在上一層的目錄下會出現 configuration/initial  裡面可以設定cluster)
    
  7. Testing
    mininet 
    sudo mn --topo linear,3 --mac --controller=remote,ip=127.0.0.1,port=6633 --switch ovsk,protocols=OpenFlow10
    md-sal apis doc
    http://localhost:8181/apidoc/explorer/index.html
    md-sal testing get topology
    curl -u admin:admin http://localhost:8181/restconf/operational/network-topology:network-topology/
    ad-sal testing get topology
    curl -u admin:admin -H 'Accept: application/json' 'http://localhost:8080/controller/nb/v2/topology/default'
    執行時需要export
    export JAVA_OPTS="-Xmx4096m -XX:MaxPermSize=512m"
    
  8. Karaf 內部的 feature install
    //karaf install featrues 可以開啟網頁
    feature:install odl-dlux-all odl-restconf odl-l2switch-switch
    http://localhost:8181/dlux/index.html
    //但查詢了http:list | grep dlux 可能不是掛載在dlux -> http://localhost:8181/index.html
    //helium-SR3 除了controller外另兩個專案rpo的新增
    feature:repo-add mvn:org.opendaylight.dlux/features-dlux/0.1.3-Helium-SR3/xml/features
    feature:repo-add mvn:org.opendaylight.openflowjava/features-openflowjava/0.5.3-Helium-SR3/xml/features
    feature:repo-add mvn:org.opendaylight.openflowplugin/features-openflowplugin/0.0.6-Helium-SR3/xml/features
    feature:repo-add mvn:org.opendaylight.l2switch/features-l2switch/0.1.3-Helium-SR3/xml/features
    feature:repo-add mvn:org.opendaylight.controller/features-adsal-compatibility/1.4.5-Helium-SR3/xml/features
    //正常運作 需要加入這些feature
    feature:install odl-base-all odl-aaa-authn odl-restconf odl-adsal-northbound odl-mdsal-apidocs odl-l2switch-switch
    //AD-SAL + MD-SAL
    feature:install odl-adsal-all odl-adsal-northbound odl-openflowjava-all odl-openflowplugin-all odl-l2switch-all odl-nsf-all odl-adsal-compatibility-all
    feature:list -i  To list only intalled features
    //cluster Testing
    feature:install odl-restconf-all
    feature:install odl-mdsal-clustering
    feature:install odl-openflowplugin-flow-services
    feature:install http
    bundle:install -s mvn:org.jolokia/jolokia-osgi/1.1.4
    //查看運作狀況
    GET http://<host>:8181/jolokia/read/org.opendaylight.controller:Category=Shards,name=member-1-shard-inventory-config,type=DistributedConfigDatastore
    
    • 補充指令 測試資料庫同步
      feature:install odl-toaster-rest
      POST /config
      {
      "toaster:toaster":
      {
      "toaster:toasterManufacturer" :"andy",
      "toaster:toasterModelNumber" : "456",
      "toaster:toasterStatus" : "up"
      }
      }
      GET/config/toaster
      
編譯指令
mvn clean install
mvn clean install -DskipTests 
mvn -Dmaven.test.failure.ignore=true --fail-at-end clean install
 
almost 7 years ago

這個問題不只是針對OpenDayLight,如果當你執行java程式時出現了java.lang.OutOfMemoryError: PermGen space的錯誤訊息,都可以使用下列方法解決問題

PermGen space全名為Permanent Generation space,jvm在執行程式時會有一區塊的記憶體是永久保留直到程式結束,這部份常用來放置一些meta訊息。
而java defult permgen value如果不夠的話就會造成此問題(OutOfMemoryError: PermGen space)。

  • 此時其實只需要在執行java程式時指定PermGen大小即可,而此大小通常有兩種變數如下
    -XX:PermSize=512m     //預設給定的記憶體保留大小
    -XX:MaxPermSize=1024m //最大給定的記憶體大小
    

此雖然網路上很多解法都是直接設定環境變數就可以運行成功,例如

export JAVA_OPTS="-XX:PermSize=512m -XX:MaxPermSize=1g"
export JAVA_PERM_MEM="512m"
export JAVA_MAX_PERM_MEM="1024m"

但經過我的測試,這樣是不一定有效的,因為我們在執行程式的時候經常是透過別人撰寫好的script,如果這些script沒有將這些環境變數執行的納入考量那就沒有用了。

  • 故可以直接在執行java的command上加入設定,如 "java XXX.jar -XX:PermSize=512m -XX:MaxPermSize=1024m"
  • (我的java底子很差...可能理解或敘述不夠精確,如果有更正確的想法我會再更改的)

進入解決opendaylight執行error正題

根據以上的想法,我們可以在opendaylight的run script上進行修改(run.sh or run.internal.sh)

  • 打開run.internal.sh
  • 移到最後面,會看到類似下面的程式碼
    $JAVA_HOME/bin/java ${extraJVMOpts} \
    
    ${agentPath} \
    
    -Djava.io.tmpdir="${iotmpdir}/work/tmp" \
    
    -Dosgi.install.area="${bdir}" \
    
    -Dosgi.configuration.area="${confarea}/configuration" \
    
    -Dosgi.frameworkClassPath="${fwclasspath}" \
    
    .....(省略)
    elif [ "${consolestart}" -eq 1 ]; then
    .... (省略) 
    $JAVA_HOME/bin/java ${extraJVMOpts} \
    
    ${agentPath} \
    
    -Djava.io.tmpdir="${iotmpdir}/work/tmp" \
    
    -Dosgi.install.area="${bdir}" \
    
    ....(省略)
    這部分的兩個判斷是內都是用來執行opendaylight的程式碼 而上面是執行後會開啟遠端console port,而下面的部分不會 所以需要在執行的參數上加上Pergen記憶體大小設定 修改後如下
    $JAVA_HOME/bin/java ${extraJVMOpts} \
    
    -XX:PermSize=512m -XX:MaxPermSize=1024m \
    
    ${agentPath} \
    
    -Djava.io.tmpdir="${iotmpdir}/work/tmp" \
    
    -Dosgi.install.area="${bdir}" \
    
    -Dosgi.configuration.area="${confarea}/configuration" \
    
    -Dosgi.frameworkClassPath="${fwclasspath}" \
    
    .....(省略)
    elif [ "${consolestart}" -eq 1 ]; then
    .... (省略) 
    $JAVA_HOME/bin/java ${extraJVMOpts} \
    
    -XX:PermSize=512m -XX:MaxPermSize=1024m \
    
    ${agentPath} \
    
    -Djava.io.tmpdir="${iotmpdir}/work/tmp" \
    
    -Dosgi.install.area="${bdir}" \
    
    ....(省略)
    如此即可避免java.lang.OutOfMemoryError: PermGen space的錯誤訊息
  • 如果是要設定整體的java執行記憶體大小可以設定script裡的jvmMaxMemory參數,例如jvmMaxMemory="-Xmx3G"

如果您是在run opendaylight helium版的./karaf 時發生錯誤的訊息,可以由下方法解決

  • 設定下列環境變數即可
    export JAVA_PERM_MEM="512m"
    export JAVA_MAX_PERM_MEM="1024m"
    
 
almost 7 years ago

目前的mininet裡的ovs仍是2.0.2

如果你有任何需要想要更新,可以依下列流程更新

  • 但如果你想要用OpenFlow1.3建議還是用目前mininet2.0.2的,目前測試升上去後與OPF1.3控制器連線時會有問題,可以connect但無法正常對談,但還不知為什麼(2014/10初測試)
    $ git clone git://github.com/mininet/mininet
    $ ./mininet/util/install.sh -a
    //刪除原本的ovs套件
    $ aptitude remove openvswitch-common openvswitch-datapath-dkms openvswitch-controller openvswitch-pki openvswitch-switch -y
    //安裝新版的ovs套件
    $ wget http://openvswitch.org/releases/openvswitch-2.3.0.tar.gz
    $ tar zxvf openvswitch-2.3.0.tar.gz
    $ cd openvswitch-2.3.0
    $ ./configure --prefix=/usr --with-linux=/lib/modules/uname -r/build
    $ make
    $ sudo make install
    $ sudo make modules_install
    $ sudo rmmod openvswitch
    $ sudo depmod -a
    $ sudo /etc/init.d/openvswitch-controller stop
    $ sudo update-rc.d openvswitch-controller disable
    $ sudo /etc/init.d/openvswitch-switch start
    

參考來源

roan's blog

 
almost 7 years ago

如果你fedora在更新或安裝新程式的時候遇到了以下的問題

Loaded plugins: langpacks, refresh-packagekit
Error: Cannot retrieve metalink for repository: fedora/20/i386. Please verify its path and try again

此時可依照下列步驟更新你的認證

  1. 刪除有關https的更新站
    # vi /etc/yum.repos.d/fedora.repo
    //把所有https 換成 http
    # vi /etc/yum.repos.d/fedora-updates.repo
    //把所有https 換成 http
    
  2. 安裝新憑證
    # yum update ca-certificates
    //or 
    # yum reinstall ca-certificates
    
    3.改回原本的https
    # vi /etc/yum.repos.d/fedora.repo
    //將剛剛改的http改回https,開頭應該是mirrorlist
    # vi /etc/yum.repos.d/fedora-updates.repo
    //將剛剛改的http改回https,開頭應該是mirrorlist
    
    以上步驟即可完成更新認證
 
almost 7 years ago

環境

**Estinet Server**
OS Fedora-17-i686-Live-Desktop
Esxi CPU 4核心
memory 2G
**controller**
Opendaylight-openflowplugin (2014/10/1 commit)
OS ubuntu 14.04lts
**模擬 openflow 1.3**

安裝基本程式

# su
# yum install screen vim
//如果不能連結server,出現以下錯誤,請參考本站其他篇logdown,
//Error: Cannot retrieve metalink for repository: fedora. Please verify its path and try again

fedora updata or install error. Cannot retrieve metalink for repository

開啟ssh並 讓ssh通過

# /sbin/service sshd enable
# /sbin/service sshd start
# iptables -I INPUT -p tcp -j ACCEPT
# iptables-save > /etc/sysconfig/iptables  

安裝estinet

  • 先EstiNet-8.0.4.2426.tar.bz2
  • 再裝patch EstiNet-8.1.4.3228.tar.bz2
    # tar -xvf EstiNet-8.0.4.2426.tar.bz2
    # cd EstiNet-8.0.4.2426/EstiNet8_InstallPackage/InstallPackage_for_LinuxFedora17_32bit/
    # tar -xvf estinet-8.0.4.2426-1.fc17.alpha.tar.bz2
    # mv estinet-8.0.4.2426-1.fc17.alpha ~/
    # su
    # ./install.sh //裝完後會要求一些設定 請按enter
    # reboot //重開機後選擇estinet kernel開機
    
  • 再裝patch EstiNet-8.1.4.3228.tar.bz2
    //登入estinet 密碼預設與帳號相通
    # su -
    # tar -xvf EstiNet-8.1.4.3228.tar.bz2
    # cd EstiNet-8.1.4.3228/InstallPackage/
    # tar -xvf estinet-8.1.4.3228-1.fc17.release.tar.bz2
    # cd estinet-8.1.4.3228-1.fc17.release
    # ./install.sh
    # reboot
    

進入estinet

# su -
# inputkey //輸入license
# reserve
//開啟三個終端機 
//第一個
# su -
# dispatcher
//第二個
# su -
# coordinator
//第三個
# su -
# estinetgui

Emulation環境設置

  • Estinet有兩張網卡,一張須可正常上網(eth0),另一張與控制器同一網段(eth1)。
  • 可上網的網段為192.168.10.0/24,與控制器相同的網段為192.168.98.0/24,設定虛擬機時得確保兩網段不可互通,否則會受到模擬時arp的假冒傳送影響。
  • 建議與控制器相連的網段不要橋接上真實網路,曾造成真實網路受到arp攻擊而癱瘓
  • 每一次重新開機均要重新配置一次網路
    //controller
    //設定IP=192.168.98.1
    //Estinet Server
    //先設定eth1 IP=192.168.98.2
    # echo 1 > /proc/sys/net/ipv4/ip_forward
    # echo 1 > /proc/sys/net/ipv4/conf/eth1/proxy_arp
    # echo 0 > /proc/sys/net/ipv4/conf/eth1/rp_filter
    # route del -net 192.168.98.0/24 dev eth1
    # route add 192.168.98.1 dev eth1
    # route add 192.168.98.3 dev lo
    
    • 接下來開始進行模擬器內部的設定,假設拓樸為下 (綠色Switch是1.0 藍色是1.3)
      示範拓樸

      設定 Controller

      設定 OPF Switch

      點擊 Node editor,更進一步的設定


      controller的內部IP可以從設定controller的那張圖看出來,他是 1.0.2.1 (灰色不可更動的那部分)

      設定 host
      先查看兩個host的內部IP


      新增在host上要執行的指令(範例只是簡單的讓兩個 host 建立tcp連線並持續傳送資訊)


      設定 simulation

      Run it

      **如果正常的話應該會出現像下面這樣的封包流,可以按播放去看封包流動的過程

#The end.....如果有空再放上其他仔細且可以使用的教學

 
about 7 years ago

前置工作

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java7-installer
$ export JAVA_HOME=/usr/lib/jvm/java-7-oracle/     //you can add it to your bashrc.
$ sudo apt-get install -y git ant mercurial aptitude curl vim screen

floodlight install

$ git clone https://bitbucket.org/sdnhub/floodlight-plus.git  (1.3)
$ cd floodlight-plus
$ ant
or
$ git clone https://github.com/rizard/floodlight (1.0)
$ cd floodlight
$ ant

mininet install&wireshark install

$ git clone git://github.com/mininet/mininet
$ ./mininet/util/install.sh -a
$ sudo /etc/init.d/openvswitch-controller stop
$ sudo update-rc.d openvswitch-controller disable
$ sudo /etc/init.d/openvswitch-switch start

start sample test

$ cd floodlight-plus;./floodlight.sh
//open other terminal
$ sudo mn --topo single,3 --mac --controller=remote,ip=127.0.0.1,port=6633 --switch ovsk,protocols=OpenFlow13
//open other terminal
$ sudo wireshark
你可以試試看 mininet 那邊 `pingall`,但預設好像沒開啟routing,所以需要下下面的指令,也就是下flow entry
$ curl -d '{"switch": "00:00:00:00:00:00:00:01", "name":"flow-mod-1", "priority":"32768", "ingress-port":"2","active":"true", "actions":"output=1"}' http://localhost:8080/wm/staticflowentrypusher/json
$ curl -d '{"switch": "00:00:00:00:00:00:00:01", "name":"flow-mod-2", "priority":"32768", "ingress-port":"1","active":"true", "actions":"output=2"}' http://localhost:8080/wm/staticflowentrypusher/json
$ curl http://localhost:8080/wm/core/switch/1/flow/json

Reference

Article update information

  • 2014/9/30 start Article
  • 2014/10/29 delete update ovs in mininet
 
about 7 years ago
# gdisk /dev/sda
GPT fdisk (gdisk) version 0.8.5

Partition table scan:
  MBR: not present
  BSD: not present
  APM: not present
  GPT: not present

Creating new GPT entries.

首先先切2M給GRUB,注意type為EF02 (BIOS boot partition)
這裡把編號設為128,維持/boot還是/dev/sd[ab]1

Command (? for help): n
Partition number (1-128, default 1): 128
First sector (34-20971486, default = 2048) or {+-}size{KMGTP}:
Last sector (2048-20971486, default = 20971486) or {+-}size{KMGTP}: +2M
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): EF02
Changed type of partition to 'BIOS boot partition'

/boot
Command (? for help): n
Partition number (1-128, default 1):
First sector (34-20971486, default = 6144) or {+-}size{KMGTP}:
Last sector (6144-20971486, default = 20971486) or {+-}size{KMGTP}: +100M
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): FD00
Changed type of partition to 'Linux filesystem'

swap,注意type為8200 (Linux swap)
Command (? for help): n
Partition number (2-128, default 2):
First sector (34-20971486, default = 210944) or {+-}size{KMGTP}:
Last sector (210944-20971486, default = 20971486) or {+-}size{KMGTP}: +1G
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 8200
Changed type of partition to 'Linux swap'

/ (root)
Command (? for help): n
Partition number (3-128, default 3):
First sector (34-20971486, default = 2308096) or {+-}size{KMGTP}:
Last sector (2308096-20971486, default = 20971486) or {+-}size{KMGTP}: +20G
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 8300
Changed type of partition to 'Linux filesystem'

Command (? for help): p
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            6144          210943   100.0 MiB   FD00  Linux RAID
   2          210944         2308095   1024.0 MiB  8200  Linux swap
   3         2308096        62914526   28.9 GiB    8300  Linux filesystem
 128            2048            6143   2.0 MiB     EF02  BIOS boot partition


Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/sda.
The operation has completed successfully.

# sgdisk /dev/sda  -R=/dev/sdb

# sgdisk -G /dev/sdb

# mkfs.btrfs -d raid1 /dev/sda3 /dev/sdb3
# btrfs filesystem show /dev/sda3
# mount -o defaults,noatime,noacl,compress=lzo,inode_cache,space_cache,autodefrag /dev/sda3 /mnt/btrfs-root
# cd /mnt/btrfs-root
# btrfs subvolume create root_subvolume
# cd root_subvolume
# btrfs subvolume create home
# btrfs subvolume create var
# btrfs subvolume create usr
# btrfs subvolume create tmp
# btrfs subvolume list -p .
ID 258 gen 12 parent 5 top level 5 path root_subvolume
ID 259 gen 7 parent 258 top level 258 path home
ID 261 gen 9 parent 258 top level 258 path var
ID 262 gen 10 parent 258 top level 258 path usr
ID 263 gen 12 parent 258 top level 258 path tmp
# cd ../
# chmod -R 0755 root_subvolume //看起來沒用
# mkdir /mnt/btrfs-system
# mount -o subvol=root_subvolume,defaults,noatime,noacl,compress=lzo,inode_cache,space_cache,autodefrag /dev/sda3 /mnt/btrfs-system
//swap boot 按原本的 並mount到正確位置上 
# cd /mnt/btrfs-system
# mdadm --create --verbose /dev/md1 --level=mirror --raid-devices=2 /dev/sd{a,b}1
# mdadm --detail --scan | tee -a /etc/mdadm.conf
# mkswap /dev/sda2
# mkswap /dev/sdb2
# swapon /dev/sd{a,b}2
# mkfs.ext2 /dev/md1
# mkdir /mnt/boot && mount /dev/md1 /mnt/boot
//安裝系統
# cd /
# pacstrap /mnt/btrfs-system base base-devel
# genfstab -U -p /mnt/btrfs-system | tee /mnt/btrfs-system/etc/fstab
# vi /mnt/btrfs-system/etc/fstab
# cp /etc/mdadm.conf /mnt/btrfs-system/etc/
\# /dev/sda3
UUID=5e36cd15-3f29-4b57-a99d-0d3230c1e483       /               btrfs           rw,noatime,compress=lzo,noacl,space_cache,autodefrag,inode_cache,subvol=root_subvolume  0 0
\# /dev/md1
UUID=21f392d6-fc78-44f5-9c05-b555a3dbbffb       /boot           ext2            rw,relatime     0 2
\# /dev/sda2
UUID=bd4c005a-e81c-46d4-9c46-f1e35f9e9b6c       none            swap            defaults        0 0
\# /dev/sdb2
UUID=1fa9b186-a957-4e14-a260-ae3eee5da8f2       none            swap            defaults,pri=-2 0 0
//chroot  安裝btrfs-progs
# arch-chroot /mnt/btrfs-system
# pacman -S btrfs-progs
# hostnamectl set-hostname linuxn.cs.nctu.edu.tw
# echo "KEYMAP=us" > /etc/vconsole.conf
# ln -s /usr/share/zoneinfo/Asia/Taipei /etc/localtime
# hwclock --systohc --utc --adjfile /etc/adjtime
# vi /etc/locale.gen
en_US.UTF-8 UTF-8
en_US ISO-8859-1
zh_CN.UTF-8 UTF-8
zh_CN GB2312
zh_TW.UTF-8 UTF-8
zh_TW BIG5
# locale-gen
# echo "LANG=en_US.UTF-8" > /etc/locale.conf
# pacman -S openssh
# systemctl enable sshd.service
# vi /etc/mkinitcpio.conf
HOOKS="base udev autodetect modconf block filesystems keyboard mdadm_udev btrfs"
# mkinitcpio -p linux
# pacman -S grub
# grub-install --target=i386-pc --recheck /dev/sda
# grub-install --target=i386-pc --recheck /dev/sdb
# cp /usr/share/locale/en\@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo
vi /etc/default/grub 
GRUB_CMDLINE_LINUX_DEFAULT="nomodeset"
# grub-mkconfig -o /boot/grub/grub.cfg
# passwd
# exit
# reboot

20141111...
未完