查看: 227|回复: 0

[other] 三丰云系统盘扩展空间的教程

[复制链接]

748

主题

39

回帖

3907

积分

管理员

总舵主

积分
3907
QQ
发表于 2026-4-10 13:59:05 | 显示全部楼层 |阅读模式
我是买的终身会员,系统盘可惜只赠送了12G,现在严重不够用了,如下图所示:

其实是可以扩展的,但扩展目录需要是没有分配的空间,这就要求我们在初始化服务器后重装系统,先从数据盘空间扩展系统盘,然后再挂载数据盘。
centos7下扩展根分区教程如下:
centos7下扩展根分区(图文详解) - 免费云服务器 _ 帮助与文档 _ 三丰云


1、查看磁盘:
  1. fdisk -l
复制代码
2、分区:
  1. fdisk /dev/sdb
复制代码
输出:
  1. [root@localhost ~]# fdisk /dev/sdb
  2. Welcome to fdisk (util-linux 2.23.2).

  3. Changes will remain in memory only, until you decide to write them.
  4. Be careful before using the write command.

  5. Device does not contain a recognized partition table
  6. Building a new DOS disklabel with disk identifier 0x49b45401.

  7. The device presents a logical sector size that is smaller than
  8. the physical sector size. Aligning to a physical sector (or optimal
  9. I/O) size boundary is recommended, or performance may be impacted.

  10. Command (m for help): n
  11. Partition type:
  12.    p   primary (0 primary, 0 extended, 4 free)
  13.    e   extended
  14. Select (default p): p
  15. Partition number (1-4, default 1): 1
  16. First sector (2048-209715199, default 2048): +30G
  17. Last sector, +sectors or +size{K,M,G} (62914560-209715199, default 209715199):
  18. Using default value 209715199
  19. Partition 1 of type Linux and of size 70 GiB is set

  20. Command (m for help): n
  21. Partition type:
  22.    p   primary (1 primary, 0 extended, 3 free)
  23.    e   extended
  24. Select (default p): p
  25. Partition number (2-4, default 2): 2
  26. First sector (2048-209715199, default 2048):
  27. Using default value 2048
  28. Last sector, +sectors or +size{K,M,G} (2048-62914559, default 62914559):
  29. Using default value 62914559
  30. Partition 2 of type Linux and of size 30 GiB is set
复制代码
再次输入p查看:
  1. Command (m for help): p

  2. Disk /dev/sdb: 107.4 GB, 107374182400 bytes, 209715200 sectors
  3. Units = sectors of 1 * 512 = 512 bytes
  4. Sector size (logical/physical): 512 bytes / 4096 bytes
  5. I/O size (minimum/optimal): 4096 bytes / 4096 bytes
  6. Disk label type: dos
  7. Disk identifier: 0x49b45401

  8.    Device Boot      Start         End      Blocks   Id  System
  9. /dev/sdb1        62914560   209715199    73400320   83  Linux
  10. /dev/sdb2            2048    62914559    31456256   83  Linux

  11. Partition table entries are not in disk order
复制代码
然后输入w保存:
  1. Command (m for help): w
  2. The partition table has been altered!

  3. Calling ioctl() to re-read partition table.
  4. Syncing disks.
