본문 바로가기

프로그래밍

Windows, 리눅스에서 폴더(서브디렉토리) 생성 가능 개수 / 최대 파일용량 확인하기

 

한 폴더에 폴더, 파일 몇 개나 만들 수 있을까요?

 

프로그래밍을 하다 보면 한 폴더에 폴더나 파일이 너무 많이 들어가면 문제가 생기는 경우가 종종 있습니다.

 

개발환경에서야 당연히 그렇게 많이 테스트하지 않으니까 잘 발견하기가 힘들죠.

 

그런데 운영에서 데이터양이 많아지다 보면 폴더에 생성할 수 있는 파일이나 폴더 개수가 제한이 있다 보니 문제가 생깁니다.

 

그런 도대체 몇 개까지 파일, 폴더를 생성할 수 있을까요?

 

한참을 인터넷을 뒤져보니 결론은

 

시스템과 디스크 타입마다 폴더, 파일 최대 개수, 최대 파일 용량이 상이하다

 

디스크 타입도 FAT부터 EXT4까지 다양합니다.

 

그럼 디스크 타입에 따라 관련 문서를 찾아 정리해볼까요?

 

FAT32

  • 최대 디스크 용량 : 2TB
  • 파일 1개 최대 용량 : 4GB
  • 디스크 최대 파일 개수 : 2억 6천 개 (268,435,437)
  • 한 폴더에 최대 파일(폴더) 개수 : 6만 5천 개 (65,534)

NTFS

  • 최대 디스크 용량 : 256TB
  • 파일 1개 최대 용량 : 256TB
  • 디스크 최대 파일 개수 : 42억 개 (4,294,967,295)
  • 한 폴더에 최대 파일(폴더) 개수 : 42억 개 (4,294,967,295)

EXT2

  • 최대 디스크 용량 :
    > 4 TB (블럭사이즈 1KB)
    > 8 TB (블럭사이즈 2KB)
    > 16 TB (블럭사이즈 4KB)
    > 32 TB (블럭사이즈 8KB)
  • 파일 1개 최대 용량 : 
    > 16 GB (블럭사이즈 1KB)
    > 256 GB (블럭사이즈 2KB)
    > 2 TB (블럭사이즈 4KB)
    > 2 TB (블럭사이즈 8KB)
  • 디스크 최대 파일 갯수 : 10의 18 제곱근
  • 한 폴더에 최대 파일(폴더) 개수 : 10의 18 제곱근

 

 

EXT3

  • 최대 디스크 용량 : EXT2와 동일
  • 파일 1개 최대 용량 : EXT2와 동일
  • 디스크 최대 파일 개수 : 상황에 따라 다름
  • 한 폴더에 최대 파일(폴더) 개수 : 상황에 따라 다름

 

EXT4

  • 최대 디스크 용량 : 256TB
  • 파일 1개 최대 용량 : 16TB
  • 디스크 최대 파일 개수 : 42억 개 (4,294,967,295)
  • 한 폴더에 최대 파일(폴더) 개수 : 42억 개 (4,294,967,295)

 

요즘 윈도우즈 같은 경우는 대부분 NTFS를 사용하고 리눅스는 EXT4를 사용할 듯합니다.

 

그럼 파일시스템을 한번 확인해볼까요?

 

윈도우에서 파일 시스템 확인하기

탐색기에서 C드라이브 선택 > 오른쪽 마우스 클릭 > 속성 클릭

 

리눅스에서 디스크 타입 확인하기

명령어 #] df -Th

대소문자 구분하니 그대로 입력해주세요.

<< ubuntu16에서 확인 >>

 

<< Centos7에서 확인 >>

아니 그런데 xfs는 뭐니???

 

Centos는 클라우드에 있는 서버인데 디스크 타입도 다른 게 들어왔네요.

 

그럼 XFS 타입은 얼마나 들어가는지 확인해 보죠.

 

<< RedHat에서의 확인>>

레드햇에서의 최대 파일 사이즈, 최대 개수는 확인이 되었지만 무료로 쓰는 Centos와 Ubuntu의 개수 용량은 확인할 수 없었습니다. 😥

 

저는 우선 폴더 개수를 얼마나 만들 수 있는지 확인해야 하니까 직접 눈으로 확인하기로 했습니다. 직접 만들어 보는 게 제일 좋은 방법이겠죠?

 

