VMware 磁盘不足,扩展磁盘后如何挂载磁盘,教程如下

 标红为输入项

 

[root@bogon ~]# fdisk -l
磁盘 /dev/sda:59.1 GB, 59055800320 字节,115343360 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x000a13d5

   设备 Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200    41943039    19921920   8e  Linux LVM

磁盘 /dev/mapper/centos_bogon-root:18.2 GB, 18249416704 字节,35643392 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节


磁盘 /dev/mapper/centos_bogon-swap:2147 MB, 2147483648 字节,4194304 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节

[root@bogon ~]# fdisk /dev/sda
欢迎使用 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):[Enter]
起始 扇区 (41943040-115343359,默认为 41943040):[Enter]
将使用默认值 41943040
Last 扇区, +扇区 or +size{K,M,G} (41943040-115343359,默认为 115343359):+13G
分区 3 已设置为 Linux 类型,大小设为 13 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)
正在同步磁盘。
[root@bogon ~]# fdisk -l

磁盘 /dev/sda:59.1 GB, 59055800320 字节,115343360 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x000a13d5

   设备 Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200    41943039    19921920   8e  Linux LVM
/dev/sda3        41943040    69206015    13631488   83  Linux

磁盘 /dev/mapper/centos_bogon-root:18.2 GB, 18249416704 字节,35643392 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节


磁盘 /dev/mapper/centos_bogon-swap:2147 MB, 2147483648 字节,4194304 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节

[root@bogon ~]# mkfs.ext4 /dev/sda3
mke2fs 1.42.9 (28-Dec-2013)
无法对 /dev/sda3 进行 stat 调用 --- 没有那个文件或目录

The device apparently does not exist; did you specify it correctly?
[root@bogon ~]# partprobe
Warning: 无法以读写方式打开 /dev/sr0 (只读文件系统)。/dev/sr0 已按照只读方式打开。
[root@bogon ~]# mkfs.ext4 /dev/sda3
mke2fs 1.42.9 (28-Dec-2013)
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
851968 inodes, 3407872 blocks
  0393 blocks (5.00%) reserved for the super user
▽ 一个数据块=0
Maximum filesystem blocks=2151677952
104 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

Allocating group tables: 完成                            
正在写入inode表: 完成                            
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成   

[root@bogon ~]# vim /etc/fstab 

#
# /etc/fstab
# Created by anaconda on Wed Sep 14 13:38:05 2022
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos_bogon-root /                       xfs     defaults        0 
0
UUID=27637017-1936-451f-93fc-6165a9599a61 /boot                   xfs     defaul
ts        0 0
/dev/mapper/centos_bogon-swap swap                    swap    defaults        0 
0
/dev/sda3 /disk ext4 defaults 0 0
"/etc/fstab" 12L, 511C 已写入                                 
[root@bogon ~]# mount -a
[root@bogon ~]# df -h
文件系统                       容量  已用  可用 已用% 挂载点
/dev/mapper/centos_bogon-root   17G   17G   16M  100% /
devtmpfs                       3.9G     0  3.9G    0% /dev
tmpfs                          3.9G  8.0K  3.9G    1% /dev/shm
tmpfs                          3.9G  8.8M  3.9G    1% /run
tmpfs                          3.9G     0  3.9G    0% /sys/fs/cgroup
/dev/sda1                     1014M  145M  870M   15% /boot
tmpfs                          781M     0  781M    0% /run/user/1002
tmpfs                          781M     0  781M    0% /run/user/0
/dev/sda3                       13G   41M   12G    1% /disk
[root@bogon ~]# pvcreate /dev/sda3
  Can't open /dev/sda3 exclusively.  Mounted filesystem?
  Can't open /dev/sda3 exclusively.  Mounted filesystem?
[root@bogon ~]# umount /dev/sda3
[root@bogon ~]# pvcreate /dev/sda3
WARNING: ext4 signature detected on /dev/sda3 at offset 1080. Wipe it? [y/n]: y
  Wiping ext4 signature on /dev/sda3.
  Physical volume "/dev/sda3" successfully created.
[root@bogon ~]# vgscan
  Reading volume groups from cache.
  Found volume group "centos_bogon" using metadata type lvm2
[root@bogon ~]# vgextend centos_bogon /dev/sda3
  Volume group "centos_bogon" successfully extended
[root@bogon ~]# lvextend -L +12G /dev/mapper/centos_bogon-root
  Size of logical volume centos_bogon/root changed from <17.00 GiB (4351 extents) to <29.00 GiB (7423 extents).
  Logical volume centos_bogon/root successfully resized.
[root@bogon ~]# xfs_growfs /dev/mapper/centos_bogon-root
meta-data=/dev/mapper/centos_bogon-root isize=512    agcount=4, agsize=1113856 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=4455424, 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
  altime =none                   extsz=4096   blocks=0, rtextents=0
▽ata blocks changed from 4455424 to 7601152
[root@bogon ~]# df -h
文件系统                       容量  已用  可用 已用% 挂载点
/dev/mapper/centos_bogon-root   29G   17G   13G   59% /
devtmpfs                       3.9G     0  3.9G    0% /dev
tmpfs                          3.9G  8.0K  3.9G    1% /dev/shm
tmpfs                          3.9G  8.8M  3.9G    1% /run
tmpfs                          3.9G     0  3.9G    0% /sys/fs/cgroup
/dev/sda1                     1014M  145M  870M   15% /boot
tmpfs                          781M     0  781M    0% /run/user/1002
tmpfs                          781M     0  781M    0% /run/user/0

[root@bogon ~]# vim /etc/fstab

#
# /etc/fstab
# Created by anaconda on Wed Sep 14 13:38:05 2022
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos_bogon-root /                       xfs     defaults        0 
0
UUID=27637017-1936-451f-93fc-6165a9599a61 /boot                   xfs     defaul
ts        0 0
/dev/mapper/centos_bogon-swap swap                    swap    defaults        0 
0
~                                                                               
"/etc/fstab" 11L, 477C 已写入

  

 

posted @ 2023-05-23 15:39  何童鞋  阅读(411)  评论(0编辑  收藏  举报