0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

論理ボリューム分割(ext4)

Posted at

環境

CentOS 6.7

VG(ボリュームグループ)確認

vgdisplay
--- Volume group ---
VG Name               centos
System ID
Format                lvm2
Metadata Areas        1
Metadata Sequence No  4
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                2
Open LV               2
Max PV                0
Cur PV                1
Act PV                1
VG Size               31.51 GiB
PE Size               4.00 MiB
Total PE              8066
Alloc PE / Size       8066 / 31.51 GiB
Free  PE / Size       0 / 0
VG UUID               gG0KE6-Go5I-VTsj-bROL-DIpP-1Fnb-7yUHMi

LV(論理ボリューム)縮小

VG確認で表示されたFree PE以上の論理ボリュームを作成しようとすると、以下のメッセージが表示されて作成できない。

lvcreate -L 5G -n Test centos
Volume group "centos" has insufficient free space (0 extents): 1280 required.

論理ボリュームを縮小させる為、インストールディスクを入れてレスキューモードで立ち上げる。
(ルートに割り当てていない論理ボリュームの場合はumountして作業すれば問題ない。)

rescue_1.png

「Rescue installed system」を選択する。

rescue_2.png

「English」を選択する。

rescue_3.png

「jp106」を選択する。

rescue_4.png

「No」を選択する。

rescue_5.png

「Skip」を選択する。

rescue_6.png

「shell Start shell」を選択する。

シェルが立ち上がるので以下のコマンドを実行する。

VGを有効にする。

lvm vgchange -a y   

縮小するLVのファイルシステムをチェックする。

fsck.ext4 -f /dev/centos/lv_root

縮小するLVのファイルシステムを縮小する。

resize2fs /dev/centos/lv_root 10G

LVのサイズを変更する。

lvm lvreduce -L10G /dev/centos/lv_root

シェルを終了する。

exit

インストールディスクを除けて起動しサイズが変更されているか確認する。
(LV Sizeが縮小時に設定したサイズになったか確認)

lvdisplay /dev/centos/lv_root
--- Logical volume ---
...
LV Size 10.00 GiB

VGを確認して空が出来たか確認する。
(Free PEが増えているか確認)

vgdisplay
--- Volume Group ---
...
Free PE / Size 4687 / 18.31 GiB

LV作成

VGに空ができたのでLVを作成する。

lvcreate -L 5G -n Test centos

Free全ての容量を割り当てる場合は以下のコマンドを実行する。

lvcreate -l 100%FREE -n Test centos

ファイルシステム構築

ext4フォーマットで構築する。

mkfs.ext4 /dev/centos/Test

マウント

作成したLVをマウントする。

mount -t ext4 /dev/centos/Test /mnt/Test

起動時に自動マウントするように/etc/fstabに以下を記述する。

/dev/centos/Test    /mnt/Test ext4 defaults 1 2
0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?