본문 바로가기
운영체제

RAID 2

by ^..^v 2019. 5. 30.
728x90
반응형

 

HDD 장치별 파티션 생성

/dev/sdb ~ /dev/sdj 동일하게 아래 작업을 반복

root@server:~# ls -l /dev/sd* ⇐ HDD 확인
brw-rw---- 1 root disk 8,   0  5월 29 22:50 /dev/sda
brw-rw---- 1 root disk 8,   1  5월 29 22:50 /dev/sda1
brw-rw---- 1 root disk 8,   2  5월 29 22:50 /dev/sda2
brw-rw---- 1 root disk 8,  16  5월 29 22:50 /dev/sdb ⇐ 파티션이 생성되지 않은 HDD
brw-rw---- 1 root disk 8,  32  5월 29 22:50 /dev/sdc ⇐
brw-rw---- 1 root disk 8,  48  5월 29 22:50 /dev/sdd ⇐
brw-rw---- 1 root disk 8,  64  5월 29 22:50 /dev/sde ⇐
brw-rw---- 1 root disk 8,  80  5월 29 22:50 /dev/sdf ⇐
brw-rw---- 1 root disk 8,  96  5월 29 22:50 /dev/sdg ⇐
brw-rw---- 1 root disk 8, 112  5월 29 22:50 /dev/sdh ⇐
brw-rw---- 1 root disk 8, 128  5월 29 22:50 /dev/sdi ⇐
brw-rw---- 1 root disk 8, 144  5월 29 22:50 /dev/sdj ⇐

root@server:~# fdisk /dev/sdb ⇐ 새롭게 추가한 HDD에 파티션을 생성
 
Welcome to fdisk (util-linux 2.27.1).
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.
Created a new DOS disklabel with disk identifier 0x71499664.

Command (m for help): n ⇐ 파티션 생성
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p ⇐ primary 파티션
Partition number (1-4, default 1): 1 ⇐ 파티션 번호 
First sector (2048-4194303, default 2048): 
Last sector, +sectors or +size{K,M,G,T,P} (2048-4194303, default 4194303): 

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

