HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Large file with NULL characters
Operating System - HP-UX
1838576
Members
4057
Online
110128
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2004 07:40 AM
07-15-2004 07:40 AM
Large file with NULL characters
I'm puzzled by file sizes of files with NULL characters. I have a file with 2264512 bytes, most of which are NULL characters (\000). When I run ls -l, it shows 2264512 for the file size. When I run du -s, it only shows 64 blocks. If I copy the file or tar the file, the new file has 4448 blocks. How can a file with that many bytes only take up 64 blocks?
Email: michael.n.daulerio@lmco.com
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2004 08:06 AM
07-15-2004 08:06 AM
Re: Large file with NULL characters
Hi Michael,
You are basically looking at something called "Sparse" files.
Try this
# echo | dd bs=1024 seek=100000 of=/tmp/large
# ll /tmp/large
# du â sk /tmp/large
ls will tell you the size is 102 MB but du will tell you the size is only 8 KB.
I dont believe tar can even begin to understand a sparse file. use fbackup to backup/restore sparse files.
A typical sparse file content will look like something like this
data data NULL NULL ......... NULL data data
Now what you see from the ls -l output is the size of the file including the NULLs.
-- Sund
You are basically looking at something called "Sparse" files.
Try this
# echo | dd bs=1024 seek=100000 of=/tmp/large
# ll /tmp/large
# du â sk /tmp/large
ls will tell you the size is 102 MB but du will tell you the size is only 8 KB.
I dont believe tar can even begin to understand a sparse file. use fbackup to backup/restore sparse files.
A typical sparse file content will look like something like this
data data NULL NULL ......... NULL data data
Now what you see from the ls -l output is the size of the file including the NULLs.
-- Sund
Learn What to do ,How to do and more importantly When to do ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2004 09:38 AM
07-15-2004 09:38 AM
Re: Large file with NULL characters
Thanks Sund,
You explain the sparse files very well. I should have given you a 10. I only gave you 7 because I couldn't get the command you gave me to create a sparse file. I figured out 2 things:
1) I couldn't create the sparse file from csh. I had to be in sh or ksh
2) It wouldn't work on an NFS mounted file system.
It took me a while to realize that my home directory is mounted from another host. I didn't use the /tmp directory as in your example. Once I got into ksh and wrote to a local file system, it worked exactly as you said.
Mike
You explain the sparse files very well. I should have given you a 10. I only gave you 7 because I couldn't get the command you gave me to create a sparse file. I figured out 2 things:
1) I couldn't create the sparse file from csh. I had to be in sh or ksh
2) It wouldn't work on an NFS mounted file system.
It took me a while to realize that my home directory is mounted from another host. I didn't use the /tmp directory as in your example. Once I got into ksh and wrote to a local file system, it worked exactly as you said.
Mike
Email: michael.n.daulerio@lmco.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2005 09:40 AM
01-04-2005 09:40 AM
Re: Large file with NULL characters
The pax command can also be used to archive & restore sparse files. I had been using cp or tar to copy files from one directory to another and was baffled because the target directory took up much more space than the source.
Email: michael.n.daulerio@lmco.com
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP