서버/Linux I 2016. 1. 27. 18:36

Linux I - 16. 파티션 작업 & 파일 시스템 생성

 

 

 

login as: root
root@192.168.1.2's password: centos
Last login: Wed Jan 27 13:28:09 2016 from 192.168.1.1
[root@CentOS /root]#

 

 

 

1. 파티션

 

파티션이란 시스템의 하드디스크 영역을 논리적으로 분할하는 것을 의미하며, 파티션 작업을 하는 목적은 다음과 같다.

(Ex : 윈도우 시스템 C, D, E 드라이브)

 

 - 루트 파티션 손상시 다중 파티션 데이터 보호, 백업 및 업그레이드 가능

 - 다중 운영체제 설치 가능

 - 파일 시스템 점검 시간 단축 및 부팅 시간 감소

 

 

[디스크 유형]

IDE(integrated Drive Electronics)

SCSI(Small Computer System Interface)

 

 

 

 

 Primary Master HardDisk

 /dev/hda

 Primary Master HardDisk

 /dev/sda

 Primary Slave HardDisk

 /dev/hdb

 Primary Slave HardDisk

 /dev/sdb

 Secondary Master HardDisk

 /dev/hdc

 Secondary Master HardDisk

 /dev/sdc

 Secondary Slave HardDisk

 /dev/hdd

 Secondary Slave HardDisk

 /dev/sdd

 

리눅스는 파티션을 디렉토리로 구분한다. (윈도우는 파티션을 드라이브 단위로 구분함)

 

 

 

[리눅스 파티션 구성]

 주파티션

주파티션 

주파티션 

확장파티션 

 hda1

hda2

hda3

 

 hda4

 

논리적인 파티션

 

hda5

 

 hda6

 hda7

 hda8

 ~ hda15

 

리눅스에서는 주파티션 및 확장 파티션을 1~4까지 구성할 수 있으며,  논리적인 파티션을 5~15까지 구성할 있다.

 

 

주파티션

기본적인 파티션이기 때문에 더이상 분리할 수 없으며, 확장 파티션까지 포함해서  총 4개까지 생성할 수 있다. 

 

확장 파티션

파티션을 5개 이상 생성할 경우 사용하는 파티션이다. 확장 파티션은 저장 공간이 별도로 없는 대신, 논리적인 파티션을 생성할 수 있도록 한다. 확장 파티션은 1개만 사용할 수 있으며, 가장 마지막 파티션 번호를 사용하는 것을 권장한다.

 

논리적인 파티션

확장 파티션에서 제공하는 논리적인 파티션이다. 

 

 

 

 

2. 파티션 작업을 위한 디스크 추가 작업

 

 

[root@CentOS /root]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_centos-lv_root
                       35G  3.7G   30G  12% /
tmpfs                1000M   72K 1000M   1% /dev/shm
/dev/sda1             477M   34M  419M   8% /boot

 

 

[root@CentOS /dev]# shutdown -h now

 


 1) SCSI 타입으로 6개 추가

 

VMware -> 'Edit virtual machine settings' 클릭 -> 'add' 클릭 -> Hard Disk 선택 -> Next

 

-> SCSI (Recommended) 선택 -> Next -> 'Create a new virtual disk' 선택 -> Next

 

-> 하드 0.2G 설정, 'store virtual disk as a single file' 선택 -> Next

 

-> 'CentOS6.6-x.vmdk' 기본 이름 사용 -> Finish 클릭

 


 2) 이런 방식으로 SCSI 타입 5개 추가 실시

 


 3) IDE 타입으로 2개 더 추가

 

 

 4) 하드 디스크 추가 결과

 

 


 5) 리눅스 부팅 실시

 

login as: root
root@192.168.1.2's password:
centos
Last login: Wed Jan 27 13:39:17 2016 from 192.168.1.1
[root@CentOS /root]#

 

[root@CentOS /root]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_centos-lv_root
                       35G  3.7G   30G  12% /
