You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users-cn@cloudstack.apache.org by Ningning Li <li...@wandoujia.com> on 2013/05/20 09:05:29 UTC

怎么增加kvm 硬盘的大小

用的lvm的存储池,虚拟机的数据盘是一个单独的卷,现在想增加虚拟机数据盘大小,请问怎么增加呢?可以不停机么?



-- 
Ningning Li
sa | Wandou Labs
qq 468032221
tel 186 1220 6308

Re: 怎么增加kvm 硬盘的大小

Posted by Gavin Lee <ga...@gmail.com>.
CloudStack下无法动态调整内存大小, 需要关机, 应用新的服务方案再开机才行.


On Mon, May 20, 2013 at 5:56 PM, Ningning Li <li...@wandoujia.com>wrote:

> 好的,多谢。
>
> 我用的是centos 6.3,现在有很多KVM虚拟机在线上用,之前没有考虑过动态调整 硬盘和网卡等。
>
> 请问 如何 动态调整cpu核数和内存大小呢 :)
>
>
>
>
>
> 2013/5/20 Gavin Lee <ga...@gmail.com>
>
> > 经常这样操作, 你可以先在新建一个Volume, 然后Attach到已运行的VM上. 再通过lvextend的相关命令扩充即可.
> 不需要关机就可操作.
> >
> > 不知你OS是什么发行版, 在Redhat/CentOS下, 假设之前有一个20G的盘, 要再扩充40G的空间,
> > 可以新添加了一个卷(/dev/sdb), 具体命令及步骤:
> >
> > 1.            Add new physical disk. Boot.
> >
> > 2.            # pvscan
> >
> > This will show you the current physical volumes.
> >
> > 3.            # fdisk /dev/sdb
> >
> > Add the disk to your machine as a primary partition. Partition type: “8e
> > (LVM)”. Obviously /dev/sdb may be different on your system.
> >
> > 4.            # pvcreate /dev/sdb1
> >
> > This creates a new physical LVM volume on our new disk.
> >
> > 5.            # vgextend VolGroup00 /dev/sdb1
> >
> > Add our new physical volume to the volume group: VolGroup00. Again, this
> > group name may by different for you, but this is what Redhat & CentOS
> > assigns by default when you install your system.
> >
> > 6.            # pvscan
> >
> > You should see the new physical volume assigned to VolGroup00.
> >
> > 7.            # lvextend -L+40G /dev/VolGroup00/LogVol00
> >
> > This increases the size of the logical volume our root partition resides
> > in. Change the -L flag as appropriate.
> >
> > We’ve just added 40GB to the logical volume used by the root partition.
> > Sweet as. Now we need to resize the file system to utilize the additional
> > space.
> >
> > 8.            Reboot into rescue mode using your CentOS CDROM.
> >
> > From memory this involves typing linux rescue as your boot option.
> >
> > 9.            When prompted, skip the mounting of system partitions.
> >
> > 10.        # lvm vgchange -a y
> >
> > This command makes your LVM volumes accessible.
> >
> > 11.        # e2fsck -f /dev/VolGroup00/LogVol00
> >
> > Run a file system check, the -f flag seems necessary. No idea what we do
> if
> > the returns an error?
> >
> > 12.        # resize2fs /dev/VolGroup00/LogVol00
> >
> > Without any parameters resize2fs will just increase the file system to
> the
> > max space available.
> >
> >
> > 需要注意的是, 这个附加的盘不要再从这个VM上Dettach
> >
> >
> >
> > 2013/5/20 Ningning Li <li...@wandoujia.com>
> >
> > > 用的lvm的存储池,虚拟机的数据盘是一个单独的卷,现在想增加虚拟机数据盘大小,请问怎么增加呢?可以不停机么?
> > >
> > >
> > >
> > > --
> > > Ningning Li
> > > sa | Wandou Labs
> > > qq 468032221
> > > tel 186 1220 6308
> > >
> >
> >
> >
> > --
> > Gavin
> >
>
>
>
> --
> Ningning Li
> sa | Wandou Labs
> qq 468032221
> tel 186 1220 6308
>



-- 
Gavin

Re: 怎么增加kvm 硬盘的大小

Posted by Ningning Li <li...@wandoujia.com>.
好的,多谢。

我用的是centos 6.3,现在有很多KVM虚拟机在线上用,之前没有考虑过动态调整 硬盘和网卡等。

请问 如何 动态调整cpu核数和内存大小呢 :)





2013/5/20 Gavin Lee <ga...@gmail.com>

