linux class 2 페이지

본문 바로가기
사이트 내 전체검색


회원로그인

linux class

파티션 설정 및 파일시스템 생성

페이지 정보

작성자 admin 작성일15-12-23 12:22 조회330회 댓글1건

본문

*. 아래 예제는 두번째 스카시 디스크 장치에 하나의 주 파티션과 하나의 확장파티션
두개의 논리 파티션을 만드는 과정이다.

*. 주파티션은 하나의 디스크에 대해 4개까지 만들수 있다.
*. 확장 파티션은 주파티션을 제외한 나머지 모든 영역이다.
*. 논리 파티션은 확장파티션 내의 파티션이다.


[root@star ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklab
el
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): m  <= m 을 입력하면 명령어 리스트를 볼수 있다.
Command action
  a  toggle a bootable flag
  b  edit bsd disklabel
  c  toggle the dos compatibility flag
  d  delete a partition
  l  list known partition types
  m  print this menu
  n  add a new partition
  o  create a new empty DOS partition table
  p  print the partition table
  q  quit without saving changes
  s  create a new empty Sun disklabel
  t  change a partition's system id
  u  change display/entry units
  v  verify the partition table
  w  write table to disk and exit
  x  extra functionality (experts only)

Command (m for help):
Command (m for help): p

Disk /dev/sdb: 213 MB, 213909504 bytes
64 heads, 32 sectors/track, 204 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

  Device Boot      Start        End      Blocks  Id  System

Command (m for help):
Command (m for help): n
Command action
  e  extended
  p  primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-204, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-204, default 204): +50M

Command (m for help): p

Disk /dev/sdb: 213 MB, 213909504 bytes
64 heads, 32 sectors/track, 204 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sdb1              1          49      50160  83  Linux

Command (m for help): n
Command action
  e  extended
  p  primary partition (1-4)
e
Partition number (1-4): 2
First cylinder (50-204, default 50):
Using default value 50
Last cylinder or +size or +sizeM or +sizeK (50-204, default 204):
Using default value 204

Command (m for help): p

Disk /dev/sdb: 213 MB, 213909504 bytes
64 heads, 32 sectors/track, 204 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sdb1              1          49      50160  83  Linux
/dev/sdb2              50        204      158720    5  Extended

Command (m for help): n
Command action
  l  logical (5 or over)
  p  primary partition (1-4)
l
First cylinder (50-204, default 50):
Using default value 50
Last cylinder or +size or +sizeM or +sizeK (50-204, default 204): +50M

Command (m for help): p

Disk /dev/sdb: 213 MB, 213909504 bytes
64 heads, 32 sectors/track, 204 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sdb1              1          49      50160  83  Linux
/dev/sdb2              50        204      158720    5  Extended
/dev/sdb5              50          98      50160  83  Linux

Command (m for help): n
Command action
  l  logical (5 or over)
  p  primary partition (1-4)
l
First cylinder (99-204, default 99):
Using default value 99

Last cylinder or +size or +sizeM or +sizeK (99-204, default 204): +50M
(* .참고 50 이라고 적으면 last cylinder 번호,+ 50 이라고 적으면 실린더 갯수를 50개 할당, + 50K 라고 적으면 50K 바이트를 할당한다는 의미)


Command (m for help): p

Disk /dev/sdb: 213 MB, 213909504 bytes
64 heads, 32 sectors/track, 204 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sdb1              1          49      50160  83  Linux
/dev/sdb2              50        204      158720    5  Extended
/dev/sdb5              50          98      50160  83  Linux
/dev/sdb6              99        147      50160  83  Linux

Command (m for help): w    <= 작업한 내용을 저장하지 않고 그냥 빠져나가려면 q 만 입력하면 된다.
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@star ~]#

*. 그리고 파티션을 삭제하려면 d 명령을 사용하면 된다.

* 확인은 -l 옵션으로 할 수 있다.

[root@star ~]# fdisk -l /dev/sdb

Disk /dev/sdb: 213 MB, 213909504 bytes
64 heads, 32 sectors/track, 204 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sdb1              1          49      50160  83  Linux
/dev/sdb2              50        204      158720    5  Extended
/dev/sdb5              50          98      50160  83  Linux
/dev/sdb6              99        147      50160  83  Linux
[root@star ~]#

파일시스템 생성은
mkfs -t ext3 /dev/sdb1  => ext3 파일시스템 생성
mkfs -t ext2 /dev/sdb1 => ext2 파일시스템 생성

