当前位置: 首页 > news >正文

centos7.9扩展已有分区空间

新增50G硬盘

分区

fdisk /dev/sdb
Command (m for help): p #打印分区表Disk /dev/sdb: 53.7 GB, 53687091200 bytes, 104857600 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: 0x8b654c5bDevice Boot      Start         End      Blocks   Id  SystemCommand (m for help): m
Command actiona   toggle a bootable flagb   edit bsd disklabelc   toggle the dos compatibility flagd   delete a partitiong   create a new empty GPT partition tableG   create an IRIX (SGI) partition tablel   list known partition typesm   print this menun   add a new partitiono   create a new empty DOS partition tablep   print the partition tableq   quit without saving changess   create a new empty Sun disklabelt   change a partition\'s system idu   change display/entry unitsv   verify the partition tablew   write table to disk and exitx   extra functionality (experts only)
Command (m for help): n #新建分区
Partition type:p   primary (0 primary, 0 extended, 4 free)e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-104857599, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-104857599, default 104857599):
Using default value 104857599
Partition 1 of type Linux and of size 50 GiB is setCommand (m for help): t #修改分区类型
Selected partition 1
Hex code (type L to list all codes): L0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris1  FAT12           27  Hidden NTFS Win 82  Linux swap / So c1  DRDOS/sec (FAT-2  XENIX root      39  Plan 9          83  Linux           c4  DRDOS/sec (FAT-3  XENIX usr       3c  PartitionMagic  84  OS/2 hidden C:  c6  DRDOS/sec (FAT-4  FAT16 <32M      40  Venix 80286     85  Linux extended  c7  Syrinx5  Extended        41  PPC PReP Boot   86  NTFS volume set da  Non-FS data6  FAT16           42  SFS             87  NTFS volume set db  CP/M / CTOS / .7  HPFS/NTFS/exFAT 4d  QNX4.x          88  Linux plaintext de  Dell Utility8  AIX             4e  QNX4.x 2nd part 8e  Linux LVM       df  BootIt9  AIX bootable    4f  QNX4.x 3rd part 93  Amoeba          e1  DOS accessa  OS/2 Boot Manag 50  OnTrack DM      94  Amoeba BBT      e3  DOS R/Ob  W95 FAT32       51  OnTrack DM6 Aux 9f  BSD/OS          e4  SpeedStorc  W95 FAT32 (LBA) 52  CP/M            a0  IBM Thinkpad hi eb  BeOS fse  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a5  FreeBSD         ee  GPTf  W95 Ext\'d (LBA) 54  OnTrackDM6      a6  OpenBSD         ef  EFI (FAT-12/16/
10  OPUS            55  EZ-Drive        a7  NeXTSTEP        f0  Linux/PA-RISC b
11  Hidden FAT12    56  Golden Bow      a8  Darwin UFS      f1  SpeedStor
12  Compaq diagnost 5c  Priam Edisk     a9  NetBSD          f4  SpeedStor
14  Hidden FAT16 <3 61  SpeedStor       ab  Darwin boot     f2  DOS secondary
16  Hidden FAT16    63  GNU HURD or Sys af  HFS / HFS+      fb  VMware VMFS
17  Hidden HPFS/NTF 64  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE
18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fd  Linux raid auto
1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid fe  LANstep
1c  Hidden W95 FAT3 75  PC/IX           be  Solaris boot    ff  BBT
1e  Hidden W95 FAT1 80  Old Minix
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'Command (m for help): p #打印修改后的分区表Disk /dev/sdb: 53.7 GB, 53687091200 bytes, 104857600 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: 0x8b654c5bDevice Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048   104857599    52427776   8e  Linux LVMCommand (m for help): w #保存退出
The partition table has been altered!Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]# lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda               8:0    0   60G  0 disk
├─sda1            8:1    0    1G  0 part /boot
└─sda2            8:2    0   59G  0 part├─centos-root 253:0    0   37G  0 lvm  /├─centos-swap 253:1    0  3.9G  0 lvm  [SWAP]└─centos-home 253:2    0 18.1G  0 lvm  /home
sdb               8:16   0   50G  0 disk
└─sdb1            8:17   0   50G  0 part
sr0              11:0    1 1024M  0 rom

创建物理卷

[root@localhost ~]# pvcreate /dev/sdb1Physical volume "/dev/sdb1" successfully created.
# 查看物理卷创建情况
[root@localhost ~]# pvdisplay--- Physical volume ---PV Name               /dev/sda2VG Name               centosPV Size               <59.00 GiB / not usable 3.00 MiBAllocatable           yesPE Size               4.00 MiBTotal PE              15103Free PE               1Allocated PE          15102PV UUID               6re5Yh-Aq8t-0vcd-busl-yly0-LF3u-8o22DL"/dev/sdb1" is a new physical volume of "<50.00 GiB"--- NEW Physical volume ---PV Name               /dev/sdb1  VG NamePV Size               <50.00 GiBAllocatable           NOPE Size               0Total PE              0Free PE               0Allocated PE          0PV UUID               haSSH9-YPNP-Ptsy-iUQa-NQl6-r7yH-tet4v4

将物理卷PV加入卷组VG

[root@localhost ~]# vgdisplay--- Volume group ---VG Name               centosSystem IDFormat                lvm2Metadata Areas        1Metadata Sequence No  4VG Access             read/writeVG Status             resizableMAX LV                0Cur LV                3Open LV               3Max PV                0Cur PV                1Act PV                1VG Size               <59.00 GiBPE Size               4.00 MiBTotal PE              15103Alloc PE / Size       15102 / 58.99 GiBFree  PE / Size       1 / 4.00 MiBVG UUID               rhqZaQ-Uxug-cylo-UTVI-m8Em-goxa-KLVcoa

将新的分区/dev/sdb1加入卷组中,卷组名为centos

[root@localhost ~]# vgextend centos /dev/sdb1Volume group "centos" successfully extended
[root@localhost ~]# vgdisplay--- Volume group ---VG Name               centosSystem IDFormat                lvm2Metadata Areas        2Metadata Sequence No  5VG Access             read/writeVG Status             resizableMAX LV                0Cur LV                3Open LV               3Max PV                0Cur PV                2Act PV                2VG Size               108.99 GiB #可以看到容量增加了PE Size               4.00 MiBTotal PE              27902Alloc PE / Size       15102 / 58.99 GiBFree  PE / Size       12800 / 50.00 GiBVG UUID               rhqZaQ-Uxug-cylo-UTVI-m8Em-goxa-KLVcoa

扩展已有分区

当前centos根分区只有40G,扩展根分区

[root@localhost ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                 1.9G     0  1.9G   0% /dev
tmpfs                    1.9G     0  1.9G   0% /dev/shm
tmpfs                    1.9G   12M  1.9G   1% /run
tmpfs                    1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/mapper/centos-root   38G  6.9G   31G  19% /
/dev/sda1               1014M  195M  820M  20% /boot
/dev/mapper/centos-home   19G   33M   19G   1% /home
tmpfs                    378M     0  378M   0% /run/user/998
tmpfs                    378M     0  378M   0% /run/user/0[root@localhost ~]# lvextend -l +100%FREE /dev/mapper/centos-rootSize of logical volume centos/root changed from <37.04 GiB (9481 extents) to <87.04 GiB (22281 extents).Logical volume centos/root successfully resized.
[root@localhost ~]# lvdisplay /dev/mapper/centos-root--- Logical volume ---LV Path                /dev/centos/rootLV Name                rootVG Name                centosLV UUID                hVt6Ll-LPMN-gulw-JcuF-q0Ry-gIfX-uy9rWxLV Write Access        read/writeLV Creation host, time localhost.localdomain, 2024-08-13 05:59:06 +0000LV Status              available# open                 1LV Size                <87.04 GiB  #已扩容Current LE             22281Segments               2Allocation             inheritRead ahead sectors     auto- currently set to     8192Block device           253:0
[root@localhost ~]# xfs_growfs /dev/mapper/centos-root #更新分配的空间
meta-data=/dev/mapper/centos-root isize=512    agcount=4, agsize=2427136 blks=                       sectsz=512   attr=2, projid32bit=1=                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=9708544, imaxpct=25=                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=4740, version=2=                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 9708544 to 22815744
[root@localhost ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                 1.9G     0  1.9G   0% /dev
tmpfs                    1.9G     0  1.9G   0% /dev/shm
tmpfs                    1.9G   12M  1.9G   1% /run
tmpfs                    1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/mapper/centos-root   88G  6.9G   81G   8% /  #已扩容根分区
/dev/sda1               1014M  195M  820M  20% /boot
/dev/mapper/centos-home   19G   33M   19G   1% /home
tmpfs                    378M     0  378M   0% /run/user/998
tmpfs                    378M     0  378M   0% /run/user/0

相关文章:

  • [LevelDB]LevelDB版本管理的黑魔法-为什么能在不锁表的情况下管理数据?
  • bus hound抓取的数据包各字段含义解释
  • DAY26 函数定义与参数
  • 2025年- H28-Lc136- 24.两两交换链表中的节点(链表)---java版
  • Java开发经验——阿里巴巴编码规范实践解析3
  • 创建指定版本的vite项目
  • 【Retinanet】训练自己的数据集
  • InfluxDB 3 Core + Java 11 + Spring Boot:打造高效物联网数据平台
  • LangChain框架实战:从入门到开发大模型应用
  • Pandas 构建并评价聚类模型② 第六章
  • 红黑树的实现
  • MidJourney生成王昭君全身像提示词
  • 学习是有方法的——费曼学习法
  • golang选项设计模式
  • 参考文献标准中与永久标识相关的PID、URN、DOI等概念的理解和区分
  • 【MyBatis-11】MyBatis批处理:提升数据操作性能的利器
  • 【LeetCode 热题100】17:电话号码的字母组合(详细解析)(Go语言版)
  • 【typenum】 11 私有模块(private.rs)
  • 开机自启rc.local
  • ctr查看镜像
  • “80后”南京大学天文与空间科学学院教授施勇加盟西湖大学
  • 倒票“黄牛”屡禁不绝怎么破?业内:强化文旅市场票务公开制度
  • “GoFun出行”订单时隔7年扣费后续:平台将退费,双方已和解
  • 大外交丨3天拿下数万亿美元投资,特朗普在中东做经济“加法”和政治“减法”
  • 陕西三原高新区违法占用土地,被自然资源局罚款10万元
  • 多地举办演唱会等吸引游客刺激消费,经济日报:引导粉丝经济理性健康发展