复制代码
继续按照三丰云的教程输入vgdisplay -v命令:
  1. [root@localhost ~]# vgdisplay -v
  2.   --- Volume group ---
  3.   VG Name               centos
  4.   System ID            
  5.   Format                lvm2
  6.   Metadata Areas        1
  7.   Metadata Sequence No  3
  8.   VG Access             read/write
  9.   VG Status             resizable
  10.   MAX LV                0
  11.   Cur LV                2
  12.   Open LV               2
  13.   Max PV                0
  14.   Cur PV                1
  15.   Act PV                1
  16.   VG Size               <14.00 GiB
  17.   PE Size               4.00 MiB
  18.   Total PE              3583
  19.   Alloc PE / Size       3583 / <14.00 GiB
  20.   Free  PE / Size       0 / 0   
  21.   VG UUID               5hlfxw-ZrTw-4lfk-qYgI-5xl7-bKn0-H1u47h
  22.    
  23.   --- Logical volume ---
  24.   LV Path                /dev/centos/swap
  25.   LV Name                swap
  26.   VG Name                centos
  27.   LV UUID                O55Fu9-JV6O-xv1J-hHVp-fqdO-XOP6-6gZOYN
  28.   LV Write Access        read/write
  29.   LV Creation host, time localhost, 2022-05-10 07:54:40 -0400
  30.   LV Status              available
  31.   # open                 2
  32.   LV Size                1.50 GiB
  33.   Current LE             384
  34.   Segments               1
  35.   Allocation             inherit
  36.   Read ahead sectors     auto
  37.   - currently set to     8192
  38.   Block device           253:1
  39.    
  40.   --- Logical volume ---
  41.   LV Path                /dev/centos/root
  42.   LV Name                root
  43.   VG Name                centos
  44.   LV UUID                cl6mgF-6vay-zqF4-qBhK-3DB5-sUZB-wc7rMf
  45.   LV Write Access        read/write
  46.   LV Creation host, time localhost, 2022-05-10 07:54:41 -0400
  47.   LV Status              available
  48.   # open                 1
  49.   LV Size                <12.50 GiB
  50.   Current LE             3199
  51.   Segments               1
  52.   Allocation             inherit
  53.   Read ahead sectors     auto
  54.   - currently set to     8192
  55.   Block device           253:0
  56.    
  57.   --- Physical volumes ---
  58.   PV Name               /dev/sda2     
  59.   PV UUID               TuE61G-54Ld-ocG4-zZHX-cQ1G-fiGj-EUesBL
  60.   PV Status             allocatable
  61.   Total PE / Free PE    3583 / 0
