디스크파티션 & VTOC

2010.05.11 16:52

조인상 조회 수:10589

원문 : http://www.ischo.net -- 조인상 // 시스템 엔지니어

Writer : http://www.ischo.net -- ischo // System Engineer in Replubic Of Korea

+++++++++++++++++++++++++++++++++++++++++++++++++++++++

 

본문 : http://www.ischo.net -- 조인상 //시스템 엔지니어

+++++++++++++++++++++++++++++++++++++++++++++++++++++++


http://www.systemadmin.pe.kr



Disk Partition

Fdisk 명령어

인텔 기반 컴퓨터들은 최대 4개 까지의 파티션을 한 디스크에 만들 수 있다. 각 파티션에 OS나 데이터를 위해 사용할 수 있다. 만일 4개 이상의 파티션을 생성하려 하면 에러 메시지가 아래와 같이 나타난다. 파티션을 나누는 명령어는 ‘fdisk’ 이다.

#/:>fdisk /dev/rdsk/c0b0t2d0p0
Total disk size is 4149 cylinders (4149.0 MB)

Cylinders Approx
Partition Status Type Start End Length % MB
====== ======== ============ ===== ==== ====== === ======
1 UNIX System 0 414 415 10 415.0
2 UNIX System 415 1244 830 20 830.0
3 UNIX System 1245 2489 1245 30 1245.0
4 UNIX System 2490 2904 415 10 415.0

SELECT ONE OF THE FOLLOWING:
0. Overwrite system master boot code
1. Create a partition
2. Change Active (Boot from) partition
3. Delete a partition
4. Exit (Update disk configuration and exit)
5. Cancel (Exit without updating disk configuration)
Enter Selection: 1

1번을 선택하여 5번째 파티션을 만들려고 하면 아래와 같은 에러메시지로 더 이상 만들 수 없다고 경고하고 있다.
The partition table is full!
You must delete an old partition before creating a new one.

아래의 내용은 기존에 아무런 파티션이 없을 때 나타나는 형식이다. 기존에 이미 파티션된 정보가 있다면 위와 같은 형식으로 나타난다.
#/:>fdisk /dev/rdsk/c0b0t2d0s0
The recommended default partitioning for your disk is:
a 100% "UNIX System" partition.
To select this, please type "y". To partition your disk differently, type "n" and the "fdisk" program
will let you select other partitions. y



주의 fdisk 명령어는 현재 마운트되어 사용중에 있는 디스크의 파티션 정보도 변경이
가능하므로 사용할 때 반드시 적용하고자 하는 디스크가 맞는지를 재삼 확인
하여야 한다.

파티션 삭제 테스트

일단 마운트되어 사용중인 디스크 하나를 선택하고 fdisk로 파티션 정보를 지워보자. 리부팅이나 ‘umount’ 시키지 않은 상태에서는 사용하는데 지장은 없다. 그러나 리부팅이나 ‘umount’ 되었다가 다시 마운트 시키면 에러 메시지가 나타난다.

#mountall
UX:vxfs mount: ERROR: Cannot open /dev/dsk/c0b0t2d0s1: No such device
UX:vxfs fsck: ERROR: Cannot open /dev/rdsk/c0b0t2d0s1: No such device
UX:/sbin/mountall: INFO: /dev/dsk/c0b0t2d0s1 not mounted
UX:vxfs mount: ERROR: Cannot open /dev/dsk/c0b0t2d0s2: No such device
UX:vxfs fsck: ERROR: Cannot open /dev/rdsk/c0b0t2d0s2: No such device
UX:/sbin/mountall: INFO: /dev/dsk/c0b0t2d0s2 not mounted
UX:ufs mount: ERROR: /dev/dsk/c0b0t2d0s4 no such device or write-protected
UX:ufs mount: ERROR: giving up on: /test4
UX:/sbin/mountall: ERROR: fsck failed for /dev/dsk/c0b0t2d0s4
UX:ufs mount: ERROR: /dev/dsk/c0b0t2d0s5 no such device or write-protected
UX:ufs mount: ERROR: giving up on: /test5
………………