> 经常这样操作, 你可以先在新建一个Volume, 然后Attach到已运行的VM上. 再通过lvextend的相关命令扩充即可. 不需要关机就可操作.
>
> 不知你OS是什么发行版, 在Redhat/CentOS下, 假设之前有一个20G的盘, 要再扩充40G的空间,
> 可以新添加了一个卷(/dev/sdb), 具体命令及步骤:
>
> 1.            Add new physical disk. Boot.
>
> 2.            # pvscan
>
> This will show you the current physical volumes.
>
> 3.            # fdisk /dev/sdb
>
> Add the disk to your machine as a primary partition. Partition type: “8e
> (LVM)”. Obviously /dev/sdb may be different on your system.
>
> 4.            # pvcreate /dev/sdb1
>
> This creates a new physical LVM volume on our new disk.
>
> 5.            # vgextend VolGroup00 /dev/sdb1
>
> Add our new physical volume to the volume group: VolGroup00. Again, this
> group name may by different for you, but this is what Redhat & CentOS
> assigns by default when you install your system.
>
> 6.            # pvscan
>
> You should see the new physical volume assigned to VolGroup00.
>
> 7.            # lvextend -L+40G /dev/VolGroup00/LogVol00
>
> This increases the size of the logical volume our root partition resides
> in. Change the -L flag as appropriate.
>
> We’ve just added 40GB to the logical volume used by the root partition.
> Sweet as. Now we need to resize the file system to utilize the additional
> space.
>
> 8.            Reboot into rescue mode using your CentOS CDROM.
>
> From memory this involves typing linux rescue as your boot option.
>
> 9.            When prompted, skip the mounting of system partitions.
>
> 10.        # lvm vgchange -a y
>
> This command makes your LVM volumes accessible.
>
> 11.        # e2fsck -f /dev/VolGroup00/LogVol00
>
> Run a file system check, the -f flag seems necessary. No idea what we do if
> the returns an error?
>
> 12.        # resize2fs /dev/VolGroup00/LogVol00
>
> Without any parameters resize2fs will just increase the file system to the
> max space available.
>
>
> 需要注意的是, 这个附加的盘不要再从这个VM上Dettach
>
>
>
> 2013/5/20 Ningning Li <li...@wandoujia.com>
>
> > 用的lvm的存储池,虚拟机的数据盘是一个单独的卷,现在想增加虚拟机数据盘大小,请问怎么增加呢?可以不停机么?
> >
> >
> >
> > --
> > Ningning Li
> > sa | Wandou Labs
> > qq 468032221
> > tel 186 1220 6308
> >
>
>
>
> --
> Gavin
>



-- 
Ningning Li
sa | Wandou Labs
qq 468032221
tel 186 1220 6308

Re: 怎么增加kvm 硬盘的大小

Posted by Gavin Lee <ga...@gmail.com>.
经常这样操作, 你可以先在新建一个Volume, 然后Attach到已运行的VM上. 再通过lvextend的相关命令扩充即可. 不需要关机就可操作.

不知你OS是什么发行版, 在Redhat/CentOS下, 假设之前有一个20G的盘, 要再扩充40G的空间,
可以新添加了一个卷(/dev/sdb), 具体命令及步骤:

1.            Add new physical disk. Boot.

2.            # pvscan

This will show you the current physical volumes.

3.            # fdisk /dev/sdb

Add the disk to your machine as a primary partition. Partition type: “8e
(LVM)”. Obviously /dev/sdb may be different on your system.

4.            # pvcreate /dev/sdb1

This creates a new physical LVM volume on our new disk.

5.            # vgextend VolGroup00 /dev/sdb1

Add our new physical volume to the volume group: VolGroup00. Again, this
group name may by different for you, but this is what Redhat & CentOS
assigns by default when you install your system.

6.            # pvscan

You should see the new physical volume assigned to VolGroup00.

7.            # lvextend -L+40G /dev/VolGroup00/LogVol00

This increases the size of the logical volume our root partition resides
in. Change the -L flag as appropriate.

We’ve just added 40GB to the logical volume used by the root partition.
Sweet as. Now we need to resize the file system to utilize the additional
space.

8.            Reboot into rescue mode using your CentOS CDROM.

>From memory this involves typing linux rescue as your boot option.

9.            When prompted, skip the mounting of system partitions.

10.        # lvm vgchange -a y

This command makes your LVM volumes accessible.

11.        # e2fsck -f /dev/VolGroup00/LogVol00

Run a file system check, the -f flag seems necessary. No idea what we do if
the returns an error?

12.        # resize2fs /dev/VolGroup00/LogVol00

Without any parameters resize2fs will just increase the file system to the
max space available.


需要注意的是, 这个附加的盘不要再从这个VM上Dettach



2013/5/20 Ningning Li <li...@wandoujia.com>

> 用的lvm的存储池,虚拟机的数据盘是一个单独的卷,现在想增加虚拟机数据盘大小,请问怎么增加呢?可以不停机么?
>
>
>
> --
> Ningning Li
> sa | Wandou Labs
> qq 468032221
> tel 186 1220 6308
>



-- 
Gavin