For increasing (or reducing) the size of the file system, we can use its flexible advantage to mange disk resource if the system deploys LVM.
At first, we have to realize whether can use all available space on the Logical Volume.
If have, we can directly grow the file system from the free space of Volume Group.
If no, we have to expand the Volume Group by adding the additional disk.
In the following lab, it will show you how to grow file system after add new disk because its operation also includes directly expand the space on LV.
Prerequisite
To check the size of the file system to realize whether the space then needs to be extend by using df –h command In the moment, the available space is 41MB and all space use 96% on the filesystem /dev/mapper/drbdVG00-drbdLV0
By using lvdisplay /dev/mapper/drbdVG00-drbdLV0 command, we can find out which Volume Group Name drbdVG00 contain this Logical Volume.
By using vgdisplay drbdVG00 command, we can find out whether the volume group drbdVG00 has available free space to allocate to the logical volume. In the moment, there is no free physical extents so that need to add new disk as adding physical volume to this volume group.
After add new disk online (# 1), we need to confirm whether the system can probe this new disk by using ls /dev/sd* commandor realize what is the status of the partition of the disk by using df –h command
Create Physical Volume
Due to the new disk never is partitioned, we will create the whole disk as a physical volume so that will convert this disk into a physical volume by using pvcreate /dev/sdc command.By using pvscan or pvscan –n command, we can know whether the physical volume is created successfully and are sure this new physical volume never belongs to any volume group now.
Add Physical Volume into the existing Volume GroupAfter the physical volume is created, we need to add it to the existing volume group by using vgextend drbdVG00 /dev/sdc command.In volume group, there is free physical content that is ready to be allocated to logical volume now by using vgdisplay drbdVG00 command.Extend Logical Volume SizeBy using lvextend –L +1020M /dev/drbdVG00/drbdLV0 command, we will extend the size of Logical Volume about 1020 MB. The “AS-IS” of using lvextend command The “TO-BE” of using lvextend command
Resize Filesystem
By using resize2fs /dev/drbdVG00/drbdLV0 command, we can resize filesystem so that logical volume will have additional space to be used now.Until now, we can use the additional space that provided by the new disk if the above process completes successfully.
Reference :
(# 1) In Hyper-V 3.0 manager, we can add the SCSI virtual disk online
and choose a location value to avoid the conflict with the existing disk.
不必問我是誰,我就像您一樣:僅是位平凡人,但卻想在人生旅途上留下生活的足跡! 哪怕是過程跌跌撞撞、經歷風風雨雨,只要有您的關注,就是我最大的欣慰與成就!!! 感謝您的蒞臨:) 下一個職涯十年信念:不到最後關頭,決不輕言放棄!!!
2013年5月11日 星期六
2013年5月8日 星期三
CentOS 6.3 --- Configure disk resource by LVM (Logical Volume Management) Command Line Interface
If the Linux Kernel version is 2.4 or above, we can use LVM tool to manage disk resource. When the running system need to add new disk, the general steps is to shutdown the system, add new disk, and restart so that the system will see the new disk. Sometimes, the disk can be added without shutdown the machine when use a hot-swappable system in real or virtual environment.
In the following lab, I have already installed CentOS minimal Guest in Hyper-V 3.0 so that it doesn’t need to reboot after add any SCSI virtual disk.
Partition the New Disk
For adding new disk, I will use LVM and its advantage for managing disk so that first running fdisk –l to realize whether the new disk has been detected.
Before add “one” new 1GB Disk (as /dev/sdb)After add “one” new 1GB Disk (as /dev/sdb)By running ls /dev/sd* command, it also has told us that the new drive /dev/sdb doesn't contain a valid partition table.The first thing is to create a partition by using fdisk /dev/sdb command and the whole disk is defined one partition.So does that the partition /dev/sdb1 will be created but its partition ID is “83”.
The second step is to change the partition’s system id from 83(Linux) to 8e(Linux LVM) by using fdisk /dev/sdb command again.So does that the partition’s system id will be “8e” now.
By running partprobe /dev/sdb1 command, it will inform the OS kernel of partition table change so that the running system doesn’t be rebooted.
Create Physical VolumeFirst, we begin to use pvcreate to initialize a block device or partition /dev/sdb1 to be used as a physical volume.The “AS-IS” of executing the pvcreate commandBy pvscan command, it scans all supported LVM block devices in the system for physical volumes.By pvdisplay command, it displays the properties of each physical volume as size, extents, volume group,etc.The “TO-BE” of executing the pvcreate command
By pvscan command, it finds out a new physical volume /dev/sdb1 as follows:By pvdisplay command, we know this new physical volume /dev/sdb1 never assign to any volume group now.
Create Volume Group
Second, we will make a volume group drbdVG00 on the physical volume /dev/sdb1 by using vgcreate command.
The “AS-IS” of executing the vgcreate command
By vgscan command, it scans all supported disk devices in the system looking for LVM physical volumes and volume groups.By vgdisplay command, it displays volume group properties (such as size, extents, number of physical volumes, etc.) in a fixed form.The “TO-BE” of executing the vgcreate command
By vgscan command, it finds out a new volume group drbdVG00By vgdisplay command, it show the properties of the volume group drbdVG00 and free PE (physical Extents) never is used.By using pvscan command, the physical volume /dev/sdb1 has already assigned to the volume group drbdVG00By using pvdisplay command, we can know what size of the physical volume /dev/sdb1 is assigned to the volume group drbdVG00
Create Logical Volume
Third, we can create a logical volume that name is drbdLV0 and size is the entire partition in volume group drbdVG00 by using lvcreate command with the syntax –n for a name and –l for the size in extents or percentage (or –L for the size in GB/MB)
syntax –l for the size in extentssyntax –l for the size in percentagesyntax –L for the size in GB/MB
The “AS-IS” of executing the lvcreate command
By lvscan command, it scans all known volume groups or all supported LVM block devices in the system for defined logical volumesBy lvdisplay command, it displays logical volume properties (such as size, layout, and mapping) in a fixed format. The “TO-BE” of executing the lvcreate command
By lvscan command, we can find out a new logical volume /dev/drbdVG00/drbdLV0By lvdisplay command, it show the properties of the new logical volume’s /dev/drbdVG00/drbdLV0 By vgdisplay command, we can find out the all extents have already been allocated.
By using ls –l command, we can see the entry /dev/drbdVG00/drbdLV0 will make a symbolic link to /dev/mapper/drbdVG00-drbdLV0
Create filesystem on Logical Volume
Finally, we have to create the filesystem as ext3, ext4 etc for the logical volume because only the file system can be saved anything. In the moment, we will create an ext4 filesystem on this new logical volume by using mkfs.ext4 /dev/drbdVG00/drbdLV0 commandMount filesystemWhen we are ready to mount the logical volume, we have to firstly create a mount point as /var/share0 by using mkdir commandnext to mount the logical volume by using mount /dev/drbdVG00/drbdLV0 /var/share0 commandBy using df –h command, we can get total disk usage on all filesystems and know the new logical volume have already been mounted.
Until now, we have completed to set up the first LVM system now. (# 1)
Reference:
(# 1) If we want to the logical volume is mounted automatically when the system boots, we have to modify /etc/fstab for /var/share0 as follows: By using mount –a command or reboot the system, we can verify the syntax in the /etc/fstab file is right.
In the following lab, I have already installed CentOS minimal Guest in Hyper-V 3.0 so that it doesn’t need to reboot after add any SCSI virtual disk.
Partition the New Disk
For adding new disk, I will use LVM and its advantage for managing disk so that first running fdisk –l to realize whether the new disk has been detected.
Before add “one” new 1GB Disk (as /dev/sdb)After add “one” new 1GB Disk (as /dev/sdb)By running ls /dev/sd* command, it also has told us that the new drive /dev/sdb doesn't contain a valid partition table.The first thing is to create a partition by using fdisk /dev/sdb command and the whole disk is defined one partition.So does that the partition /dev/sdb1 will be created but its partition ID is “83”.
The second step is to change the partition’s system id from 83(Linux) to 8e(Linux LVM) by using fdisk /dev/sdb command again.So does that the partition’s system id will be “8e” now.
By running partprobe /dev/sdb1 command, it will inform the OS kernel of partition table change so that the running system doesn’t be rebooted.
Create Physical VolumeFirst, we begin to use pvcreate to initialize a block device or partition /dev/sdb1 to be used as a physical volume.The “AS-IS” of executing the pvcreate commandBy pvscan command, it scans all supported LVM block devices in the system for physical volumes.By pvdisplay command, it displays the properties of each physical volume as size, extents, volume group,etc.The “TO-BE” of executing the pvcreate command
By pvscan command, it finds out a new physical volume /dev/sdb1 as follows:By pvdisplay command, we know this new physical volume /dev/sdb1 never assign to any volume group now.
Create Volume Group
Second, we will make a volume group drbdVG00 on the physical volume /dev/sdb1 by using vgcreate command.
The “AS-IS” of executing the vgcreate command
By vgscan command, it scans all supported disk devices in the system looking for LVM physical volumes and volume groups.By vgdisplay command, it displays volume group properties (such as size, extents, number of physical volumes, etc.) in a fixed form.The “TO-BE” of executing the vgcreate command
By vgscan command, it finds out a new volume group drbdVG00By vgdisplay command, it show the properties of the volume group drbdVG00 and free PE (physical Extents) never is used.By using pvscan command, the physical volume /dev/sdb1 has already assigned to the volume group drbdVG00By using pvdisplay command, we can know what size of the physical volume /dev/sdb1 is assigned to the volume group drbdVG00
Create Logical Volume
Third, we can create a logical volume that name is drbdLV0 and size is the entire partition in volume group drbdVG00 by using lvcreate command with the syntax –n for a name and –l for the size in extents or percentage (or –L for the size in GB/MB)
syntax –l for the size in extentssyntax –l for the size in percentagesyntax –L for the size in GB/MB
The “AS-IS” of executing the lvcreate command
By lvscan command, it scans all known volume groups or all supported LVM block devices in the system for defined logical volumesBy lvdisplay command, it displays logical volume properties (such as size, layout, and mapping) in a fixed format. The “TO-BE” of executing the lvcreate command
By lvscan command, we can find out a new logical volume /dev/drbdVG00/drbdLV0By lvdisplay command, it show the properties of the new logical volume’s /dev/drbdVG00/drbdLV0 By vgdisplay command, we can find out the all extents have already been allocated.
By using ls –l command, we can see the entry /dev/drbdVG00/drbdLV0 will make a symbolic link to /dev/mapper/drbdVG00-drbdLV0
Create filesystem on Logical Volume
Finally, we have to create the filesystem as ext3, ext4 etc for the logical volume because only the file system can be saved anything. In the moment, we will create an ext4 filesystem on this new logical volume by using mkfs.ext4 /dev/drbdVG00/drbdLV0 commandMount filesystemWhen we are ready to mount the logical volume, we have to firstly create a mount point as /var/share0 by using mkdir commandnext to mount the logical volume by using mount /dev/drbdVG00/drbdLV0 /var/share0 commandBy using df –h command, we can get total disk usage on all filesystems and know the new logical volume have already been mounted.
Until now, we have completed to set up the first LVM system now. (# 1)
Reference:
(# 1) If we want to the logical volume is mounted automatically when the system boots, we have to modify /etc/fstab for /var/share0 as follows: By using mount –a command or reboot the system, we can verify the syntax in the /etc/fstab file is right.
標籤:
技術---CentOS,
技術---Hyper-V
訂閱:
文章 (Atom)
Since 2010 Design by Davidwa
©Copyright Davidwa Inc. All rights reserved.
©Copyright Davidwa Inc. All rights reserved.