在通过vSphere客户端编辑来宾VM的设置来增加Ubuntu12.04LTS VM的OS磁盘大小之后,当我从操作系统(df -h)中检查时,我没有看到磁盘大小的增加。
在windows上,我进入磁盘管理器并扩展卷以使用未分配的空间(通过增加磁盘大小创建)。如何确保操作系统在Linux中看到磁盘空间的增加?
发布于 2012-08-22 15:27:54
展开的磁盘大小是未分配和未分区的。您需要首先使用fdisk或diskpart对新磁盘空间进行分区。之后,您可能需要格式化新分区。根据您正在使用的文件系统类型,命令将有所不同,但作为一个示例,对于ext3,您将调用mkfs.ext3,然后根据操作系统的不同,您将能够增加逻辑卷。如果使用的是LVM,则只需在对新空间进行分区/初始化之后就可以扩展原始卷。
发布于 2014-12-29 16:59:24
在运行Centos 6 VMWare VPS的VMWare EXSi 5.5上,以下步骤将分区从12G扩展到26GB。
1)标识设备名称(默认情况下为/dev/sda ),并通过运行命令确认新的大小:
# fdisk -l2)获取/dev/sda设备的分区列表:
# ls -al /dev/sda*
brw-rw---- 1 root disk 8, 0 Dec 29 15:32 /dev/sda
brw-rw---- 1 root disk 8, 1 Dec 29 15:32 /dev/sda1
brw-rw---- 1 root disk 8, 2 Dec 29 15:32 /dev/sda23)创建新的主分区
# fdisk /dev/sda
Then type:
n (enter) [create new partition]
p (enter) [primary partition]
3 (enter) [next available number from listed /dev/sda partitions in 2)
(enter) [start cylinder]
(enter to use all available physical space) or specify size in +cylinders, +size{K,M,G}
t (enter) [change partition type]
3 (enter) [selecting /dev/sda3 partition]
8e (enter) [this sets partition type to Linux LVM or type L then enter to see list of types]
w (enter)
The partition table has been altered!4)重新启动Centos 6.X,然后使用root权限重新登录
# reboot5)检查新分区是否就绪,并键入'8e':
# fdisk -l
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 2089 16264192 8e Linux LVM
/dev/sda3 2089 3916 14678054 8e Linux LVM6)创建物理卷:
# pvcreate /dev/sda3
Physical volume "/dev/sda3" successfully created7)查找卷组名称:
# vgdisplay
--- Volume group ---
VG Name vg_app1
...8)扩大体积:
# vgextend vg_app1 /dev/sda3
Volume group "vg_app1" successfully extended9)将现有卷组扩展到新的物理卷(+100%空闲可更改到所需大小)。由于我们正在扩展根分区,因此指向vg_app1卷组中的vg_app1。
# lvextend -l +100%FREE /dev/vg_app1/lv_root
Size of logical volume vg_app1/lv_root changed from 11.63 GiB (2978 extents) to 25.63 GiB (6561 extents).
Logical volume lv_root successfully resized10)调整逻辑根卷的大小:
# resize2fs /dev/vg_app1/lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg_app1/lv_root is mounted on /; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 2
Performing an on-line resize of /dev/vg_app1/lv_root to 6718464 (4k) blocks.
The filesystem on /dev/vg_app1/lv_root is now 6718464 blocks long.注意:如果是Red虚拟机,请使用ext2online而不是resize2fs。
11)检查可用空间:
# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_app1-lv_root
26G 10G 14G 42% /
tmpfs 9.8G 0 9.8G 0% /dev/shm
/dev/sda1 477M 88M 364M 20% /boothttps://serverfault.com/questions/420070
复制相似问题