본문 바로가기

Linux/CentOS Linux 6.5

Chapter 7. Partition

Chapter 7. Partition
1. File System
 - 자료를 계층적으로 저장, 탐색, 접근, 조작하기 위한 추상적 자료구조의 집합
 - File에 이름을 붙이고, 저장이나 검색을 위해 논리적으로 그것들이 어디에 위치시켜야 하는지 등을 나타내는 방법이다.
 - 컴퓨터의 File과 그 안에 든 자료를 저장 및 찾기를 보다 편리하고 편하게 사용할 수 있도록 유지 관리하는 방법 또는 네트워크상에 존재한 File에 접근하기 위한 가상적 Interface이다.
 - File System은 각각의 운영체제별로 종류가 다양하며 기능부분도 다른 점이 있다.
 - Linux의 File System
  · ext2
  · ext3
  · ext4

 

2. Partition
 - 연속된 저장 공간을 하나 이상의 연속되고 독립된 영역으로 나눠 사용할 수 있도록 정의한 규약
 - Partition의 주의사항
  · Partition을 나누기 위해서는 저장장치에 연속된 공간이 있어야 한다.
  · 하나의 HDD에서는 여러 Partition을 나눌 수 있지만, 두 개의 HDD를 이용해 하나의 Partition을 만들 수는 없다.

  · 새로운 HDD를 인식해 Partition을 나눌 경우 가장 처음 생성된 주 영역(Primary)에 File System이 생성되며 이후 생성된 Partition은 직접 Format해 File System을 생성해야 한다.
 - 단일 Partition과 다중 Partition의 차이점
  · 다중 Partition은 MBR(Master Boot Record)이 존재
  · MBR(Master Boot Record)
  ◦ DOS Partition에서만 해당되는 것으로 Partition이 나눠진 경우 각 Partition을 관리할 수 있는 Partition Table과 Booting이 가능하도록 하는 Boot Program이 있는 영역
  ◦ 물리적으로 Disk의 첫 번째 Sector를 의미
  ◦ MBR은 크게 Boot Code, Partition Table, Signature로 구성되어 있다.
  ◦ MBR의 구조

 - HDD Type
  · IDE
  ◦ 병렬 Hard Drive를 연결한 방식
  ◦ 이름은 hd+'문자' 방식이며 문자는 컴퓨터가 임의로 알파벳을 부여한다.
      ex)hda, hdb, hdd etc.
  ◦ hdc는 CD-ROM으로 사용 불가능 하다.
  · SCSI
  ◦ 직렬 Hard Drive를 연결한 방식
  ◦ 이름은 sd+'문자'의 방식이며 문자는 컴퓨터가 임의로 알파벳을 부여한다.
        ex)sda, sdb, sdc etc.
 - HDD(Hard Disk Drive) & Partition
  · Partition의 내부는 세 가지 종류인 주 영역(Primary), 확장 영역(Extended), 논리 영역(Logical)으로 나뉜다.
  · 주 영역(Primary)은 4개까지만 허용되고, 확장 영역(Extended)은 1개만 허용, 논리 영역(Logical)은 개수 제한은 없으나 확장 영역 안에 존재한다.

  · 주 영역(Primary)은 1번부터 시작하며 논리 영역(Logical)은 5번부터 시작한다.

     ex) Primary : sda1, sda2, sda3, sda4  /  Logical : sda5, sda6, sda7 etc.
  · Partition 분할의 예

    ※ Partition의 숫자가 5개 이상일 때부터 확장 영역(Extended)을 이용해 추가해야 한다.

 

