Skip to content

Fdisk

Categories

Example

fdisk -l
모든 디스크의 파티션 설정 현황 확인.
fdisk /dev/sda
프롬프트 진입 및 /dev/sda장치 선택.

List of commands

  • a: 부팅파티션을 설정할 수 있습니다.
  • b: BSD로 디스크라벨 설정합니다.
  • c: DOS호환가능한 플래그 설정합니다.
  • d: 파티션을 삭제할 수 있습니다.
  • l: 설정가능한 파티션 타입을 보여줍니다.
  • m: 파티션 설정도움말을 보여줍니다.
  • n: 새로운 파티션을 생성할 수 있습니다.
  • o: 새로운 도스파티션 테이블을 생성합니다.
  • p: 현재 설정된 파티션정보를 보여줍니다.
  • q: 설정된 정보를 저장하지않고 fdisk를 빠져나갑니다.
  • s: SUN 디스크라벨을 생성합니다.
  • t: 파티션 타입을 변경할 수 있습니다.
  • u: 유닛(units)정보를 열람하거나 변경할 수 있습니다.
  • v: 지정된 파티션을 검사합니다.
  • w: 현재까지 설정한 파티션정보를 저장하고 fdisk를 빠져나갑니다.
  • x: 파티션설정 전문가 모드로 들어감.
    • 이 전문가 모드에서는 실린더(Cylinder)수나 헤드(Head)수 그리고 트랙(Track)당 섹터(Sector)수를 변경할 수 있습니다.

Primary, Extended, Logical partition

먼저 파티션의 종류에 대하여 알아보자. 파티션은 primary, extended, logical 파티션으로 구분할 수 있다. 하나의 하드디스크에는 최대 4개의 primary 파티션이 존재할 수 있다. 하나의 하드디스크에 5개 이상의 파티션이 필요할 경우 extended 파티션을 만들어 그 안에 여러 개의 logical 파티션을 둘 수 있는 것이다. 이때 하나의 하드디스크에 만들 수 있는 extended 파티션의 개수는 무조건 하나이다. 그리고 extended 파티션을 만든다면 primary 파티션은 최대 3개까지 만들 수 있다. 또한 만들 수 있는 logical 파티션의 개수도 59개로 제한된다. 따라서 하나의 하드디스크에 만들 수 있는, 그리고 데이타의 저장이 가능한 파티션의 최대 개수는 62개인 (primary 3개, logical 59개) 셈이다. extended 파티션에는 데이타를 저장할 수 없다. extended 파티션은 logical 파티션들을 감싸고 있는 껍데기라고 생각하면 된다.

Troubleshooting

vfat signature

vfat 서명을 제거한다는 메시지가 출력 된다.

Created a new partition 1 of type 'Linux' and of size 7.3 GiB.
Partition #1 contains a vfat signature.

Do you want to remove the signature? [Y]es/[N]o:

The signature partition is basically a mark/beacon there is something there, and it is not empty. It also may identify a partition.

It is useful on the context of several utilities/OS to tell the partition has already data there.

Moving a partition size/recreating a partition is usually a non-destructive operation up to the point before formatting it.

So a signature warning is signalling you "There is already data here!...are you sure you want to go ahead?"

As for removing it or not, it depends on wether you are for instance resizing a partition or creating a partition anew. If you are creating a partition anew, obviously you may want to remove the signature, if you are resizing a partition you surely want to keep it.

The use of partition signatures is not exclusive to Linux.

From How to wipe a signature from a disk device on Linux with wipefs command

Each disk and partition has some sort of signature and metadata/magic strings on it. The metadata used by operating system to configure disks or attach drivers and mount disks on your system

한마디로 "이미 데이터가 존재하는데, 제거할 거냐?" 라고 물어보는 거다.

파티션 맵을 수정할 수 없습니다

다른 OS에서 디스크 포맷이 불가능 할 경우 파티션 테이블을 변경하면 된다. fdisk를 아래와 같이 사용하면 된다.

$ sudo fdisk /dev/sdd
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): m

Help:

  DOS (MBR)
   a   toggle a bootable flag
   b   edit nested BSD disklabel
   c   toggle the dos compatibility flag

  Generic
   d   delete a partition
   F   list free unpartitioned space
   l   list known partition types
   n   add a new partition
   p   print the partition table
   t   change a partition type
   v   verify the partition table
   i   print information about a partition

  Misc
   m   print this menu
   u   change display/entry units
   x   extra functionality (experts only)

  Script
   I   load disk layout from sfdisk script file
   O   dump disk layout to sfdisk script file

  Save & Exit
   w   write table to disk and exit
   q   quit without saving changes

  Create a new label
   g   create a new empty GPT partition table
   G   create a new empty SGI (IRIX) partition table
   o   create a new empty DOS partition table
   s   create a new empty Sun partition table

Command (m for help): o

Created a new DOS disklabel with disk identifier 0xe5a2446d.
The old iso9660 signature will be removed by a write command.

Command (m for help): p
Disk /dev/sdd: 28.7 GiB, 30752000000 bytes, 60062500 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
Disklabel type: dos
Disk identifier: 0xe5a2446d

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

파티션 복구

리눅스의 fdisk는 Windows 시스템의 fdisk와 달리 잘못 사용한 경우에 복구가 가능하다. 우선 이전의 실린더 숫자를 적어 두고 파티션을 나눈다. 그러면, 파티션을 잘못하고 저장한 경우 다른 시스템에 연결하여 실린더를 맞추어 이전의 것을 복구할 수 있다. 이것은 보안을 위해서도 사용될 수 있는데, 하드디스크의 실린더 숫자를 적어 놓고 파티션을 다르게 해버리면 파일시스템을 제대로 사용할 수 없게 된다. 이렇게 실린더 숫자를 적어 두는 것은 불시의 사고에 대비하는 방법이기도 한데, 만약 fdisk를 하면서 실수로 잘못 저장한 경우에 이전의 실린더 번호대로 복구하면 이전 상태 그대로 된다.

See also

Favorite site

Tutorials

References


  1. Joy_and_books_-Linux_sysadmin-_fdisk.pdf