리눅스에서 폴더 100만 개 생성해보기

테스트는 Centos7 xfs 디스크 타입으로 진행했습니다.

 

1. vi make.sh

2. 폴더 100만 개 만들어 보는 스크립트를 작성했습니다.(나중에 지우기 좋게 앞에 folder라는 명칭을 달았습니다)

folder1~ folder1000000 이 생성되겠죠?

for var in {1..1000000}
do
        echo folder$var
        mkdir folder$var
done

3. 저장 후 실행해주세요. ./make.sh, 100만 개니까 한참 걸립니다. 1시간 정도 걸렸네요 😅

4. 폴더 개수를 세어 봅시다. 

명령어 #] ls -l | grep ^d | wc -l

 

<< 100만개 폴더 생성 확인 >>

잘 만들어졌습니다. 하하하하 😍

 

XFS 파일 시스템이 최신 나온 형태이니 아무래도 Redhat 관련 자료에서 보는 것과 같이 

파일, 폴더 생성 개수는 제한이 없을 것으로 판단됩니다.

그래도 눈으로 확인하고 싶으신 분들은 저처럼 한번 만들어 보시길 추천해드립니다. 😀😄😄

그리고 폴더 개수가 많아지는 형태는 성능상 좋지 않으니 정말 정말 부득이한 경우를 제외하곤 사용하지 않길 바랍니다.

 

p.s.

지우기는 rm -rf folder*로 지우니 너무 많다고 한번에 안되네요;;;

이런식으로 여러번에 나눠 지우시길 바랍니다.

 

 

참조 사이트

en.wikipedia.org/wiki/File_Allocation_Table#FAT32

 

File Allocation Table - Wikipedia

FATDeveloper(s)Microsoft, NCR, SCP, IBM, Compaq, Digital Research, Novell, CalderaFull nameFile Allocation TableVariants8-bit FAT, FAT12, FAT16, FAT16B, FAT32, ExFAT, FATX, FAT+Introduced1977 (1977) with Standalone Disk BASIC-80Partition identifierMBR/EBR

en.wikipedia.org

en.wikipedia.org/wiki/NTFS

 

NTFS - Wikipedia

From Wikipedia, the free encyclopedia Jump to navigation Jump to search NTFSDeveloper(s)MicrosoftFull nameNT File System[1]IntroducedJuly 1993; 27 years ago (1993-07) with Windows NT 3.1Partition identifier0x07 (MBR)EBD0A0A2-B9E5-4433-87C0-68B6B72699C7

en.wikipedia.org

en.wikipedia.org/wiki/Ext2

 

ext2 - Wikipedia

From Wikipedia, the free encyclopedia Jump to navigation Jump to search File system for the Linux kernel The ext2 or second extended file system is a file system for the Linux kernel. It was initially designed by Rémy Card as a replacement for the extende

en.wikipedia.org

en.wikipedia.org/wiki/Ext3

 

ext3 - Wikipedia

ext3Developer(s)Stephen TweedieFull nameThird extended file systemIntroducedNovember 2001 with Linux 2.4.15Partition identifier0x83 (MBR) EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 (GPT)StructuresDirectory contentsTable, hashed B-tree with dir_index enabledFile

en.wikipedia.org

en.wikipedia.org/wiki/Ext4

 

ext4 - Wikipedia

ext4Developer(s)Mingming Cao, Andreas Dilger, Alex Zhuravlev (Tomas), Dave Kleikamp, Theodore Ts'o, Eric Sandeen, Sam Naghshineh, othersFull nameFourth extended file systemIntroduced Stable: 21 October 2008 Unstable: 10 October 2006 with Linux 2.6.28, 2.6.

en.wikipedia.org

access.redhat.com/articles/rhel-limits

 

Red Hat Enterprise Linux technology capabilities and limits - Red Hat Customer Portal

This article provides the supported and theoretical limits of Red Hat Enterprise Linux.

access.redhat.com

stackoverflow.com/questions/466521/how-many-files-can-i-put-in-a-directory

 

How many files can I put in a directory?

Does it matter how many files I keep in a single directory? If so, how many files in a directory is too many, and what are the impacts of having too many files? (This is on a Linux server.) Backgr...

stackoverflow.com