Linux gparted 工具分区扩容
1:gparted 官网下载地址:https://sourceforge.net/projects/gparted/
2:虚拟机磁盘扩展分区后关机,使用ISO 映像文件加载工具
3:虚拟机开机进入BOIS方法:
1、关闭虚拟机,找到虚拟机系统的存放目录(注:不是虚拟机这个软件的安装目录),然后进入到相应系统的文件夹。(举例:如是WIN7系统,找到win7的文件夹,用记事本打开一个.vmx的文件(这里是TestOS.vmx),在最后加入一行 bios.forceSetupOnce = "TRUE",如下图),(注:一次性修改设置,重启虚拟机后需要重新配置参数)
4:进入BOIS 选择CD ROM Drive:
使用left键选择boot,使用up/down建选中CD ROM Drive后按-/+号将其置顶。完成后按F10,保存退出。
CDROM后选择GParted Live
进入GParted就可以看到目前的分区信息了
最后重启操作系统
生产服务器上,数据仓库的数据文件放在目录/fastdfs上,随着数据仓库的增长,为确保该目录能够动态扩容,也可以考虑对该目录采用卷管理,当发现/fastdfs的Use%>80后,必须采取扩容措施,具体扩容方式如下:
fdisk -l
Disk /dev/sda: 53.6 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 3916 31350847+ 8e Linux LVM
可以看到,本虚机只有一个磁盘/dev/sda,被划分为两个分区/dev/sda1和/dev/sda2,其中/dev/sda2的分区格式为Linux LVM,挂载其上的就是目录/fastdfs。
fdisk /dev/sda
The number of cylinders for this disk is set to 6527.
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/sda: 53.6 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 3916 31350847+ 8e Linux LVM
然后输入 n {new partition}指令,然后在提示中 输入p {primary partition},然后输入分区号 3 {partition number} ,(上面显示我已经有2个分区了,这个是第3个)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (3917-6527, default 3917):
Using default value 3917
Last cylinder or +size or +sizeM or +sizeK (3917-6527, default 6527):
Using default value 6527
在fdisk中用p指令也可以看到已有的分区情况。然后 输入t {change partition id}指令,然后按提示输入刚才的分区号3,然后输入分区类型 8e {Linux LVM partition},最后 输入w指令,将以上改动写入分区表,在输入w指令前,可以用p指令看到新的分区情况如下:
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 3916 31350847+ 8e Linux LVM
/dev/sda3 3917 6527 20972857+ 8e Linux LVM
检查分区情况,fdisk -l
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 3916 31350847+ 8e Linux LVM
/dev/sda3 3917 6527 20972857+ 8e Linux LVM
可以看到已创建的新的分区/dev/sda3,分区格式是Linux LVM
pvcreate /dev/sda3
physical volume "/dev/sda3" successfully created
查看物理卷情况
pvdisplay
/dev/cdrom: open failed: No medium found
--- Physical volume ---
PV Name /dev/sda2
VG Name VolGroup00
PV Size 29.90 GB / not usable 24.06 MB
Allocatable yes
PE Size (KByte) 32768
Total PE 956
Free PE 2
Allocated PE 954
PV UUID o9H0fA-136u-HmOM-Ga3O-7R0i-VRAS-F1mNxZ
--- NEW Physical volume ---
PV Name /dev/sda3
VG Name
PV Size 20.00 GB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID Qib59l-uCF5-5fo0-6oqH-5Url-yuSA-Y6N0E0
物理卷/dev/sda3已创建成功,大小20G
vgextend VolGroup00 /dev/sda3
Volume group "VolGroup00" successfully extended
[[email protected] ~]# vgdisplay
--- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 2
Act PV 2
VG Size 49.88 GB
PE Size 32.00 MB
Total PE 1596
Alloc PE / Size 954 / 29.81 GB
Free PE / Size 642 / 20.06 GB
VG UUID 8D7xnq-UPBK-LW2U-OCmc-Dl23-cpP1-qLLSHn
可以看到卷组VolGroup00已新扩展空间20G
先查看当前逻辑卷的情况
lvdisplay
[[email protected] ~]# lvdisplay
LV Name /dev/VolGroup00/LogVol00
VG Name VolGroup00
LV UUID QDtSfz-1SlB-xl3P-mRZp-H3dx-erAx-mAwrt2
LV Write Access read/write
LV Status available
LV Size 30 GB
Current LE 1534
Segments 3
Allocation inherit
Read ahead sectors 0
Block device 253:0
扩展逻辑卷,增加的大小就是之前vgdisplay总的free PE值
lvextend -l +642 /dev/VolGroup00/LogVol00
再次查看逻辑卷
lvdisplay
--- Logical volume ---
LV Name /dev/VolGroup00/LogVol00
VG Name VolGroup00
LV UUID QDtSfz-1SlB-xl3P-mRZp-H3dx-erAx-mAwrt2
LV Write Access read/write
LV Status available
LV Size 50 GB
Current LE 1534
Segments 3
Allocation inherit
Read ahead sectors 0
Block device 253:0
发现卷LogVol00已扩展到了50G
[[email protected] ~]# resize2fs /dev/mapper/VolGroup00-LogVol00
resize2fs 1.35 (28-Feb-2004)
/dev/mapper/VolGroup00-LogVol00 is mounted; can't resize a mounted filesystem!
查看磁盘分配情况,确认目录/fastdfs分配的空间是否增加,Use%是否降了下来。
df -h