Vmware私有云虚拟机(CentOS 6.5 OS)之根分区扩容
2015-08-25 14:21
537 查看
注:适用于未使用lvm管理的分区,目前仅在CentOS 6.5 上操作,其他系统尚未测试,请谨慎操作
一、查看当前分区状况[root@disk-test ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 26G 2.3G 22G 10% /
tmpfs 1.9G 0 1.9G 0% /dev/shm
/dev/sda1 194M 34M 151M 19% /boot
---------------------------------------------------------------------------
二、[b]控制台调增虚拟机磁盘[/b]
关闭系统,在控制台调增虚拟机磁盘大小为50G,重启系统
[root@disk-test ~]# fdisk -l
Disk /dev/sda: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000cea7e
Device Boot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 26 548 4194304 82 Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3 548 3917 27057152 83 Linux #注意这里起始cylinder 是548,起始cylinder 绝对不可以改,这样会破坏原分区的数据。
---------------------------------------------------------------------
三、扩展根分区/dev/sda3
[root@sjsa-disk-test ~]# fdisk /dev/sda
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): p
Disk /dev/sda: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000cea7e
Device Boot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 26 548 4194304 82 Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3 548 3917 27057152 83 Linux
Command (m for help): d
Partition number (1-4): 3 #根/分区是多少就输入几,这里是/dev/sda3
Command (m for help): p
Disk /dev/sda: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000cea7e
Device Boot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 26 548 4194304 82 Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3 #之前是多少,这里还输入多少
First cylinder (548-6527, default 548):
Using default value 548
Last cylinder, +cylinders or +size{K,M,G} (548-6527, default 6527): #由之前3917,扩为6527
Using default value 6527
Command (m for help): p
Disk /dev/sda: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000cea7e
Device Boot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 26 548 4194304 82 Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3 548 6527 48027999+ 83 Linux #变成了6527
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 or after you run partprobe(8) or kpartx(8)
Syncing disks.
三、重启系统,完成根分区扩充
执行如下命令,重启系统
[root@sjsa-disk-test ~]# reboot
执行如下命令,完成根分区扩充
[root@sjsa-disk-test ~]# resize2fs /dev/sda3
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/sda3 is mounted on /; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 3
Performing an on-line resize of /dev/sda3 to 12006999 (4k) blocks.
The filesystem on /dev/sda3 is now 12006999 blocks long.
四、验证
查看当前磁盘状态
[root@sjsa-disk-test ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 46G 2.3G 41G 6% /
tmpfs 1.9G 0 1.9G 0% /dev/shm
/dev/sda1 194M 34M 151M 19% /boot
如上,完成对根分区的扩充
相关文章推荐
- Linux find命令之exec
- 制作Linux发行版U盘运行系统
- CentOS修改时区以及同步时间
- centos6.5下架设maven仓库
- 【linux】ubuntu 14.04下安装mysql 5.5
- linux常用命令(查看某些软件是否已安装)
- linux 每个程序员都应该知道的8个Linux命令
- 【linux命令与工具】lsmod命令
- Linux V4L2 摄像头视频采集
- linux recv返回值socket_error 和 socket之shutdown() 的关系
- hacking a friend's Linux buzzer driver in OK335xS
- 8.23玩转linux第三天之history、alias、unalias 、mkdir、rmdir、tree命令(一)
- 迅为4412开发板Linux驱动教程之GPIO的初始化
- linux 3.4.103 内核移植到 S3C6410 开发板 移植失败 (问题总结,日本再战!)
- linux 如何显示一个文件的某几行(中间几行)
- CentOS 6.5 安装Gitlab 7.12.2
- 29个你必须知道的Linux命令
- Linux系统启动详解
- Linux命令行文本处理工具
- Linux用户基础