Chinaunix首页 | 论坛 | 博客
  • 博客访问: 356924
  • 博文数量: 51
  • 博客积分: 916
  • 博客等级: 准尉
  • 技术积分: 539
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-01 15:37
文章分类

全部博文(51)

文章存档

2014年(1)

2012年(49)

2011年(1)

我的朋友

分类: LINUX

2012-07-02 17:03:29

转自:http://blog.stastnarodina.com/honza-en/spot/howto-add-disk-to-vmware-ubuntu-guest-without-reboot-using-lvm/

HOWTO: add disk to VMware Ubuntu guest without reboot using LVM

This howto is mostly built on the great tutorial available at . My spot tries to be more Ubuntu and LVM specific. This manual was tested on Ubuntu 9.04 (jaunty) Server edition guest OS.

Add Virtual Hard Disk

add-disk1 A new hard disk can be added easily to a running virtual machine in VMWare Infrastructure Web Access by clicking Add Hardware and following the wizard.

Note: I assume that all of the commands given are run under superuser (root) rights. To become root type

  1. sudo su root 

Detect new SCSI Disk

The package provides the script rescan-scsi-bus.sh, which does exacly what we need. Install it and run it:

  1. apt-get install scsitools rescan-scsi-bus.sh

This should detect the newly added hard disk and make it available in /dev/ – /dev/sdb in the case you are adding a new drive for the first time. The output of fdisk -l should include the newly detected disk.

Format the new disk

Format the newly detected drive using fdisk

  1. fdisk /dev/sdb
  2.     n (for new partition)
  3.     p (for primary partition)
  4.     1 (partition number)
  5.     (keep the other values default)
  6.     w (write changes)

Change the type of the partition to LVM Linux:

  1. fdisk /dev/sdb
  2.     t (change the partition type)
  3.     8e (for Linux LVM) w (write changes)
LVM Initialize LVM Physical Volume pvcreate /dev/sdb1 Add Physical Volume to Volume Group

List the Volume groups available at your machine.

  1. vgdisplay

Replace VolGroupName with what you read from the output of the last command.

  1. vgextend VolGroupName /dev/sdb1
You should see the newly aquired free space in the output of vgdisplay Resize Logical Volumes

After adding some free space to your Volume Group, you can distribute it to the Logical Volumes. The list of Logical Volumes can be obtained by running

  1. lvdisplay
Run the following commands for each Logical Volume you want to resize (add space to). Again – replace /dev/VolGroupNa­me/Name with the Logical Volume name you can read from the output of the last command. The +10G means Add 10 GB

  1. lvextend -L +10G /dev/VolGroupName/Name

The last step is to resize the ext3 filesystem (use different tool is you use different filesystem):

  1. resize2fs /dev/VolGroupName/Name
阅读(1901) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~