2024年1月24日发(作者:)

虚拟机虚拟磁盘分成单个文件存储好还是多个文件存储好?各有什么优缺点?九天博客

现在的计算机一般都是采用的是ntfs文件系统。

比如安装VM的时候也是建议你采用单个文件格式便于存储。但是前提是磁盘使用ntfs文件格式。

如果你计算机是采用FAT32文件格式,那么最大单文件大小: 4

GB (Fat16分区是2 GB ),分区大小不超过32GB左右。也就是说你的虚拟机磁盘空间不可能大于这个数字。否则就会出错。

而ntfs格式的文件系统支持文件大小均在2TB上。

如何将单个Vmware虚拟机vmdk文件拆分为多个

通过vmware workstation软件创造出来的虚拟机,在虚拟机目录下有时会出现多个以vmdk后缀名结尾的文件,多个文件占用的空间都很大,感觉很乱,并且这样虚拟机运行的效率也很低。

出现这种情况的原因是在创建虚拟机时,在指定硬盘容量时,选择了Split virtual disk into multiple files,并且下面有说明,这种多个文件模式更易于将虚拟机转移到其他的电脑上,并且会降低性能且会占用更多的硬盘空间。

如果选择Store virtual disk as a single file模式,虚拟机就会在一个文件中,不仅会提高性能减少占用硬盘空间,而且看着更舒服。

但是这两个模式之间可以转换吗,通过vmware workstation自带的一个工具就可以做到。

在vmware workstation的安装目录下,有一个文件,在命令行下执行,可以看到这个软件的用法,如下:

VMware Virtual Disk Manager – build 471780.

Usage: OPTIONS|

Offline disk manipulation utility

Operations, only one may be specified at a time:

-c : create disk. Additional creation options must

be specified. Only local virtual disks can be

created.

-d : defragment the specified virtual disk. Only

local virtual disks may be defragmented.

-k : shrink the specified virtual disk. Only local

virtual disks may be shrunk.

-n: rename the specified virtual disk; need to

specify destination disk-name. Only local virtual

disks may be renamed.

-p : prepare the mounted virtual disk specified by

the mount point for shrinking.

-r: convert the specified disk; need to specify

destination disk-type. For local destination disks

the disk type must be specified.

-x: expand the disk to the specified capacity. Only

local virtual disks may be expanded.

-R : check a sparse virtual disk for consistency and atte

mpt

to repair any errors.

-e : check for disk chain consistency.

-D : make disk deletable. This should only be used on di

sks

that have been copied from another product.

Other Options:

-q : do not log messages

Additional options for create and convert:

-a: (for use with -c only) adapter type

(ide, buslogic, lsilogic). Pass lsilogic for other a

dapter types.

-s: capacity of the virtual disk

-t: disk type id

Disk types:

0 : single growable virtual disk

1 : growable virtual disk split in 2GB files

2 : preallocated virtual disk

3 : preallocated virtual disk split in 2GB files

4 : preallocated ESX-type virtual disk

5 : compressed disk optimized for streaming

6 : thin provisioned virtual disk – ESX 3.x and above

The capacity can be specified in sectors, KB, MB or GB.

The acceptable ranges:

ide adapter : [1MB, 2040.0GB]

scsi adapter: [1MB, 2040.0GB]

ex 1: -c -s 850MB -a ide -t 0

ex 2: -d

ex 3: -r -t 0

dk

ex 4: -x 36GB

ex 5: -n

ex 6: -r -t 4 -h

-u username -f passwordfile

“[storage1]/path/to/”

ex 7: -k

ex 8: -p

(A virtual disk first needs to be mounted at)

用法已经说的很清楚了,这里假设需要转化的虚拟机位于F:,那么通过以下命令操作来实现将多个vmdk文件转化成一个文件:

-r “F:” -t 0

“F:”

注意目标文件和源文件名不能一样,转换后原有虚拟机仍然存在,删除并新建后,使用现有磁盘添加新的vmdk文件即可。

有时,当我们创建虚拟机vmware里面的应用程序,我们可能会选择创建分割的虚拟磁盘中的多个文件2GB的文件,这是为了提高复制过程,主要用于存储虚拟机文件系统不支持创建更大的文件。还有种情况是虚拟化物理机器的时候,虚拟硬盘会自动采用小文件的存储方式。