리눅스 디스크 용량 확인

Jmnote (토론 | 기여)님의 2012년 7월 5일 (목) 11:12 판 (→‎기본)
리눅스 디스크 용량 확인
fdisk

1 기본

명령어
fdisk -l | grep Disk
실행예시
[root@jmnote ~]# fdisk -l | grep Disk
Disk /dev/cciss/c0d0: 450.0 GB, 450064605184 bytes
→ 450.0GB라고 나오는데 실제로는 450GiB이며, GB로 환산하면 419.2GB이다.
[math]\displaystyle{ 450064605184 \mbox{bytes}\div1024\div1024\div1024\approx419.2 \mbox{GB} }[/math]

2 합산

2.1 GB 단위

명령어
fdisk -l | egrep 'Disk.*bytes' | awk '{ sub(/,/,""); sum +=$5;print $1" "$2" "$3" "$4" "$5" "$6 } END { print "total: " sum/1024/1024/1024 " GB" }'
실행예시
[root@localhost ~]# fdisk -l | egrep 'Disk.*bytes' | awk '{ sub(/,/,""); sum +=$5;print $1" "$2" "$3" "$4" "$5" "$6 } END { print "total: " sum/1024/1024/1024 " GB" }'
Disk /dev/xvda: 107.3 GB 107374182400 bytes
Disk /dev/xvdb: 107.3 GB 107374182400 bytes
total: 200 GB
  • 위에 107.3 GB라고 나오는데 실제로는 107.3 GiB (=100GB)를 의미한다.
  • 107374182400 bytes를 1024로 세번 나누어 보면 정확히 100GB가 나온다.

2.2 Byte 단위

명령어
fdisk -l | egrep 'Disk.*bytes' | awk '{ sub(/,/,""); sum +=$5;print $1" "$2" "$3" "$4" "$5" "$6 } END { print "total: " sum" Bytes" }'
실행예시
[root@localhost ~]# fdisk -l | egrep 'Disk.*bytes' | awk '{ sub(/,/,""); sum +=$5;print $1" "$2" "$3" "$4" "$5" "$6 } END { print "total: " sum" Bytes" }'
Disk /dev/xvda: 107.3 GB 107374182400 bytes
Disk /dev/xvdb: 107.3 GB 107374182400 bytes
total: 214748364800 Bytes

3 같이 보기

4 주석

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}