LoginSignup
4
5

More than 5 years have passed since last update.

Ubuntu 17 + Windows 10 デュアルブート環境構築

Last updated at Posted at 2018-03-01

はじめに

UEFI対応のマザーボードを搭載したPCにUbuntu 17とWindows 10をデュアルブート構成で構築する。
OSはUbuntuをメインにGPUを利用した分析が主な利用目的。
管理を行うユーザと分析を行うユーザとユーザで権限を分ける。
PCの起動とアクセスが遠隔で行えるように構成する。

IP、ポート、ユーザ名などは説明の為の仮設定。環境に合わせて変更。

サーバ構成情報

HW

パーツ 型番 個数 スペック メモ
MB Z370M-S01 1
CPU Intel Core i7-8700K 1 6core/12thread/3.7GHz
MEM PC4-192000 4 8GB/DDR4-2400/Dual Channel
Graphic NVIDIA GeForce GTX1080Ti 1 11GB/DisplayPort*3/HDMI*1
SSD(M.2) Intel 600p 1 256GB データ一時保存用
HDD WD Blue WD10EZEX 3 1TB/7200rpm Ubuntu用/データバックアップ保存用/Windows10用

SW

OS

  • Ubuntu 17.10 Desktop版(日本語化)
  • Windows 10 Home Edition
    • 必要な時だけデュアルブートで切り替え
    • Microsoftアカウント: hoge@mail.com

NW

  • ブロードバンドルータ
    • RS-500KI
  • 構成
    • ブロードバンドルータグローバルIP
    • 10.0.0.1/16
    • ブローダバンドルータプライベートIP
    • 192.168.1.1/24
    • サーバプライベートIP
    • 192.168.1.2(ブロードバンドルータにDHCPの固定IP払い出し設定)

内部からのアクセス方法

サーバ遠隔起動マジックパケット送信用宛先

  • 192.168.1.2:9
    • サーバの遠隔起動にはWakeOnLanを利用する。
    • 分析サーバのMACアドレスは「XX:XX:XX:XX:XX:XX」 ### SSH接続宛先
  • 192.168.1.2:22
    • % ssh ユーザ名@192.168.1.2

外部からのアクセス方法

サーバ遠隔起動マジックパケット送信用宛先

  • 10.0.0.1:9
    • サーバの遠隔起動にはWakeOnLanを利用する。
    • 分析サーバのMACアドレスは「XX:XX:XX:XX:XX:XX」 ### SSH接続宛先
  • 10.0.0.1:22
    • % ssh ユーザ名@10.0.0.1 -p 30022

構築

UEFI(BIOSの次世代規格)設定

  • UEFIのコンソールへ遷移する方法は、電源ON後に「Delete」ボタンを押下し続ける。後述のGO2BIOSの設定をすると電源ボタンの長押しでも遷移可能。

Settings > Advanced

  • Windows OS Configuration > Windows 10 WHQL Support: Disabled
    • Secure Boot 含め全てDisableになる。
    • Boot mode selectが自動でUEFI+Legacyになるので後ろの手順でUEFIに変更。

Settings > Boot > Boot Configuration

  • GO2BIOS: Enable(電源ボタン4秒間長押しでUEFIのコンソールへ遷移させる設定)
  • Boot Configuration > Boot mode select: UEFI
  • Boot Configuration > FIXED BOOT ORDER Piorities
    • 1: UEFI USB CD/DVD
    • 2: UEFI Hard Disk
    • ※M2(SSD)がインストールされている場合はSTAT1は利用不可なので注意
    • https://jp.msi.com/Motherboard/Z370M-MORTAR/Specification
      • 4 x SATA 6Gb/s ports1
      • 2 x M.2 slots (Key M)
      • M2_1 supports up to PCIe 3.0 x4, 2242/ 2260 /2280 storage devices
      • M2_2 supports up to PCIe 3.0 x4 and SATA 6Gb/s, 2280 storage devices
      • SATA1 port will be unavailable when an M.2 SATA SSD module has been installed in the M2_2 slot.s

OSインストール(Ubuntu)

  • SATA2に接続したHDDへインストール
  • 一度LVMで自動的にパーティションを切ってインストール。(手動でのパーティション設定ではLVMの設定ができないため)
    • 基本パーティション
    • /dev/sda1: efi
    • /dev/sda2: ファイルシステムなし ※sda1以外の全ての領域
    • LVMパーティション ※sda2をLVMの物理ボリュームとして利用される。
    • /dev/mapper/ubuntu-vg-root: ext4
    • /dev/mapper/ubuntu-vg-swap: swap
  • 再度ブートメディアを使って今度は手動でパーティションを設定

    • M2はext4で1つのパーティションに(Windowsがプリインストールされている場合ブートローダ、OS、リカバリ、バックアップなどのパーティションは全て削除)
    • 「ブートローダをインストールするデバイス」にはSATA2に接続したHDDのデバイスパスを指定「/dev/sda1」
  • ユーザ名: admin

  • ホスト名: earth

