Skip to content

Commit a49f9e5

Browse files
committed
Enhanced mkvdisk
new -m option instructs mkvdisk to create a fixed (=static, non-dynamic) VHD, VHDX or VDI image
1 parent e15c93a commit a49f9e5

File tree

5 files changed

+16
-8
lines changed

5 files changed

+16
-8
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ $RECYCLE.BIN/
2121
# =========================
2222
# Operating System Files
2323
# =========================
24+
BUGS.TXT

FATtools/scripts/mkvdisk.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ def create_parser(parser_create_fn=argparse.ArgumentParser,parser_create_args=No
88
par.add_argument('image_file',help="The image file or disk device to write to",metavar="IMAGE_FILE")
99
par.add_argument("-s", "--size", dest="image_size", help="specify virtual disk size. K, M, G or T suffixes accepted", metavar="SIZE",required=True)
1010
par.add_argument("-b", "--base", dest="base_image", help="specify a virtual disk image base to create a differencing image with default parameters", metavar="BASE")
11+
par.add_argument("-m", "--monolithic", dest="monolithic", help="immediately allocates all image sectors (except for VMDK)", action="store_true", default=False)
1112
par.add_argument("-f", "--force", dest="force", help="overwrites a pre-existing image", action="store_true", default=False)
1213
return par
1314

@@ -60,7 +61,11 @@ def call(args):
6061
else:
6162
fmt = vmdkutils
6263

63-
fmt.mk_dynamic(args.image_file, fssize, overwrite='yes')
64+
if not args.monolithic or fmt == vmdkutils:
65+
fmt.mk_dynamic(args.image_file, fssize, overwrite='yes')
66+
else:
67+
fmt.mk_fixed(args.image_file, fssize, overwrite='yes')
68+
6469
print("Virtual disk image '%s' created."%args.image_file)
6570

6671
if __name__ == '__main__':

FATtools/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.0.9'
1+
__version__ = '1.0.10'

FATtools/vhdutils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,8 +660,11 @@ def mk_crc(s):
660660
return struct.pack('>i', ~crc)
661661

662662

663-
def mk_fixed(name, size):
663+
def mk_fixed(name, size, overwrite='no'):
664664
"Creates an empty fixed VHD or transforms a previous image if 'size' is -1"
665+
if os.path.exists(name):
666+
if size != -1 and overwrite!='yes':
667+
raise BaseException("Can't silently overwrite a pre-existing VHD image!")
665668
if os.path.exists(name):
666669
f = myfile(name, 'r+b')
667670
if size == -1:

README.MD

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FATtools
22
========
33

4-
Install using pip install .
4+
Install from PyPI using `pip install FATtools` (easier) or downloading the source code (or the released packages) from here.
55

66
Born to re-sort directory entries in a FAT32 root table to cope with some hardware MP3 players' limits, it now provides full read/write support in Python 3 (both 32- and 64-bit) for FAT12/16/32 and exFAT filesystems, for hacking and recovering purposes.
77

@@ -39,9 +39,6 @@ Code is GPLed (look at GPL.TXT).
3939

4040

4141

42-
Sample usage (see inside 'samples' directory for more usage samples).
43-
44-
4542
# At a glance
4643

4744
The package installs a `fattools` script, you can use this to perform simple command line operations.
@@ -86,7 +83,7 @@ part = Volume.vopen('MyDiskImage.img', 'r+b', 'partition0')
8683
mkfat.exfat_mkfs(part, part.size)
8784
```
8885

89-
- to order items inside directory tables easily, with GUI:
86+
- to order items inside directory tables easily, with GUI and drag support:
9087
```
9188
fattools reordergui
9289
```
@@ -171,3 +168,5 @@ for t in T:
171168
o.sort()
172169
vclose(o)
173170
```
171+
172+
Please look inside 'samples' directory for more usage samples.

0 commit comments

Comments
 (0)