|
|
我是买的终身会员,系统盘可惜只赠送了12G,现在严重不够用了,如下图所示:
其实是可以扩展的,但扩展目录需要是没有分配的空间,这就要求我们在初始化服务器后重装系统,先从数据盘空间扩展系统盘,然后再挂载数据盘。
centos7下扩展根分区教程如下:
centos7下扩展根分区(图文详解) - 免费云服务器 _ 帮助与文档 _ 三丰云
1、查看磁盘:
2、分区:
输出:
- [root@localhost ~]# fdisk /dev/sdb
- Welcome to fdisk (util-linux 2.23.2).
- Changes will remain in memory only, until you decide to write them.
- Be careful before using the write command.
- Device does not contain a recognized partition table
- Building a new DOS disklabel with disk identifier 0x49b45401.
- The device presents a logical sector size that is smaller than
- the physical sector size. Aligning to a physical sector (or optimal
- I/O) size boundary is recommended, or performance may be impacted.
- 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-209715199, default 2048): +30G
- Last sector, +sectors or +size{K,M,G} (62914560-209715199, default 209715199):
- Using default value 209715199
- Partition 1 of type Linux and of size 70 GiB is set
- Command (m for help): n
- Partition type:
- p primary (1 primary, 0 extended, 3 free)
- e extended
- Select (default p): p
- Partition number (2-4, default 2): 2
- First sector (2048-209715199, default 2048):
- Using default value 2048
- Last sector, +sectors or +size{K,M,G} (2048-62914559, default 62914559):
- Using default value 62914559
- Partition 2 of type Linux and of size 30 GiB is set
复制代码 再次输入p查看:
- Command (m for help): p
- Disk /dev/sdb: 107.4 GB, 107374182400 bytes, 209715200 sectors
- Units = sectors of 1 * 512 = 512 bytes
- Sector size (logical/physical): 512 bytes / 4096 bytes
- I/O size (minimum/optimal): 4096 bytes / 4096 bytes
- Disk label type: dos
- Disk identifier: 0x49b45401
- Device Boot Start End Blocks Id System
- /dev/sdb1 62914560 209715199 73400320 83 Linux
- /dev/sdb2 2048 62914559 31456256 83 Linux
- Partition table entries are not in disk order
复制代码 然后输入w保存:
- Command (m for help): w
- The partition table has been altered!
- Calling ioctl() to re-read partition table.
- Syncing disks.
复制代码 继续按照三丰云的教程输入vgdisplay -v命令:
- [root@localhost ~]# vgdisplay -v
- --- Volume group ---
- VG Name centos
- System ID
- Format lvm2
- Metadata Areas 1
- Metadata Sequence No 3
- VG Access read/write
- VG Status resizable
- MAX LV 0
- Cur LV 2
- Open LV 2
- Max PV 0
- Cur PV 1
- Act PV 1
- VG Size <14.00 GiB
- PE Size 4.00 MiB
- Total PE 3583
- Alloc PE / Size 3583 / <14.00 GiB
- Free PE / Size 0 / 0
- VG UUID 5hlfxw-ZrTw-4lfk-qYgI-5xl7-bKn0-H1u47h
-
- --- Logical volume ---
- LV Path /dev/centos/swap
- LV Name swap
- VG Name centos
- LV UUID O55Fu9-JV6O-xv1J-hHVp-fqdO-XOP6-6gZOYN
- LV Write Access read/write
- LV Creation host, time localhost, 2022-05-10 07:54:40 -0400
- LV Status available
- # open 2
- LV Size 1.50 GiB
- Current LE 384
- Segments 1
- Allocation inherit
- Read ahead sectors auto
- - currently set to 8192
- Block device 253:1
-
- --- Logical volume ---
- LV Path /dev/centos/root
- LV Name root
- VG Name centos
- LV UUID cl6mgF-6vay-zqF4-qBhK-3DB5-sUZB-wc7rMf
- LV Write Access read/write
- LV Creation host, time localhost, 2022-05-10 07:54:41 -0400
- LV Status available
- # open 1
- LV Size <12.50 GiB
- Current LE 3199
- Segments 1
- Allocation inherit
- Read ahead sectors auto
- - currently set to 8192
- Block device 253:0
-
- --- Physical volumes ---
- PV Name /dev/sda2
- PV UUID TuE61G-54Ld-ocG4-zZHX-cQ1G-fiGj-EUesBL
- PV Status allocatable
- Total PE / Free PE 3583 / 0
复制代码 继续为/dev/sdb1和/dev/sdb2创建物理卷:
- [root@localhost ~]# pvcreate /dev/sdb1
- Physical volume "/dev/sdb1" successfully created.
- [root@localhost ~]# pvdisplay
- --- Physical volume ---
- PV Name /dev/sda2
- VG Name centos
- PV Size <14.00 GiB / not usable 3.00 MiB
- Allocatable yes (but full)
- PE Size 4.00 MiB
- Total PE 3583
- Free PE 0
- Allocated PE 3583
- PV UUID TuE61G-54Ld-ocG4-zZHX-cQ1G-fiGj-EUesBL
-
- "/dev/sdb1" is a new physical volume of "70.00 GiB"
- --- NEW Physical volume ---
- PV Name /dev/sdb1
- VG Name
- PV Size 70.00 GiB
- Allocatable NO
- PE Size 0
- Total PE 0
- Free PE 0
- Allocated PE 0
- PV UUID INW6T0-4iPa-4FoY-VJT1-QlDP-AfjP-wn0EfA
-
- [root@localhost ~]# pvcreate /dev/sdb2
- Physical volume "/dev/sdb2" successfully created.
- [root@localhost ~]# pvdisplay
- --- Physical volume ---
- PV Name /dev/sda2
- VG Name centos
- PV Size <14.00 GiB / not usable 3.00 MiB
- Allocatable yes (but full)
- PE Size 4.00 MiB
- Total PE 3583
- Free PE 0
- Allocated PE 3583
- PV UUID TuE61G-54Ld-ocG4-zZHX-cQ1G-fiGj-EUesBL
-
- "/dev/sdb1" is a new physical volume of "70.00 GiB"
- --- NEW Physical volume ---
- PV Name /dev/sdb1
- VG Name
- PV Size 70.00 GiB
- Allocatable NO
- PE Size 0
- Total PE 0
- Free PE 0
- Allocated PE 0
- PV UUID INW6T0-4iPa-4FoY-VJT1-QlDP-AfjP-wn0EfA
-
- "/dev/sdb2" is a new physical volume of "<30.00 GiB"
- --- NEW Physical volume ---
- PV Name /dev/sdb2
- VG Name
- PV Size <30.00 GiB
- Allocatable NO
- PE Size 0
- Total PE 0
- Free PE 0
- Allocated PE 0
- PV UUID MOOZ7E-soPj-h6aa-yqCm-KoCJ-9Wee-aV9BfU
-
- [root@localhost ~]# vgextend centos /dev/sdb2
- Volume group "centos" successfully extended
- [root@localhost ~]# lvdisplay
- --- Logical volume ---
- LV Path /dev/centos/swap
- LV Name swap
- VG Name centos
- LV UUID O55Fu9-JV6O-xv1J-hHVp-fqdO-XOP6-6gZOYN
- LV Write Access read/write
- LV Creation host, time localhost, 2022-05-10 07:54:40 -0400
- LV Status available
- # open 2
- LV Size 1.50 GiB
- Current LE 384
- Segments 1
- Allocation inherit
- Read ahead sectors auto
- - currently set to 8192
- Block device 253:1
-
- --- Logical volume ---
- LV Path /dev/centos/root
- LV Name root
- VG Name centos
- LV UUID cl6mgF-6vay-zqF4-qBhK-3DB5-sUZB-wc7rMf
- LV Write Access read/write
- LV Creation host, time localhost, 2022-05-10 07:54:41 -0400
- LV Status available
- # open 1
- LV Size <12.50 GiB
- Current LE 3199
- Segments 1
- Allocation inherit
- Read ahead sectors auto
- - currently set to 8192
- Block device 253:0
-
- [root@localhost ~]# lvextend -L +30G /dev/centos/root
- Insufficient free space: 7680 extents needed, but only 7679 available
- [root@localhost ~]# lvextend -L +29.9G /dev/centos/root
- Rounding size to boundary between physical extents: 29.90 GiB.
- Size of logical volume centos/root changed from <12.50 GiB (3199 extents) to <42.40 GiB (10854 extents).
- Logical volume centos/root successfully resized.
- [root@localhost ~]# xfs_growfs /dev/centos/root
- meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=818944 blks
- = sectsz=4096 attr=2, projid32bit=1
- = crc=1 finobt=0 spinodes=0
- data = bsize=4096 blocks=3275776, imaxpct=25
- = sunit=0 swidth=0 blks
- naming =version 2 bsize=4096 ascii-ci=0 ftype=1
- log =internal bsize=4096 blocks=2560, version=2
- = sectsz=4096 sunit=1 blks, lazy-count=1
- realtime =none extsz=4096 blocks=0, rtextents=0
- data blocks changed from 3275776 to 11114496
- [root@localhost ~]# df -h
- Filesystem Size Used Avail Use% Mounted on
- /dev/mapper/centos-root 43G 1.3G 42G 4% /
- devtmpfs 3.9G 0 3.9G 0% /dev
- tmpfs 3.9G 0 3.9G 0% /dev/shm
- tmpfs 3.9G 8.7M 3.9G 1% /run
- tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
- /dev/sda1 1014M 145M 870M 15% /boot
- tmpfs 782M 0 782M 0% /run/user/0
- [root@localhost ~]# fdisk -l
- Disk /dev/sdb: 107.4 GB, 107374182400 bytes, 209715200 sectors
- Units = sectors of 1 * 512 = 512 bytes
- Sector size (logical/physical): 512 bytes / 4096 bytes
- I/O size (minimum/optimal): 4096 bytes / 4096 bytes
- Disk label type: dos
- Disk identifier: 0x49b45401
- Device Boot Start End Blocks Id System
- /dev/sdb1 62914560 209715199 73400320 83 Linux
- /dev/sdb2 2048 62914559 31456256 83 Linux
- Partition table entries are not in disk order
- Disk /dev/sda: 16.1 GB, 16106127360 bytes, 31457280 sectors
- Units = sectors of 1 * 512 = 512 bytes
- Sector size (logical/physical): 512 bytes / 4096 bytes
- I/O size (minimum/optimal): 4096 bytes / 4096 bytes
- Disk label type: dos
- Disk identifier: 0x00077442
- Device Boot Start End Blocks Id System
- /dev/sda1 * 2048 2099199 1048576 83 Linux
- /dev/sda2 2099200 31457279 14679040 8e Linux LVM
- Disk /dev/mapper/centos-root: 45.5 GB, 45524975616 bytes, 88915968 sectors
- Units = sectors of 1 * 512 = 512 bytes
- Sector size (logical/physical): 512 bytes / 4096 bytes
- I/O size (minimum/optimal): 4096 bytes / 4096 bytes
- Disk /dev/mapper/centos-swap: 1610 MB, 1610612736 bytes, 3145728 sectors
- Units = sectors of 1 * 512 = 512 bytes
- Sector size (logical/physical): 512 bytes / 4096 bytes
- I/O size (minimum/optimal): 4096 bytes / 4096 bytes
复制代码 格式化/dev/sdb1,将数据盘剩余的/dev/sdb1挂载的data目录:
- [root@localhost ~]# mkfs -t ext4 -c /dev/sdb1
- mke2fs 1.42.9 (28-Dec-2013)
- Discarding device blocks: done
- Filesystem label=
- OS type: Linux
- Block size=4096 (log=2)
- Fragment size=4096 (log=2)
- Stride=0 blocks, Stripe width=0 blocks
- 4587520 inodes, 18350080 blocks
- 917504 blocks (5.00%) reserved for the super user
- First data block=0
- Maximum filesystem blocks=2166358016
- 560 block groups
- 32768 blocks per group, 32768 fragments per group
- 8192 inodes per group
- Superblock backups stored on blocks:
- 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
- 4096000, 7962624, 11239424
- Checking for bad blocks (read-only test): done
- Allocating group tables: done
- Writing inode tables: done
- Creating journal (32768 blocks): done
- Writing superblocks and filesystem accounting information: done
复制代码 创建data目录:
- [root@localhost ~]# mkdir -p /data
- [root@localhost ~]# mount /dev/sdb1 /data
复制代码 根据linux数据库开启自动挂载配置指令 - 开发技术 - 寿光赢创志诚信息技术有限公司 - Powered by Discuz!
设置开机自动挂载数据盘。
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
×
|