vmware虚拟机添加虚拟磁盘的方法


1. 为VMware虚拟机添加虚拟磁盘
打开虚拟机-> 虚拟机设置 -> 磁盘 -> add -> hard disk -> next -> next -> create new disk -> 输入大小和选择保存到单一文件; -> 输入文件名 -> finish;

2. 挂载到linux系统
首先重启虚拟机系统
# 2.1 确认新增的虚拟磁盘设备文件
# sudo fdisk -l
------------------------------------------------------------------------
Disk /dev/sdf: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders, total 209715200 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 identifier: 0x00000000

Disk /dev/sdf doesn't contain a valid partition table
------------------------------------------------------------------------

# 2.2 为新增磁盘配置分区
# sudo fdisk /dev/sdf 
------------------------------------------------------------------------
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xc388f37d.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): m #输入m打印帮助信息
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   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): n #选择n新建分区
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): #使用默认值p直接回车
Using default response p
Partition number (1-4, default 1): #使用默认值1直接回车
Using default value 1
First sector (2048-209715199, default 2048): #使用默认值2048直接回车
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199): 
Using default value 209715199

Command (m for help): w #写入分区信息(保存)
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
------------------------------------------------------------------------

# 2.3 格式化磁盘分区为ext4格式

# 首先查看新增磁盘的分区信息
# sudo fdisk -l
------------------------------------------------------------------------
Disk /dev/sdf: 107.4 GB, 107374182400 bytes
43 heads, 44 sectors/track, 110843 cylinders, total 209715200 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 identifier: 0xc388f37d

   Device Boot      Start         End      Blocks   Id  System
/dev/sdf1            2048   209715199   104856576   83  Linux
------------------------------------------------------------------------

# 然后对/dev/sdf1 进行格式化
# sudo mkfs.ext4 /dev/sdf1
------------------------------------------------------------------------
mke2fs 1.42.9 (4-Feb-2014)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
6553600 inodes, 26214144 blocks
1310707 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
800 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, 
    4096000, 7962624, 11239424, 20480000, 23887872

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
------------------------------------------------------------------------

# 2.4 挂载分区到系统

# 首先确认分区的UUID
# sudo blkid /dev/sdf1
------------------------------------------------------------------------
/dev/sdf1: UUID="3c0633c0-fc64-4252-adae-c124ebeb2962" TYPE="ext4"
------------------------------------------------------------------------

# 然后将UUID写入到 /etc/fstab 文件
# sudo vi /etc/fstab
------------------------------------------------------------------------
UUID=3c0633c0-fc64-4252-adae-c124ebeb2962 /mnt/dev-toolkits                auto    rw,suid,dev,exec,auto,nouser,async      0       0
------------------------------------------------------------------------
# 最后执行重新挂载所有文件系统命令
# sudo mount -a
------------------------------------------------------------------------
mount: mount point /mnt/dev-toolkits does not exist
------------------------------------------------------------------------
# 报错了,提示挂载点目录不存在,所以创建挂载点目录后重试
# sudo mkdir -p /mnt/dev-toolkits
# sudo mount -a

# 最后执行df命令查看文件系统挂载情况
# df -h
------------------------------------------------------------------------
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1       489G   14G  450G   3% /
/dev/sdf1        99G   60M   94G   1% /mnt/dev-toolkits
------------------------------------------------------------------------

# 至此已经配置完毕,以后每次重启,该磁盘都会自动挂载到配置的目录
 

猜你喜欢

转载自blog.csdn.net/halazi100/article/details/85846672