文章正文

linux-虚拟机-磁盘扩容-新增磁盘

【文档】2020-04-23

简介linux-虚拟机-磁盘扩容-新增磁盘

1、通过vmware虚拟机管理界面-扩容功能,增加磁盘容量

2、通过fdisk管理,新增分区同时格式化

执行fdisk -l 或df -Th 查看磁盘情况
//
先删除sda3根分区,然后重新创建sda3根分区
[root@node ~]# 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): m
 Command action
    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)
 
 Command (m for help): d  ##删除分区
 Partition number (1-3, default 3): 3 ##临时先删除sda3分区
 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 #指定分区号3,重新创建sda3分区
 First sector (17303552-104857599, default 17303552): #回车
 Using default value 17303552
 Last sector, +sectors or +size{K,M,G} (17303552-104857599, default 104857599): #回车
 Using default value 104857599
 Partition 3 of type Linux and of size 41.8 GiB is set #提示OK
 
 Command (m for help): w #按w保存退出
 The partition table has been altered! #提示OK

重启系统,reboot

3、挂载磁盘

执行xfs_growfs /dev/sda3

[root@node~]# xfs_growfs /dev/sda3
meta-data=/dev/sda3              isize=512    agcount=8, agsize=769984 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=5701376, 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 5701376 to 10944256
[root@node03 ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3        42G   11G   32G  25% /
devtmpfs        2.9G     0  2.9G   0% /dev
tmpfs           3.0G     0  3.0G   0% /dev/shm
tmpfs           3.0G   13M  2.9G   1% /run
tmpfs           3.0G     0  3.0G   0% /sys/fs/cgroup
/dev/sda1       253M  153M  101M  61% /boot
tmpfs           595M  8.0K  595M   1% /run/user/990
tmpfs           595M     0  595M   0% /run/user/0
You have new mail in /var/spool/mail/root


附录:

查找磁盘的UUID,输入blkid 命令:

UUID=a6c8972c-7036-49cf-9a7a-321657969fdd /                       xfs     defaults        0 0

UUID=a53ab987-9db8-4a40-b0a5-bc45b4fe19f4 /boot                   xfs     defaults        0 0

UUID=10617683-fea6-4734-bea7-f8e307857664 swap                    swap    defaults        0 0

UUID=e4195160-32d4-43d2-9df7-20a0919a48a6 /data                   xfs     defaults        0 0

打赏支持

感谢您的支持,加油!

打开微信扫码打赏,你说多少就多少

找书费时,联系客服快速查找!

扫码支持

在线客服8:30-22:30,若离线请留言!

获取教程,请联系在线客服!

扫码支持

在线客服8:30-22:30,若离线请留言!

热门阅读

找PDF电子书,太费时间?

  • 微信扫描二维码,让客服快速查找。
  • 在线客服8:30-22:30,若离线请留言!

    PDF电子书