追加したディスクの設定方法(マウント手順):Linux系OSの場合
コントロールパネルより追加したディスクを、OSから認識させる設定の一例を説明します。お客様のご利用に応じて詳細設定を行ってください。
- 事前にコントロールパネルより、サーバーにディスクを追加する必要があります。
- 本ページでは、スタンダードイメージとして提供している Ubuntu 18.04 に 100 GB の増設ディスク (標準ディスク) をマウントした際の実行結果を例として解説いたします。
- スタンダードイメージとして提供しているRed Hat Enterprise Linux 6.10、CentOS 6.10、 Red Hat Enterprise Linux7.6、 CentOS7.6、 Ubuntu 16.04、Ubuntu 18.04のOSイメージについて、本手順で増設ディスクをext4でフォーマットしディスクを追加できます。
オンラインでディスクを追加する場合は、まずこちらの操作を行います。
# for i in $(find /sys/class/scsi_host -name 'scan') $(find /sys/devices -name 'scan') ;do echo "- - -" > $i ; done
※古いバージョンのOSでは、CPUやメモリを大量に消費したり、ディスクへの書き込みを大量に行っている場合、サーバーが異常な状態に陥る可能性があるため、事前に処理を停止してください。スタンダードイメージから作成したサーバーにつきましては、高負荷時でも正しく動作することを確認しております。
追加したディスクを確認します。コントロールパネルで追加したディスクが認識できていることを確認します。
root@ubuntu:~# fdisk -l Disk /dev/sda: 30 GiB, 32212254720 bytes, 62914560 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x0e9305f5 Device Boot Start End Sectors Size Id Type /dev/sda1 * 2048 999423 997376 487M 83 Linux /dev/sda2 999424 5101567 4102144 2G 82 Linux swap / Solaris /dev/sda3 5101568 62912511 57810944 27.6G 83 Linux Disk /dev/sdb: 100 GiB, 107374182400 bytes, 209715200 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes root@ubuntu:~#
上記結果の
Disk /dev/sdb: 100 GiB 107374182400 bytes, 209715200 sectors
が増設ディスクに該当します。- fdiskコマンドを使用し、領域を作成します。
手順 2 で確認した増設ディスクのパーティション (
/dev/sdb
) を指定して fdisk コマンドを実行します。root@ubuntu:~# fdisk /dev/sdb Welcome to fdisk (util-linux 2.31.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table. Created a new DOS disklabel with disk identifier 0x182250b7.
n
を入力し新たにパーティションを作成します。Command (m for help): n
p
を入力し基本領域を選択します。Partition type p primary (0 primary, 0 extended, 4 free) e extended (container for logical partitions) Select (default p): p
1
を入力し領域番号を指定します。Partition number (1-4, default 1): 1
始点・終点シリンダを指定します (default 値を入力、今回は始点が
2048
、終点が209715199
) 。First sector (2048-209715199, default 2048): 2048 Last sector, +sectors or +size{K,M,G,T,P} (2048-209715199, default 209715199): 209715199 Created a new partition 1 of type 'Linux' and of size 100 GiB.
p
を入力しデバイス確認をします (今回は /dev/sdb1 が表示されていればよい) 。Command (m for help): p Disk /dev/sdb: 100 GiB, 107374182400 bytes, 209715200 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x182250b7 Device Boot Start End Sectors Size Id Type /dev/sdb1 2048 209715199 209713152 100G 83 Linux
w
を入力しテーブルをディスクに書き込み終了します。Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks. root@ubuntu:~#
パーティションの更新情報を認識させます。
# partprobe
パーティションをフォーマットします。
上記 fdisk コマンドにて出力した値を入力します (ここでは
/dev/sdb1
)。root@ubuntu:~# mkfs -t ext4 /dev/sdb1 mke2fs 1.44.1 (24-Mar-2018) Creating filesystem with 26214144 4k blocks and 6553600 inodes Filesystem UUID: fdc11bf5-c65b-4e88-b3a4-1288142de082 Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872 Allocating group tables: done Writing inode tables: done Creating journal (131072 blocks): done Writing superblocks and filesystem accounting information: done root@ubuntu:~#
処理が完了しプロンプトが返ってくるまで、しばらくお待ちください。
マウントするディレクトリを作成します。
ここでは、「/add_disk1」を作成してマウントします。# mkdir /add_disk1
追加したディスクの UUID を確認します。
root@ubuntu:~# blkid /dev/sda1: UUID="19ff119b-e070-4c35-9957-fe22717f918f" TYPE="ext4" PARTUUID="0e9305f5-01" /dev/sda2: UUID="4b395b2b-d0a3-4d92-8a29-d314e1be5867" TYPE="swap" PARTUUID="0e9305f5-02" /dev/sda3: UUID="719a740c-1de4-44d8-80f0-d8308091cd00" TYPE="ext4" PARTUUID="0e9305f5-03" /dev/sdb1: UUID="fdc11bf5-c65b-4e88-b3a4-1288142de082" TYPE="ext4" PARTUUID="182250b7-01" root@ubuntu:~#
上記結果から、今回の例では増設ディスク (
/dev/sdb1
) の UUID はfdc11bf5-c65b-4e88-b3a4-1288142de082
であることが分かります。自動マウント設定を行ないます。再起動した場合も自動的にマウントするよう設定を行ないます。
「/etc/fstab」を編集します。「/etc/fstab」に増設ディスクのパーティション情報を追記します。
今回の例では最終行に
UUID=fdc11bf5-c65b-4e88-b3a4-1288142de082 /add_disk1 ext4 defaults 1 2
を追加します。※ fstabに記述したままコントロールパネルからディスクをはずすと、起動時にエラーとなり起動しません。ディスクをはずす前に、必ずfstabの記述を削除してください。
root@ubuntu:~# vi /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> # / was on /dev/sda3 during installation UUID=719a740c-1de4-44d8-80f0-d8308091cd00 / ext4 errors=remount-ro 0 1 # /boot was on /dev/sda1 during installation UUID=19ff119b-e070-4c35-9957-fe22717f918f /boot ext4 defaults 0 2 # swap was on /dev/sda2 during installation UUID=4b395b2b-d0a3-4d92-8a29-d314e1be5867 none swap sw 0 0 /dev/fd0 /media/floppy0 auto rw,user,noauto,exec,utf8 0 0 UUID=fdc11bf5-c65b-4e88-b3a4-1288142de082 /add_disk1 ext4 defaults 1 2
作成したディレクトリにマウントします。
# mount /dev/sdb1 /add_disk1
マウントしたディスクが認識されているか、確認します。
root@ubuntu:~# df -h Filesystem Size Used Avail Use% Mounted on udev 209M 0 209M 0% /dev tmpfs 48M 800K 47M 2% /run /dev/sda3 28G 1.6G 25G 7% / tmpfs 236M 0 236M 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 236M 0 236M 0% /sys/fs/cgroup /dev/sda1 464M 70M 366M 17% /boot tmpfs 48M 0 48M 0% /run/user/0 /dev/sdb1 98G 61M 93G 1% /add_disk1 root@ubuntu:~#
上記結果から
/dev/sdb1 98G 61M 93G 1% /add_disk1
と表示されているので増設ディスクが正しくマウントされていることが確認できます。