로그인

검색

[ubuntu server 22.04] 파티션 만들기 (fdisk)

[ubuntu server 22.04] 파티션 만들기 (fdisk)

 

1. 기본 명령어

 

m - manual/help
p - 파티션테이블 보여주기
n - 새로운 파티션 만들기
d - 파티션 삭제
w - 저장하고 나가기
q - 저장안하고 나가기

 

 

2. 디스크 할당

+4G   ; 4g 만큼 할당  (= +4000M)

 

 

 

hs7@hcp:~$ lsblk

NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
loop0         7:0    0 59.8M  1 loop /snap/core20/2321
loop1         7:1    0 59.8M  1 loop /snap/core20/2267
loop2         7:2    0 77.4M  1 loop /snap/lxd/27950
loop3         7:3    0 77.4M  1 loop /snap/lxd/28384
loop4         7:4    0 33.7M  1 loop /snap/snapd/21467
loop5         7:5    0 33.7M  1 loop /snap/snapd/21761
sda           8:0    1 29.1G  0 disk                                                  #여기에 파티션만듬
mmcblk0     179:0    0 14.8G  0 disk
├─mmcblk0p1 179:1    0  256M  0 part /boot/firmware
└─mmcblk0p2 179:2    0 14.6G  0 part /


hs7@hcp:~$ sudo fdisk /dev/sda

Welcome to fdisk (util-linux 2.37.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

The device contains 'ext4' signature and it will be removed by a write command. See fdisk(8) man page and --wipe option for more details.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x68a7b706.

Command (m for help): p                                           #기존 파티션 살펴보기
Disk /dev/sda: 29.12 GiB, 31266439168 bytes, 61067264 sectors
Disk model: Storage Device
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: 0x68a7b706

 

Command (m for help): n                                    #새로운 파티션 만듬
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p):

Using default response p.
Partition number (1-4, default 1):
First sector (2048-61067263, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-61067263, default 61067263): +4G                      #4기가 선언

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

 

Command (m for help): n                                    #새로운 파티션 만듬
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p):

Using default response p.
Partition number (2-4, default 2):
First sector (8390656-61067263, default 8390656):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (8390656-61067263, default 61067263):

Created a new partition 2 of type 'Linux' and of size 25.1 GiB.        

                       

Command (m for help): p                                         #파티션 정보보기
Disk /dev/sda: 29.12 GiB, 31266439168 bytes, 61067264 sectors
Disk model: Storage Device
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: 0x68a7b706

Device     Boot   Start      End  Sectors  Size Id Type
/dev/sda1          2048  8390655  8388608    4G 83 Linux
/dev/sda2       8390656 61067263 52676608 25.1G 83 Linux

 

Command (m for help): w                              #저장하고 나가기
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

 

hs7@hcp:~$ lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
loop0         7:0    0 59.8M  1 loop /snap/core20/2321
loop1         7:1    0 59.8M  1 loop /snap/core20/2267
loop2         7:2    0 77.4M  1 loop /snap/lxd/27950
loop3         7:3    0 77.4M  1 loop /snap/lxd/28384
loop4         7:4    0 33.7M  1 loop /snap/snapd/21467
loop5         7:5    0 33.7M  1 loop /snap/snapd/21761
sda           8:0    1 29.1G  0 disk
├─sda1        8:1    1    4G  0 part
└─sda2        8:2    1 25.1G  0 part

mmcblk0     179:0    0 14.8G  0 disk
├─mmcblk0p1 179:1    0  256M  0 part /boot/firmware
└─mmcblk0p2 179:2    0 14.6G  0 part /
hs7@hcp:~$

 

 

 

 

3. 만든 파티션 포멧하기

hs7@hcp:~$ sudo mkfs.ext4 /dev/sda2
mke2fs 1.46.5 (30-Dec-2021)
Creating filesystem with 6584576 4k blocks and 1646592 inodes
Filesystem UUID: fe52be67-415b-4a40-8e85-f2d57e83f62c
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000

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

hs7@hcp:~$

 

 

 

 

 

 

이 게시물을

이 댓글을 삭제하시겠습니까?