home / 회원가입 / 로그인
인스타공백닷컴
인스타 결과 Font
자유게시판
CentOS 7.x 하드디스크 추가와 마운트 하기
오분순삭 2022-01-22 00:06:42 | 조회: 486 | 댓글: 0

OS : CentOS 7

 

 



Linux 서버에 100GB HDD를 새로 추가하여 /data (100GB) 파티션을 생성하겠습니다.

 

 

 



작업 전, df -Th 명령으로 확인한 현재 디스크 용량 상태입니다.

[root@localhost ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda3 xfs 96G 1.4G 95G 2% /
devtmpfs devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs tmpfs 3.9G 8.3M 3.9G 1% /run
tmpfs tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda1 xfs 506M 128M 379M 26% /boot
tmpfs tmpfs 782M 0 782M 0% /run/user/0
cs

 

작업 전, parted -l 명령으로 확인한 현재 디스크 상태입니다.

[root@localhost ~]# parted -l
Model: Msft Virtual Disk (scsi)
Disk /dev/sda: 107GB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 538MB 537MB primary xfs boot
2 538MB 4833MB 4295MB primary linux-swap(v1)
3 4833MB 107GB 103GB primary xfs

Error: /dev/sdb: unrecognised disk label
Model: Msft Virtual Disk (scsi)
Disk /dev/sdb: 107GB
Sector size (logical/physical): 512B/4096B
Partition Table: unknown
Disk Flags:
cs

 

fdisk -l 명령으로 서버에 추가 장착된 디스크를 확인합니다.

/dev/sdb가 추가되었습니다

[root@localhost ~]# fdisk -l
Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: dos
Disk identifier: 0x000cb19f
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1050623 524288 83 Linux
/dev/sda2 1050624 9439231 4194304 82 Linux swap / Solaris
/dev/sda3 9439232 209715199 100137984 83 Linux
Disk /dev/sdb: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
cs

 

fdisk <디스크명> 명령으로 디스크 파티션 설정을 시작합니다.

[root@localhost ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x3bfb7f75.
The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted.
Command (m for help):
cs

 

m을 입력하면 입력가능한 명령과 명령에 따른 동작을 확인할 수 있습니다.

Command (m for help): mCommand action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition g create a new empty GPT partition table G create an IRIX (SGI) partition table 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)cs

 

d를 입력하여 기존에 설정한 파티션이 있다면 삭제합니다. (파티션 설정이 없다면 아래와 같은 메시지를 볼 수 있습니다.)

Command (m for help): d


No partition is defined yet!
cs

 

n을 입력하여 새 파티션 추가를 시작합니다.

Command (m for help): ncs

 

​추가할 파티션 타입을 선택합니다. 주 파티션 사용을 위해 를 입력합니다.

Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): < ENTER >
Using default response p
cs

 

- BIOS/MBR 기반 하드디스크 드라이브에는 표준 파티션을 최대 4개까지 생성할 수 있습니다. 일반적으로 이러한 표준 파티션은 주 파티션(Primary Partition)으로 지정됩니다. 제한 이상(5개 이상)의 파티션을 생성하기 위해서는 확장 파티션(Extended Partition)을 사용해야 합니다. 이 확장 파티션은 논리 파티션(Logical Partition)이라는 추가 파티션으로 나눌 수 있는 특수한 파티션입니다. 확장 파티션은 그 자체만으로 파일을 저장할 수 없고 추가된 논리 파티션에 저장할 수 있습니다.

 

 

사용할 파티션 번호를 입력합니다. default 값 1 사용을 위해 를 입력합니다.

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

 

시작 섹터를 선택합니다. default 값 2048 사용을 위해 를 입력합니다.

First sector (2048-209715199, default 2048): < ENTER >
Using default value 2048
cs

 

마지막 섹터를 선택합니다. 최대 default 값 사용을 위해 를 입력합니다.

Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199): < ENTER >
Using default value 209715199
Partition 1 of type Linux and of size 100 GiB is set
cs

 

w를 입력하여 파티션 설정을 저장합니다.

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

 

fdisk -l 명령으로 추가된 파티션 영역을 확인할 수 있습니다.


[root@localhost ~]# fdisk -l
Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: dos
Disk identifier: 0x000cb19f
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1050623 524288 83 Linux
/dev/sda2 1050624 9439231 4194304 82 Linux swap / Solaris
/dev/sda3 9439232 209715199 100137984 83 Linux
Disk /dev/sdb: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: dos
Disk identifier: 0x3bfb7f75
Device Boot Start End Blocks Id System
/dev/sdb1 2048 209715199 104856576 83 Linux
cs

 

추가된 파티션 영역 /dev/sdb1을 /data 디렉토리에 마운트 하기 전에 Filesystem을 지정합니다.

기존 다른 파티션과 같이 CentOS 7 기본 Filesystem xfs로 지정하도록 하겠습니다.

[root@localhost ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda3 xfs 96G 1.3G 95G 2% /
devtmpfs devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs tmpfs 3.9G 8.3M 3.9G 1% /run
tmpfs tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda1 xfs 506M 128M 379M 26% /boot
tmpfs tmpfs 782M 0 782M 0% /run/user/0
cs

 

mkfs.xfs <파티션 영역>명령으로 xfs Filesystem을 지정합니다.

[root@localhost ~]# mkfs.xfs /dev/sdb1
meta-data=/dev/sdb1 isize=512 agcount=4, agsize=6553536 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=26214144, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=12799, version=2
= sectsz=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
cs

(지정할 수 있는 Filesystem Type 종류)

[root@localhost ~]# mkfs.
mkfs.btrfs mkfs.cramfs mkfs.ext2 mkfs.ext3 mkfs.ext4 mkfs.minix mkfs.xfs
cs

 

​마운트할 /data 디렉토리를 만들어 줍니다.

[root@localhost ~]# mkdir /datacs

 

/dev/sdb1 파티션 영역을 /data 디렉토리에 마운트합니다.

[root@localhost ~]# mount /dev/sdb1 /datacs

 

df -Th명령으로 마운트 상태를 확인할 수 있습니다.

[root@localhost ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda3 xfs 96G 1.3G 95G 2% /
devtmpfs devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs tmpfs 3.9G 8.3M 3.9G 1% /run
tmpfs tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda1 xfs 506M 128M 379M 26% /boot
tmpfs tmpfs 782M 0 782M 0% /run/user/0
/dev/sdb1 xfs 100G 33M 100G 1% /data
cs

 

시스템 재시작 후에도 마운트를 유지하기 위해 /etc/fstab 내용을 수정합니다.

[root@localhost ~]# vi /etc/fstabcs

 

아래와 같이 내용을 추가합니다.

<마운트 파티션 영역> <마운트 위치> <파일시스템 유형> <마운트 옵션> <파일 체크 옵션>

#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=5802172c-ec11-45fd-b3b2-d304c0c56da7 / xfs defaults 0 0
UUID=93c80928-2543-410e-b506-2ef3217004cc /boot xfs defaults 0 0
UUID=df812037-f55b-42e2-9cfa-802f6d9a6872 swap swap defaults 0 0
/dev/sdb1 /data xfs defaults 1 1
cs
ShortUrl : https://instablank.com/v19468 복사
댓글 리스트 새로고침
등록된 댓글이 없습니다.
댓글 쓰기
욕설 / 비하발언 / 선정적인 표현과 이미지등 금지
후원하기
쿠팡에서 쇼핑하기
KR US JP ES CN
인스타 공백닷컴 instarblank.com
instablank.help@gmail.com