tmpfs                1000M   72K 1000M   1% /dev/shm
/dev/sda1             477M   34M  419M   8% /boot

 


[root@CentOS /root]# ls /dev/sd*                                             CentOS 6.x부터는 hd*도 sd*로 다 표기된다. 
/dev/sda   /dev/sda2  /dev/sdc  /dev/sde  /dev/sdg  /dev/sdi
/dev/sda1  /dev/sdb   /dev/sdd  /dev/sdf  /dev/sdh

 

 - 하드 디스크 추가가 제대로 되었다면, VMware Snapshot 실시한다. (이름 : 디스크 추가 완료)

 

 

 

 

3. 파티션 작업

 

'fdisk' 명령어를 이용하여 파티션 생성, 삭제, 타입 설정을 수행한다. 시스템에 하드 디스크를 추가하여도 파티션 설정이 없다면, 포멧(파일 시스템 작업)을 수행할 수 없다. 그렇기 때문에 하드 디스크를 추가한 다음에 파티션 설정을 실시해야 한다.

 

 

[root@CentOS /root]# fdisk -l /dev/sda

Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 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: 0x0001eb07

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        5222    41430016   8e  Linux LVM

 

[root@CentOS /root]# 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
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

 

 

 

Ex1) 'dev/sdb'파티션 작업 예제

 

 

 - 도움말 기능, 파티션 생성 및 삭제

 

[root@CentOS /root]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x0c65d597.
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): 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): p

Disk /dev/sdb: 213 MB, 213909504 bytes
64 heads, 32 sectors/track, 204 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0c65d597

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): 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): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-204, default 1): 1
Last cylinder, +cylinders or +size{K,M,G} (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
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0c65d597

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1          51       52208   83  Linux

 


Command (m for help): d
Selected partition 1

 

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
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0c65d597

   Device Boot      Start         End      Blocks   Id  System

 

 

 

- 주파티션(50M, 30M, 30M, 30M) 4개 생성

 

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): 1
Last cylinder, +cylinders or +size{K,M,G} (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
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x992d33c0

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1          51       52208   83  Linux

 

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

 

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
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x992d33c0

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1          51       52208   83  Linux
/dev/sdb2              52          82       31744   83  Linux

 

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

 

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
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x992d33c0

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1          51       52208   83  Linux
/dev/sdb2              52          82       31744   83  Linux
/dev/sdb3              83         113       31744   83  Linux

 

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

 

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
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x992d33c0

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1          51       52208   83  Linux
/dev/sdb2              52          82       31744   83  Linux
/dev/sdb3              83         113       31744   83  Linux
/dev/sdb4             114         144       31744   83  Linux

 


Command (m for help): n                                                       더이상 파티션 생성 불가
You must delete some partition andadd an extended partition first

 

 

 

 - 확장 파티션(50M) 생성 및 논리적인 파티션(30M, 나머지 모든 영역) 생성
 

Command (m for help): d
Partition number (1-4): 4

 

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
e
Selected partition 4
First cylinder (114-204, default 114): 114
Last cylinder, +cylinders or +size{K,M,G} (114-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
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x992d33c0

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1          51       52208   83  Linux
/dev/sdb2              52          82       31744   83  Linux
/dev/sdb3              83         113       31744   83  Linux
/dev/sdb4             114         164       52224    5  Extended   (논리적인 파티션을 위한 하드디스크라고 생각하면됨)

 

Command (m for help): n
First cylinder (114-164, default 114): 114
Last cylinder, +cylinders or +size{K,M,G} (114-164, default 164): +30M

 

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
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x992d33c0

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1          51       52208   83  Linux
/dev/sdb2              52          82       31744   83  Linux
/dev/sdb3              83         113       31744   83  Linux
/dev/sdb4             114         164       52224    5  Extended
/dev/sdb5             114         144       31728   83  Linux

Command (m for help): n
First cylinder (145-164, default 145): 145
Last cylinder, +cylinders or +size{K,M,G} (145-164, default 164): 164

 

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
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x992d33c0

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1          51       52208   83  Linux
/dev/sdb2              52          82       31744   83  Linux
/dev/sdb3              83         113       31744   83  Linux
/dev/sdb4             114         164       52224    5  Extended
/dev/sdb5             114         144       31728   83  Linux
/dev/sdb6             145         164       20464   83  Linux



 

 - '/dev/sdb3' 주파티션 삭제 및 주파티션 재생성

 

Command (m for help): d
Partition number (1-6): 3

 

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
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x992d33c0

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1          51       52208   83  Linux
/dev/sdb2              52          82       31744   83  Linux
/dev/sdb4             114         164       52224    5  Extended
/dev/sdb5             114         144       31728   83  Linux
/dev/sdb6             145         164       20464   83  Linux


Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
No free sectors available  (논리적인 파티션은 5번 이상부터 생성할 수 있기 때문에, '3'은 논리적인 파티션으로 생성 불가능)

 

 

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
p
Selected partition 3
First cylinder (83-204, default 83): 165
Last cylinder, +cylinders or +size{K,M,G} (165-204, default 204): 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
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x992d33c0

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1          51       52208   83  Linux
/dev/sdb2              52          82       31744   83  Linux
/dev/sdb3             165         204       40960   83  Linux
/dev/sdb4             114         164       52224    5  Extended
/dev/sdb5             114         144       31728   83  Linux
/dev/sdb6             145         164       20464   83  Linux

Partition table entries are not in disk order  ('/dev/sdb3 ' 실린더 순서가 맞지 않아서 나오는 메세지, 권장 사항 아님)

 

Command (m for help): 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): w
The partition table has been altered!

 

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

 


[root@CentOS /root]# ls /dev/sdb*
/dev/sdb  /dev/sdb1  /dev/sdb2  /dev/sdb3  /dev/sdb4  /dev/sdb5  /dev/sdb6


[root@CentOS /root]# 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
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x992d33c0

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1          51       52208   83  Linux
/dev/sdb2              52          82       31744   83  Linux
/dev/sdb3             165         204       40960   83  Linux
/dev/sdb4             114         164       52224    5  Extended
/dev/sdb5             114         144       31728   83  Linux
/dev/sdb6             145         164       20464   83  Linux

Partition table entries are not in disk order

 


 

Ex2) '/dev/sdb' 파티션 삭제

 