fdisk가 지워진 디스크의 디바이스가 없다는 식으로 나타나지만 /dev/dsk 와 /dev/rdsk에서 보면 디바이스 파일은 여전이 존재하고 있다. 그리고 디스크의 VTOC 정보도 그대로 살아있다. 다시 fdisk로 파티션 정보를 복구하여 ‘mountall’ 하면 정상적으로 마운트된다.

fdisk로 파티션 정보를 지우면 하드웨어 관련 정보 파일이 손상을 입어 콘솔에 에러를 뿌리게 된다.
AMIRDMON[severe] : Adapter Enquiry failed for 1 adaptor
/usr/tmp/hwrdmon open failed, errno 0x2

이 에러 메시지는 /usr/tmp 밑에 hwrdmon 파일이 없으면 콘솔에 계속 뿌려 준다. 이때는 시스템을 리부팅하면 hwrdmon 파일이 다시 만들어져 에러 메시지가 없어 질 것이다.
#/usr/tmp:>ls -al
c--------- 1 root root 108, 32 Oct 24 19:03 hwrdmon
#/usr/tmp:>cp hwrdmon hwrdmon.old
UX:cp: ERROR: Read error in hwrdmon: No such device


VTOC 정보


VTOC는 Volume Table of Contents의 약자로, 새로 디스크를 만들 때 ‘diskadd’이나 ‘disksetup’ 명령어를 사용하는데 이때에 VTOC 정보가 만들어 진다. 만들어진 정보는 slice 7번에 기록되어 필요할 때에 호출되고 이용된다.

디스크가 설치된 후에 VTOC을 관리하는 명령어로는 2 가지가 주로 이용된다: prtvtoc, edvtoc.


Prtvtoc 명령어

‘prtvtoc’ 명령어는 하드 디스크의 VTOC 정보를 보여 준다. 해당 디스크의 구성 정보를 통하여 슬라이스 몇 개로 나누어져 있고, 어는 정도의 디스크 용량으로 나누어져 있는지를 알고자 할 때 사용하면 유용하다. 먼저 루트 디스크의 VTOC 정보를 표시하여 보자.

#/:>prtvtoc /dev/rdsk/c0b0t0d0s0
slice 0: DISK permissions: VALID UNMOUNTABLE starting sector: 63 (cyl 0) length: 8385867 (522.00 cyls)
slice 1: ROOT permissions: VALID starting sector: 578340 (cyl 36) length: 2875635 (179.00 cyls)
slice 2: SWAP permissions: VALID UNMOUNTABLE starting sector: 96390 (cyl 6) length: 481950 (30.00 cyls)
slice 4: HOME permissions: VALID starting sector: 3453975 (cyl 215) length: 4209030 (262.00 cyls)
slice 7: BOOT permissions: VALID UNMOUNTABLE starting sector: 63 (cyl 0) length: 34 (0.00 cyls)
slice 8: ALT SEC/TRK permissions: VALID UNMOUNTABLE starting sector: 97 (cyl 0) length: 15968 (0.99 cyls)
slice 10: STAND permissions: VALID starting sector:16065 (cyl 1) length: 80325 (5.00 cyls)
slice 11: VAR permissions: VALID starting sector: 7663005 (cyl 477) length: 626535 (39.00 cyls)
slice 15: VOLPRIVATE permissions: VALID UNMOUNTABLE starting sector: 8289540 (cyl 516) length: 16065 (1.00 cyls)

이러한 VTOC 정보를 가지고 ‘edvtoc’ 명령어를 이용하면 다른 디스크의 VTOC 정보에 업어칠 수 있다. VTOC 정보를 먼저 파일로 받아내어 필요한 내용으로 편집을 할 수도 있다.

옵션 “-f”를 이용하여 파일로 받겠다는 의미로 받고자 하는 VTOC 내용을 담을 파일 이름을 알기 쉽게 임의의 이름으로 만들어 준다. vtocfile.c0b0t0d0s0이란 이름으로 만들어 보자. 아래의 명령어는/dev/rdsk/c0b0t0d0s0의 VTOC 내용을 vtocfile.c0b0t0d0s0 파일로 저장하는 명령어이다.

