Operating System - HP-UX
1821051 Members
2889 Online
109631 Solutions
New Discussion юеВ

How to create a specific size file?like,solaris:mkfile. thanks.

 
renx
Occasional Advisor

How to create a specific size file?like,solaris:mkfile. thanks.

How to create a specific size file?like,solaris:mkfile. thanks.
rx
4 REPLIES 4
Sudhakar.J
Advisor

Re: How to create a specific size file?like,solaris:mkfile. thanks.

Hi,

Do u mean to create a file with a specific size, then u can use prealloc command.
This command creates a file in bytes.

For instance,

prealloc test 1024 --> to create one kb file by name test.


ATB,
Sudhakar
Patrick Wallek
Honored Contributor

Re: How to create a specific size file?like,solaris:mkfile. thanks.

Yes, you do need to use the prealloc command.

However, the file size you specify with prealloc is in BYTES, not KB, not MB, just plain old BYTES.

So, if you do:

# prealloc test 1024

You will get a 1024 BYTE file.

If you want to create a 1 MB file, you need to do:

# prealloc test 1048576
renx
Occasional Advisor

Re: How to create a specific size file?like,solaris:mkfile. thanks.

thank you
rx
Fragon
Trusted Contributor

Re: How to create a specific size file?like,solaris:mkfile. thanks.

Hi, make a specific size file , you can use "prealloc", but please make sure:
1. The free space in the disk must large than the specific size;
2. If the "file" exists and not zero, the prealloc will fail;
3. Usually make a script to use prealloc, if "file" exists and not zero, empty it first; or if the free space is not enough , make a warning and exit.

BTW, please assign points to whom really help you!

-ux