Linux虛擬機怎麼添加磁盤?

1、VMware workstation菜單欄👉虛擬機👉設置👉添加👉硬盤👉下一步

 

2、SCSI👉下一步:

3、建立新虛擬磁盤👉下一步

4、選擇本身須要的硬盤大小👉當即分配磁盤取消勾選👉將虛擬磁盤存儲爲單個文件👉下一步

 

5、完成

6、重啓虛擬機後,使用lsblk命令查看磁盤狀況

[root@localhost ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0    0   20G  0 disk ├─sda1 8:1    0    1G  0 part /boot └─sda2 8:2    0   19G  0 part ├─centos-root 253:0    0   17G  0 lvm  / └─centos-swap 253:1    0    2G  0 lvm [SWAP] sdb 8:16 0 5G 0 disk sr0 11:0    1 1024M  0 rom

發現已經成功添加新硬盤sdb。html

7、使用fdisk建立新分區

[root@localhost ~]# fdisk /dev/sdb 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. Device does not contain a recognized partition table Building a new DOS disklabel with disk identifier 0x03295b0a. Command (m for help):

而後輸入 p  ,回車:node

Command (m for help): p Disk /dev/sdb: 5368 MB, 5368709120 bytes, 10485760 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: 0x03295b0a Device Boot Start End Blocks Id System Command (m for help):

輸入  n  回車:linux

Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): 

輸入  p  回車, 1  回車,回車,回車:centos

Select (default p): p Partition number (1-4, default 1): 1 First sector (2048-10485759, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-10485759, default 10485759): Using default value 10485759 Partition 1 of type Linux and of size 5 GiB is set

輸入  p  ,回車:app

Command (m for help): p Disk /dev/sdb: 5368 MB, 5368709120 bytes, 10485760 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: 0x03295b0a Device Boot Start End Blocks Id System /dev/sdb1            2048    10485759     5241856   83 Linux Command (m for help):

輸入  w  ,回車,保存退出。至此,磁盤分區完成。ide

Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.

8、使用mkfs.ext4命令進行格式化

先查看分區表ui

[root@localhost ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0    0   20G  0 disk ├─sda1 8:1    0    1G  0 part /boot └─sda2 8:2    0   19G  0 part ├─centos-root 253:0    0   17G  0 lvm  / └─centos-swap 253:1    0    2G  0 lvm [SWAP] sdb 8:16   0    5G  0 disk └─sdb1 8:17   0    5G  0 part sr0 11:0    1 1024M  0 rom

發現新分區是sdb1(我只分了一個主分區,因此是sdb1。)而後咱們對sdb1進行格式化spa

[root@localhost ~]# mkfs.ext4 /dev/sdb1 mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 327680 inodes, 1310464 blocks 65523 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=1342177280
40 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 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done

至此格式化完成。3d

9、掛載分區

我以掛載到根分區的data目錄爲例:code

新建/data目錄

[root@localhost /]# mkdir data

掛載分區到/data目錄

[root@localhost /]# mount /dev/sdb1 /data

查看磁盤使用狀況

[root@localhost /]# df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/centos-root xfs        17G  1.3G   16G   8% / devtmpfs devtmpfs 1.9G     0  1.9G   0% /dev tmpfs tmpfs 1.9G     0  1.9G   0% /dev/shm tmpfs tmpfs 1.9G   12M  1.9G   1% /run tmpfs tmpfs 1.9G     0  1.9G   0% /sys/fs/cgroup /dev/sda1               xfs      1014M  148M  867M  15% /boot tmpfs tmpfs 378M 0  378M   0% /run/user/0
/dev/sdb1               ext4      4.8G   20M  4.6G   1% /data

至此,虛擬機添加磁盤操做結束。

原文出處:https://www.cnblogs.com/quail2333/p/11173511.html

相關文章
相關標籤/搜索