#/:>prtvtoc -f vtocfile.c0b0t0d0s0 /dev/rdsk/c0b0t0d0s0

vtocfile.c0b0t0d0s0파일의 내용을 살펴보자. 변경을 해야 한다면 vi 편집기를 이용하면 된다.



#/:>cat vtocfile.c0b0t0d0s0
#SLICE TAG FLAGS START SIZE
0 0x5 0x201 63 8385867
1 0x2 0x200 578340 2875635
2 0x3 0x201 96390 481950
3 0x0 0x0 0 0
4 0xb 0x200 3453975 4209030
5 0x0 0x0 0 0
6 0x0 0x0 0 0
7 0x1 0x201 63 34
8 0xd 0x201 97 15968
9 0x0 0x0 0 0
10 0x9 0x200 16065 80325
11 0xa 0x200 7663005 626535
12 0x0 0x0 0 0
13 0x0 0x0 0 0
14 0x0 0x0 0 0
15 0xf 0x201 8289540 16065

다음은 TAG에 대한 슬라이스 타입을 정의한 내용이다.
#define V_BOOT 0x01 /* Boot slice */
#define V_ROOT 0x02 /* Root filesystem */
#define V_SWAP 0x03 /* Swap filesystem */
#define V_USR 0x04 /* Usr filesystem */
#define V_BACKUP 0x05 /* full disk */
#define V_ALTS 0x06 /* alternate sector space */
#define V_OTHER 0x07 /* non-unix space */
#define V_ALTTRK 0x08 /* alternate track space */
#define V_STAND 0x09 /* Stand slice */
#define V_VAR 0x0a /* Var slice */
#define V_HOME 0x0b /* Home slice */
#define V_DUMP 0x0c /* dump slice */
#define V_ALTSCTR 0x0d /* Alternate sector/track */
#define V_MANAGED1 0x0e /* Volume management public slice */
#define V_MANAGED2 0x0f /* Volume management private slice */

다음은 FLAGS로 슬라이스와 관련된 permission flag들이다. 이들은 필요에 따라 조합이 된다. 가령 swap 파티션은 0x201인데, 이는 0x200과 0x01 플래그를 합친것과 같으므로 특성은 “Partition is valid to use, unmountable partition”이 된다.
#define V_UNMNT 0x01 /* Unmountable partition */
#define V_RONLY 0x10 /* Read only */
#define V_VALID 0x200 /* Partition is valid to use */

다음은 루트용이 아닌 일반 디스크에 관한 VTOC 정보이다.
#/:>cat vtocfile1
#SLICE TAG FLAGS START SIZE
0 0x5 0x201 32 8497120
1 0x4 0x200 2048 1056768
2 0x4 0x200 1058816 1056768
3 0x4 0x200 2115584 1056768
4 0x4 0x200 3172352 1056768
5 0x4 0x200 4229120 1056768
6 0x4 0x200 5285888 1056768
7 0x1 0x201 32 34
8 0xd 0x201 66 1982
9 0x4 0x201 6342656 1056768
10 0x4 0x200 7399424 1097728
11 0x0 0x0 0 0
12 0x0 0x0 0 0
13 0x0 0x0 0 0
14 0x0 0x0 0 0
15 0x0 0x0 0 0

다음은 옵션 “-p”로 디스크의 물리적인 특성 값을 알 수 있다. “-p” 옵션을 사용하여PDINFO(Physical Disk Information)으로 알려진 정보를 얻어낼 수 있다. PDINFO 정보는 boot 슬라이스에 저장되어 있으며, 보통 부팅할 때이나 디스크가 초기화 될때 마다 sanity check으로 이용된다.
#/:>prtvtoc -p /dev/rdsk/c0b0t0d0s0
Device /dev/rdsk/c0b0t0d0s0
device type: 4 (DPT_SCSI_HD)
cylinders: 522 heads: 255
sectors/track: 63 bytes/sector: 512
number of partitions: 16 size of alts table: 2048
media stamp: "HIchQVFCpfxG"

