Linux 레이드 1 구성 - raid 1 for Ubuntu 16.04

Linux  소프트 레이드 1 구성 - soft raid 1 for Ubuntu 16.04

먼저 fdisk 명령어로 하드 디스크를 확인한다.
First, Check hdd devices list using fdisk command

nawan@sptechlab:~$ sudo fdisk -l
Disk /dev/sda: 232.9 GiB, 250059350016 bytes, 488397168 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: 0x19ddd262

Device     Boot    Start       End   Sectors  Size Id Type
/dev/sda1           2048  31250431  31248384 14.9G 82 Linux swap / Solaris
/dev/sda2  *    31250432 488396799 457146368  218G 83 Linux


Disk /dev/sdb: 232.9 GiB, 250059350016 bytes, 488397168 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: 0xfb19af56

Device     Boot     Start       End   Sectors   Size Id Type
/dev/sdb1  *           63 204796619 204796557  97.7G  7 HPFS/NTFS/exFAT
/dev/sdb2       204796620 488392064 283595445 135.2G  7 HPFS/NTFS/exFAT

확인 결과 250G /dev/sda 와 /dev/sdb 이렇게 두개의 하드 디스크를 확인 할 수 있다. 그리고 이 디스크를 이용하여 레이드를 구성 할 것이다.
I'm gonna make RAID 1 that I found two hdd disk /dev/sda and /dev/sdb.

/dev/sda 와 /dev/sdb의 파티션을 설정 한다.
Set up the partitions on /dev/sda and /dev/sdb

nawan@sptechlab:~$ sudo fdisk /dev/sda

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.


Command (m for help): n
To create more partitions, first replace a primary with an extended partition.


그러나 이미 하드디스크에는 파티션이 잡혀 있으므로 삭제 해준다.
But i can't make partition because it already has partitions. so i need to erase partitions using 'd' command

Command (m for help): d
Partition number (1,2, default 2): 1

Partition 1 has been deleted.

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

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
Partition number (1-4, default 1): ENTER
First sector (2048-488397167, default 2048): ENTER
Last sector, +sectors or +size{K,M,G,T,P} (2048-488397167, default 488397167): ENTER

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

Command (m for help): t
Selected partition 1
Partition type (type L to list all types): l //뭐가 있는지 궁금해서 L리스트로 확인 하였다.
//I just check list all types

 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 'FAT12' 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 하드 디스크도 동일 하게 작업 해 준다.
And do it again same things on /dev/sdb

nawan@sptechlab:~$ sudo fdisk /dev/sdb
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.

Command (m for help): d
Partition number (1,2, default 2): 1

Partition 1 has been deleted.

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

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
Partition number (1-4, default 1): ENTER
First sector (2048-488397167, default 2048): ENTER
Last sector, +sectors or +size{K,M,G,T,P} (2048-488397167, default 488397167): ENTER

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

Command (m for help): t
Selected partition 1
Partition type (type L to list all types): fd
Changed type of partition 'Linux' to 'Linux raid autodetect'.

Command (m for help): p // check a partition info 
Disk /dev/sdb: 232.9 GiB, 250059350016 bytes, 488397168 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: 0xfb19af56

Device     Boot Start       End   Sectors   Size Id Type
/dev/sdb1        2048 488397167 488395120 232.9G fd Linux raid autodetect

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

그리고 fdisk 를 이용하여 설정한 파티션이 정상적으로 되었는지 확인한다.
you can find partitions info /dev/sda, /dev/sdb

nawan@sptechlab:~$ sudo fdisk -l
Disk /dev/sda: 232.9 GiB, 250059350016 bytes, 488397168 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: 0x19ddd262

Device     Boot Start       End   Sectors   Size Id Type
/dev/sda1        2048 488397167 488395120 232.9G fd Linux raid autodetect


Disk /dev/sdb: 232.9 GiB, 250059350016 bytes, 488397168 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: 0xfb19af56

Device     Boot Start       End   Sectors   Size Id Type
/dev/sdb1        2048 488397167 488395120 232.9G fd Linux raid autodetect


mdadm을 이용해 레이드를 구성한뒤 ext4로 포멧한다.
Make a Raid 1 /dev/md device using mdadm, and format the /dev/md device to ext4.
//i named it md1

nawan@sptechlab:~$ sudo mdadm --create /dev/md1 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1
mdadm: Note: this array has metadata at the start and
    may not be suitable as a boot device.  If you plan to
    store '/boot' on this device please ensure that
    your boot-loader understands md/v1.x metadata, or use
    --metadata=0.90
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md1 started.

nawan@sptechlab:~$ sudo mkfs.ext4 /dev/md1
mke2fs 1.42.13 (17-May-2015)
Creating filesystem with 61016608 4k blocks and 15261696 inodes
Filesystem UUID: a10cae37-0ed4-449e-9447-82e9c084dba9
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872

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

마운트할 디렉터리를 만들고 /dev/md 를 마운트 한다.
Make a directory and mount with /dev/md

nawan@sptechlab:/$ sudo mkdir /raid1
nawan@sptechlab:/$ sudo mount /dev/md1 /raid1

마지막으로 UUID 를 확인하여 재부팅이 되어도 마운트 될 수 있도록 fstab에 등록한다.
Last, check the UUID and register on the fstab, so that even if you reboot the system , it can be mounted

nawan@sptechlab:/$ lsblk -o NAME,UUID
NAME    UUID
sda
└─sda1  ceebf8da-d7a3-7997-b9bf-46f38d648b30
  └─md1 a10cae37-0ed4-449e-9447-82e9c084dba9
sdb
└─sdb1  ceebf8da-d7a3-7997-b9bf-46f38d648b30
  └─md1 a10cae37-0ed4-449e-9447-82e9c084dba9

nawan@sptechlab:/$ vim /etc/fstab

# raid 1 /dev/md1 //add this lines on /etc/fstab

UUID=a10cae37-0ed4-449e-9447-82e9c084dba9 /raid1     ext4    defaults        0       0

md1 이 잘 마운트 됐는지 확인한다.
nawan@sptechlab:/$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/md1        229G   60M  218G   1% /raid1

댓글

가장 많이 본 글