OS設定(Ubuntu)

パッケージインストール

# apt install openssl-server
※インストールするとサービスに登録され自動起動される。

root@earth:~# ps -ef | grep sshd | grep -v grep
root       945     1  0 11:02 ?        00:00:00 /usr/sbin/sshd -D

root@earth:~# systemctl list-unit-files -t service | grep sshd
sshd.service                               enabled

※rcディレクトリでどのレベルから起動するか確認
root@earth:~# find /etc/{init.d,rc*} -type f,l -name '*ssh' -exec ls -l {} \;
-rwxr-xr-x 1 root root 3837  8月 28  2017 /etc/init.d/ssh
lrwxrwxrwx 1 root root 13  2月 27 16:38 /etc/rc2.d/S01ssh -> ../init.d/ssh
lrwxrwxrwx 1 root root 13  2月 27 16:38 /etc/rc3.d/S01ssh -> ../init.d/ssh
lrwxrwxrwx 1 root root 13  2月 27 16:38 /etc/rc4.d/S01ssh -> ../init.d/ssh
lrwxrwxrwx 1 root root 13  2月 27 16:38 /etc/rc5.d/S01ssh -> ../init.d/ssh

※以下は任意で
# apt install vim
# apt install zsh

アカウント作成

  • 以下のグループを作成し、必要に応じで権限を与える。
    • general(インストール時に自動的に作成。OSのシャットダウン再起動できるグループ)
    • analysis(データ保存用デバイスへアクセスできるグループ)
    • wheel(sudoできるユーザのグループ)
■グループ作成
# groupadd -g 1001 general
# groupadd -g 1002 analysis
# groupadd -g 777 wheel

■ユーザ作成
# useradd -u UID -g GID -G 補助グループID -m ユーザ名
# useradd -u 1001 -g 1000 -G 777  -m operator
# useradd -u 1002 -g 1000 -G 1002 -m analyst

■ユーザの初期パスワード設定
# passwd ユーザ名
※ユーザ名と同じもの

■初回ログイン時にパスワード変更を強制するよう設定
# passwd -e ユーザ名

sudo権限設定

■wheelグループにroot権限を全てのコマンドで許可
# vim /etc/sudoers.d/wheel
%wheel ALL=(ALL) NOPASSWD: ALL

■generalグループにshutdownとrebootコマンドを許可
# vim /etc/sudoers.d/general
Cmnd_Alias POWER_ManalysisGEMENT = /sbin/shutdown, /sbin/reboot
%general ALL=(ALL) POWER_ManalysisGEMENT

ssh接続のための設定

■sshd(サーバ)設定
# vim /etc/sshd/sshd_config
※以下を設定
…
# 公開鍵認証有効
PubkeyAuthentication yes
# パスワードログイン禁止
PasswordAuthentication no

■各ユーザの公開鍵設置
~/.ssh/authorized_keys(ディレクトリは作成し、EC2に設置しているもを配置)

データ保存用デバイスマウント設定(/etc/fstab)

  • M2SSD: /mnt/m2へマウント(所有権はroot:analysis、パーミッションは770に変更)
  • HDD3: /mnt/hhd3へマウント(所有権はroot:analysis、パーミッションは770に変更)
■ボリュームのUUIDを確認する
root@earth:~# lsblk -f
NAME                  FSTYPE      LABEL UUID                                   MOUNTPOINT
sda
├─sda1                vfat              8177-CD7E                              /boot/efi
└─sda2                LVM2_member       ZTWgHn-lpMM-DGiJ-d6FL-rIkR-WZtU-YmkCCx
  ├─ubuntu--vg-root   ext4              973eae48-447c-4222-ae3a-74e538ad592a   /
  └─ubuntu--vg-swap_1 swap              783ada34-31e6-4f98-af68-a7b25638e1dd   [SWAP]
sdb
└─sdb1                ext4              7b2f48dc-8f30-4e94-87bb-396136149632   /mnt/hdd3
sdc
├─sdc1
└─sdc2                ntfs              D2C2CC9BC2CC84E7
nvme0n1
└─nvme0n1p1           ext4              0fd85f90-a11a-4092-a08f-e0fedb000c2f   /mnt/m2

