메뉴 건너뛰기

리눅스 하드디스크 추가

관리자 2019.02.12 19:50 조회 수 : 1430

1. 하드디스크 추가, 리눅스 파티션 생성(fdisk)

 

물론 디스크가 먼저 추가되어야 합니다. 물리적인 서버든, 가상서버든 먼저 디스크를 추가합니다.


[root@localhost ~]# df -h   -- > 작업 전 파티션 확인
Filesystem           Size  Used Avail Use% Mounted on 
/dev/mapper/cl-root   46G  3.1G   43G   7% / 
devtmpfs             1.9G     0  1.9G   0% /dev 
tmpfs                1.9G     0  1.9G   0% /dev/shm 
tmpfs                1.9G  8.5M  1.9G   1% /run 
tmpfs                1.9G     0  1.9G   0% /sys/fs/cgroup 
/dev/sda1           1014M  184M  831M  19% /boot 
tmpfs                380M     0  380M   0% /run/user/0 

리눅스(CentOS)를 인스톨 할 때 mininum 기본값으로 설치하면,
대략 위와 같이 파티션이 형성됩니다.



[root@localhost ~]# fdisk -l    --> 파티션을 생성하기 위해서는 fdisk를 사용합니다.

Disk /dev/sdb: 2199.0 GB, 2199023255552 bytes, 4294967296 sectors
--> /dev/sdb 가 2TB 있습니다.

Disk /dev/sda: 53.7 GB, 53687091200 bytes, 104857600 sectors 
--> /dev/sdb, 현재 구성되어 있는 디스크입니다.

   Device Boot      Start         End      Blocks   Id  System 
/dev/sda1   *        2048     2099199     1048576   83  Linux 
/dev/sda2         2099200   104857599    51379200   8e  Linux LVM 




[root@localhost ~]# fdisk /dev/sdb    --> sdb 파티션 생성작업 시작

Command (m for help): p  --> 현재 디스크 상황 보여주기

Disk /dev/sdb: 2199.0 GB, 2199023255552 bytes, 4294967296 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 label type: dos 
Disk identifier: 0x88eb3dc1 

   Device Boot      Start         End      Blocks   Id  System 

Command (m for help): n   -> new의 약자. 디스크를 생성합니다.
Partition type: 
   p   primary (0 primary, 0 extended, 4 free) 
   e   extended 
Select (default p): p 
--> 새롭게 추가한 디스크는 primary로 생성합니다.
Partition number (1-4, default 1): 
First sector (2048-4294967295, default 2048): 
Using default value 2048 
Last sector, +sectors or +size{K,M,G} (2048-4294967294, default 4294967294): 
Using default value 4294967294 
Partition 1 of type Linux and of size 2 TiB is set 
--> 디스크를 나누지 않고 전체를 사용하려면, 기본값으로 전부 엔터 하면 됩니다.
만약 나누려면 sector를 적당한 값으로 나누면 됩니다. 용량단위(MB)로 나눌 수도 있습니다.

Command (m for help): p  --> 디스크 현황 보기

Disk /dev/sdb: 2199.0 GB, 2199023255552 bytes, 4294967296 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 label type: dos 
Disk identifier: 0x88eb3dc1 

   Device Boot      Start         End      Blocks   Id  System 
/dev/sdb1            2048  4294967294  2147482623+  83  Linux 
--> /dev/sdb1 이 새로 생성되었습니다.

Command (m for help): w --> write의 약자. 저장하고 fdisk를 빠져 나옵니다.

 

 

 

 

 

 

 

 


2. 디스크 포맷, 마운트 하기

 

[root@localhost ~]# mkfs.ext4 /dev/sdb1 
--> ext4 파일시스템으로 포맷합니다. ext4가 지원되지 않는 리눅스 시스템은 ext3로 포맷합니다.

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



[root@localhost ~]# mkdir /backup    --> 마운트 할 디렉토리 생성
[root@localhost ~]# mount -t ext4 /dev/sdb1 /backup     -->  생성한 디렉토리에 마운트
[root@localhost ~]# df -h 
Filesystem           Size  Used Avail Use% Mounted on 
/dev/mapper/cl-root   46G  3.1G   43G   7% / 
devtmpfs             1.9G     0  1.9G   0% /dev 
tmpfs                1.9G     0  1.9G   0% /dev/shm 
tmpfs                1.9G  8.5M  1.9G   1% /run 
tmpfs                1.9G     0  1.9G   0% /sys/fs/cgroup 
/dev/sda1           1014M  184M  831M  19% /boot 
tmpfs                380M     0  380M   0% /run/user/0 
/dev/sdb1            2.0T   81M  1.9T   1% /backup 




