仮想マシンディスクの新しいパーティション

仮想マシンのディスク拡張を記録する

ノートブックのディスク容量がかなり大きいことを見ると、事前にインストールしたときに割り当てられた容量が小さく感じられ、少し拡張されます。

ファイルシステムのサイズを表示する

[仮想マシン] -> [設定] -> [ディスク] -> [拡張機能]をクリックし、適切なディスクサイズの拡張機能を選択します。

  1. 次に、現在のファイルシステム、ストレージの割り当てを確認しますが、新しく拡張されたメモリがシステムによってロードされていることを確認できませんでした。
[root@localhost ~]# df -hT
Filesystem     Type      Size  Used Avail Use% Mounted on
devtmpfs       devtmpfs  3.8G     0  3.8G   0% /dev
tmpfs          tmpfs     3.9G     0  3.9G   0% /dev/shm
tmpfs          tmpfs     3.9G   13M  3.8G   1% /run
tmpfs          tmpfs     3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/sda1      xfs        60G  4.1G   56G   7% /
/dev/sda2      xfs        25G  771M   25G   4% /var
tmpfs          tmpfs     781M   32K  781M   1% /run/user/1000
/dev/sr0       iso9660   4.4G  4.4G     0 100% /run/media/root/CentOS 7 x86_64
tmpfs          tmpfs     781M     0  781M   0% /run/user/0

  1. 拡張後のディスク全体の実際のサイズと、パーティション化された各パーティションのサイズを確認します。
[root@localhost ~]# fdisk -l 

Disk /dev/sda: 161.1 GB, 161061273600 bytes, 314572800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0009cdd8

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048   125831167    62914560   83  Linux
/dev/sda2       125831168   178259967    26214400   83  Linux
/dev/sda3       178259968   188743679     5241856   82  Linux swap / Solaris
  1. 次に、同じディスクにもう1つのパーティションを分割します
[root@localhost ~]# 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): p

Disk /dev/sda: 161.1 GB, 161061273600 bytes, 314572800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0009cdd8

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048   125831167    62914560   83  Linux
/dev/sda2       125831168   178259967    26214400   83  Linux
/dev/sda3       178259968   188743679     5241856   82  Linux swap / Solaris

Command (m for help): n
Partition type:
   p   primary (3 primary, 0 extended, 1 free)
   e   extended
Select (default e): p
Selected partition 4
First sector (188743680-314572799, default 188743680): 
Using default value 188743680
Last sector, +sectors or +size{
    
    K,M,G} (188743680-314572799, default 314572799): 
Using default value 314572799
Partition 4 of type Linux and of size 60 GiB is set

  1. パーティション分割後の状況を照会する
Command (m for help): p

Disk /dev/sda: 161.1 GB, 161061273600 bytes, 314572800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0009cdd8

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048   125831167    62914560   83  Linux
/dev/sda2       125831168   178259967    26214400   83  Linux
/dev/sda3       178259968   188743679     5241856   82  Linux swap / Solaris
/dev/sda4       188743680   314572799    62914560   83  Linux

Command (m for help): wp
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.

  1. 後者は、現在のシステムがビジーであり、古いテーブルがまだ使用中であることを警告します。新しいテーブルを使用するには、再起動する必要があります。次に、再起動し、新しいパーティションをフォーマットして、ディレクトリdata1を作成し、パーティションを現在のシステムにマウントします。ディレクトリ。
[root@localhost ~]# reboot
[root@localhost mapper]#  mkfs.xfs /dev/sda4
[root@localhost mapper]# mkdir /data1
[root@localhost mapper]# mount /dev/sda4 /data1
[root@localhost mapper]# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        3.8G     0  3.8G   0% /dev
tmpfs           3.9G     0  3.9G   0% /dev/shm
tmpfs           3.9G   13M  3.8G   1% /run
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/sda1        60G  4.1G   56G   7% /
/dev/sda2        25G  812M   25G   4% /var
tmpfs           781M   12K  781M   1% /run/user/42
tmpfs           781M     0  781M   0% /run/user/0
/dev/sda4        60G   33M   60G   1% /data1

  1. システムを再起動した後、ディスクを手動で再度マウントする必要があるため、起動後に自動的にマウントすることをお勧めします。
[root@localhost ~]# vim /etc/fstab
#
# /etc/fstab
# Created by anaconda on Wed Mar 17 16:49:42 2021
#
# 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
#
UUID=9311cbde-d447-4a56-8f74-092e065c9420 /                       xfs     defaults        0 0
UUID=489ce9aa-e8e2-4203-98c4-2491f8bd09ec /var                    xfs     defaults        0 0
UUID=a8da9bdf-e3ee-4cb8-b652-5e17632f0a44 swap                    swap    defaults        0 0
/dev/sda4       /data1  xfs     defaults        0       0  

おすすめ

転載: blog.csdn.net/m0_48187193/article/details/114965177