LoginSignup
0
2

More than 3 years have passed since last update.

ESXi6.7上のcentos7.7に仮想ボリュームを作成してマウントする

Posted at

VMware ESXi6.7上のCentOS7.7に、仮想ハードディスクを割り当ててマウントします。

1.仮想ハードディスクの割り当て

VMware ESXi6.7上から、CentOS7.7の仮想マシンに新たな仮想ハードディスクを割り当てします。

対象の仮想マシン画面から編集を選択する。
image.png

設定の編集画面から、ハードディスクの追加をクリックする。
image.png

新規標準ハードディスクを選択する。
image.png

新規ハードディスクが設定項目群として追加されるので、内容を適宜編集する。保存ボタンを押し、設定を確定する。

設定 内容
容量 150GB
場所 (データストア内)
ディスクプロビジョニング シンプロビジョニング

image.png

2.新規仮想ディスクの特定

以下、CentOSより行います。
ESXiから割り当てた仮想ハードディスクのディスクラベルを特定します。

partedコマンドから、パーティション未構成の新しいディスクを特定する。
対象のディスクラベルにはディスクラベルが認識できません。と後ろにつく。

# parted -l
モデル: VMware Virtual disk (scsi)
ディスク /dev/sda: 17.2GB
セクタサイズ (論理/物理): 512B/512B
パーティションテーブル: msdos
ディスクフラグ:

番号  開始    終了    サイズ  タイプ   ファイルシステム  フラグ
 1    1049kB  1075MB  1074MB  primary  xfs               boot
 2    1075MB  17.2GB  16.1GB  primary                    lvm


エラー: /dev/sdb: ディスクラベルが認識できません。
モデル: VMware Virtual disk (scsi)
ディスク /dev/sdb: 161GB
セクタサイズ (論理/物理): 512B/512B
パーティションテーブル: unknown
ディスクフラグ:
《以下略》

よって、/dev/sdbが対象と特定。

3.新規仮想ディスクのパーティショニング

まっさら状態のディスクのパーティショニングを行います。
今回はパーティションで分けず、フルで利用します。

fdiskコマンドでパーティショニングを開始する。
mコマンドでヘルプの表示、
nコマンドで新規パーティションの作成、
wコマンドでパーティションテーブルの上書き保存を行う。

# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).

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
Building a new DOS disklabel with disk identifier 0x295ea658.

コマンド (m でヘルプ): m
コマンドの動作
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

コマンド (m でヘルプ):
《続く》

mコマンドでヘルプの表示

コマンド (m でヘルプ): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
パーティション番号 (1-4, default 1): 1
最初 sector (2048-314572799, 初期値 2048):
初期値 2048 を使います
Last sector, +sectors or +size{K,M,G} (2048-314572799, 初期値 314572799):
初期値 314572799 を使います
Partition 1 of type Linux and of size 150 GiB is set

コマンド (m でヘルプ):
《続く》

nコマンドで新規パーティションの作成、
パーティションタイプはpを選択(標準パーティション)、
最初 sector および Last sector では何も入力せずにEnterキーを押して
デフォルト値を利用する

コマンド (m でヘルプ):w
パーティションテーブルは変更されました!

ioctl() を呼び出してパーティションテーブルを再読込みします。
ディスクを同期しています。
#

wコマンドでパーティションテーブルの上書き保存

確認はpartedコマンドで行う。
対象のディスクラベルにてタイプにprimaryと表示されるはず。

# parted -l
《中略》
モデル: VMware Virtual disk (scsi)
ディスク /dev/sdb: 161GB
セクタサイズ (論理/物理): 512B/512B
パーティションテーブル: msdos
ディスクフラグ:

番号  開始    終了   サイズ  タイプ   ファイルシステム  フラグ
 1    1049kB  161GB  161GB   primary
《後略》

4.ファイルシステムの作成

パーティショニングした領域に対するファイルシステムの作成を行います。

mkfsコマンドを使ってファイルシステムの作成を行う。
ファイルシステムはext4とする。

# mkfs -t ext4 /dev/sdb
mke2fs 1.42.9 (28-Dec-2013)
/dev/sdb is entire device, not just one partition!
Proceed anyway? (y,n) y
Discarding device blocks: done
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
9830400 inodes, 39321600 blocks
1966080 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2187329536
1200 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
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 (32768 blocks): done
Writing superblocks and filesystem accounting information: done

#


確認はpartedコマンドで行う。
対象のディスクラベルにてファイルシステムにext4と表示されるはず。

# parted -l
《中略》
モデル: VMware Virtual disk (scsi)
ディスク /dev/sdb: 161GB
セクタサイズ (論理/物理): 512B/512B
パーティションテーブル: loop
ディスクフラグ:

番号  開始    終了   サイズ  タイプ   ファイルシステム  フラグ
 1    0.00B  161GB  161GB   ext4
《後略》

5.マウント先ディレクトリの作成

mkdirコマンドでマウント先ディレクトリを作成します。
今回は/shareにマウントします。

# mkdir /share
#

6.マウントの実行

いよいよ、仮想ハードディスクをディレクトリにマウントします。
mountコマンドで行います。

# mount /dev/sdb /share/
#

確認はdfコマンドにて行います。

# df -h
ファイルシス                       サイズ  使用  残り 使用% マウント位置
devtmpfs                             484M     0  484M    0% /dev
tmpfs                                496M     0  496M    0% /dev/shm
tmpfs                                496M  7.1M  489M    2% /run
tmpfs                                496M     0  496M    0% /sys/fs/cgroup
/dev/mapper/centos_cent77--01-root    14G  1.2G   13G    9% /
/dev/sda1                           1014M  136M  879M   14% /boot
tmpfs                                100M     0  100M    0% /run/user/0
/dev/sdb                             148G   61M  140G    1% /share
#

最下行に表示されている。

7.OS起動時の自動マウント設定

/etc/fstabファイルに記述を行い、OS起動時に自動マウントするようにします。
ファイルの最下行に以下内容を追記します。

/dev/sdb /share ext4 defaults 1 2
[device dir filesystem mountoption dump fsck]
なお、dumpは実施が1でしないが0、fsckは1が最優先、その他2、しないが0となる。

/etc/fstab
#
# /etc/fstab
# Created by anaconda on Sat Feb  1 23:40:38 2020
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos_cent77--01-root /                       xfs     defaults        0 0
UUID=1d35d83b-8c5e-4acc-981c-24f43d5546df /boot                   xfs     defaults        0 0
/dev/mapper/centos_cent77--01-swap swap                    swap    defaults        0 0
/dev/sdb        /share  ext4    defaults        1       2

以上!

参考

第 6 回 パーティションとファイルシステムを扱う
https://www.ibm.com/developerworks/jp/linux/library/l-roadmap6/

■HDDを増設する方法
http://www.express.nec.co.jp/linux/distributions/knowledge/device/hdd.html

追加ディスクマウント(CentOS7)
https://web.arena.ne.jp/support/suiteprov4/manual/diskmount_cetnos7.html

4.4. ディスクをマウントする(Linux系OSの場合)
https://www.cloudn-service.com/guide/manuals/html/flat/rsts/ManageDisks/mount_disks_linux.html

Linux(CentOS)におけるHDD追加手順
https://tech.godpress.net/?p=442

HDD増設手順メモ
https://qiita.com/bwtakacy/items/c181f661e8655c42d85a

0
2
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
0
2