[root@CentOS /root]# fdisk /dev/sdb

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): p

 

Disk /dev/sdb: 213 MB, 213909504 bytes
64 heads, 32 sectors/track, 204 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x992d33c0

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1          51       52208   83  Linux
/dev/sdb2              52          82       31744   83  Linux
/dev/sdb3             165         204       40960   83  Linux
/dev/sdb4             114         164       52224    5  Extended
/dev/sdb5             114         144       31728   83  Linux
/dev/sdb6             145         164       20464   83  Linux

Partition table entries are not in disk order

 

Command (m for help): d
Partition number (1-6): 6

 

Command (m for help): d
Partition number (1-5): 5

 

Command (m for help): d
Partition number (1-5): 4

 

Command (m for help): d
Partition number (1-4): 3

 

Command (m for help): d
Partition number (1-4): 2

 

Command (m for help): d
Selected partition 1

 

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
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x992d33c0

   Device Boot      Start         End      Blocks   Id  System

 

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

 

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


 

 

 

Ex3) '/dev/sdc' 파티션 설정 및 삭제

 

첫번째 주파티션 : 30M

두번째 확장 파티션 : 150번 실린더까지 할당

 

                     논리 파티션 : 50개 실린더 할당 (+49)

                     논리 파티션 : 나머지 모든 영역 할당

 

세번째 주파티션 : 180번 실린더까지 할당

네번째 주파티션 : 나머지 모든 영역 할당

 

 

