linux扩展根分区详细步骤

Linux虚拟机扩展根分区!

虚拟机根分区空间不够用,在虚拟机管理界面进行单个磁盘扩展(图形化界面操作略),比如原来是30G,扩展至40G,(扩展需要关机之后操作)

其中的10G空间需要重新分区,以下是分区相关操作让扩展的空间生效:

登录系统之后:

df -h  发现空间没有发生变化:

[[email protected] ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/VolGroup-lv_root

25G   19G  4.2G  82% /

tmpfs                 642M     0  642M   0% /dev/shm

/dev/sda1             485M   34M  426M   8% /boot

fdisk -l   发现总容量已经扩展。

[[email protected] ~]# fdisk -l

Disk /dev/sda: 42.9 GB, 42949672960 bytes

255 heads, 63 sectors/track, 5221 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: 0x00069f1c

------------------------------

对扩展的磁盘进行分区:

[[email protected] ~]# 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): p

Disk /dev/sda: 42.9 GB, 42949672960 bytes

255 heads, 63 sectors/track, 5221 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: 0x00069f1c

Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          64      512000   83  Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2              64        4047    31992832   8e  Linux LVM

Command (m for help): n

Command action

e   extended

p   primary partition (1-4)

3

Invalid partition number for type `3‘

Command action

e   extended

p   primary partition (1-4)

p

Partition number (1-4): 3

First cylinder (4047-5221, default 4047):

Using default value 4047

Last cylinder, +cylinders or +size{K,M,G} (4047-5221, default 5221):

Using default value 5221

Command (m for help): p -------查看分区后的情况

Disk /dev/sda: 42.9 GB, 42949672960 bytes

255 heads, 63 sectors/track, 5221 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: 0x00069f1c

Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          64      512000   83  Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2              64        4047    31992832   8e  Linux LVM

/dev/sda3            4047        5221     9431826+  83  Linux

---新增的sda3

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.

[[email protected] ~]#

--------------------使用命令发现partprobe /dev/sda3发现分区并没有起作用:

[[email protected] ~]# partprobe /dev/sda3

Error: Could not stat device /dev/sda3 - No such file or directory.

[[email protected] ~]# pvcreate /dev/sda3

Device /dev/sda3 not found (or ignored by filtering).

-----重启系统。

------LVM操作。扩展根分区

[[email protected] ~]# pvcreate /dev/sda3

Physical volume "/dev/sda3" successfully created

[[email protected] ~]# vgs

VG       #PV #LV #SN Attr   VSize  VFree

VolGroup   1   2   0 wz--n- 30.51g    0

[[email protected] ~]# vgextend VolGroup /dev/sda3

Volume group "VolGroup" successfully extended

[[email protected] ~]# vgs

VG       #PV #LV #SN Attr   VSize  VFree

VolGroup   2   2   0 wz--n- 39.50g 8.99g

[[email protected] ~]# lvextend -L +8.99G /dev/mapper/VolGroup-lv_root

Rounding size to boundary between physical extents: 8.99 GiB

Extending logical volume lv_root to 33.50 GiB

Logical volume lv_root successfully resized

[[email protected] ~]# resize2fs /dev/mapper/VolGroup-lv_root

resize2fs 1.41.12 (17-May-2010)

Filesystem at /dev/mapper/VolGroup-lv_root is mounted on /; on-line resizing required

old desc_blocks = 2, new_desc_blocks = 3

Performing an on-line resize of /dev/mapper/VolGroup-lv_root to 8781824 (4k) blocks.

The filesystem on /dev/mapper/VolGroup-lv_root is now 8781824 blocks long.

----命令操作根分区情况,发现已经生效:

[[email protected] ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/VolGroup-lv_root

33G   19G   13G  60% /

tmpfs                 642M     0  642M   0% /dev/shm

/dev/sda1             485M   34M  426M   8% /boot

[[email protected] ~]#

完成扩展。!

时间: 2024-10-22 09:36:13

linux扩展根分区详细步骤的相关文章

linux 扩展根分区

参考链接:  http://blog.51cto.com/lubcdc/1763133 原文地址:https://www.cnblogs.com/hzijone/p/8544905.html

Linux下扩展根分区-非LVM

在配置大数据节点的过程中,node03节点由于安装了图形化界面,以及IDEA等工具,导致/根分区只有几百兆了,因此需要对根分区进行扩容,本文是在参考如下博文(https://www.jianshu.com/p/9db2df60fd0a)的基础上完成的,感谢被引用的博主,这里也记录一下. VMware虚拟机中配置 (1)进入虚拟机设置界面,选择扩展磁盘容量. (2) 本次是在原来30G的基础上扩展为50G. (3)成功后发现提示,必须从客户机操作系统内部对磁盘重新进行分区和扩展文件系统,因此需要进

Linux合并分区详细步骤

需求:将home分区合并到根分区中. -----------合并分区---------- umount /home mkdir /home1 mount  /dev/mapper/VolGroup-lv_home /home1 cd /home1 mv * /home cd .. umount /home1 lvremove  /dev/mapper/VolGroup-lv_home rm -rf /home1 vgs lvextend -L +491.65G /dev/mapper/VolGr

linux扩容根分区脚本,适合用于centos 6、centos 7版本

#!/bin/bash#auther chentongsan,time 2019-05-30#Description: 适用于系统根分区扩容,第一次.第二次.第三次--..适合用于centos 6.centos 7版本#扫描总线,识别新增添加的磁盘.echo "- - -" > /sys/class/scsi_host/host0/scanecho "- - -" > /sys/class/scsi_host/host1/scanecho "-

为linux扩展swap分区

1.查看当前swap分区使用情况 [[email protected] ~]# swapon -s Filename Type Size Used Priority /dev/sda2                               partition 10485752 111296 -1 2.创建一个file,用来扩展swap分区 [[email protected] ~]# dd < /dev/zero >/opt/swapfile1 bs=1M count=200 200+0

RHEL7虚拟机中不重启的情况下加新硬盘及扩展根分区容量

在VMware中添加一块新的5G硬盘 显示当前分区 # fdisk -l 通常在你在虚拟机中添加一块新硬盘时,你可能会看到新硬盘没有自动加载.这是因为连接到硬盘的SCSI总线需要重新扫描来使得新硬盘可见. 这里有一个简单的命令来重新扫描SCSI总线和SCSI设备. 确定主机总线号 # ls /sys/class/scsi_host/ host0 host11 host14 host17 host2 host22 host25 host28 host30 host4 host7 host1 hos

Linux统计根分区使用率

1 #!/bin/bash 2 3 # 统计根分区使用率 4 # 作者: shaohsiung 5 # 时间: 2018/11/19 6 7 rate=$(df -h | grep "dev/sda3" | awk '{print $5}' | cut -d "%" -f1) 8 9 if [ $rate -ge 80 ] 10 then 11 echo "Root partition usage exceeds 80%, mail has been se

linux安装系统分区详细介绍及常用ls命令

linux对于没有基础的初学者来说,最难的就是第一步,不为什么因为万事开头难,第一步就是装系统分区,而这里面最难的我认为就是分区部分,如果是让系统自动分区那就很简单,但对于初学者一般都是要手动分区的,特别是全英文的系统,对于英语基础差的童鞋,分区那里无疑是最难的,下面就跟好我的节奏带你上分!大家看下图,我们要选择最后一个,意思是要手动安装分区.接下来就会出现下个画面在这里就是重要的分区了,讲分区之前给大家说一下windows的分区,比方说windows上面有一个硬盘,我要把这个硬盘分四个区:C

Linux创建逻辑卷详细步骤

1.物理卷物理卷是由磁盘或分区转换得来的,由一个一个pe组成(每个pe默认大小为4MB). 分区的类型必须修改为8e创建pv:格式:pvcreate 分区1 [分区2 分区3 --查看系统中有哪些pv:pvscan查看某个pv的详细信息:pvdisplay 某个pv删除某个pv:pvremove 某个pv 2.卷组卷组由一个或多个物理卷组成创建vg:格式:vgcreate vg名称 pv1 [pv2 pv3 --] 创建vg并将pe的大小修改为8M格式:vgcreate -s 8M vg名称 p