Counting small files against a big disk

Small items are described in kilobytes: a text document of 40 kB, an email of 75 kB, a web page of 250 kB, a log line of a fraction of one. When a volume is sold in terabytes, the kilobyte view tells you how many such items fit. This page multiplies the terabytes by 1,000,000,000. The default of 10 TB gives 10,000,000,000 kB. Divide by the size of one item and the quotient is the item count. For example, 1 TB at 50 kB per document holds 20,000,000 documents, an estimate that suits records managers and anyone sizing a document archive. Scanned pages are larger than typed ones, so sample your own files first.

The conversion in two steps

A terabyte is 1,000 gigabytes, a gigabyte is 1,000 megabytes and a megabyte is 1,000 kilobytes, so the chain is 1,000 × 1,000 × 1,000 = 1,000,000,000 kB per TB. The formula is kB = TB × 1,000,000,000. A 0.5 TB drive is 500,000,000 kB, and 3 TB is 3,000,000,000 kB. In the opposite direction, divide by a billion, so 250,000,000 kB is 0.25 TB. The lowercase k in kB is the SI symbol for 1,000 bytes. The page does not use 1,024, and the kibibyte, KiB, appears in its own converter for the binary reading. Entering 250,000,000 kB with kilobytes as the source and terabytes as the target returns 0.25 TB, a quick test of the direction before you use a long value.

Web hosting and page weight

Page weight is usually reported in kB. A page of 250 kB served to 4,000,000 visitors moves 1,000,000,000 kB, which is 1 TB of traffic. Hosting plans quote monthly transfer in GB or TB, so the conversion is how a site owner checks whether a traffic spike will exceed a plan. A 2 TB transfer allowance equals 2,000,000,000 kB, which covers 8,000,000 visits to a 250 kB page. Real sites also serve images, scripts and API calls, and caches shift the numbers. Page weight reports from a browser developer tool give a better figure than any rule of thumb.

Email archives and documents

Email systems report mailbox sizes in MB or GB, but an administrator thinking about message counts works in kilobytes. If the average message is 75 kB with attachments, 1 TB holds about 13,333,333 messages (1,000,000,000 / 75). A legal team scanning contracts at 120 kB per page for 5,000,000 pages needs 600,000,000 kB, which is 0.6 TB. Scanned pages vary with resolution and compression, so the kilobyte-per-page value should come from a sample of your own scans. After the conversion, add a margin for indexes, since full-text search indexes often add a considerable fraction to the original data.

Logs and telemetry

An application that writes 2 kB of log data per request and handles 50 requests per second produces 100 kB per second, about 8,640,000 kB a day, or 0.00864 TB. Over 365 days that is 3.15 TB. Dividing a retention volume by a daily rate in kilobytes shows how many days fit. A 10 TB log volume at 8,640,000 kB per day holds 1,157 days in principle, but compression, replication and index overhead change the figure. Sensor and telemetry projects use the same arithmetic with small packets, where the kilobyte is the natural unit and the terabyte describes the storage budget. Replication multiplies the figure: three copies of a 3.15 TB year of logs need 9.45 TB, and a compression ratio of 5 to 1 would bring the stored volume down toward 1.9 TB.

Block sizes and slack space

A file system allocates space in blocks. With a 4 kB block, a file of 1 kB still takes 4 kB, and a file of 4.1 kB takes 8 kB. For a pile of small files, the total storage can far exceed the sum of their sizes. A million files of 1 kB take about 4,000,000 kB on disk, which is 0.004 TB, four times the data. When you do an estimate from kilobytes per file, decide whether you are counting logical size or allocated size. This page converts a plain number and has no knowledge of the allocation scheme on your disk. For a rough conversion of logical to allocated size, round each file up to the next multiple of the block size and add the results, a step that a spreadsheet can do with its ceiling function.

kB, KB and Kb

Writing conventions cause errors. The SI symbol for kilobyte is kB with a lowercase k and uppercase B, and it means 1,000 bytes. Some software prints KB for 1,024 bytes, which is the kibibyte, KiB. A lowercase b means bits, so kb or kbit is 125 bytes. Network speeds are usually quoted in kbit/s and file sizes in kB, which is a factor of 8 apart. This page assumes kB equals 1,000 bytes, so a file listed as 250 kB is 250,000 bytes. If a tool lists KB for the same file, look at its documentation to see whether it divides by 1,000 or 1,024.

Reading very large results

A result of 10,000,000,000 kB is hard to read, so for reports convert it back to a convenient unit. The reverse conversion is handy when a system reports totals in kilobytes, for example a monitoring tool that prints disk usage in kB. A total of 7,250,000,000 kB is 7.25 TB. Spreadsheets sometimes switch to scientific notation for such numbers, and a rounding step can lose digits. A monitoring export might show 7.25E+09 for 7,250,000,000, which hides the last digits entirely. Keep the full integer in your source data and round only for display. The factor is a power of 10, so you can always check the result by moving the decimal point nine places.

Source code, text and ebook collections

Plain text is small. A novel runs roughly 500 to 800 kB as text, so 1 TB holds well over a million of them, and a code repository of 20,000 kB is 0.00002 TB. Developers who mirror many repositories can multiply the average size by the count and convert. A mirror of 50,000 repositories at 20,000 kB each takes 1,000,000,000 kB, which is 1 TB. Compressed archives and git history change the sizes, so use the actual on-disk size of a few sample repositories. Because the kilobyte is the unit in which these items are measured, the conversion keeps the estimate in the same terms as the sample values.