此产品的文档集力求使用非歧视性语言。在本文档集中,非歧视性语言是指不隐含针对年龄、残障、性别、种族身份、族群身份、性取向、社会经济地位和交叉性的歧视的语言。由于产品软件的用户界面中使用的硬编码语言、基于 RFP 文档使用的语言或引用的第三方产品使用的语言,文档中可能无法确保完全使用非歧视性语言。 深入了解思科如何使用包容性语言。
思科采用人工翻译与机器翻译相结合的方式将此文档翻译成不同语言,希望全球的用户都能通过各自的语言得到支持性的内容。 请注意:即使是最好的机器翻译,其准确度也不及专业翻译人员的水平。 Cisco Systems, Inc. 对于翻译的准确性不承担任何责任,并建议您总是参考英文原始文档(已提供链接)。
本文档介绍如何向Linux虚拟机(VM)添加磁盘空间。
Linux(和Linux VM)安装在硬盘上,无论是真实的还是虚拟的。在此之上,堆叠一个卷管理器,后跟一个通常使用的文件系统。
对于Linux VM,要增加文件系统的大小,需要执行以下步骤:
注意:许多调整大小选项是RISK的,可能使VM处于不可引导状态或数据损坏。小心。
注意:在增加磁盘空间之前,请确保已清理现有文件系统。通常,/tmp、/var/tmp、/var/tmp/broadhop和/var/log中的文件不需要,可以删除,而不是添加磁盘空间。
#df -h文件系统:______________________________安装在:____________________
以下是df -h命令的输出示例:
[root@sessionmgr02 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
18G 2.4G 15G 15% /
/dev/mapper/VolGroup00-LogVol02
5.7G 140M 5.3G 3% /home
/dev/mapper/VolGroup00-LogVol03
30G 27G 1.5G 97% /data
/dev/sda1 99M 40M 55M 43% /boot
tmpfs 16G 0 16G 0% /dev/shm
tmpfs 8.0G 1.1G 7.0G 13% /data/sessions.1
# pvdisplayPV名称:____________________________________
以下是pvdisplay命令的输出示例:
[root@sessionmgr02 ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name VolGroup00
PV Size 69.89 GB / not usable 18.64 MB
Allocatable yes
PE Size (KByte) 32768
Total PE 2236
Free PE 320
Allocated PE 1916
PV UUID HO3ICX-nRhO-FaBA-MvB3-Zlzv-JLG4-vNFQeU
注意:PV名称(/dev/sda2)显示两个内容。第一部分(/dev/sda)显示设备,第二部分(2)显示分区号。
要添加的磁盘空间:<amount>:____________________________________
# vgdisplay
分配PE/大小:_________________________________空闲PE/大小:___________________
此处显示vgdisplay命令的输出示例:
[root@sessionmgr02 ~]# vgdisplay
--- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 9
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 4
Open LV 4
Max PV 0
Cur PV 1
Act PV 1
VG Size 74.88 GB
PE Size 32.00 MB
Total PE 2396
Alloc PE / Size 1916 / 59.88 GB
Free PE / Size 480 / 15.00 GB
VG UUID pPSNBU-FRWO-z3aC-iAxS-ewaw-jOFT-dTcBKd
注意:如果有足够的可用空间用于此扩展,请继续执行第4节。如果可用空间不足,请停止此过程,并在继续之前将磁盘空间添加到Datastore。
# shutdown -h now
此示例显示shutdown -h now命令的输出:
[root@sessionmgr02 ~]# shutdown -h now
Broadcast message from root (pts/0) (Wed Dec 18 11:48:20 2013):
The system is going down for system halt NOW!
注意:增加的量必须小于Datastore上的可用空间量。 不要过度调配。
注意:等待5分钟,使VM完全加载。
# ssh
此示例显示ssh命令的输出:
[root@pcrfclient01 ~]# ssh 172.10.1.30
\\Last login: Wed Dec 18 11:48:14 2013 from 172.10.1.9
Spacewalk kickstart on 2010-08-23
[root@sessionmgr02 ~]#
# fdisk -l /dev/sda
磁盘大小:_______________________________
此示例显示fdisk -l /dev/sda命令的输出:
[root@sessionmgr02 ~]# fdisk -l /dev/sda
Disk /dev/sda2: 75.0 GB, 75047454720 bytes
255 heads, 63 sectors/track, 9124 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
此示例输出显示/dev/sda2当前已分配75G。
# fdisk
此示例显示fdisk /dev/sda命令的输出:
[root@sessionmgr02 ~]# fdisk /dev/sda
The number of cylinders for this disk is set to 9137.
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):
Command (m for help): p
此示例显示在键入字母“p”后显示分区表的输出:
Command (m for help): p
Disk /dev/sda: 75.1 GB, 75161927680 bytes
255 heads, 63 sectors/track, 9137 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 9137 73288530 8e Linux LVM
Command (m for help):
开始:__________________________ID:______________________
Command (m for help): d
此示例显示输入d后的结果:
Disk /dev/sda: 75.1 GB, 75161927680 bytes
255 heads, 63 sectors/track, 9137 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 9137 73288530 8e Linux LVM
Command (m for help): d
Partition number (1-4):
Partition number (1-4): <number>
此示例显示输入分区编号后的结果:
Disk /dev/sda: 75.1 GB, 75161927680 bytes
255 heads, 63 sectors/track, 9137 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 9137 73288530 8e Linux LVM
Command (m for help): d
Partition number (1-4): 2
Command (m for help):
Command (m for help): n
此示例显示输入n后的结果:
Disk /dev/sda: 75.1 GB, 75161927680 bytes
255 heads, 63 sectors/track, 5221 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 9137 73288530 8e Linux LVM
Command (m for help): d
Partition number (1-4): 2
Command (m for help): n
Command action
e extended
p primary partition (1-4)
Command (m for help): n
Command (m for help): p
此示例显示在输入p后的输出:
Disk /dev/sda: 75.1 GB, 75161927680 bytes
255 heads, 63 sectors/track, 5221 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 9137 73288530 8e Linux LVM
Command (m for help): d
Partition number (1-4): 2
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4):
Partition number (1-4): 2
此示例显示输入分区编号后的结果:
Disk /dev/sda: 75.1 GB, 75161927680 bytes
255 heads, 63 sectors/track, 5221 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 9137 73288530 8e Linux LVM
Command (m for help): d
Partition number (1-4): 2
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (14-9137, default 14):
此示例显示在您接受默认值并按Enter:
Disk /dev/sda: 75.1 GB, 75161927680 bytes
255 heads, 63 sectors/track, 5221 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 9137 73288530 8e Linux LVM
Command (m for help): d
Partition number (1-4): 2
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (14-9790, default 14):
Using default value 14
Last cylinder or +size or +sizeM or +sizeK (14-9790, default 9790):
此示例显示接受默认值并按Enter键后的结果:
Disk /dev/sda: 75.1 GB, 75161927680 bytes
255 heads, 63 sectors/track, 5221 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 9137 73288530 8e Linux LVM
Command (m for help): d
Partition number (1-4): 2
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (14-9790, default 14):
Using default value 14
Last cylinder or +size or +sizeM or +sizeK (14-9790, default 9790):
Using default value 9790
Command (m for help):
Command (m for help): t
此示例显示输入t后的结果:
Disk /dev/sda: 75.1 GB, 75161927680 bytes
255 heads, 63 sectors/track, 5221 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 9137 73288530 8e Linux LVM
Command (m for help): d
Partition number (1-4): 2
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (14-9790, default 14):
Using default value 14
Last cylinder or +size or +sizeM or +sizeK (14-9790, default 9790):
Using default value 9790
Command (m for help): t
Partition number (1-4):
Partition number (1-4): 2
此示例显示输入分区编号后的结果:
Disk /dev/sda: 75.1 GB, 75161927680 bytes
255 heads, 63 sectors/track, 5221 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 9137 73288530 8e Linux LVM
Command (m for help): d
Partition number (1-4): 2
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (14-9790, default 14):
Using default value 14
Last cylinder or +size or +sizeM or +sizeK (14-9790, default 9790):
Using default value 9790
Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes):
Hex code (type L to list codes): 8e
此示例显示输入十六进制代码后的结果:
Disk /dev/sda: 75.1 GB, 75161927680 bytes
255 heads, 63 sectors/track, 5221 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 9137 73288530 8e Linux LVM
Command (m for help): d
Partition number (1-4): 2
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (14-9790, default 14):
Using default value 14
Last cylinder or +size or +sizeM or +sizeK (14-9790, default 9790):
Using default value 9790
Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 8e
Changed system type of partition 2 to 8e (Linux LVM)
Command (m for help):
Command (m for help): w
此示例显示在提示符处输入w后的结果:
Disk /dev/sda: 75.1 GB, 75161927680 bytes
255 heads, 63 sectors/track, 5221 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 9137 73288530 8e Linux LVM
Command (m for help): d
Partition number (1-4): 2
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (14-9790, default 14):
Using default value 14
Last cylinder or +size or +sizeM or +sizeK (14-9790, default 9790):
Using default value 9790
Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 8e
Changed system type of partition 2 to 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: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
[root@sessionmgr02 ~]#
这将退出fdisk并带您进入根提示符。
# init 6
[root@sessionmgr02 ~]# fdisk -l /dev/sda
Disk /dev/sda2: 80.4 GB, 80418562560 bytes
255 heads, 63 sectors/track, 9777 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
此示例输出显示/dev/sda现在已分配80GB。
警告:此过程有些风险。 小心。
# pvresize /dev/sda2
此示例显示在您输入pvresize命令后的结果:
[root@sessionmgr02 ~]# pvresize /dev/sda2
Physical volume "/dev/sda2" changed
1 physical volume(s) resized / 0 physical volume(s) not resized
此示例显示输入vgdisplay命令后的结果:
[root@sessionmgr02 ~]# vgdisplay
--- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 9
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 4
Open LV 4
Max PV 0
Cur PV 1
Act PV 1
VG Size 74.88 GB
PE Size 32.00 MB
Total PE 2396
Alloc PE / Size 1916 / 59.88 GB
Free PE / Size 480 / 15.00 GB
VG UUID pPSNBU-FRWO-z3aC-iAxS-ewaw-jOFT-dTcBKd
本示例显示在上一节中添加的磁盘空间。
记录Filesystem和Mounted on the values from the df命令的输出。
# df -h
文件系统:_______________________装载于:_______________________
[root@sessionmgr02 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
18G 2.4G 15G 15% /
/dev/mapper/VolGroup00-LogVol02
5.7G 140M 5.3G 3% /home
/dev/mapper/VolGroup00-LogVol03
30G 27G 1.5G 97% /data
/dev/sda1 99M 40M 55M 43% /boot
tmpfs 16G 0 16G 0% /dev/shm
tmpfs 8.0G 1.1G 7.0G 13% /data/sessions.1
要添加的磁盘空间:<amount>:___________________________
# lvextend -L+5G /dev/mapper/VolGroup-LogVol-03
此示例显示在输入lvextend命令后的结果:
[root@sessionmgr02 ~]# lvextend -L+5G /dev/mapper/VolGroup00-LogVol03
Extending logical volume LogVol03 to 45.00 GB
Logical volume LogVol03 successfully resized
[root@sessionmgr02 ~]#
这会将新添加的空间添加到逻辑卷。
警告:此命令可能需要一些时间才能完成。
# resize2fs <filesystem>
此示例显示在您输入resize2fs命令后的结果:
[root@sessionmgr02 ~]# resize2fs /dev/mapper/VolGroup00-LogVol03
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/mapper/VolGroup00-LogVol03 is
mounted on /data; on-line resizing required
Performing an on-line resize of /dev/mapper/VolGroup00-LogVol03
to 11796480 (4k) blocks.
The filesystem on /dev/mapper/VolGroup00-LogVol03 is now 11796480 blocks long.
[root@sessionmgr02 ~]#
# df -h
输入df -h命令的示例结果:
[root@sessionmgr02 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
18G 2.4G 15G 15% /
/dev/mapper/VolGroup00-LogVol02
5.7G 140M 5.3G 3% /home
/dev/mapper/VolGroup00-LogVol03
44G 22G 21G 52% /data
/dev/sda1 99M 40M 55M 43% /boot
tmpfs 16G 0 16G 0% /dev/shm
tmpfs 8.0G 4.0K 8.0G 1% /data/sessions.1
版本 | 发布日期 | 备注 |
---|---|---|
1.0 |
29-Jun-2015 |
初始版本 |