부팅 될 때 신규로 추가한 디스크를 fstab에 등록하기 위해서는 uuid로 마운트하는 방법과, /dev 위치로 마운트 하는 방법이 있습니다. 어떤 방법을 사용해도 상관없고, /dev 위치로 마운트하는 것이 좀 더 편하지만, uuid로 마운트 해보겠습니다.

[root@localhost ~]# ls -la /dev/disk/by-uuid/ 
total 0 
drwxr-xr-x 2 root root 120 Jun 29 23:25 . 
drwxr-xr-x 5 root root 100 Jun 29 22:46 .. 
lrwxrwxrwx 1 root root  10 Jun 29 22:46 0bdb72af-3279-4852-98e9-d73211f694 -> ../../dm-1 
lrwxrwxrwx 1 root root  10 Jun 29 23:25 47b5d817-f881-423d-b2f6-efa9ba3a8c -> ../../sdb1   --> 신규로 추가한 sdb1 uuid 확인
lrwxrwxrwx 1 root root  10 Jun 29 22:46 4e90cbda-a275-4128-a703-7e28821a90 -> ../../dm-0 
lrwxrwxrwx 1 root root  10 Jun 29 22:46 7a00c89a-cd13-42ac-8f4b-011fd49520 -> ../../sda1 



[root@localhost ~]# vi /etc/fstab  --> fastb 수정 

/dev/mapper/cl-root     /                       xfs     defaults        0 0 
UUID=7a00c89a-cd13-42ac-8f4b-09311fd49520 /boot                   xfs     defaults        0 0 
UUID=47b817-f881-423d-b2f6-ef08a9ba3a8c /backup                 ext4    defaults        1 0 
--> uuid 값으로 마운트 합니다.
#/dev/sdb1                                /backup                 ext4    defaults        1 0 
--> 이 방법도 가능합니다. 위 마운트 값과 중복되면 안되기 때문에 주석처리 했습니다.
/dev/mapper/cl-swap     swap                    swap    defaults        0 0 

fstab 마지막 숫자는 1 0 으로 설정합니다. 마지막 숫자를 1로 하면 일정기간마다 fsck 체크를 하기 때문에, 디스크가 클 경우(1TB 이상)는 반드시 0으로 설정합니다.

서버 리부팅해서 정상적으로 신규디스크가 마운트 되는 지 확인합니다.

번호 제목 글쓴이 날짜 조회 수
34 git, github 사용하기. vscode에서 github 연동하기(2023.02.09) file 관리자 2023.02.08 1298
33 록키리눅스(Rocky Linux) 네트워크 설정하기 - nmcli, nmtui file 관리자 2023.02.01 35627
32 CentOS 종료 대비, 록키 리눅스(Rocky Linux) 설치하기 file 관리자 2023.01.27 1360
31 플래시 설치파일 file 관리자 2021.01.13 356
30 tar 압축하면서 다른 디렉토리에 풀기 file 관리자 2020.11.14 475
» 리눅스 하드디스크 추가 관리자 2019.02.12 1430
28 [MySQL]ERROR 1819 (HY000): Your password does not satisfy the current policy requirements 관리자 2018.12.23 1295
27 [리눅스]phpinfo() 실행 시 하얀 화면이 나타날 경우 대처방법 file 관리자 2018.12.13 3703
26 [리눅스]rsync 설정 후, crontab 스케줄 등록 관리자 2018.08.28 2740
25 [리눅스][XE]백업복구(서버이관) 시 오류-03.사이트 메뉴 편집, 사이트 디자인 설정 출력 안되는 현상 file 관리자 2018.08.27 11124
24 [리눅스][XE]백업복구(서버이관) 시 오류-02.아파치 rewrite에러 file 관리자 2018.08.27 516
23 [리눅스][XE]백업복구(서버이관) 시 오류-01.No matching DirectoryIndex (index.html) fonud 오류 file 관리자 2018.08.27 1461
22 [리눅스][XE][오류]msg_is_not_administrator file 관리자 2018.08.08 1242
21 [리눅스]CentOS에서 하드디스크 추가 관리자 2018.03.21 8843
20 [리눅스]리눅스 파일 압축 암호 설정 및 해제(ZIP) 관리자 2017.07.30 18083
19 [리눅스]CentOS 7,최신 APM 소스설치-5) PHP, gd library jpeg support file 관리자 2017.02.21 1853
18 [리눅스]CentOS 7 root password 분실 file 관리자 2016.12.27 6353
17 [리눅스]vsftpd ftp 파일전송오류(451 Failure writing to local file) 관리자 2016.12.20 4117
16 [리눅스]APM(apache+php+mysql) 다른서버로 이관하기(백업-복구하기) 관리자 2016.09.12 4673
15 [리눅스]XE(XpressEngine)설정 file 관리자 2016.07.26 684