前往小程序,Get更优阅读体验!
立即前往
发布
社区首页 >专栏 >VMware 中 Linux 调整分区大小

VMware 中 Linux 调整分区大小

作者头像
gigiwangs
发布2019-02-28 17:17:00
发布2019-02-28 17:17:00
6.9K00
代码可运行
举报
文章被收录于专栏:吉吉在这里吉吉在这里
运行总次数:0
代码可运行

Precondition :VMware Player 中安装的Fedora 17 Linux 32bit,个人较久远的测试环境,安装时没有进行磁盘规划,默认20G空间(动态调整),安装在根/下。 Background :在上述环境中安装IBM DB2 Express-C 10.5(v10.5fp1_linuxia32_expc.tar.gz),安装时/tmp空间不足,无法安装。 Plan:需要进行磁盘扩容。考虑到使用VMware Player虚拟机。

1.首先调整虚拟机大小:

2.虚拟机开机,使用fdisk 命令新建新区 fdisk  /dev/sda 添加 /dev/sda3

3.接下来就贴代码了:

代码语言:javascript
代码运行次数:0
复制
Fedora release 17 (Beefy Miracle)
Kernel 3.4.0-1.fc17.i686 on an i686 (0)

[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
rootfs 6.5G 6.0G 529M 92% /
devtmpfs 494M 0 494M 0% /dev
tmpfs 502M 0 502M 0% /dev/shm
tmpfs 502M 940K 502M 1% /run
/dev/mapper/vg-lv_root 6.5G 6.0G 529M 92% /
tmpfs 502M 0 502M 0% /sys/fs/cgroup
tmpfs 502M 0 502M 0% /media
/dev/sda1 497M 81M 392M 17% /boot

[root@localhost ~]# # fdisk /dev/sda

[root@localhost ~]# fdisk -l

Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders, total 62914560 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00002255

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 16777215 7875584 8e Linux LVM
/dev/sda3 16777216 62914559 23068672 83 Linux

Disk /dev/mapper/vg-lv_swap: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders, total 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/mapper/vg-lv_root: 6979 MB, 6979321856 bytes
255 heads, 63 sectors/track, 848 cylinders, total 13631488 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

[root@localhost ~]# pvcreate /dev/sda3
Writing physical volume data to disk "/dev/sda3"
Physical volume "/dev/sda3" successfully created

[root@localhost ~]# vgextend /dev/mapper/vg /dev/sda3 
Volume group "vg" successfully extended
[root@localhost ~]# lvextend -L +20G /dev/mapper/vg-lv_root
Extending logical volume lv_root to 26.50 GiB
Logical volume lv_root successfully resized

[root@localhost ~]# resize2fs /dev/mapper/vg-lv_root 
resize2fs 1.42 (29-Nov-2011)
Filesystem at /dev/mapper/vg-lv_root is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 2
The filesystem on /dev/mapper/vg-lv_root is now 6946816 blocks long.

[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
rootfs 27G 6.2G 21G 24% /
devtmpfs 494M 0 494M 0% /dev
tmpfs 502M 0 502M 0% /dev/shm
tmpfs 502M 956K 502M 1% /run
/dev/mapper/vg-lv_root 27G 6.2G 21G 24% /
tmpfs 502M 0 502M 0% /sys/fs/cgroup
tmpfs 502M 0 502M 0% /media
/dev/sda1 497M 81M 392M 17% /boot
[root@localhost ~]#

至此,操作结束,空间调整为30GB,满足使用需求。当然,此方案针对虚拟机中已安装的没有采用LVM的linux分区大小调整,其它不必参考此方案。

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2014/02/18,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档