Operating System - HP-UX
1823753 Members
4088 Online
109664 Solutions
New Discussion юеВ

How do I create a large file (>2GB)

 
SOLVED
Go to solution
Anthony deRito
Respected Contributor

How do I create a large file (>2GB)


I want to test the largefile option on my VxFS filesystem. How can I quickly create a large file >2GB?
13 REPLIES 13
Trond Haugen
Honored Contributor
Solution

Re: How do I create a large file (>2GB)

dd if=/stand/vmunix of=/sparse bs=1024k seek=3000
This creates a 3 GB sparse file. IO error = no largefile capability. No IO error = normal completion. ll() file = 3gb file

Regards,
Trond
Regards,
Trond Haugen
LinkedIn
Pete Randall
Outstanding Contributor

Re: How do I create a large file (>2GB)

prealloc filename 2100000000


Pete

Pete
Jeff Schussele
Honored Contributor

Re: How do I create a large file (>2GB)

Hi Anthony,

Use the prealloc command to create a file of any size.
Since 2GB is 1024 * 1024 * 2 = 2,097,152 then it has to be larger - so

prealloc large_filename 2098000 would suffice

Rgds,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Rodney Hills
Honored Contributor

Re: How do I create a large file (>2GB)

You can use "dd".

dd if=/dev/zero of=/yourfile count=20

This will create a file 20*512 bytes.

HTH

-- Rod Hills
There be dragons...
Pete Randall
Outstanding Contributor

Re: How do I create a large file (>2GB)

Actually, I got kind of carried away with my zeroes there. Something like

prealloc filename 2100000

would be more appropriate!


Pete

Pete
Jeff Schussele
Honored Contributor

Re: How do I create a large file (>2GB)

Ooops - left off a few 0s - of course it should be

2098000000

Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Geoff Wild
Honored Contributor

Re: How do I create a large file (>2GB)

prealloc is the way to go:

prealloc testfile 25000000

prealloc(1) prealloc(1)

NAME
prealloc - preallocate disk storage

SYNOPSIS
prealloc name size

DESCRIPTION
prealloc preallocates at least size bytes of disk space for an
ordinary file name, creating the file if name does not already exist.
The space is allocated in an implementation-dependent fashion for fast
sequential reads and writes of the file.


Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Jeff Schussele
Honored Contributor

Re: How do I create a large file (>2GB)

No Pete, you were right the 1st time.
My calculation *should* have been
1000 * 1024 * 1024 *2 = 2,097,152,000

Hence 2089000000 is correct & your 2100000000 would be OK.

Prealloc operates in bytes - not Kbytes

Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Pete Randall
Outstanding Contributor

Re: How do I create a large file (>2GB)

Thanks, Jeff, I thought I was losing it (again)!

;^)


Pete

Pete
Anthony deRito
Respected Contributor

Re: How do I create a large file (>2GB)

You guys are awesome. Thanks for your help on this.

I also tried the dd option on my Solaris boxes (since prealloc is not available on SOlaris). It seems that Veritas VxFS filesystem has the largefile option already on by default because it is not bombing like it is on my HP boxes. Can anyone verify this? I am running Veritas 3.5.

Anthony
Jeff Schussele
Honored Contributor

Re: How do I create a large file (>2GB)

Whether LVM or VxVM is the volume mgr, the fsadm command will tell you if largefiles is on - just run it against the mount point.

#fsadm /mnt_point

If it doesn't return largefiles - then it's not on.

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Geoff Wild
Honored Contributor

Re: How do I create a large file (>2GB)

Actually, on solaris, use mkfile:

Maintenance Commands mkfile(1M)

NAME
mkfile - create a file

SYNOPSIS
mkfile [ -nv ] size [k | b | m ] filename ...

DESCRIPTION
mkfile creates one or more files that are suitable for use
as NFS-mounted swap areas, or as local swap areas. When a
root user executes mkfile(), the sticky bit is set and the
file is padded with zeros by default. When non-root users
execute mkfile(), they must manually set the sticky bit
using chmod(1). The default size is in bytes, but it can be
flagged as kilobytes, blocks, or megabytes, with the k, b,
or m suffixes, respectively.

for a 4GB file:

mkfile testfile 4196M

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Bill Hassell
Honored Contributor

Re: How do I create a large file (>2GB)

Note that prealloc is *not* a 'fast' way to create a large file. It will take a while. Also note that VxVM (Veritas Volume Manager) and LVM know nothing about files. That is the function of mksf or newfs. The disks are carved up with volume managers but only a filesystem knows about files. Use fsadm to verify the capability of the filesystem:

fsadm -F vxfs /var
fsadm -F vxfs /dev/vg00/rlvol8

(note the use of rlvol8, not lvol8). Note also that you need to add the largefiles option in fstab. This is also a check to make sure the filesystem supports largefiles..if it doesn't then mount will fail. You can change any vxfs filesystem to add support for largefiles with fsadm.


Bill Hassell, sysadmin