复制代码
继续为/dev/sdb1和/dev/sdb2创建物理卷:
  1. [root@localhost ~]# pvcreate /dev/sdb1
  2.   Physical volume "/dev/sdb1" successfully created.
  3. [root@localhost ~]# pvdisplay
  4.   --- Physical volume ---
  5.   PV Name               /dev/sda2
  6.   VG Name               centos
  7.   PV Size               <14.00 GiB / not usable 3.00 MiB
  8.   Allocatable           yes (but full)
  9.   PE Size               4.00 MiB
  10.   Total PE              3583
  11.   Free PE               0
  12.   Allocated PE          3583
  13.   PV UUID               TuE61G-54Ld-ocG4-zZHX-cQ1G-fiGj-EUesBL
  14.    
  15.   "/dev/sdb1" is a new physical volume of "70.00 GiB"
  16.   --- NEW Physical volume ---
  17.   PV Name               /dev/sdb1
  18.   VG Name               
  19.   PV Size               70.00 GiB
  20.   Allocatable           NO
  21.   PE Size               0   
  22.   Total PE              0
  23.   Free PE               0
  24.   Allocated PE          0
  25.   PV UUID               INW6T0-4iPa-4FoY-VJT1-QlDP-AfjP-wn0EfA
  26.    
  27. [root@localhost ~]# pvcreate /dev/sdb2
  28.   Physical volume "/dev/sdb2" successfully created.
  29. [root@localhost ~]# pvdisplay
  30.   --- Physical volume ---
  31.   PV Name               /dev/sda2
  32.   VG Name               centos
  33.   PV Size               <14.00 GiB / not usable 3.00 MiB
  34.   Allocatable           yes (but full)
  35.   PE Size               4.00 MiB
  36.   Total PE              3583
  37.   Free PE               0
  38.   Allocated PE          3583
  39.   PV UUID               TuE61G-54Ld-ocG4-zZHX-cQ1G-fiGj-EUesBL
  40.    
  41.   "/dev/sdb1" is a new physical volume of "70.00 GiB"
  42.   --- NEW Physical volume ---
  43.   PV Name               /dev/sdb1
  44.   VG Name               
  45.   PV Size               70.00 GiB
  46.   Allocatable           NO
  47.   PE Size               0   
  48.   Total PE              0
  49.   Free PE               0
  50.   Allocated PE          0
  51.   PV UUID               INW6T0-4iPa-4FoY-VJT1-QlDP-AfjP-wn0EfA
  52.    
  53.   "/dev/sdb2" is a new physical volume of "<30.00 GiB"
  54.   --- NEW Physical volume ---
  55.   PV Name               /dev/sdb2
  56.   VG Name               
  57.   PV Size               <30.00 GiB
  58.   Allocatable           NO
  59.   PE Size               0   
  60.   Total PE              0
  61.   Free PE               0
  62.   Allocated PE          0
  63.   PV UUID               MOOZ7E-soPj-h6aa-yqCm-KoCJ-9Wee-aV9BfU
  64.    
  65. [root@localhost ~]# vgextend centos /dev/sdb2
  66.   Volume group "centos" successfully extended
  67. [root@localhost ~]# lvdisplay
  68.   --- Logical volume ---
  69.   LV Path                /dev/centos/swap
  70.   LV Name                swap
  71.   VG Name                centos
  72.   LV UUID                O55Fu9-JV6O-xv1J-hHVp-fqdO-XOP6-6gZOYN
  73.   LV Write Access        read/write
  74.   LV Creation host, time localhost, 2022-05-10 07:54:40 -0400
  75.   LV Status              available
  76.   # open                 2
  77.   LV Size                1.50 GiB
  78.   Current LE             384
  79.   Segments               1
  80.   Allocation             inherit
  81.   Read ahead sectors     auto
  82.   - currently set to     8192
  83.   Block device           253:1
  84.    
  85.   --- Logical volume ---
  86.   LV Path                /dev/centos/root
  87.   LV Name                root
  88.   VG Name                centos
  89.   LV UUID                cl6mgF-6vay-zqF4-qBhK-3DB5-sUZB-wc7rMf
  90.   LV Write Access        read/write
  91.   LV Creation host, time localhost, 2022-05-10 07:54:41 -0400
  92.   LV Status              available
  93.   # open                 1
  94.   LV Size                <12.50 GiB
  95.   Current LE             3199
  96.   Segments               1
  97.   Allocation             inherit
  98.   Read ahead sectors     auto
  99.   - currently set to     8192
  100.   Block device           253:0
  101.    
  102. [root@localhost ~]# lvextend -L +30G /dev/centos/root
  103.   Insufficient free space: 7680 extents needed, but only 7679 available
  104. [root@localhost ~]# lvextend -L +29.9G /dev/centos/root
  105.   Rounding size to boundary between physical extents: 29.90 GiB.
  106.   Size of logical volume centos/root changed from <12.50 GiB (3199 extents) to <42.40 GiB (10854 extents).
  107.   Logical volume centos/root successfully resized.
  108. [root@localhost ~]# xfs_growfs /dev/centos/root
  109. meta-data=/dev/mapper/centos-root isize=512    agcount=4, agsize=818944 blks
  110.          =                       sectsz=4096  attr=2, projid32bit=1
  111.          =                       crc=1        finobt=0 spinodes=0
  112. data     =                       bsize=4096   blocks=3275776, imaxpct=25
  113.          =                       sunit=0      swidth=0 blks
  114. naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
  115. log      =internal               bsize=4096   blocks=2560, version=2
  116.          =                       sectsz=4096  sunit=1 blks, lazy-count=1
  117. realtime =none                   extsz=4096   blocks=0, rtextents=0
  118. data blocks changed from 3275776 to 11114496
  119. [root@localhost ~]# df -h
  120. Filesystem               Size  Used Avail Use% Mounted on
  121. /dev/mapper/centos-root   43G  1.3G   42G   4% /
  122. devtmpfs                 3.9G     0  3.9G   0% /dev
  123. tmpfs                    3.9G     0  3.9G   0% /dev/shm
  124. tmpfs                    3.9G  8.7M  3.9G   1% /run
  125. tmpfs                    3.9G     0  3.9G   0% /sys/fs/cgroup
  126. /dev/sda1               1014M  145M  870M  15% /boot
  127. tmpfs                    782M     0  782M   0% /run/user/0
  128. [root@localhost ~]# fdisk -l

  129. Disk /dev/sdb: 107.4 GB, 107374182400 bytes, 209715200 sectors
  130. Units = sectors of 1 * 512 = 512 bytes
  131. Sector size (logical/physical): 512 bytes / 4096 bytes
  132. I/O size (minimum/optimal): 4096 bytes / 4096 bytes
  133. Disk label type: dos
  134. Disk identifier: 0x49b45401

  135.    Device Boot      Start         End      Blocks   Id  System
  136. /dev/sdb1        62914560   209715199    73400320   83  Linux
  137. /dev/sdb2            2048    62914559    31456256   83  Linux

  138. Partition table entries are not in disk order

  139. Disk /dev/sda: 16.1 GB, 16106127360 bytes, 31457280 sectors
  140. Units = sectors of 1 * 512 = 512 bytes
  141. Sector size (logical/physical): 512 bytes / 4096 bytes
  142. I/O size (minimum/optimal): 4096 bytes / 4096 bytes
  143. Disk label type: dos
  144. Disk identifier: 0x00077442

  145.    Device Boot      Start         End      Blocks   Id  System
  146. /dev/sda1   *        2048     2099199     1048576   83  Linux
  147. /dev/sda2         2099200    31457279    14679040   8e  Linux LVM

  148. Disk /dev/mapper/centos-root: 45.5 GB, 45524975616 bytes, 88915968 sectors
  149. Units = sectors of 1 * 512 = 512 bytes
  150. Sector size (logical/physical): 512 bytes / 4096 bytes
  151. I/O size (minimum/optimal): 4096 bytes / 4096 bytes


  152. Disk /dev/mapper/centos-swap: 1610 MB, 1610612736 bytes, 3145728 sectors
  153. Units = sectors of 1 * 512 = 512 bytes
  154. Sector size (logical/physical): 512 bytes / 4096 bytes
  155. I/O size (minimum/optimal): 4096 bytes / 4096 bytes
