Chinaunix首页 | 论坛 | 博客
  • 博客访问: 160399
  • 博文数量: 31
  • 博客积分: 1720
  • 博客等级: 上尉
  • 技术积分: 305
  • 用 户 组: 普通用户
  • 注册时间: 2009-04-13 13:47
文章分类

全部博文(31)

文章存档

2014年(3)

2013年(1)

2012年(10)

2011年(1)

2010年(3)

2009年(13)

分类: LINUX

2009-08-31 17:44:22

XEN extend DomU disk

Extend DomU's LVM/DRBD disk

I had a need to extend one disk in a DomU I use as a file share. This disk is configured for the DomU in addition to the root and swap. This disk is mounted in the DomU and used as the NFS and Samba root. Before I extended this disk I used a test DomU to perform the same operation, on that test DomU I extended the root partition to see if that would cause any problems.

I was successful in all my tests and the only downtime during this operation was a reboot of the DomU. So extending any partition matching the prerequisites below should work without problems.

Below I will described how I went along.

Prerequisites

You need to have a DomU installed as described in my . The DomU will have a separate DRBD device for each file system with the underlying device being a Logical Volume (LV). So for a system with a root and a swap partition, you would have two DRBD devices in the Dom0 each with an underlying LV. So no partitioning should be done in the DomU.

Procedure

We start by extending the underlying Logical Volume (LV) on both nodes. Run the following (on both nodes):

lvextend -v -L+100G /dev/vg/test-disk 

This will extend the LV called "test-disk" in the Volume Group "vg" with 100GB.

Next step is to extend the corresponding DRBD device so it knows about the increased size of the LV. This step is only required on one node.
Run the following only on the primary node:

root@ha1:/# drbdadm resize test-disk

This will resize the DRBD device called test-disk. Note that I use the same name for the LV as for the DRBD device.

Reboot DomU:

root@ha1:/# xm console test
test:/# reboot

After reboot we need to resize the file system. My device is called /dev/xvdc and it had an original size of 100GB, so I resized /dev/xvdc to 200GB. Login to the DomU again and perform the resize:

root@ha1:/# xm console test
test:/# resize2fs /dev/xvdc 200G

Done!
Or atleast now you only have to wait for the resize to complete. Please be patient because it can take some time. My resize from 100GB to 200GB took at least 10-15 minutes.

Below you fill find the output from "df -h" before and after the resize as well as the output of the resize2fs command:

 

Before RESIZE:

test:/# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/xvda             9.9G  1.8G  7.6G  19% /
tmpfs                 193M     0  193M   0% /lib/init/rw
udev                  193M   44K  193M   1% /dev
tmpfs                 193M  4.0K  193M   1% /dev/shm
/dev/xvdc              99G   91G  3.1G  97% /data

Performing the RESIZE:

test:/# resize2fs /dev/xvdc 200G
resize2fs 1.40-WIP (14-Nov-2006)
Filesystem at /dev/xvdc is mounted on /data; on-line resizing required
old desc_blocks = 7, new_desc_blocks = 13
Performing an on-line resize of /dev/xvdc to 52428800 (4k) blocks.
The filesystem on /dev/xvdc is now 52428800 blocks long.

After RESIZE:

test:/# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/xvda             9.9G  1.8G  7.6G  19% /
tmpfs                 193M     0  193M   0% /lib/init/rw
udev                  193M   44K  193M   1% /dev
tmpfs                 193M  4.0K  193M   1% /dev/shm
/dev/xvdc             197G   91G   97G  49% /data
Last Updated on Sunday, 26 October 2008 09:20

转自


阅读(1240) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~