[Linux] Rocky Linux 9.5 FDISK MBR 파티셔닝 : ext4/XFS 포맷과 fstab 자동 마운트






1. 개요

  • 이 문서는 fdisk를 사용해 MBR(DOS) 디스크에 파티션을 생성하고, ext4/XFS 파일시스템을 포맷·마운트/etc/fstab에 등록했다가, 안전하게 해제·삭제하는 전 과정을 단계별로 설명합니다.
  • 예시는 /dev/vdb 128GiB 디스크에 64GiB ext4 + 64GiB XFS 2개 파티션을 생성하는 흐름을 기반으로 합니다.
  • 마지막에는 파티션을 삭제하여 원상복구하는 방법까지 포함합니다.



2. 버전

  • Rocky Linux 9.5



3. 설명




3-1. MBR(DOS Disklabel)

  • 레거시 파티션 방식입니다.
  • 기본적으로 최대 4개의 Primary 파티션을 지원하며, 약 2 TiB 한계 등 제약이 있습니다.



3-2. GPT

  • 현대적 파티션 방식입니다.
  • 대용량·다수 파티션에 유리하며, fdisk에서 g로 생성하실 수 있습니다.



3-3. Primary Partition

  • MBR 기준 기본 파티션 유형입니다.



3-4. UUID/PARTUUID

  • 파일시스템/파티션의 고유 식별자입니다.
  • fstab에 UUID를 사용하시면 장치명 변경에도 안전합니다.



3-5. /etc/fstab

  • 부팅 시 자동 마운트를 정의하는 설정 파일입니다.
번호필드명의미대표 입력 예시핵심 포인트
1spec무엇을 마운트? (소스)UUID=...PARTUUID=.../dev/nvme0n1p2/dev/mapper/vg/lvserver:/exp(NFS), //srv/share(CIFS), tmpfsUUID 권장 (blkidlsblk -f로 확인)
2file어디에 마운트? (대상 경로)//home/data/boot/efinone(swap)디렉터리 미리 생성필요
3vfstype파일시스템 유형ext4xfsvfatbtrfsswapnfscifstmpfsiso9660ntfs-3gbind 마운트는 보통 none 사용 + 옵션에 bind
4options마운트 옵션(쉼표로 나열)defaultsnofail_netdevro/rwnoexecnosuidnodevnoatime/relatimediscardx-systemd.automountuid=,gid=(CIFS/FAT)용도/FS별 최적화(아래 템플릿 참고)
5dumpdump 백업 사용 여부0(대부분), 1(백업 대상)거의 항상 0
6pass부팅 시 fsck 순서1(루트), 2(그 외), 0(검사 안 함)XFS/네트워크/ISO 등은 0 권장



4. DISK 확인

# fdisk -l


출력 예시:

Disk /dev/vda: 256 GiB, 274877906944 bytes, 536870912 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: 0x27fda27d

Device     Boot   Start       End   Sectors  Size Id Type
/dev/vda1          2048   8390655   8388608    4G 82 Linux swap / Solaris
/dev/vda2  *    8390656 536870911 528480256  252G 83 Linux

Disk /dev/vdb: 128 GiB, 137438953472 bytes, 268435456 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



5. Partition 생성




5-1. 생성(원하는 용량으로 생성)

# fdisk /dev/vdb


설정 예시:

Command (m for help): n

Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): <ENTER>
Using default response p.

Partition number (1-4, default 1): <ENTER>

First sector (2048-268435455, default 2048): <ENTER>

Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-268435455, default 268435455): +64G

Created a new partition 1 of type 'Linux' and of size 64 GiB.



5-2. 확인

Command (m for help): p


출력 예시:

Disk /dev/vdb: 128 GiB, 137438953472 bytes, 268435456 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: 0xdfd86f8e

Device     Boot Start       End   Sectors Size Id Type
/dev/vdb1        2048 134219775 134217728  64G 83 Linux



5-3. 추가 생성(나머지 전체)

Command (m for help): n

Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): <ENTER>
Using default response p.

Partition number (2-4, default 2): <ENTER>

First sector (134219776-268435455, default 134219776): <ENTER>

Last sector, +/-sectors or +/-size{K,M,G,T,P} (134219776-268435455, default 268435455): <ENTER>
Created a new partition 2 of type 'Linux' and of size 64 GiB.



5-4. 확인

Command (m for help): p


출력 예시:

Disk /dev/vdb: 128 GiB, 137438953472 bytes, 268435456 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: 0xdfd86f8e

Device     Boot     Start       End   Sectors Size Id Type
/dev/vdb1            2048 134219775 134217728  64G 83 Linux
/dev/vdb2       134219776 268435455 134215680  64G 83 Linux



5-5. 저장 후 종료

Command (m for help): wq



5-6. 생성 확인

# fdisk -l /dev/vdb


출력 예시:

Disk /dev/vdb: 128 GiB, 137438953472 bytes, 268435456 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: 0xdfd86f8e

Device     Boot     Start       End   Sectors Size Id Type
/dev/vdb1            2048 134219775 134217728  64G 83 Linux
/dev/vdb2       134219776 268435455 134215680  64G 83 Linux



6. 파일시스템 생성




6-1. ext4

# mkfs.ext4 /dev/vdb1 


출력 예시:

mke2fs 1.46.5 (30-Dec-2021)
Discarding device blocks: done                            
Creating filesystem with 16777216 4k blocks and 4194304 inodes
Filesystem UUID: 55212d85-8e23-49e0-a494-c8e4f6954dfc
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
	4096000, 7962624, 11239424

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (131072 blocks): done
Writing superblocks and filesystem accounting information: done   



