CentOS 扩展/dev/mapper/VolGroup-lv_root容量

项目部署生产环境,由于客户不懂linux,每次都是最简单的安装(硬盘分区全部按最新安装),每次拿到系统,都要耗费一番功夫,也出现过不少坑(磁盘分完,重启,远程连接不上)。现把硬盘分配过程写下,希望日后或其他同事能用到。

 

## Step 1: 查看磁盘空间,lv_root ,目的扩容 lv_root

[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                       50G  6.4G   41G  14% /
tmpfs                 7.8G   72K  7.8G   1% /dev/shm
/dev/sda1             477M   42M  411M  10% /boot
/dev/mapper/VolGroup-lv_home
                       41G   48M   39G   1% /home

## Step 2:查看隐藏的磁盘

[root@localhost ~]# fdisk -l

 

Disk /dev/sda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 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: 0x0005c645

   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       13055   104344576   8e  Linux LVM

Disk /dev/sdb: 1099.5 GB, 1099511627776 bytes
255 heads, 63 sectors/track, 133674 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: 0x19a7886a

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1      133674  1073736373+  8e  Linux LVM

Disk /dev/mapper/VolGroup-lv_root: 1153.2 GB, 1153190330368 bytes

。。。。。。。。

重点信息 --> Disk /dev/sdb: 1099.5 GB

##Step 3:fdisk 进入/dev/sda, 创建新分区 /dev/sdb1

[root@localhost ~]# fdisk /dev/sdb

        Command (m for help):

Command (m for help): n               # new 新分区
Command action
   e   extended
   p   primary partition (1-4)
p                                    #    选择主分区
Partition number (1-4): 1            #   分区序号 3
--> 一路回车即可
Command (m for help): t                # 修改分区格式
Partition number (1-4): 1            # 选择分区序号
Hex code (type L to list codes): 8e            # 格式选择8e   linux LVM
Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): p                # 显示分区信息
。。。。。。
Command (m for help): w
The partition table has been altered!       

## Step 4:重启

[root@localhost ~]# reboot

## Step 5:创建物理卷

[root@localhost ~]# pvcreate /dev/sdb1

## Step 6: 查看新建的物理卷和大小

[root@ganxide ~]# pvdisplay

## Step 7:添加新的物理卷到lv_root同一个卷组

[root@ganxide ~]# vgextend VolGroup /dev/sdb1

## Step 8:查看卷组信息

[root@ganxide ~]# vgdisplay

## Step 9:增加lv_root的大小,1.0T

[root@localhost ~]# lvresize -L +1.0T /dev/mapper/VolGroup-lv_root

## Step 10:重新识别大小, xfs_qrowfs 是centos7的命令,在centos6.X中是resize2fs

  [root@localhost ~]# resize2fs /dev/mapper/VolGroup-lv_root

注:这点很重要,之前因为忘记了这步,折腾了不少时间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 = 4, new_desc_blocks = 68
Performing an on-line resize of /dev/mapper/VolGroup-lv_root to 281540608 (4k) blocks.
The filesystem on /dev/mapper/VolGroup-lv_root is now 281540608 blocks long.

## Step 11:查看扩容后的大小-----》大功告成!

[root@localhost ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                      1.1T  6.4G  997G   1% /
tmpfs                 7.8G   72K  7.8G   1% /dev/shm
/dev/sda1             477M   42M  411M  10% /boot
/dev/mapper/VolGroup-lv_home
                       41G   48M   39G   1% /home

你可能感兴趣的:(Linux)