위에서 “device type: 4 (DPT_SCSI_HD)”라고 되어 있는데, 이는 DPT(Disk Parameter Type)로 디스크 파라미터 종류를 나타낸다. DPT에는 여러가지가 있는데 다음과 같다.
DPT_NOTDISK 0 Not a disk device
DPT_WINI 1 Winchester( IDE/EIDE)
DPT_FLOPPY 2 Floppy
DPT_OTHER 3 Other type of disk
DPT_SCSI_HD 4 SCSI disk
DPT_SCSI_OD 5 SCSI optional



다음은 디스크에 결함이 있어 섹터 단위로 다른 섹터로 포인터를 이동시킨다. 그와 관련된 정보를 표시하는 옵션 “-a”를 이용한 명령어 이다. 아무 변경이 없다면 아래와 같이 표시되고 변경된 값이 있다면 무언가 표시될 것이다.
#/:>prtvtoc -a /dev/rdsk/c0b0t0d0s0
ALTERNATE SECTOR/TRACK MAPPING TABLE:
Bad Sector Start Alternate Sector Start Count
1012678 -> 1012678 1
15962 alternate sector(s) left for allocation.

Edvtoc 명령어

Prtvtoc 명령어와 연계되어 사용하는 명령어로서, VTOC를 편집할 수 있는 명령어이다. 사용하는 형식은 다음과 같다.
# edvtoc -f vtoc-file raw-device
-f vtoc-file 업어칠 VTOC 정보 파일
raw-device /dev/rdsk/c0b0t1d0s0와 같이 마스터 슬라이스 번호까지 준다.

아래의 경우 /tmp/vtoc.t1d0s0란 VTOC 정보를 디스크 /dev/rdsk/c0b0t6d0s0 디바이스에 업어치라는 내용이다.
# edvtoc –f /tmp/vtoc.t1d0s0 /dev/rdsk/c0b0t6d0s0

“-f” 옵션은 디스크 파티션 정보를 업어치지만, “-p” 옵션은 디스크의 물리적 정보 즉 실린더 수, 헤드 수, 섹터 수 같은 정보를 업어치는데 사용된다.
# edvtoc -p raw-device















Slices

모든 유닛스 파티션에는 반드시 슬라이스 개념을 사용하고 있다. 슬라이스에는 몇가지 종류가 있으며, 파일시스템으로 사용하기도 하고 특정 용도로 사용되기도 한다. 슬라이스를 나누는 방법에는 OS디스크쪽과 일반 데이터 디스크쪽으로 구분하여 설명되어야 한다.

슬라이스는 보통 slice 0에서 15까지를 사용한다. 파티션당 최대 슬라이스 수는 184개이다. 다음 “Device 디렉토리”편에 자세히 설명하여 놓았다.

#/:>prtvtoc /dev/rdsk/c0b0t0d0s0
slice 0: DISK permissions: VALID UNMOUNTABLE starting sector: 63 (cyl 0) length: 8385867 (522.00 cyls)
slice 1: ROOT permissions: VALID starting sector: 578340 (cyl 36) length: 2875635 (179.00 cyls)
slice 2: SWAP permissions: VALID UNMOUNTABLE starting sector: 96390 (cyl 6) length: 481950 (30.00 cyls)
slice 4: HOME permissions: VALID starting sector: 3453975 (cyl 215) length: 4209030 (262.00 cyls)
slice 7: BOOT permissions: VALID UNMOUNTABLE starting sector: 63 (cyl 0) length: 34 (0.00 cyls)
slice 8: ALT SEC/TRK permissions: VALID UNMOUNTABLE starting sector: 97 (cyl 0) length: 15968 (0.99 cyls)
slice 10: STAND permissions: VALID starting sector:16065 (cyl 1) length: 80325 (5.00 cyls)
slice 11: VAR permissions: VALID starting sector: 7663005 (cyl 477) length: 626535 (39.00 cyls)
slice 15: VOLPRIVATE permissions: VALID UNMOUNTABLE starting sector: 8289540 (cyl 516) length: 16065 (1.00 cyls)

