根分区扩容记录

[root@db01 ~]# fdisk /dev/sda
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.

Command (m for help): d
Partition number (1-3, default 3): 3
Partition 3 is deleted

Command (m for help): n
Partition type:
   p   primary (2 primary, 0 extended, 2 free)
   e   extended
Select (default p): p
Partition number (3,4, default 3): 3
First sector (2099200-104857599, default 2099200): 
Using default value 2099200
Last sector, +sectors or +size{K,M,G} (2099200-104857599, default 104857599): 
Using default value 104857599
Partition 3 of type Linux and of size 49 GiB is set

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: Device or resource busy.
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.
[root@db01 ~]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   50G  0 disk 
├─sda1   8:1    0  256M  0 part /boot
├─sda2   8:2    0  768M  0 part [SWAP]
├─sda3   8:3    0   19G  0 part /
└─sda4   8:4    0    1K  0 part 
sr0     11:0    1 1024M  0 rom  
[root@db01 ~]# reboot
[root@db01 ~]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   50G  0 disk 
├─sda1   8:1    0  256M  0 part /boot
├─sda2   8:2    0  768M  0 part [SWAP]
└─sda3   8:3    0   49G  0 part /
sr0     11:0    1 1024M  0 rom  
[root@db01 ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        476M     0  476M   0% /dev
tmpfs           487M     0  487M   0% /dev/shm
tmpfs           487M  7.6M  479M   2% /run
tmpfs           487M     0  487M   0% /sys/fs/cgroup
/dev/sda3        19G   16G  3.2G  84% /
/dev/sda1       253M  136M  118M  54% /boot
tmpfs            98M     0   98M   0% /run/user/0
[root@db01 ~]# partprobe

[root@db01 ~]# xfs_growfs /
meta-data=/dev/sda3              isize=512    agcount=4, agsize=1245120 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=4980480, 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=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 4980480 to 12844800
[root@db01 ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        476M     0  476M   0% /dev
tmpfs           487M     0  487M   0% /dev/shm
tmpfs           487M  7.6M  479M   2% /run
tmpfs           487M     0  487M   0% /sys/fs/cgroup
/dev/sda3        49G   16G   34G  33% /
/dev/sda1       253M  136M  118M  54% /boot
tmpfs            98M     0   98M   0% /run/user/0
[root@db01 ~]# 

分为6步:
1:使用fdisk对磁盘进行分区,并修改分区类型为lvm
2:对分区创建物理卷pv
3:创建卷组vg,并将物理卷加入到卷组中
4:创建逻辑卷lv,并指定使用vg的大小
5:初始化刚创建的逻辑卷
6:磁盘挂载,并修改fstab文件,重启验证

如果只是单纯的使用fdisk分区,未来扩容是相当麻烦的事,建议使用lvm。

上一篇:HBase(三)——搭建Fully-distributed


下一篇:虚拟机中的centos(/dev/mapper/centos-root)扩展分区