3. Partition 관련 명령어
 - Partition 구성 및 확인

  · 시스템에 연결된 Disk 정보 확인

  ◦ 명령어 사용 시

 # fdisk -l
 Disk /dev/sda: 21.5 GB, 21474836480 bytes
 255 heads, 63 sectors/track, 2610 cylinders
 Units = cylinders of 16065 * 512 = 8225280 bytes
 Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Disk identifier: 0x000acfc4

    Device Boot      Start         End      Blocks   Id  System
 /dev/sda1   *           1          26      204800   83  Linux
 Partition 1 does not end on cylinder boundary.
 /dev/sda2              26         791     6144000   83  Linux
 Partition 2 does not end on cylinder boundary.
 /dev/sda3             791        1313     4194304   82  Linux swap / Solaris
 /dev/sda4            1313        2611    10427392    5  Extended
 /dev/sda5            1313        1568     2048000   83  Linux
 /dev/sda6            1568        1594      204800   83  Linux
 /dev/sda7            1594        2611     8171520   83  Linux

  · Partition 확인

  ◦ CentOS 6.0부터 IDE Type 인식이 되지 않으며 SCSI(sda)로 확인해야 한다.
  ◦ 명령어 사용 시

 # fdisk -l /dev/sda

 Disk /dev/sda: 21.5 GB, 21474836480 bytes
 255 heads, 63 sectors/track, 2610 cylinders
 Units = cylinders of 16065 * 512 = 8225280 bytes
 Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Disk identifier: 0x000acfc4

    Device Boot      Start         End      Blocks   Id  System
 /dev/sda1   *           1          26      204800   83  Linux
 Partition 1 does not end on cylinder boundary.
 /dev/sda2              26         791     6144000   83  Linux
 Partition 2 does not end on cylinder boundary.
 /dev/sda3             791        1313     4194304   82  Linux swap / Solaris
 /dev/sda4            1313        2611    10427392    5  Extended
 /dev/sda5            1313        1568     2048000   83  Linux
 /dev/sda6            1568        1594      204800   83  Linux
 /dev/sda7            1594        2611     8171520   83  Linux

 Disk /dev/sda1: 209 MB, 209715200 bytes
 255 heads, 63 sectors/track, 25 cylinders
 Units = cylinders of 16065 * 512 = 8225280 bytes
 Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Disk identifier: 0x00000000


 Disk /dev/sda2: 6291 MB, 6291456000 bytes
 255 heads, 63 sectors/track, 764 cylinders
 Units = cylinders of 16065 * 512 = 8225280 bytes
 Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Disk identifier: 0x00000000  


 Disk /dev/sda3: 4294 MB, 4294967296 bytes
 255 heads, 63 sectors/track, 522 cylinders
 Units = cylinders of 16065 * 512 = 8225280 bytes
 Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Disk identifier: 0x00000000 


 Disk /dev/sda5: 2097 MB, 2097152000 bytes
 255 heads, 63 sectors/track, 254 cylinders
 Units = cylinders of 16065 * 512 = 8225280 bytes
 Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Disk identifier: 0x00000000 


 Disk /dev/sda6: 209 MB, 209715200 bytes
 255 heads, 63 sectors/track, 25 cylinders
 Units = cylinders of 16065 * 512 = 8225280 bytes
 Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Disk identifier: 0x00000000


 Disk /dev/sda7: 8367 MB, 8367636480 bytes
 255 heads, 63 sectors/track, 1017 cylinders
 Units = cylinders of 16065 * 512 = 8225280 bytes
 Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Disk identifier: 0x00000000

  · Partition 구성

  ◦ fdisk /dev/sda를 사용하면 명령어(Command)를 이용해 Partition을 관리하게 되며 명령어를 잘 모를 시 m을 입력하면 관련 명령어를 보여준다.
  ◦ 명령어 사용 시

 # fdisk /dev/sda
 Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklab
 Building a new DOS disklabel with disk identifier 0x46c8dd40.
 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)

 WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
          switch off the mode (command 'c') and change display units to
          sectors (command 'u').

 Command (m for help):

  ◦ 새로운 Partition 생성

 # fdisk /dev/sda
 Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
 Building a new DOS disklabel with disk identifier 0x4e4ccbc7.
 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)

 WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
          switch off the mode (command 'c') and change display units to
          sectors (command 'u').

 Command (m for help): n
 Command action
    e   extended
    p   primary partition (1-4)
 p
 Partition number (1-4): 1
 First cylinder (1-130, default 1):
 Using default value 1
 Last cylinder, +cylinders or +size{K,M,G} (1-130, default 130): +500M

 Command (m for help): p

 Disk /dev/sda: 1073 MB, 1073741824 bytes
 255 heads, 63 sectors/track, 130 cylinders
 Units = cylinders of 16065 * 512 = 8225280 bytes
 Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Disk identifier: 0xa97b9770

    Device Boot      Start         End      Blocks   Id  System
 /dev/sda1               1          65      522081   83  Linux

 Command (m for help): w
 The partition table has been altered!

 Calling ioctl() to re-read partition table.
 Syncing disks. 

   ▹ 명령어 n을 이용해 Partition을 생성
   ▹ Cylinder를 할당하고 크기를 설정
   ▹ 생성된 정보 확인
   ▹ 명령어 w를 이용해 Partition 정보 저장
  ◦ File System 생성
   ▹ vfat

    ▸  File System을 생성하기 위해서는 먼저 vfat으로 Format한 후 다른 File System으로 Format한다.
    ▸  vfat으로 Format하지 않으면 ext2, ext3, ext4로 생성되지 않는다.
    ▸  명령어 사용 시

 # mkfs -t vfat /dev/sda1
 mkfs.vfat 3.0.9 (31 Jan 2010)

   ▹ ext4

    ▸  File System을 ext4로 바꾸는 명령어이다.
    ▸  명령어 사용 시

 # mkfs.ext4 /dev/sda1
 mke2fs 1.41.12 (17-May-2010)
 Filesystem label=
 OS type: Linux
 Block size=1024 (log=0)
 Fragment size=1024 (log=0)
 Stride=0 blocks, Stripe width=0 blocks
 130560 inodes, 522080 blocks
 26104 blocks (5.00%) reserved for the super user
 First data block=1
 Maximum filesystem blocks=67633152
 64 block groups
 8192 blocks per group, 8192 fragments per group
 2040 inodes per group
 Superblock backups stored on blocks:
         8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409

 Writing inode tables: done
 Creating journal (8192 blocks): done
 Writing superblocks and filesystem accounting information: done

 This filesystem will be automatically checked every 31 mounts or
 180 days, whichever comes first.  Use tune2fs -c or -i to override

 


'Linux > CentOS Linux 6.5' 카테고리의 다른 글

Chapter 9. Network of Linux  (0) 2015.08.07
Chapter 8. Mount  (0) 2015.08.07
Chapter 6. Package  (0) 2015.08.07
Chapter 5. 허가권(Permissions) & 소유권(Ownership)  (0) 2015.08.07
Chapter 4. 사용자(Users) & 그룹(Group)  (0) 2015.08.07