또는
mke2fs -j /dev/sdb1 => ext3 파일시스템 생성

=====================================================

swap file system 생성 및 추가

swap 영역 생성하기
os 설치후에 swap 영역이 더 필요하다라고 생각되면
스왑파티션을 생성하거나 빈 디스크 블럭을 할당하여
swap 영역을 추가할 수 있다.

1. swap 파티션을 생성하고 swap 영역 추가하는 경우
[root@titan p2]# fdisk -l /dev/sdc
Disk /dev/sdc: 213 MB, 213909504 bytes
64 heads, 32 sectors/track, 204 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes

  Device Boot      Start        End      Blocks  Id  System
/dev/sdc1              1          49      50160  82  Linux swap
/dev/sdc2              50          98      50176  83  Linux
/dev/sdc3              99        204      108544  83  Linux
[root@titan p2]#

/dev/sdc1 을 swap 파티션으로 사용하기 위해 파일시스템 타입을 Linux swap으로
지정하였다.

그런다음

[root@titan ~]# mkswap /dev/sdc1
Setting up swapspace version 1, size = 51359 kB
[root@titan ~]#
[root@titan ~]# swapon -v /dev/sdc1 (v 옵션을 생략해도 되지만 그 밑에 있는 실행결과를 보여주지 않는다)
swapon on /dev/sdc1
[root@titan ~]#
[root@titan ~]# swapon
usage: swapon [-hV]
      swapon -a [-e] [-v]
      swapon [-v] [-p priority] special|LABEL=volume_name|UUID=uuid ...
      swapon [-s]
[root@titan ~]# swapon -s
Filename                                Type            Size    Used    Priority
/dev/sda5                              partition      522072  3096    -1
/dev/sdc1                              partition      50152  0      -5       
[root@titan ~]#

swap 영역이 활성화 되었음을 알수 있다.

2. swap 파일을 swap 영역을 할당하려면

[root@titan p2]# dd if=/dev/zero of=./swapfile bs=1024 count=30000

swap file 은 dd 명령으로 생성한다.
약 30메가 크기로 디스크 블럭을 할당하고 디스크 블럭을 0으로 초기화 하였다.

이 디스크 영역을 swap 영역으로 할당하기 위해서는

[root@titan p2]# mkswap swapfile
Setting up swapspace version 1, size = 30715 kB

[root@titan p2]# mkswap swapfile
Setting up swapspace version 1, size = 30715 kB
[root@titan p2]# chmod 600 swapfile  <= swap file은 보안상 퍼미션을 600으로 하는것이 좋다.
[root@titan p2]# swapon -v swapfile <= swap file 퍼미션이 600 이 아니면 보안경고메세지가 출력될것이다.
swapon on swapfile
[root@titan p2]# swapon -s
Filename                                Type            Size    Used    Priority
/dev/sda5                              partition      522072  3876    -1
/dev/sdc1                              partition      50152  0      -5
/mnt/p2/swapfile                        file            29992  0      -7
[root@titan p2]#
swap 영역이 활성화 되었음을 알수 있다.

그리고 리부팅후에도 계속 사용하기 위해서는 fstab 파일에 등록해두어야 한다.

/dev/sdc1              swap                    swap    defaults        0 0
/mnt/p2                swap                    swap    defaults        0 0
[root@titan p2]#
기존의 등록되어 있는 swap 영역 한줄을 복사해서 사용하면 간단히 추가할수 있다.

그리고 swap 파티션 장치명을 label 명으로 fstab 에 등록하려면
mkswap 명령어를 사용할 때 아래와 같이 레이블명을 넣어주면 된다.

mkswap -L SWAP-sdc1 /dev/sdc1

댓글목록

mycolor님의 댓글

mycolor 작성일

/dev/sdc
----------------------
첫번째 - 주 250메가
두번째 - 확장 ~ 80번실린더까지 할당
          논리 - 실린더갯수 10개
          논리 - 나머지 모든용량
세번째 - 주 100메가
네번째 - ?  디스크의 남은모든용량

----------------------------------
작업완료 후 확인방법은
fdisk -l  /dev/sdc
ls  /dev/sdc*


접속자집계

오늘
54
어제
75
최대
611
전체
448,104
개인정보취급방침 서비스이용약관 twoseven.kr All rights reserved.
상단으로