扩展Fedora 16虚拟机的根分区磁盘容量(VMware workstation 7)
1. 关闭虚拟机fedora 16,通过vmware的虚拟机/设置/来扩展磁盘容量(8G);
2. 通过命令parted -l /dev/sda print确认磁盘空间已正确增加;
3. 因为fedora 16使用GPT,所有不用fdisk而用parted来创建新加磁盘空间的分区(lvm):
3.1 [root@fedora ~]# parted /dev/sda (输入的命令)
GNU Parted 3.0
Using /dev/sda
Welcome to GNU Parted! Type ‘help’ to view a list of commands.
(parted) print (输入的命令)
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sda: 16.1GB (显示磁盘整体空间)
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 1049kB 2097kB 1049kB bios_grub
2 2097kB 526MB 524MB ext4 ext4 boot
3 526MB 8589MB 8063MB lvm
(已分区的却只有8G,刚扩展的8G并未在此显示)
3.2 (parted)mkpart newpart 8589MB 16.0G (将扩展的8G建立为新分区)
(parted) print
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sda: 16.1GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 1049kB 2097kB 1049kB bios_grub
2 2097kB 526MB 524MB ext4 ext4 boot
3 526MB 8589MB 8063MB lvm
4 8589MB 16.0GB 7411MB newpart
(parted) set 4 lvm (将新建分区设定为lvm)
New state? [on]/off? on
(parted) print
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sda: 16.1GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 1049kB 2097kB 1049kB bios_grub
2 2097kB 526MB 524MB ext4 ext4 boot
3 526MB 8589MB 8063MB lvm
4 8589MB 16.0GB 7411MB newpart lvm
4. 利用lvm管理工具将新建分区扩展到根分区:
4.1 [root@fedora ~]# vgdisplay (查看lvm卷组名称)
— Volume group —
VG Name vg_fedora
……….
4.2 pvcreate /dev/sda4 (创建新物理卷)
4.3 vgextend vg_fedora /dev/sda4 (扩展到卷组)
4.4 lvdisplay
— Logical volume —
LV Name /dev/vg_fedora/lv_root
VG Name vg_fedora
………….
4.5 lvextend /dev/vg_fedora/lv_root /dev/sda4 (扩展到逻辑卷)
4.6 resize2fs /dev/vg_fedora/lv_root (刷新根分区逻辑卷的容量)