复制代码
格式化/dev/sdb1,将数据盘剩余的/dev/sdb1挂载的data目录:
  1. [root@localhost ~]# mkfs -t ext4 -c /dev/sdb1
  2. mke2fs 1.42.9 (28-Dec-2013)
  3. Discarding device blocks: done                           
  4. Filesystem label=
  5. OS type: Linux
  6. Block size=4096 (log=2)
  7. Fragment size=4096 (log=2)
  8. Stride=0 blocks, Stripe width=0 blocks
  9. 4587520 inodes, 18350080 blocks
  10. 917504 blocks (5.00%) reserved for the super user
  11. First data block=0
  12. Maximum filesystem blocks=2166358016
  13. 560 block groups
  14. 32768 blocks per group, 32768 fragments per group
  15. 8192 inodes per group
  16. Superblock backups stored on blocks:
  17.         32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
  18.         4096000, 7962624, 11239424

  19. Checking for bad blocks (read-only test): done                                                
  20. Allocating group tables: done                           
  21. Writing inode tables: done                           
  22. Creating journal (32768 blocks): done
  23. Writing superblocks and filesystem accounting information: done
复制代码
创建data目录:
  1. [root@localhost ~]# mkdir -p /data
  2. [root@localhost ~]# mount /dev/sdb1 /data
复制代码
根据linux数据库开启自动挂载配置指令 - 开发技术 - 寿光赢创志诚信息技术有限公司 - Powered by Discuz!
设置开机自动挂载数据盘。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
道不同,不相为谋!理想要有,万一实现了呢?
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注公众号

相关侵权、举报、投诉及建议等,请发 E-mail:2513533699@qq.com

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.|鲁ICP备19000917号|鲁公网安备37078302000320号

在本版发帖
关注公众号
QQ客服返回顶部