6-2. xfs

# mkfs.xfs /dev/vdb2 


출력 예시:

meta-data=/dev/vdb2              isize=512    agcount=4, agsize=4194240 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1    bigtime=1 inobtcount=1 nrext64=0
data     =                       bsize=4096   blocks=16776960, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=16384, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
Discarding blocks...Done.



7. MOUNT




7-1. 수동 마운트

# mkdir /mnt/{ext4,xfs}
# mount /dev/vdb1 /mnt/ext4/
# mount /dev/vdb2 /mnt/xfs/



7-2. 확인

# df -Th


출력 예시:

Filesystem     Type      Size  Used Avail Use% Mounted on
devtmpfs       devtmpfs  4.0M     0  4.0M   0% /dev
tmpfs          tmpfs      16G     0   16G   0% /dev/shm
tmpfs          tmpfs     6.3G  8.7M  6.3G   1% /run
/dev/vda2      xfs       252G   15G  238G   6% /
tmpfs          tmpfs     3.2G  4.0K  3.2G   1% /run/user/0
/dev/vdb1      ext4       63G   24K   60G   1% /mnt/ext4
/dev/vdb2      xfs        64G  489M   64G   1% /mnt/xfs



7-3. 자동 마운트 설정



7-3-1. UUID 확인

# blkid /dev/vdb1


출력 예시:

/dev/vdb1: UUID="55212d85-8e23-49e0-a494-c8e4f6954dfc" TYPE="ext4" PARTUUID="dfd86f8e-01"


7-3-2. /etc/fstab 설정

# vi /etc/fstab 


설정 예시:

+ UUID=55212d85-8e23-49e0-a494-c8e4f6954dfc       /mnt/ext4       ext4    defaults        0 0
+ /dev/vdb2                                       /mnt/xfs        xfs     defaults        0 0



7-4. 재부팅

# reboot



7-5. 확인

# df -Th


출력 예시:

Filesystem     Type      Size  Used Avail Use% Mounted on
devtmpfs       devtmpfs  4.0M     0  4.0M   0% /dev
tmpfs          tmpfs      16G     0   16G   0% /dev/shm
tmpfs          tmpfs     6.3G  8.7M  6.3G   1% /run
/dev/vda2      xfs       252G   15G  238G   6% /
tmpfs          tmpfs     3.2G  4.0K  3.2G   1% /run/user/0
/dev/vdb1      ext4       63G   24K   60G   1% /mnt/ext4
/dev/vdb2      xfs        64G  489M   64G   1% /mnt/xfs



8. Partition 삭제




8-1. /etc/fstab 설정 삭제

# vi /etc/fstab


설정 예시:

- UUID=55212d85-8e23-49e0-a494-c8e4f6954dfc       /mnt/ext4       ext4    defaults        0 0
- /dev/vdb2                                       /mnt/xfs        xfs     defaults        0 0



8-2. /etc/fstab 확인

# cat /etc/fstab 


출력 예시:

UUID=2843d0a7-070f-4d68-b456-7096e8d328a6 /                       xfs     defaults        0 0
UUID=9ac41100-cedc-4a7d-aac0-0dc89de9deb2 none                    swap    defaults        0 0



8-3. 마운트 해제

# umount /mnt/ext4 /mnt/xfs
# df -Th


출력 예시:

Filesystem     Type      Size  Used Avail Use% Mounted on
devtmpfs       devtmpfs  4.0M     0  4.0M   0% /dev
tmpfs          tmpfs      16G     0   16G   0% /dev/shm
tmpfs          tmpfs     6.3G  8.7M  6.3G   1% /run
/dev/vda2      xfs       252G   15G  238G   6% /
tmpfs          tmpfs     3.2G  4.0K  3.2G   1% /run/user/0



8-4. Partition 삭제

# fdisk /dev/vdb


설정 예시:

Command (m for help): p
Disk /dev/vdb: 128 GiB, 137438953472 bytes, 268435456 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: 0xdfd86f8e

Device     Boot     Start       End   Sectors Size Id Type
/dev/vdb1            2048 134219775 134217728  64G 83 Linux
/dev/vdb2       134219776 268435455 134215680  64G 83 Linux

Command (m for help): d

Partition number (1,2, default 2): 1
Partition 1 has been deleted.



8-5. 삭제 확인

Command (m for help): p


출력 예시:

Disk /dev/vdb: 128 GiB, 137438953472 bytes, 268435456 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: 0xdfd86f8e

Device     Boot     Start       End   Sectors Size Id Type
/dev/vdb2       134219776 268435455 134215680  64G 83 Linux



8-6. Partition 추가 삭제

Command (m for help): d
Selected partition 2
Partition 2 has been deleted.



8-7. 확인

Command (m for help): p


출력 예시:

Disk /dev/vdb: 128 GiB, 137438953472 bytes, 268435456 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: 0xdfd86f8e



8-8. 저장 후 종료

Command (m for help): wq



8-9. 삭제 확인

# fdisk -l /dev/vdb 


출력 예시:

Disk /dev/vdb: 128 GiB, 137438953472 bytes, 268435456 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: 0xdfd86f8e



9. FDISK 옵션




9-1. FDISK 옵션 확인

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



9-2. FDISK 여유 공간 확인

Command (m for help): F


출력 예시:

Unpartitioned space /dev/vdb: 128 GiB, 137437904896 bytes, 268433408 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes

Start       End   Sectors  Size
 2048 268435455 268433408  128G



댓글 남기기