■マウントポイントを作成
root@earth:~# mkdir /mnt/m2
root@earth:~# mkdir /mnt/hdd3

root@earth:~# ls -l /mnt/
合計 8
drwxr-xr-x 2 root root 4096  2月 28 13:58 hdd3
drwxr-xr-x 2 root root 4096  2月 27 16:29 m2

■fstabにマウントのエントリを追加
root@earth:~# vim /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/mapper/ubuntu--vg-root /               ext4    errors=remount-ro 0       1
# /boot/efi was on /dev/sda1 during installation
UUID=8177-CD7E  /boot/efi       vfat    umask=0077      0       1
/dev/mapper/ubuntu--vg-swap_1 none            swap    sw              0       0
UUID=0fd85f90-a11a-4092-a08f-e0fedb000c2f /mnt/m2   ext4 defaults,errors=remount-ro 0       1
UUID=7b2f48dc-8f30-4e94-87bb-396136149632 /mnt/hdd3 ext4 defaults,errors=remount-ro 0       1

■マウント前の状態
root@earth:~# df -h
Filesystem                   Size  Used Avail Use% Mounted on
udev                          16G     0   16G   0% /dev
tmpfs                        3.2G  9.8M  3.2G   1% /run
/dev/mapper/ubuntu--vg-root  884G  4.6G  835G   1% /
tmpfs                         16G     0   16G   0% /dev/shm
tmpfs                        5.0M  4.0K  5.0M   1% /run/lock
tmpfs                         16G     0   16G   0% /sys/fs/cgroup
/dev/sda1                    511M   29M  483M   6% /boot/efi
tmpfs                        3.2G   20K  3.2G   1% /run/user/121
tmpfs                        3.2G     0  3.2G   0% /run/user/1001

■マウント
root@earth:~# mount -a

■マウント後の状態
root@earth:~# df -h
Filesystem                   Size  Used Avail Use% Mounted on
…
/dev/nvme0n1p1               234G   61M  222G   1% /mnt/m2
/dev/sdb1                    916G   77M  870G   1% /mnt/hdd3

■analysisグループが読み書きできるように権限変更
root@earth:~# chown -R root:analysis /mnt/hdd3
root@earth:~# chown -R root:analysis /mnt/m2
root@earth:~# chmod -R 770 /mnt/hdd3
root@earth:~# chmod -R 770 /mnt/m2

root@earth:~# ls -l /mnt/
合計 8
drwxrwx--- 3 root analysis 4096  2月 28 14:04 hdd3
drwxrwx--- 3 root analysis 4096  2月 27 18:53 m2

GRUB設定

■OS選択画面のタイムアウト設定(コメントアウトのみ)
※タイムアウトの秒数を変更したい場合は「GRUB_TIMEOUT」の値を変更する。デフォルトは10秒。
root@earth:~# vim /etc/default/grub
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
#GRUB_HIDDEN_TIMEOUT=0          ※コメントアウト
#GRUB_HIDDEN_TIMEOUT_QUIET=true ※コメントアウト        
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"

OSインストール(Windows)

  • Ubuntuインストールの際にefiシステムパーティションが作成されている前提
    • インストーラが自動的にUbuntuインストール時に作成したefiシステムパーティションにWindowsのBootManagerをインストールする。
    • もしefiシステムパーティションがない場合は、インストール対象に選択したボリュームにefiシステムパーティションが作成される。
    • インストール後Ubuntuのブートローダ(Grub)のメニューにWindowsが表示される。(はず)
    • 十分確認できていないが、インストール後にUbuntuでupdate-grubを行う必要があるかも。

OS設定(Windows)

  • 初期インストール時にはMicrosoftアカウントが必要になるが、インストール後はローカルアカウントでのログインに切り替えることができる。
    • 管理者(admin)と一般ユーザ(general)を作成する。

ブロードバンドルータ設定

詳細設定-高度な設定 - ルーター(ルータ)設定マニュアルを参考に
型番は異なるが参考に。
* DHCPのIP固定的に払い出し
* サーバのNICのMACアドレス(XX:XX:XX:XX:XX:XX)を登録。
* WAN→LAN中継機能
* 有効(port30009)
* WakeOnLanのマジックパケットをLAN内に転送する為
* 静的IPマスカレード設定を追加
* メインセッションのグローバルIP:30022 -> 192.168.1.2:22

参考

パーティション設定・マルチブート環境設定

OS設定

4
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
5