CentOS7.1 KVM虚拟化之虚拟机根分区扩容(8)
2016-03-16 13:34
671 查看
注:适用于未使用KVM管理的分区,要求根分区为最后一个分区
fdisk -l
Disk /dev/vda: 16.1 GB, 16106127360 bytes
255 heads, 63 sectors/track, 1958 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/vda1 * 1 25 200781 83 Linux
/dev/vda2 26 156 1052257+ 82 Linux swap / Solaris
/dev/vda3 157 1305 9229342+ 83 Linux #注意这里起始cylinder 是157,起始cylinder 绝对不可以改,否则会破坏原分区的数据。
fdisk /dev/vda
The number of cylinders for this disk is set to 1958.
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): p
Disk /dev/vda: 16.1 GB, 16106127360 bytes
255 heads, 63 sectors/track, 1958 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/vda1 * 1 25 200781 83 Linux
/dev/vda2 26 156 1052257+ 82 Linux swap / Solaris
/dev/vda3 157 1305 9229342+ 83 Linux
Command (m for help): d
Partition number (1-4): 3
#根/分区是多少就输入几,这里是/dev/vda3
Command (m for help): p
Disk /dev/vda: 16.1 GB, 16106127360 bytes
255 heads, 63 sectors/track, 1958 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/vda1 * 1 25 200781 83 Linux
/dev/vda2 26 156 1052257+ 82 Linux swap / Solaris
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3
#之前是多少,这里还输入多少
First cylinder (157-1958, default 157):
Using default value 157
Last cylinder or +size or +sizeM or +sizeK (157-1958, default
1958): #由之前1305,扩为1958
Using default value 1958
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
[root@localhost ~]#reboot
重启后执行如下命令,完成根分区扩充
[root@localhost ~]#resize2fs /dev/vda3
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/vda3 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/vda3 to 3618641 (4k) blocks.
The filesystem on /dev/vda3 is now 3618641 blocks long.
[root@localhost ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/vda3 14G 1.3G 12G 11% /
/dev/vda1 190M 12M 169M 7% /boot
tmpfs 379M 0 379M 0% /dev/shm
如上,完成根分区扩容
一、扩展虚拟机磁盘
1.关闭虚拟机
virsh shutdown vm1-clone
2.查看虚拟机磁盘当前大小
[root@kvm01 ~]# qemu-img info /vm-images/vm1-clone.img image: /vm-images/vm1-clone.img file format: qcow2 virtual size: 10G (11206127360 bytes) disk size: 1.7G cluster_size: 65536 Format specific information: compat: 1.1 lazy refcounts: true
3.扩展磁盘大小
qemu-img resize /vm-images/vm1-clone.img +5G
4.再次查看虚拟机磁盘当前大小
[root@kvm01 ~]# qemu-img info /vm-images/vm1-clone.img image: /vm-images/vm1-clone.img file format: qcow2 virtual size: 15G (16106127360 bytes) disk size: 1.7G cluster_size: 65536 Format specific information: compat: 1.1 lazy refcounts: true
二、扩展虚拟机根分区
1.查看当前分区状况,可以看到磁盘/dev/vda大小变化
[root@localhost ~]#fdisk -l
Disk /dev/vda: 16.1 GB, 16106127360 bytes
255 heads, 63 sectors/track, 1958 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/vda1 * 1 25 200781 83 Linux
/dev/vda2 26 156 1052257+ 82 Linux swap / Solaris
/dev/vda3 157 1305 9229342+ 83 Linux #注意这里起始cylinder 是157,起始cylinder 绝对不可以改,否则会破坏原分区的数据。
2.扩展根分区
[root@localhost ~]#fdisk /dev/vda
The number of cylinders for this disk is set to 1958.
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): p
Disk /dev/vda: 16.1 GB, 16106127360 bytes
255 heads, 63 sectors/track, 1958 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/vda1 * 1 25 200781 83 Linux
/dev/vda2 26 156 1052257+ 82 Linux swap / Solaris
/dev/vda3 157 1305 9229342+ 83 Linux
Command (m for help): d
Partition number (1-4): 3
#根/分区是多少就输入几,这里是/dev/vda3
Command (m for help): p
Disk /dev/vda: 16.1 GB, 16106127360 bytes
255 heads, 63 sectors/track, 1958 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/vda1 * 1 25 200781 83 Linux
/dev/vda2 26 156 1052257+ 82 Linux swap / Solaris
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3
#之前是多少,这里还输入多少
First cylinder (157-1958, default 157):
Using default value 157
Last cylinder or +size or +sizeM or +sizeK (157-1958, default
1958): #由之前1305,扩为1958
Using default value 1958
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
三、重启虚拟机,完成根分区扩容
执行如下命令,重启系统[root@localhost ~]#reboot
重启后执行如下命令,完成根分区扩充
[root@localhost ~]#resize2fs /dev/vda3
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/vda3 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/vda3 to 3618641 (4k) blocks.
The filesystem on /dev/vda3 is now 3618641 blocks long.
四、验证
查看当前磁盘状态[root@localhost ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/vda3 14G 1.3G 12G 11% /
/dev/vda1 190M 12M 169M 7% /boot
tmpfs 379M 0 379M 0% /dev/shm
如上,完成根分区扩容
相关文章推荐
- CentOS6.4下Mysql数据库的安装与配置
- 《kali linux 渗透测试初级教程》免费下载
- linux下使用yum安装mysql详解
- linux 进程详解
- linux yum 用法
- linux系统的 " ghost " 备份
- centos下为php添加gd扩展
- Linux常用操作命令
- 《kali linux 渗透测试初级教程》全套视频与课件免费下载
- CentOS下SVN服务器运行,windows作为客户端连接SVN服务器失败的处理
- 从零开始搭建 reviewboard 环境(五) -- reviewboard 在linux中的使用
- ORA-15025: could not open disk"...." ORA-27041: unable to open file Linux-x86_64 Error: 13: Permiss
- linux --> Event Loop介绍
- Linux内核设计第四周学习总结 使用库函数API和C代码中嵌入汇编代码两种方式使用同一个系统调用
- linux系统启动报错:An error occurred during the file system check(linux学习记录)
- linux --> 为什么寄存器比内存快?
- Linux系统文件权限的备份与恢复
- kali linux 2.0 无法安装vmware tools
- linux myql主从复制和双主备份
- Linux---man中文配置