在虚拟机扩展linux系统的硬盘
来源:互联网 发布:贵金属软件 编辑:程序博客网 时间:2024/05/14 07:06
/dev/sda1 * 1 64 512000 83 Linux
/dev/sda2 64 2611 20458496 8e Linux LVM
Disk /dev/mapper/vg_zxw-lv_root: 18.8 GB, 18832424960 bytes
255 heads, 63 sectors/track, 2289 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: 0x00000000
Disk /dev/mapper/vg_zxw-lv_root doesn't contain a valid partition table
Disk /dev/mapper/vg_zxw-lv_swap: 2113 MB, 2113929216 bytes
255 heads, 63 sectors/track, 257 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: 0x00000000
Disk /dev/mapper/vg_zxw-lv_swap doesn't contain a valid partition table
根据提示信息可以判断出此系统的磁盘接口为SCSI,对应“sda”如果上面的红色字体是“hda”,那么此系统的磁盘接口为IDE对应“hda”所以我做一下操作:
#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 //“ 列出fdisk的帮助”
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):n //” 命令n用于添加新分区"
Command action
e extended
p primary partition (1-4)
p //" 选择创建主分区"此时,
Partition number (1-4):3 //fdisk会让你选择主分区的编号,如果已经有了主分区sda1,sda2,那么编号就选3,即要创建的该分区为sda3.
First cylinder (2611-3916, default 2611): //此时,fdisk又会让你选择该分区的开始值这个就是分区的Start 值(start cylinder);这里最好直接按回车,
Using default value 2611
Last cylinder, +cylinders or +size{K,M,G} (2611-3916, default 3916): //此时,fdisk又会让你选择该分区的开始值这个就是分区的End 值这里最好直接按回车,
Using default value 3916
Command (m for help): w //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.
三、我们的新建分区/dev/sda3,却不是LVM的。所以,接下来使用fdisk将其改成LVM的。
#fdisk /dev/sda
Command (m for help): m
Command (m for help): t //改变分区系统id
Partition number (1-4): 3 //指定分区号
Hex code (type L to list codes): 8e //指定要改成的id号,8e代表LVM。
Command (m for help): w
四、重启系统后,登陆系统。(一定要重启系统,否则无法扩充新分区)
五、格式化该新添加的分区:
#fdisk -l
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
/dev/sda2 64 2611 20458496 8e Linux LVM
/dev/sda3 2611 3916 10483750 8e Linux LVM
你会发现多了一块分区。
#mkfs -t ext4 /dev/sda3 //在硬盘分区“/dev/sda3”上创建“ext4”文件系统(注意:用 df -lhT指令查看你的分区格式是ext4还是ext3,格式不对不会成功!)。
此时我们就可以使用该新增分区啦:
六、扩充新分区
#pvcreate /dev/sda3 //pvcreate指令用于将物理硬盘分区初始化为物理卷,以便被LVM使用。要创建物理卷必须首先对硬盘进行分区,并且将硬盘分区的类型设置为“8e”后,才能使用pvcreat指令将分区初始化为物理卷。
Physical volume "/dev/sda3" successfully created
#vgextend vg_hadoop /dev/sda3 (其中是当前需要扩充的lvm组名,可以通过pvdisplay查看,找到VG Name(第二行吧)例如我的是:VG Name vg_hadoop) //vgextend指令用于动态的扩展卷组,它通过向卷组中添加物理卷来增加卷组的容量。
#vgdisplay //用于显示LNM卷组的元数据信息。
# lvextend -L 180G /dev/mapper/vg_hadoop-lv_root /dev/sda3 (注意:红色方框里的容量为最大可到的容量,-L 后跟的大小需小于它!)
Logical volume vg_hadoop-lv_root successfully resized
#e2fsck -a /dev/mapper/vg_hadoop-lv_root //使用e2fsck指令检查文件系统错误。也可用“fsck -t ext2 -V /dev/sda3/检查ext2文件系统。
(做fsck,检查文件系统)
#resize2fs /dev/mapper/vg_hadoop-lv_root //resize2fs指令被用来增大或者收缩未加载的“ext2/ext3/ext4”文件系统的大小。(这步很重要,否则原来容量不变!!)
#df -lhT //查看一下你的系统磁盘空间"/"容量变了没!
好了,看我的根目录"/"由18G变为了178G!成功!
- 在虚拟机扩展linux系统的硬盘
- 扩展虚拟机硬盘 - linux
- 虚拟机Linux下扩展硬盘的方法
- Linux 系统的 VMware 虚拟机压缩硬盘
- Vmware硬盘不够了? Linux虚拟机硬盘空间扩展的实现
- 扩展Linux虚拟机硬盘、分区一例
- 扩展Linux虚拟机硬盘、分区一例
- 如何给虚拟机上的linux系统添加虚拟硬盘
- EXSI上虚拟机硬盘的扩展
- 在vmware的linux虚拟机中添加硬盘
- 扩展虚拟机硬盘大小
- VirtualBox扩展虚拟机硬盘
- ubuntu虚拟机扩展硬盘
- 扩展 centos 虚拟机硬盘
- VirtualBox扩展虚拟机硬盘
- 扩展Win7虚拟机硬盘
- 虚拟机为linux系统添加新硬盘
- 在虚拟机VMWare下为ubuntu扩展硬盘大小
- 学习JAVA一
- HTML 表单(form) 详解
- LeeCode-Remove Linked List Elements
- YEOMAN知识点整理及翻译
- 山东省第五届ACM省赛题——Circle(递推求概率)
- 在虚拟机扩展linux系统的硬盘
- 如果json字符串中的key值中没有数据解析用opt,也会出现空指针异常。
- Oracle_expdp_impdp用法详解
- @RequestBody和@ResponseBody的简单使用
- 最大公约数的实现
- 欢迎使用CSDN-markdown编辑器
- Swift 很强大的图表库-Charts使用
- 25.Spark Sort-Based Shuffle内幕彻底解密
- Java基础笔记:Java的基本语法