[root@CentOS /root]# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x78557309.
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-204, default 1): 1
Last cylinder, +cylinders or +size{K,M,G} (1-204, default 204): +30M

 

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

 

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (32-150, default 32): 32
Last cylinder, +cylinders or +size{K,M,G} (32-150, default 150): +49

 

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (82-150, default 82): 82
Last cylinder, +cylinders or +size{K,M,G} (82-150, default 150): 150

 

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (151-204, default 151): 151
Last cylinder, +cylinders or +size{K,M,G} (151-204, default 204): 180

 

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
p
Selected partition 4
First cylinder (181-204, default 181): 181
Last cylinder, +cylinders or +size{K,M,G} (181-204, default 204): 204

Command (m for help): p

 

Disk /dev/sdc: 213 MB, 213909504 bytes
64 heads, 32 sectors/track, 204 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x78557309

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1          31       31728   83  Linux
/dev/sdc2              32         150      121856    5  Extended
/dev/sdc3             151         180       30720   83  Linux
/dev/sdc4             181         204       24576   83  Linux
/dev/sdc5              32          81       51184   83  Linux
/dev/sdc6              82         150       70640   83  Linux

 

 

 

 

 

 

 

 

첫번째 주파티션 : 30M 할당

두번째 확장 파티션 : 150번 실린더까지 할당

 

세번째 주파티션 : 180번 실린더까지 할당

네번째 주파티션 : 나머지 모든 영역 할당

 

논리 파티션 : 50개 실린더 할당 (+49)

논리 파티션 : 나머지 모든 영역 할당

 

 


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

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


[root@CentOS /root]# ls /dev/sdc*
/dev/sdc  /dev/sdc1  /dev/sdc2  /dev/sdc3  /dev/sdc4  /dev/sdc5  /dev/sdc6


 

[root@CentOS /test]# fdisk /dev/sdc

 

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): p

 

Disk /dev/sdc: 213 MB, 213909504 bytes
64 heads, 32 sectors/track, 204 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x78557309

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1          31       31728   83  Linux
/dev/sdc2              32         150      121856    5  Extended
/dev/sdc3             151         180       30720   83  Linux
/dev/sdc4             181         204       24576   83  Linux
/dev/sdc5              32          81       51184   83  Linux
/dev/sdc6              82         150       70640   83  Linux


Command (m for help): d
Partition number (1-6): 6

 

Command (m for help): d
Partition number (1-5): 5

 

Command (m for help): d
Partition number (1-5): 4

 

Command (m for help): d
Partition number (1-5): 3

 

Command (m for help): d
Partition number (1-5): 2

 

Command (m for help): d
Selected partition 1

 

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

 

Calling ioctl() to re-read partition table.
Syncing disks.
[root@CentOS /test]#
[root@CentOS /test]# ls /dev/sdc*
/dev/sdc

 

 

Ex4) '/dev/sdb' 파티션 설정 및 삭제

 

첫번째 주파티션 :  50M 할당

두번째 주파티션 :  50M 할당

세번째 주파티션 :  50M 할당

네번째 확장 파티션 : 나머지 모든 영역 할당

 

                  논리파티션 : 모든 영역 할당

 

 

[root@CentOS /root]# fdisk /dev/sdb

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-204, default 1): 1
Last cylinder, +cylinders or +size{K,M,G} (1-204, default 204): +50M

 

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

 

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


Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
e
Selected partition 4
First cylinder (154-204, default 154): 154
Last cylinder, +cylinders or +size{K,M,G} (154-204, default 204): 204

 

Command (m for help): n
First cylinder (154-204, default 154): 154
Last cylinder, +cylinders or +size{K,M,G} (154-204, default 204): 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
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x992d33c0

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1          51       52208   83  Linux
/dev/sdb2              52         102       52224   83  Linux
/dev/sdb3             103         153       52224   83  Linux
/dev/sdb4             154         204       52224    5  Extended
/dev/sdb5             154         204       52208   83  Linux

 

 

 

 

 

 

첫번째 주파티션 :  50M 할당

두번째 주파티션 :  50M 할당

세번째 주파티션 :  50M 할당

네번째 확장 파티션 : 나머지 모든 영역 할당

 

                  논리파티션 : 모든 영역 할당

 

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

 

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

[root@CentOS /root]# ls /dev/sdb*
/dev/sdb  /dev/sdb1  /dev/sdb2  /dev/sdb3  /dev/sdb4  /dev/sdb5

 

[root@CentOS /root]# fdisk /dev/sdb

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): d
Partition number (1-5): 5

 

Command (m for help): d
Partition number (1-5): 4

 

Command (m for help): d
Partition number (1-4): 3

 

Command (m for help): d
Partition number (1-4): 2

 

Command (m for help): d
Selected partition 1

 

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
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x992d33c0

   Device Boot      Start         End      Blocks   Id  System

 

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

 

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

[root@CentOS /root]# ls /dev/sdb*
/dev/sdb

 

 

 

Ex5) '/dev/sdb' 파티션 설정

 

첫번째 주파티션 :  50M 할당

두번째 주파티션 :  50M 할당

세번째 주파티션 :  50M 할당

네번째 주파티션 : 나머지 모든 영역 할당

 

 

[root@CentOS /root]# fdisk /dev/sdb

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-204, default 1): 1
Last cylinder, +cylinders or +size{K,M,G} (1-204, default 204): +50M

 

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

 

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

 

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Selected partition 4
First cylinder (154-204, default 154): 154
Last cylinder, +cylinders or +size{K,M,G} (154-204, default 204): 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
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x992d33c0

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1          51       52208   83  Linux
/dev/sdb2              52         102       52224   83  Linux
/dev/sdb3             103         153       52224   83  Linux
/dev/sdb4             154         204       52224   83  Linux

 

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

 

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

[root@CentOS /root]# ls /dev/sdb*
/dev/sdb  /dev/sdb1  /dev/sdb2  /dev/sdb3  /dev/sdb4

 

 

 

 

4. 파일 시스템 생성

 

 - 파일 시스템이란 파일을 저장하고 관리하는 구조 체계를 의미하며, 리눅스에서는 포멧을 파일 시스템 생성이라고 한다.

 - 파일 시스템을 생성하려면 'mkfs' 명령어를 이용하면 된다.

 

 

    ext2 : 리눅스 이전 버전에서 사용했던 파일 시스템

    ext3 : CentOS5.x 에서 사용하는 파일 시스템

    ext4 : CentOS 6.x 에서 사용하는 파일 시스템

 

 

 

[root@CentOS /root]# 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
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x992d33c0

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1          51       52208   83  Linux
/dev/sdb2              52         102       52224   83  Linux
/dev/sdb3             103         153       52224   83  Linux
/dev/sdb4             154         204       52224   83  Linux

 

 

[root@CentOS /root]# mkfs -t ext4 /dev/sdb1          (# mkfs.ext4 /dev/sdb1)
[root@CentOS /root]# mkfs -t ext4 /dev/sdb2          (# mkfs.ext4 /dev/sdb2)

[root@CentOS /root]# mkfs -t ext4 /dev/sdb3          (# mkfs.ext4 /dev/sdb3)

[root@CentOS /root]# mkfs -t ext4 /dev/sdb4          (# mkfs.ext4 /dev/sdb4)

 

 

 

 - 파일 시스템 생성이 완료되었다면, VMware Snapshot 실시한다. (이름 : 파일 시스템 생성 완료)

 

'서버 > Linux I' 카테고리의 다른 글

Linux I - 17. 마운트 관리  (0) 2016.01.28
Linux I - 15. 디렉토리 구조  (0) 2016.01.27
Linux I - 14. 파일 타입  (0) 2016.01.27
Linux I - 13. 작업 관리 (at & cron)  (0) 2016.01.26
Linux I - 12. 프로세스 관리  (0) 2016.01.25
Posted by 김정우 강사(카카오톡 : kim10322)
,


Q