linux class(new) 1 페이지

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


회원로그인

linux class(new)

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

페이지 정보

작성자 admin 작성일16-02-02 17:36 조회2,578회 댓글2건

본문

*. 주파티션은 하나의 디스크에 대해 4개까지 만들수 있다. (파티션 번호는 1번~4번까지 할당)
*. 확장 파티션은 디스크 하나에 1개만 만들수 있다.(파티션 번호는 1번~4번중에서 하나 할당)
*. 논리 파티션은 확장파티션 내의 파티션이다.(파티션 번호는 5번 이상으로 할당됨)

* 참고 - 파티션 설정 예

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

/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): 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-512, default 1): 1 ; 1은 디폴트값이므로 그냥 숫자입력없이 엔터키만 쳐도 된다.
Last cylinder, +cylinders or +size{K,M,G} (1-512, default 512): +200M

Command (m for help): p

Disk /dev/sdb: 536 MB, 536870912 bytes
64 heads, 32 sectors/track, 512 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: 0x0006f604

Device Boot Start End Blocks Id System
/dev/sdb1 1 201 205808 83 Linux

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

Disk /dev/sdb: 536 MB, 536870912 bytes
64 heads, 32 sectors/track, 512 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: 0x0006f604

Device Boot Start End Blocks Id System
/dev/sdb1 1 201 205808 83 Linux
/dev/sdb2 202 512 318464 5 Extended

Command (m for help): n
Command action
l logical (5 or over)
p primary partition (1-4)
l
First cylinder (202-512, default 202):
Using default value 202
Last cylinder, +cylinders or +size{K,M,G} (202-512, default 512):
Using default value 512
-----------------------------------------------------------------------------------------------
Command (m for help): p
Disk /dev/sdb: 536 MB, 536870912 bytes
64 heads, 32 sectors/track, 512 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: 0x0006f604

Device Boot Start End Blocks Id System
/dev/sdb1 1 201 205808 83 Linux
/dev/sdb2 202 512 318464 5 Extended
/dev/sdb5 202 512 318448 83 Linux

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

Calling ioctl() to re-read partition table.
Syncing disks.
------------------------------------------------------------------------------------------------
/root# ls /dev/sdb? ; 파티션 테이블을 저장할때 파티션 장치파일이 생성된다.
/dev/sdb1 /dev/sdb2 /dev/sdb5
/root#
그 외에 파티션 설정 명령으로 cfdisk , parted 명령어가 있다.
* fdisk 는 파티션 하나가 최대 2기가 까지 설정할수 있다.
파티션 크기를 2TB 를 초과해서 설정하는 경우에는 parted 로 설정해야 한다.


/root# cfdisk /dev/sdc
cfdisk (util-linux-ng 2.17.2)
Disk Drive: /dev/sdc
Size: 536870912 bytes, 536 MB
Heads: 64 Sectors per Track: 32 Cylinders: 512
Name Flags Part Type FS Type [Label] Size (MB)
---------------------------------------------------------------------------------------
sdc1 Primary Linux 99.62
sdc5 Logical Linux 200.28
sdc3 Primary Linux 236.98

[ Bootable ] [ Delete ] [ Help ] [ Maximize ] [ Print ]
[ Quit ] [ Type ] [ Units ] [ Write ]


/root# parted /dev/sda
GNU Parted 2.1
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sda: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 1049kB 2149MB 2147MB primary linux-swap(v1)
2 2149MB 3222MB 1074MB primary ext4
3 3222MB 19.4GB 16.2GB primary ext4 boot
4 19.4GB 21.5GB 2097MB extended
5 19.4GB 21.5GB 2096MB logical ext4
(parted)


* 파티션 출력 및 설정을 섹터 단위로 하는경우
----------------------------------------------------------------------

[root /dev]# fdisk -l /dev/sdb
Disk /dev/sdb: 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: 0x0008dc29

Device Boot Start End Blocks Id System
/dev/sdb1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sdb2 64 2611 20458496 8e Linux LVM
[root /dev]#

실린더 번호가 중첩되어 출력되었고 그것으로 인하여 경고메시지가 출력되었다.
하지만 이것은 LBA 방식의 디스크와 CHS 방식의 디스크의 차이점때문이다.
LBA 방식의 디스크에서는 실린더 번호가 중첩되어 나타날수 있다.

아래와 같이 c,u 옵션을 사용해서 출력해보면 문제가 없다는것을 알수 있다.
c 옵션 : dos 호환모드 플래그 설정 off
u 옵션 : 섹터 단위로 출력

[root /dev]# fdisk -lcu /dev/sda
Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0008dc29

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 41943039 20458496 8e Linux LVM
[root /dev]# fdisk -l /dev/sdb


아래는 dos 호환모드를 끄고 실린더 단위 대신에 섹터 단위로 설정하는 방법이다.

[root /dev]# 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 0x711e2a25.
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): c
DOS Compatibility flag is not set

Command (m for help): u
Changing display/entry units to sectors

Command (m for help): p

Disk /dev/sdc: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders, total 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x711e2a25

Device Boot Start End Blocks Id System

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

Command (m for help): p

Disk /dev/sdc: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders, total 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x711e2a25

Device Boot Start End Blocks Id System
/dev/sdc1 2048 1026047 512000 83 Linux

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First sector (1026048-2097151, default 1026048):
Using default value 1026048
Last sector, +sectors or +size{K,M,G} (1026048-2097151, default 2097151):
Using default value 2097151

Command (m for help): p

Disk /dev/sdc: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders, total 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x711e2a25

Device Boot Start End Blocks Id System
/dev/sdc1 2048 1026047 512000 83 Linux
/dev/sdc2 1026048 2097151 535552 83 Linux

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

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

*. fdisk -cu /dev/sdc ; 이렇게 하고 바로 설정해도 결과는 같다.

파일시스템 생성 : mkfs(또는 mke2fs)
mkfs -t ext4 /dev/sdb1(== mkfs.ext4 /dev/sdb1) ==>ext4 파일시스템 생성
mkfs -t ext3 /dev/sdb1 (== mkfs.ext3 /dev/sdb1) ==> ext3 파일시스템 생성
mkfs -t ext2 /dev/sdb1 (== mkfs.ext2 /dev/sdb1) ==> ext2 파일 시스템 생성
또는
mke2fs -j /dev/sdb1 => ext3 파일시스템 생성
*. mkfs /dev/sdb1 ; 파일시스템 타입을 생략하면 ext2 로 파일시스템이 생성된다.

댓글목록

엘케피탄님의 댓글

엘케피탄 작성일

parted는 2G 이상이 아니라 2T 이상 일때 사용하는거 아닌가요?
fdisk가 GPT 지원이 안되기때문에...
오타가 난것같아요~

admin님의 댓글

admin 댓글의 댓글 작성일

수정하였습니다.
알려주셔서 감사합니다.


접속자집계

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