vmware安装centos7磁盘扩容

虚拟机设置中点击扩展,并增加磁盘

进入虚拟机后:

1. 找到未使用的磁盘

 df -hT,目前是1T的空间

文件系统                类型      容量  已用  可用 已用% 挂载点
devtmpfs                devtmpfs  7.8G     0  7.8G    0% /dev
tmpfs                   tmpfs     7.8G     0  7.8G    0% /dev/shm
tmpfs                   tmpfs     7.8G  8.9M  7.8G    1% /run
tmpfs                   tmpfs     7.8G     0  7.8G    0% /sys/fs/cgroup
/dev/mapper/centos-root  xfs       965G   85G  881G    9% /
/dev/sda1                xfs      1014M  188M  827M   19% /boot
/dev/mapper/centos-home  xfs        50G   33M   50G    1% /home
tmpfs                   tmpfs     1.6G     0  1.6G    0% /run/user/0

   fdisk -l

磁盘是2T的容量

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
磁盘  /dev/sda :2199.0 GB, 2199023255552 字节,4294967296 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I /O  大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x000b948d
    设备 Boot      Start         End      Blocks   Id  System
/dev/sda1    *        2048     2099199     1048576   83  Linux
/dev/sda2          2099200  2147483647  1072692224   8e  Linux LVM
磁盘  /dev/mapper/centos-root :1036.3 GB, 1036286689280 字节,2023997440 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I /O  大小(最小/最佳):512 字节 / 512 字节
磁盘  /dev/mapper/centos-swap :8455 MB, 8455716864 字节,16515072 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I /O  大小(最小/最佳):512 字节 / 512 字节
磁盘  /dev/mapper/centos-home :53.7 GB, 53687091200 字节,104857600 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I /O  大小(最小/最佳):512 字节 / 512 字节

2. 新建分区

fdisk /dev/sda

然后输入m->n->p->回车->回车->回车->w

然后重起机器 reboot

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
WARNING: The size of this disk is 2.2 TB (2199023255552 bytes).
DOS partition table  format  can not be used on drives  for  volumes
larger than (2199023255040 bytes)  for  512-byte sectors. Use parted(1) and GUID
partition table  format  (GPT).
欢迎使用  fdisk  (util-linux 2.23.2)。
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。
命令(输入 m 获取帮助):m
命令操作
    a   toggle a bootable flag
    b   edit bsd disklabel
    c   toggle the dos compatibility flag
    d   delete a partition
    g   create a new empty GPT partition table
    G   create an IRIX (SGI) partition table
    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)
命令(输入 m 获取帮助):n
Partition  type :
    p   primary (2 primary, 0 extended, 2  free )
    e   extended
Select (default p): p
分区号 (3,4,默认 3):
起始 扇区 (2147483648-4294967295,默认为 2147483648):
将使用默认值 2147483648
Last 扇区, +扇区 or +size{K,M,G} (2147483648-4294967294,默认为 4294967294):
将使用默认值 4294967294
分区 3 已设置为 Linux 类型,大小设为 1024 GiB
命令(输入 m 获取帮助):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)
正在同步磁盘。

  可以看到,新的分区号是3

3. 对分区进行格式化,格式化后的文件系统也是xfs格式 

fdisk -l,可以看到新的分区号是3

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
磁盘  /dev/sda :2199.0 GB, 2199023255552 字节,4294967296 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I /O  大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x000b948d
    设备 Boot      Start         End      Blocks   Id  System
/dev/sda1    *        2048     2099199     1048576   83  Linux
/dev/sda2          2099200  2147483647  1072692224   8e  Linux LVM
/dev/sda3       2147483648  4294967294  1073741823+  83  Linux
磁盘  /dev/mapper/centos-root :1036.3 GB, 1036286689280 字节,2023997440 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I /O  大小(最小/最佳):512 字节 / 512 字节
磁盘  /dev/mapper/centos-swap :8455 MB, 8455716864 字节,16515072 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I /O  大小(最小/最佳):512 字节 / 512 字节
磁盘  /dev/mapper/centos-home :53.7 GB, 53687091200 字节,104857600 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I /O  大小(最小/最佳):512 字节 / 512 字节

 对/dev/sda3进行格式化

mkfs.xfs /dev/sda3

1
2
3
4
5
6
7
8
9
meta-data= /dev/sda3               isize=512    agcount=4, agsize=67108864 blks
          =                       sectsz=512   attr=2, projid32bit=1
          =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=268435455, imaxpct=25
          =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=131071, version=2
          =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

4. 创建pv

pvcreate /dev/sda3

然后输入y

1
2
3
WARNING: xfs signature detected on  /dev/sda3  at offset 0. Wipe it? [y /n ]: y
   Wiping xfs signature on  /dev/sda3 .
   Physical volume  "/dev/sda3"  successfully created.

5. 处理逻辑卷

vgs

1
2
VG      #PV #LV #SN Attr   VSize     VFree
centos   1   3   0 wz--n- <1023.00g 4.00m

vgextend centos /dev/sda3

1
Volume group  "centos"  successfully extended

vgs

1
2
VG      #PV #LV #SN Attr   VSize  VFree
centos   2   3   0 wz--n- <2.00t 1.00t

 可以看到由原来的1023G变成了2T。其中1T是空闲的

df -h 

查看要扩容的文件系统的位置 ,这是是/dev/mapper/centos-root

1
2
3
4
5
6
7
8
9
文件系统                 容量  已用  可用 已用% 挂载点
devtmpfs                 7.8G     0  7.8G    0%  /dev
tmpfs                    7.8G     0  7.8G    0%  /dev/shm
tmpfs                    7.8G  8.9M  7.8G    1%  /run
tmpfs                    7.8G     0  7.8G    0%  /sys/fs/cgroup
/dev/mapper/centos-root   965G   85G  881G    9% /
/dev/sda1                1014M  188M  827M   19%  /boot
/dev/mapper/centos-home    50G   33M   50G    1%  /home
tmpfs                    1.6G     0  1.6G    0%  /run/user/0

lvextend -l +100%free /dev/mapper/centos-root

1
2
Size of logical volume centos /root  changed from <965.12 GiB (247070 extents) to 1.94 TiB (509214 extents).
Logical volume centos /root  successfully resized.

6. 扩容,调整分区

xfs_growfs /dev/mapper/centos-root

1
2
3
4
5
6
7
8
9
10
meta-data= /dev/mapper/centos-root  isize=512    agcount=4, agsize=63249920 blks
          =                       sectsz=512   attr=2, projid32bit=1
          =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=252999680, imaxpct=25
          =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=123535, version=2
          =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 252999680 to 521435136

 df -h

扩容成功

1
2
3
4
5
6
7
8
9
文件系统                 容量  已用  可用 已用% 挂载点
devtmpfs                 7.8G     0  7.8G    0%  /dev
tmpfs                    7.8G     0  7.8G    0%  /dev/shm
tmpfs                    7.8G  8.9M  7.8G    1%  /run
tmpfs                    7.8G     0  7.8G    0%  /sys/fs/cgroup
/dev/mapper/centos-root   2.0T   85G  1.9T    5% /
/dev/sda1                1014M  188M  827M   19%  /boot
/dev/mapper/centos-home    50G   33M   50G    1%  /home
tmpfs                    1.6G     0  1.6G    0%  /run/user/0
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

lxr1908

用钱砸我

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值