redhet7.5扩展分区

本文介绍了如何在RedHat7.5系统中进行硬盘扩展分区的操作,包括查看分区情况、创建扩展分区、建立逻辑分区、保存退出并重启生效、创建物理卷、卷组扩容、逻辑卷扩容以及文件系统扩容的详细步骤。

1.查看fdisk -l 分区情况:

[root@localhost ~]# fdisk -l

Disk /dev/sda: 1000.1 GB, 1000123400192 bytes, 1953366016 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0009f4c4

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200   249823231   123862016   8e  Linux LVM


Disk /dev/mapper/rhel-root: 50 GB, 912680550400 bytes, 1782579200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/rhel-swap: 8321 MB, 8321499136 bytes, 16252928 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mapper/rhel-home: 64.8 GB, 64818774016 bytes, 126599168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

[root@localhost ~]# df -h
Filesystem             Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root  50G   4.5G   46G   1% /
devtmpfs               3.8G     0  3.8G   0% /dev
tmpfs                  3.8G     0  3.8G   0% /dev/shm
tmpfs                  3.8G  9.3M  3.8G   1% /run
tmpfs                  3.8G     0  3.8G   0% /sys/fs/cgroup
/dev/sda1             1014M 1014M   36K 100% /boot
/dev/mapper/rhel-home   61G   34M   61G   1% /home
tmpfs                  774M     0  774M   0% /run/user/0

一共1000G,这里一共只用了128G,需要对硬盘进行扩容。
2.创建扩展分区:

fdisk /dev/sda
Command (m for help): m   //输入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): n
Command action
   e   extended
   p   primary partition (1-4)
   help): e							//建立扩展分区

Partition number (1-4): 3			//建立扩展分区/dev/sda3
First cylinder (2611-7832, default 2611): 
Using default value 2611
Last cylinder, +cylinders or +size{K,M,G} (2611-7832, default 7832): 
Using default value 7832
 
Command (m for help): p			//打印分区

3.在扩展分区上创建逻辑分区
Command (m for help): n
输入 : l 建立逻辑分区
Command (m for help): p #查看分区结果

Command (m for help): n					//创建分区
Command action
   l   logical (5 or over)						
   p   primary partition (1-4)
l												//创建逻辑分区
First cylinder (2611-7832, default 2611): 
Using default value 2611
Last cylinder, +cylinders or +size{K,M,G} (2611-7832, default 7832): 
Using default value 7832
 
Command (m for help): p
 
Disk /dev/sda: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 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: 0x0004bbc1
 
Device Boot      	Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200   249823231   123862016   8e  Linux LVM
/dev/sda3       249823232  1953366015   851771392    5  Extended
/dev/sda5       249825280  1953366015   851770368   83  Linux

4.保存退出,重启生效
Command (m for help):w #保存退出

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: 设备或资源忙.
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.

5.创建物理卷

[root@master local]# pvcreate /dev/sda5
  Physical volume "/dev/sda5" successfully created

6、卷组扩容

[root@master local]# vgextend rhel /dev/sda5
  Volume group "rhel" successfully extended

4、查看扩容之后的卷组信息

[root@localhost ~]# vgdisplay
  --- Volume group ---
  VG Name               rhel
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  6
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               <930.43 GiB
  PE Size               4.00 MiB
  Total PE              238190
  Alloc PE / Size       235038 / <918.12 GiB
  Free  PE / Size       3152 / 12.31 GiB
  VG UUID               czG05O-1bjV-9Qq9-gwih-Q0IL-mc0z-dyPgiR

5、逻辑卷扩容

[root@localhost ~]# df -h
Filesystem             Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root  50G   4.5G   46G   1% /
devtmpfs               3.8G     0  3.8G   0% /dev
tmpfs                  3.8G     0  3.8G   0% /dev/shm
tmpfs                  3.8G  9.3M  3.8G   1% /run
tmpfs                  3.8G     0  3.8G   0% /sys/fs/cgroup
/dev/sda1             1014M 1014M   36K 100% /boot
/dev/mapper/rhel-home   61G   34M   61G   1% /home
tmpfs                  774M     0  774M   0% /run/user/0

[root@localhost ~]# lvextend -L +800G /dev/mapper/rhel-root 
  Extending logical volume lv_root to 800 GiB
  Logical volume lv_root successfully resized

这里的+800G是根据一开始输入命令:vgdisplay中倒数第二排free空闲出来的内存,设置为800G。
6、查看扩容之后的逻辑卷

[root@localhost ~]# lvdisplay /dev/rhel/root
  --- Logical volume ---
  LV Path                /dev/rhel/root
  LV Name                root
  VG Name                rhel
  LV UUID                IjFDz6-V1D8-5L1n-9Npy-YLpe-2xCm-xsMuTM
  LV Write Access        read/write
  LV Creation host, time localhost, 2020-10-10 10:32:44 +0800
  LV Status              available
  # open                 1
  LV Size                850.00 GiB
  Current LE             217600
  Segments               3
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:0

7、文件系统扩容

[root@localhost ~]# xfs_growfs /dev/rhel/root
meta-data=/dev/mapper/rhel-root  isize=512    agcount=68, agsize=3276800 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=222822400, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=6400, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[root@localhost ~]# df -h
Filesystem             Size  Used Avail Use% Mounted on
/dev/mapper/rhel-root  850G  4.5G  846G   1% /
devtmpfs               3.8G     0  3.8G   0% /dev
tmpfs                  3.8G     0  3.8G   0% /dev/shm
tmpfs                  3.8G  9.4M  3.8G   1% /run
tmpfs                  3.8G     0  3.8G   0% /sys/fs/cgroup
/dev/sda1             1014M 1014M   36K 100% /boot
/dev/mapper/rhel-home   61G  8.5G   52G  14% /home
tmpfs                  774M     0  774M   0% /run/user/0

参考:
https://blog.csdn.net/chongxin1/article/details/76072071

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值