知识屋:更实用的电脑技术知识网站
所在位置:首页 > 操作系统 > linux

ESXI4.1 linux虚拟机调整扩充磁盘大小

发布时间:2014-09-05 15:38:19作者:知识屋


ESXI4.1 linux虚拟机调整扩充磁盘大小
 
首先调整磁盘大小为60G  www.zhishiwu.com  
注意: 如果虚拟机做快照是无法调节置备大小的,要先删除快照才能调整


 
点确定后,重启虚拟机OS
[root@download1 ~] shutdown -r now
 
[root@download1 ~]fdisk -l
 
Disk /dev/sda: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        2610    20860402+  8e  Linux LVM
[root@download1 ~]# df -hl
文件系统              容量  已用 可用 已用% 挂载点
/dev/mapper/VolGroup00-LogVol00
                       19G   12G  6.4G  64% /
/dev/sda1              99M   20M   75M  21% /boot
tmpfs                 2.0G     0  2.0G   0% /dev/shm
 
 [root@download1 ~]# fdisk /dev/sda
 
The number of cylinders for this disk is set to 7832.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
 
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (2611-7832, default 2611): 默认回车
Using default value 2611
Last cylinder or +size or +sizeM or +sizeK (2611-7832, default 7832):默认回车
Using default value 7832
 
Command (m for help): t
Partition number (1-4): 3
Hex code (type L to list codes): 8e
Changed system type of partition 3 to 8e (Linux LVM)
 
Command (m for help): p
 
Disk /dev/sda: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        2610    20860402+  8e  Linux LVM
/dev/sda3            2611        7832    41945715   8e  Linux LVM
 
Command (m for help): w      保存退出
The partition table has been altered!
 
Calling ioctl() to re-read partition table.
 
WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
 
重启虚拟机OS
[root@download1 ~]# shutdown -r now
[root@download1 ~]fdisk -l
Disk /dev/sda: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        2610    20860402+  8e  Linux LVM
/dev/sda3            2611        7832    41945715   8e  Linux LVM
[root@download1 ~]# df -hl
文件系统              容量  已用 可用 已用% 挂载点
/dev/mapper/VolGroup00-LogVol00
                       19G   12G  6.4G  64% /
/dev/sda1              99M   20M   75M  21% /boot
tmpfs                 2.0G     0  2.0G   0% /dev/shm
[root@download1 ~]# df -T /dev/sda1
文件系统      类型     1K-块        已用     可用 已用% 挂载点
/dev/sda1     ext3      101086     19487     76380  21% /boot
 
 格式化/dev/sda3
[root@download1 ~]# mkfs.ext3 /dev/sda3   
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
5248992 inodes, 10486428 blocks
524321 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
321 block groups
32768 blocks per group, 32768 fragments per group
16352 inodes per group
Superblock backups stored on blocks:
         32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
         4096000, 7962624
Writing inode tables: done                           
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 28 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
  创建PV
[root@download1 ~]# pvcreate /dev/sda3
  Physical volume "/dev/sda3" successfully created
  查看PV状态
[root@download1 ~]# pvdisplay
  /dev/hdc: open failed: 找不到介质
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               VolGroup00
  PV Size               19.89 GB / not usable 19.49 MB
  Allocatable           yes (but full)
  PE Size (KByte)       32768
  Total PE              636
  Free PE               0
  Allocated PE          636
  PV UUID               KjvMTJ-8laN-yuwe-N0oA-jtsF-Z0oc-CnzOUX
  
  "/dev/sda3" is a new physical volume of "40.00 GB"
  --- NEW Physical volume ---
  PV Name               /dev/sda3
  VG Name              
  PV Size               40.00 GB
  Allocatable           NO
  PE Size (KByte)       0
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               J9yLqC-vpK8-jiwd-5STl-kbRT-BGMg-UB6uPk
  
[root@download1 ~]# vgdisplay 
  /dev/hdc: open failed: 找不到介质
  --- Volume group ---
  VG Name               VolGroup00
  System ID            
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  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               19.88 GB
  PE Size               32.00 MB
  Total PE              636
  Alloc PE / Size       636 / 19.88 GB
  Free  PE / Size       0 / 0  
  VG UUID               V6H9Dr-e1mb-7E3v-uEgv-UyYX-da9Q-fD8VVp
  
  刚创建的PV加入相应的VG
[root@download1 ~]# vgextend VolGroup00 /dev/sda3
  /dev/hdc: open failed: 找不到介质
  Volume group "VolGroup00" successfully extended
 
[root@download1 ~]# vgdisplay
  /dev/hdc: open failed: 找不到介质
  --- Volume group ---
  VG Name               VolGroup00
  System ID            
  Format                lvm2
  Metadata Areas        2
  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                2
  Act PV                2
  VG Size               59.88 GB
  PE Size               32.00 MB
  Total PE              1916
  Alloc PE / Size       636 / 19.88 GB
  Free  PE / Size       1280 / 40.00 GB
  VG UUID               V6H9Dr-e1mb-7E3v-uEgv-UyYX-da9Q-fD8VVp
  
    查看LV状态
  [root@download1 ~]# lvdisplay
  /dev/hdc: open failed: 找不到介质
  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
  LV UUID                sSmNj2-Gw4B-hYE2-9nUw-ybJV-6Yxa-DU4VJt
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                19.12 GB
  Current LE             612
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
  
  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol01
  VG Name                VolGroup00
  LV UUID                LIrXiG-3IiO-LhjI-o3yN-vI5T-Yamm-FxD31j
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                768.00 MB
  Current LE             24
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1
  
=========================================================
[root@download1 ~]# lvextend -l +2559 /dev/VolGroup00/   勿回车
LogVol00  LogVol01 
注意!不知道选哪个,通过以下命令获取可以得到
[root@download1 ~]# df -hl
文件系统              容量  已用 可用 已用% 挂载点
/dev/mapper/VolGroup00-LogVol00
                       19G   12G  6.4G  64% /
/dev/sda1              99M   20M   75M  21% /boot
tmpfs                 2.0G     0  2.0G   0% /dev/shm
=========================================================
 
为/dev/VolGroup00/LogVol00增加容量
[root@download1 ~]# lvextend -l +2559 /dev/VolGroup00/LogVol00
  /dev/hdc: open failed: 找不到介质
  Extending logical volume LogVol00 to 99.09 GB
  Insufficient free space: 2559 extents needed, but only 1280 available
 
[root@download1 ~]# lvextend -l +1280 /dev/VolGroup00/LogVol00
  /dev/hdc: open failed: 找不到介质
  Extending logical volume LogVol00 to 59.12 GB
  Logical volume LogVol00 successfully resized
 
用 resize2fs 调整文件系统大小
[root@download1 ~]# resize2fs /dev/mapper/VolGroup00-LogVol00
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/mapper/VolGroup00-LogVol00 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/mapper/VolGroup00-LogVol00 to 15499264 (4k) blocks.
The filesystem on /dev/mapper/VolGroup00-LogVol00 is now 15499264 blocks long.
[root@download1 ~]# df -hl
 
文件系统              容量  已用 可用 已用% 挂载点
/dev/mapper/VolGroup00-LogVol00
                       58G   12G   44G  21%    /
/dev/sda1              99M   20M   75M  21% /boot
tmpfs                 2.0G     0  2.0G   0% /dev/shm
 
(免责声明:文章内容如涉及作品内容、版权和其它问题,请及时与我们联系,我们将在第一时间删除内容,文章内容仅供参考)
收藏
  • 人气文章
  • 最新文章
  • 下载排行榜
  • 热门排行榜