Command (m for help): t ⇐ 파티션 타입 지정(변경)
Selected partition 1
Partition type (type L to list all types): L

 0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris        
 1  FAT12           27  Hidden NTFS Win 82  Linux swap / So c1  DRDOS/sec (FAT-
 2  XENIX root      39  Plan 9          83  Linux           c4  DRDOS/sec (FAT-
 3  XENIX usr       3c  PartitionMagic  84  OS/2 hidden or  c6  DRDOS/sec (FAT-
 4  FAT16 <32M      40  Venix 80286     85  Linux extended  c7  Syrinx         
 5  Extended        41  PPC PReP Boot   86  NTFS volume set da  Non-FS data    
 6  FAT16           42  SFS             87  NTFS volume set db  CP/M / CTOS / .
 7  HPFS/NTFS/exFAT 4d  QNX4.x          88  Linux plaintext de  Dell Utility   
 8  AIX             4e  QNX4.x 2nd part 8e  Linux LVM       df  BootIt         
 9  AIX bootable    4f  QNX4.x 3rd part 93  Amoeba          e1  DOS access     
 a  OS/2 Boot Manag 50  OnTrack DM      94  Amoeba BBT      e3  DOS R/O        
 b  W95 FAT32       51  OnTrack DM6 Aux 9f  BSD/OS          e4  SpeedStor      
 c  W95 FAT32 (LBA) 52  CP/M            a0  IBM Thinkpad hi ea  Rufus alignment
 e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a5  FreeBSD         eb  BeOS fs        
 f  W95 Ext'd (LBA) 54  OnTrackDM6      a6  OpenBSD         ee  GPT            
10  OPUS            55  EZ-Drive        a7  NeXTSTEP        ef  EFI (FAT-12/16/
11  Hidden FAT12    56  Golden Bow      a8  Darwin UFS      f0  Linux/PA-RISC b
12  Compaq diagnost 5c  Priam Edisk     a9  NetBSD          f1  SpeedStor      
14  Hidden FAT16 <3 61  SpeedStor       ab  Darwin boot     f4  SpeedStor      
16  Hidden FAT16    63  GNU HURD or Sys af  HFS / HFS+      f2  DOS secondary  
17  Hidden HPFS/NTF 64  Novell Netware  b7  BSDI fs         fb  VMware VMFS    
18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fc  VMware VMKCORE 
1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid fd  Linux raid auto ⇐ 요걸로 선택
1c  Hidden W95 FAT3 75  PC/IX           bc  Acronis FAT32 L fe  LANstep        
1e  Hidden W95 FAT1 80  Old Minix       be  Solaris boot    ff  BBT            
Partition type (type L to list all types): fd ⇐ 레이드 형식으로 지정(변경)
Changed type of partition 'Linux' to 'Linux raid autodetect'.

Command (m for help): w ⇐ 파티션 정보 저장
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.


*** /dev/sdb ~ /dev/sdj 모두 동일하게 작업 

root@server:~# ls /dev/sd*  
/dev/sda   /dev/sdb   /dev/sdc1  /dev/sde   /dev/sdf1  /dev/sdh   /dev/sdi1 
/dev/sda1  /dev/sdb1  /dev/sdd   /dev/sde1  /dev/sdg   /dev/sdh1  /dev/sdj 
/dev/sda2  /dev/sdc   /dev/sdd1  /dev/sdf   /dev/sdg1  /dev/sdi   /dev/sdj1 

*** /dev/sdXN 형식의 장치가 추가된 것을 확인할 수 있음
*** X : HDD 장치 이름
*** N : 파티션 번호

 

mdadm 패키지 설치

root@server:~# apt-get install -y mdadm 

root@server:~# reboot  


RAID 생성

root@server:~# fdisk -l /dev/sdb ⇐ /dev/sdb 장치의 파티션 정보를 조회
Disk /dev/sdb: 2 GiB, 2147483648 bytes, 4194304 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: 0x71499664 

Device     Boot Start     End Sectors Size Id Type 
/dev/sdb1        2048 4194303 4192256   2G fd Linux raid autodetect ⇐ /dev/sdb 장치의 파티션 정보

root@server:~# fdisk -l /dev/sdc ⇐ /dev/sdc 장치의 파티션 정보를 조회
Disk /dev/sdc: 1 GiB, 1073741824 bytes, 2097152 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: 0x87fa3045 

Device     Boot Start     End Sectors  Size Id Type 
/dev/sdc1        2048 2097151 2095104 1023M fd Linux raid autodetect ⇐ /dev/sdc 장치의 파티션 정보 

root@server:~# mdadm --create /dev/md9 --level=linear --raid-devices=2 /dev/sdb1 /dev/sdc1 ⇐ RAID를 구성(생성) 
mdadm: Defaulting to version 1.2 metadata 
mdadm: array /dev/md9 started. 

root@server:~# mdadm --detail --scan ⇐ RAID 정보 조회
ARRAY /dev/md9 metadata=1.2 name=server:9 UUID=3953c26d:3e5f2393:67523452:a252342b 

root@server:~# mkfs.ext4 /dev/md9 ⇐ 파일 시스템을 지정 
mke2fs 1.42.13 (17-May-2015) 
Creating filesystem with 785408 4k blocks and 196608 inodes 
Filesystem UUID: 15c3eb76-222b-4443-9d17-f714d9389ae3 
Superblock backups stored on blocks:  
32768, 98304, 163840, 229376, 294912 

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

root@server:~# mkdir /raidLinear ⇐ 마운트 디렉터리를 생성 
root@server:~# mount /dev/md9 /raidLinear ⇐ 마운트 
root@server:~# ls /raidLinear/ 
lost+found 
root@server:~# df ⇐ 디스크 상태 확인 
Filesystem     1K-blocks    Used Available Use% Mounted on 
udev              479660       0    479660   0% /dev 
tmpfs              99848    6360     93488   7% /run 
/dev/sda2       78499768 4400604  70088516   6% / 
tmpfs             499232      12    499220   1% /dev/shm 
tmpfs               5120       0      5120   0% /run/lock 
tmpfs             499232       0    499232   0% /sys/fs/cgroup 
tmpfs              99848      36     99812   1% /run/user/0 
/dev/sr0         1451056 1451056         0 100% /media/root/Ubuntu 16.04 LTS amd64 
/dev/md9         3026704    4608   2848632   1% /raidLinear ⇐ 2G + 1G = 3G RAID 구성


마운트 및 RAID 정보 저장 후 리부팅

root@server:~# gedit /etc/fstab ⇐ fstab에 마운트 정보 저장
/dev/md9 /raidLinear ext4 defaults 0 0 


*** mdadm 버그 때문에 추가 설정 *** 

root@server:~# mdadm --detail --scan ⇐ RAID 정보 조회
ARRAY /dev/md9 metadata=1.2 name=server:9 UUID=e4459886:398d4f24:cf8d7d83:963d0d2b 

root@server:~# gedit /etc/mdadm/mdadm.conf ⇐ RAID 정보 추가 
ARRAY /dev/md9 metadata=1.2 UUID=e4459886:398d4f24:cf8d7d83:963d0d2b 

root@server:~# cat /etc/mdadm/mdadm.conf ⇐ RAID 정보 추가 확인 
    : 
ARRAY /dev/md9 metadata=1.2 UUID=e4459886:398d4f24:cf8d7d83:963d0d2b 

root@server:~# update-initramfs -u ⇐ initramfs 업데이트
update-initramfs: Generating /boot/initrd.img-4.4.0-21-generic 

root@server:~# reboot ⇐ 리부팅



728x90
반응형

'운영체제' 카테고리의 다른 글

Ubuntu Server 설치  (0) 2020.09.03
VirtualBox에 Ubuntu Desktop 설치  (0) 2020.09.02
RAID 1  (0) 2019.05.30
리눅스 필수 개념과 명령어 01  (0) 2019.05.29
하드디스크 관리 2  (0) 2019.05.11

댓글