VirtualBox に Ubuntu 16.04 LTS を入れる のバックアップの現在との差分(No.1)

更新


  • 追加された行はこの色です。
  • 削除された行はこの色です。
[[公開メモ]]

* Petalinux の推奨なのでこのバージョンです [#cef3114c]

サーバー用のディストリビューションになります。

LTS は長期サポート版ということで、[[2021年4月 までのサポート>https://ja.wikipedia.org/wiki/Ubuntu#.E3.82.B5.E3.83.9D.E3.83.BC.E3.83.88.E6.9C.9F.E9.96.93]] が予定されています。

* インストールメディアのダウンロード [#u285ba0a]

https://www.ubuntu.com/download/server

サイズは 667MB でした。
ubuntu-16.04.1-server-amd64.iso のサイズは 667MB でした。

* VirtualBox の準備 [#r519a54e]

VirtualBox マネージャから [新規] で、Ubuntu16LTS と名付けました。

&ref(virtualbox-create-ubuntuvm.png,,66%);

ハードディスクサイズは60GB取ってあります。
かなり大きめですが可変サイズディスクなので、
実際に使用した分しか実ディスクを圧迫しません。

&ref(virtualbox-create-ubuntuvm2.png,,66%);

* インストールメディアを挿入して起動 [#pac13b64]

VM の右クリックから [設定]-[ストレージ] で光学ドライブに
上でダウンロードした C:\Users\osamu\Downloads\ubuntu-16.04.1-server-amd64.iso 
を割り当て、起動します。

&ref(insert-install-medium.png,,66%);

* インストール [#q25cf2fb]

- 言語をカーソルキーで選択して ENTER
- [Ubuntu Server をインストール] を選択
- ロケール情報で 日本 をどんどん選択
- ネットワーク接続は自動検出されました
- ホスト名は ubuntu16lts
- 自分のユーザーアカウントを作成
- 暗号化はせず
- タイムゾーンは Asia/Tokyo で YES
- パーティショニングはディスク全体を使用し LVM をセットアップ
-- あとはデフォルト設定
- プロキシ設定は空のまま
- セキュリティアップデートは自動でインストールする
- ソフトウェアの選択でマニュアル設定を選んだところ何も聞かれなかった???
- マスターブートレコードに GRUB をインストールする
- 自動で CD イメージがイジェクトされるので、最後に [続ける] を押して再起動

ここまででコンソールが立ち上がるようになった。

&ref(ubuntu16lts-as-installed.png,,66%);

登録したユーザーは sudo グループに含まれ、始めから sudo できるようになっていた。

 LANG:console
 $ sudo apt-get install etckeeper
 $ sudo apt-get install jed           # 個人的によく使っているエディタ
 $ sudo shutdown 0

で一旦仮想マシンの電源をオフにする。

この時点でディスクの使用量は 1.4GB くらい。
何がそんなに入っているんだろう?

* ネットワーク設定 [#g7909418]

VirtualBox マネージャで VM を右クリックして [設定]-[ネットワーク]-[アダプター2]
にてネットワークアダプターを有効化し、[ホストオンリーアダプター] を割り当てる

&ref(network-config.png,,66%);

もう一度起動すると、enp0s8 というのが増えているので、
これを dhcp でつながるように設定する。

 LANG:console
 $ export LANG=C
 $ sudo ifconfig -a
  enp0s8   ...
           ...
 $ cat << EOT | sudo tee -a /etc/network/interfaces
 
 # The host only interface
 auto enp0s8
 iface enp0s8 inet dhcp
 EOT
 $ sudo /etc/init.d/networking restart
 [ OK ] Restarting networking (via systemctl): networking.service.
 $ sudo ifconfig
  enp0s8   ...
           inet addr:192.168.56.101  ...
           ...
 $ sudo apt-get install openssh-server

これで ssh でつなげられるようになった。

* samba 設定 [#je2da8ed]

 LANG:console
 $ sudo apt-get install samba
 $ sudo jed /etc/samba/smb.conf
    [homes]
      comment = Home Directories
      browsable = no
      read only = no
      create mask = 0644
      directory mask = 0755
 $ # samba インストール前に作られた既存ユーザーについては
 $ # 別途 samba に登録してやる必要がある
 $ sudo pdbedit -a -u osamu
  new password:
  retype new password:
 $ sudo /etc/init.d/samba restart
  [ ok ] Restarting nmbd (via systemctl): nmbd.service.
  [ ok ] Restarting smbd (via systemctl): smbd.service.
  [ ok ] Restarting samba-ad-dc (via systemctl): samba-ad-dc.service.

これでつながるようになりました。


* デスクトップ環境を整える場合 [#o18dcf9d]

軽量と名高い LXDE を入れる?

 LANG:console
 $ sudo apt-get install --no-install-recommends xserver-xorg lxde lxdm fonts-takao-gothic fonts-takao-pgothic fonts-takao-mincho desktop-base lxlauncher lxtask
  パッケージリストを読み込んでいます... 完了
  依存関係ツリーを作成しています
  状態情報を読み取っています... 完了
  提案パッケージ:
    cpp-doc gcc-5-locales evince-gtk libasound2-plugins alsa-utils libfm-tools nautilus-actions gvfs
    liblcms2-utils librsvg2-bin gimp libreoffice pidgin update-notifier xfce4-power-manager
    firefox | www-browser menu iceweasel | www-browser fonts-dejavu libxml2-dev tint2 openbox-menu
    openbox-gnome-session openbox-kde-session mesa-utils nickle cairo-5c xorg-docs-core arj lhasa rar rpm unar
    zip
  推奨パッケージ:
    xdg-utils at-spi2-core colord libtxc-dxtn-s2tc | libtxc-dxtn-s2tc0 | libtxc-dxtn0 libgtk2.0-bin
    gtk2-engines alsamixergui clipit deluge | transmission-gtk evince-gtk | pdf-viewer gnome-disk-utility
    gnome-mplayer gnome-system-tools gucharmap iceweasel | www-browser lxmusic | audacious lxpolkit menu-xdg
    usermode wicd | network-manager-gnome gnome-screenshot gksu notification-daemon xscreensaver obconf 
    python-xdg | obsession scrot gvfs-backends gvfs-fuse policykit-1-gnome | mate-polkit | lxpolkit p7zip-full 
    unzip
  この操作後に追加で 369 MB のディスク容量が消費されます。
 $ sudo reboot

&ref(電気回路/zynq/Petalinux のビルド/lxdm-screen.png,,33%);

* 他に入れたパッケージ [#o7960589]

 LANG:console
 $ sudo apt-get install bash-completion
 $ wget https://github.com/peco/peco/releases/download/v0.4.7/peco_linux_amd64.tar.gz
 $ tar fxz peco_linux_amd64.tar.gz peco_linux_amd64/peco -O | sudo tee /usr/local/bin/peco > /dev/null
 $ sudo chmod a+x /usr/local/bin/peco
 $ rm peco_linux_amd64.tar.gz
 $ cat > ~/.gitconfig
 [user]
         email = osamu@big.jp
         name = Osamu Takeuchi
 [alias]
   s = status
   co = checkout
   l = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
   la = log --graph --all --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
   tag-date="for-each-ref --sort=-taggerdate --format='%(taggerdate:short) %(tag) %(taggername) %(subject)' refs/tags"
   # SYNTAX: git d
   #
   # 履歴一覧を表示して選択した履歴との diff を取る
   # 初期状態のまま Enter を押せば単に git diff と打ったのと同様に HEAD と working copy との間の差分をとる
   # 履歴を1つ選んで Enter を押せば、その履歴と working copy との差分を取る
   # Ctrl+space で2つ選べば、その間の差分を取る
   #
   d = !git diff --minimal --ignore-all-space `git log --oneline --branches | peco | ruby -e 'STDIN.readlines.reverse.each{|s| puts s[0..6]}'`
 
   # SYNTAX: git add-files
   #
   # git add するファイルを peco で選択する
   add-files= "!if [ \"`git status --porcelain | grep -E '^.[^ ]'`\" != \"\" ]; then git add `git status --porcelain | grep -E '^.[^ ]' | peco | sed -e 's/.* //'`; fi"
 
   # SYNTAX: git rm-files
   #
   # git rmするファイルを peco で選択する
   rm-files= "!if [ \"`git status --porcelain | grep -E '^.[^ ]'`\" != \"\" ]; then git rm `git status --porcelain | grep -E '^.[^ ]' | peco | sed -e 's/.* //'`; fi"
 
   # SYNTAX: git reset-files
   #
   # git reset するファイルを peco で選択する
   reset-files = "!if [ \"`git status --porcelain | grep -E '^[^\\? ]'`\" != \"\" ]; then git reset `git status --porcelain | grep -E '^[^\\? ]' | peco | sed -e 's/.* //'`; fi"
 ^D
 $ cat >> ~/.bashrc
 function peco-cd() {
     local n="1"
     if [ $# -eq "1" ]; then
       n=$1
     fi
     local dir="$( find . -maxdepth $n -type d | sed -e 's;\./;;' | peco )"
     if [ ! -z "$dir" ] ; then
         cd "$dir"
     fi
 }
 
 function peco-kill() {
   kill `ps aux | peco | awk '{print $2}'`
 }
 
 function peco-kill-kill() {
   kill -KILL `ps aux | peco | awk '{print $2}'`
 }
 
 export HISTCONTROL="ignoredups"
 peco-history() {
     local NUM=$(history | wc -l)
     local FIRST=$((-1*(NUM-1)))
 
     if [ $FIRST -eq 0 ] ; then
         history -d $((HISTCMD-1))
         echo "No history" >&2
         return
     fi  
 
     local CMD=$(fc -l $FIRST | sort -k 2 -k 1nr | uniq -f 1 | sort -nr | sed -E 's/^[0-9]+[[:blank:]]+//' | peco | head -n 1)
 
     if [ -n "$CMD" ] ; then
         history -s $CMD
 
         if type osascript > /dev/null 2>&1 ; then
             (osascript -e 'tell application "System Events" to keystroke (ASCII character 30)' &)
         fi  
     else
         history -d $((HISTCMD-1))
     fi  
 }
 bind -x '"\C-r":peco-history'
 ^D

* 質問・コメント [#bb4f7fa4]

#article_kcaptcha


Counter: 5730 (from 2010/06/03), today: 1, yesterday: 0