위에는 루트 디스크에 관한 정보이고 아래는 일반 디스크에 관한 VTOC 정보로 비교하여 보자.

#/:>prtvtoc /dev/rdsk/c0b0t2d0s0
slice 0: DISK permissions: VALID UNMOUNTABLE starting s..:32 (cyl 0) length: 8497120 (4148.98 cyls)
slice 1: USER permissions:VALID starting sector: 2048 (cyl 1) length: 1056768 (516.00 cyls)
slice 2:USER permissions: VALID starting sector: 1058816 (cyl 517) length: 1056768 (516.00 cyls)
slice 3: USER permissions: VALID starting sector: 2115584 (cyl 1033) length: 1056768 (516.00 cyls)
slice 4: USER permissions: VALID starting sector: 3172352 (cyl 1549) length: 1056768 (516.00 cyls)
slice 5: USER permissions: VALID starting sector: 4229120 (cyl 2065) length: 1056768 (516.00 cyls)
slice 6: USER permissions: VALID starting sector: 5285888 (cyl 2581) length: 1056768 (516.00 cyls)
slice 7: BOOT permissions:VALID UNMOUNTABLE starting sector: 32 (cyl 0) length: 34 (0.02 cyls)
slice 8: ALT SEC/TRK permissions:VALID UNM..BLE starting sector:66 (cyl 0) length: 1982 (0.97 cyls)
slice 9: USER permissions:VALID UNM..BLE starting sector:6342656 (cyl 3097) length: 1056768 (516.00 cyls)
slice 10: USER permissions: VALID starting sector: 7399424 (cyl 3613) length: 1097728 (536.00 cyls)

위에 루트 디스크와 일반 디스크에 대한 파티션 정보를 열거하여 놓았다. length를 계산하는 약식방법은 다음과 같다. Length 단위는 블록이므로 MB 단위로 계산 하려면, 가령 8497120이라면 대략 (8497120/2)=4248560에서 끝에서 3자리인 560을 떼어낸 후 MB를 붙이면 4248MB 정도가 전체 파티션에 대한 디스크 크기가 된다. 이는 1 Block=512 Bytes를 근거로 계산한 것이다. 정식으로 계산하자면 8497120 blocks = 8497120 x 512 bytes = 8497120 x 512 / 1024 KB =
(8497120 x 512 /1024) /1024 MB = 4148MB = 4148 MB/1024 = 4 GB라는 결과가 나온다.

공통정보:
s0 디스크 전체에 대한 유닉스 파티션으로 length는 전체 디스크 크기이다.
s7 boot 슬라이스가 있는 곳으로 OS의 boot loader가 있는 곳이다. 디스크의
Master Boot Record나 /stand 파티션과는 의미가 다르다. 혼돈해서는 안된다.
그리고 VTOC 정보, identification 정보인PDINFO가 있는 곳이다.
s8 alternate sector 슬라이스로, 이 곳에는 remap된 sector들과 spare sector들에 관한
정보와 다른 remapping된 정보도 가지고 있다.

root 디스크:
s1 root 파일시스템
s2 swap 슬라이스
s3 /usr 파일시스템
s4 /home 파일시스템
s5 현재 사용 안함
s6 dump 슬라이스. 메모리에 덤프를 받는 대신 디스크의 이 영역에 덤프를 받은다.
s9 현재 사용 안함.
s10 커널이 상주 하는 곳으로 /stand용으로 사용한다.
s11 /var 파일시스템
s12 /home2 파일시스템
s13 /tmp 파일시스템
s14 Volume management public 슬라이스. Veritas Volume Manager에 의해 사용됨.
s15 Volume management private 슬라이스. Veritas Volume Manager에 의해 사용됨.
서버에 요청 중입니다. 잠시만 기다려 주십시오...