Environment

  • Node: H410I-plus, i3-10100 데스크탑 환경
  • OS: Ubuntu 20.04.3 LTS (GNU/Linux 5.4.0-91-generic x86_64)

Current Status

우선 레이드에 추가할 하드를 설치하고 cat /proc/mdstat을 통해 현재 레이드 상태를 확인:

$ cat /proc/mdstat
Personalities : [raid6] [raid5] [raid4] [linear] [multipath] [raid0] [raid1] [raid10]
md0 : active raid5 sda1[0] sdd1[3] sdb1[1]
      7813769216 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/3] [UUU]
      bitmap: 0/30 pages [0KB], 65536KB chunk

unused devices: <none>

현재 레이드는 레벨5, 3개의 파티션(sda1, sdb1, sdd1)으로 구성되어 있다. 아직 새로운 하드는 포맷도 안 한 상태이므로 목록에 뜨지 않는다. 우선 새 하드를 포맷 해야겠다.

HDD Format

파티션 생성을 위해 parted를 실행하면

$ sudo parted /dev/sdc
GNU Parted 3.3
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted)

와 같이 뜬다. help를 입력하면 도움말이 뜬다:

(parted) help
  align-check TYPE N                       check partition N for TYPE(min|opt) alignment
  help [COMMAND]                           print general help, or help on COMMAND
  mklabel,mktable LABEL-TYPE               create a new disklabel (partition table)
  mkpart PART-TYPE [FS-TYPE] START END     make a partition
  name NUMBER NAME                         name partition NUMBER as NAME
  print [devices|free|list,all|NUMBER]     display the partition table, available devices, free space, all found partitions, or a particular partition
  quit                                     exit program
  rescue START END                         rescue a lost partition near START and END
  resizepart NUMBER END                    resize partition NUMBER
  rm NUMBER                                delete partition NUMBER
  select DEVICE                            choose the device to edit
  disk_set FLAG STATE                      change the FLAG on selected device
  disk_toggle [FLAG]                       toggle the state of FLAG on selected device
  set NUMBER FLAG STATE                    change the FLAG on partition NUMBER
  toggle [NUMBER [FLAG]]                   toggle the state of FLAG on partition NUMBER
  unit UNIT                                set the default unit to UNIT
  version                                  display the version number and copyright information of GNU Parted
(parted)

파티션 생성을 위해서 mkpart를 입력하면

(parted) mkpart
Error: /dev/sdc: unrecognised disk label
(parted)

와 같은 에러 메세지와 함께 파티션이 만들어지지 않는다. 우선 레이블을 생성해야겠다. 단순히 mklabel만 치면

(parted) mklabel
New disk label type?

와 같이 레이블 방식을 묻기에 gpt라고 다시 지정하였다. 이제는 print를 하면 파티션 테이블이 제대로 뜬다. (아직 아무 파티션도 없지만.)

(parted) mklabel
New disk label type? gpt
(parted) print
Model: ATA HGST HUS726T4TAL (scsi)
Disk /dev/sdc: 4001GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start  End  Size  File system  Name  Flags

(parted)

이제 레이드 구성을 위한 파티션을 추가하면,

(parted) mkpart
Partition name?  []? raid01
File system type?  [ext2]? ext4
Start? 1049kB
End? 4001GB
(parted) set 1 raid on
(parted) align-check
alignment type(min/opt)  [optimal]/minimal? optimal
Partition number? 1
1 aligned
(parted) print
Model: ATA HGST HUS726T4TAL (scsi)
Disk /dev/sdc: 4001GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name    Flags
 1      1049kB  4001GB  4001GB  ext4         raid01  raid

(parted)

와 같이 파티션이 생성되었다. quit을 입력하여 parted를 종료한다.

Grow RAID5

이제 기존의 레이드 파티션에 새로운 멤버를 추가할 차례. 우선 기존의 파티션을 좀 더 자세히 살펴본다:

$ sudo mdadm --detail /dev/md0
/dev/md0:
           Version : 1.2
     Creation Time : Wed Jan 27 13:48:19 2021
        Raid Level : raid5
        Array Size : 7813769216 (7451.79 GiB 8001.30 GB)
     Used Dev Size : 3906884608 (3725.90 GiB 4000.65 GB)
      Raid Devices : 3
     Total Devices : 3
       Persistence : Superblock is persistent

     Intent Bitmap : Internal

       Update Time : Thu Dec  9 04:33:08 2021
             State : clean
    Active Devices : 3
   Working Devices : 3
    Failed Devices : 0
     Spare Devices : 0

            Layout : left-symmetric
        Chunk Size : 512K

Consistency Policy : bitmap

              Name : jeong-server:0  (local to host jeong-server)
              UUID : cd20c299:f82ac683:c031d89a:3d4dd058
            Events : 35680

    Number   Major   Minor   RaidDevice State
       0       8        1        0      active sync   /dev/sda1
       1       8       17        1      active sync   /dev/sdb1
       3       8       49        2      active sync   /dev/sdd1

우선 이 레이드에 새로운 하드를 추가해주자.

$ sudo mdadm --add /dev/md0 /dev/sdc1
mdadm: added /dev/sdc1

이후 다시 레이드 구성을 살펴보면,

$ sudo mdadm --detail /dev/md0
/dev/md0:
           Version : 1.2
     Creation Time : Wed Jan 27 13:48:19 2021
        Raid Level : raid5
        Array Size : 7813769216 (7451.79 GiB 8001.30 GB)
     Used Dev Size : 3906884608 (3725.90 GiB 4000.65 GB)
      Raid Devices : 3
     Total Devices : 4
       Persistence : Superblock is persistent

     Intent Bitmap : Internal

       Update Time : Thu Dec  9 04:38:28 2021
             State : clean
    Active Devices : 3
   Working Devices : 4
    Failed Devices : 0
     Spare Devices : 1

            Layout : left-symmetric
        Chunk Size : 512K

Consistency Policy : bitmap

              Name : jeong-server:0  (local to host jeong-server)
              UUID : cd20c299:f82ac683:c031d89a:3d4dd058
            Events : 35681

    Number   Major   Minor   RaidDevice State
       0       8        1        0      active sync   /dev/sda1
       1       8       17        1      active sync   /dev/sdb1
       3       8       49        2      active sync   /dev/sdd1

       4       8       33        -      spare   /dev/sdc1

와 같이 새로운 하드는 working device가 아닌 spare device로 들어가 있음을 알 수 있다. 이 상태로 놔두면 새로 추가된 드라이브는 일단은 그냥 가만히 있는다. 열일중인 세 개의 하드 중 하나에 문제가 발생하면 그때 리빌드가 진행되면서 스페어 하드가 문제의 하드를 대신할 것이다. 하지만 나는 지금 이 하드를 추가해서 레이드 용량을 늘리길 원한다.

$ sudo mdadm --grow --raid-devices=4 /dev/md0

를 입력하면 레이드5 구성의 하드디스크는 이제 3개에서 4개로 증가한다. 스페어도 활성화가 된다. 다시 레이드 정보를 띄어보면

$ sudo mdadm --detail /dev/md0
/dev/md0:
           Version : 1.2
     Creation Time : Wed Jan 27 13:48:19 2021
        Raid Level : raid5
        Array Size : 7813769216 (7451.79 GiB 8001.30 GB)
     Used Dev Size : 3906884608 (3725.90 GiB 4000.65 GB)
      Raid Devices : 4
     Total Devices : 4
       Persistence : Superblock is persistent

     Intent Bitmap : Internal

       Update Time : Thu Dec  9 04:42:33 2021
             State : clean, reshaping
    Active Devices : 4
   Working Devices : 4
    Failed Devices : 0
     Spare Devices : 0

            Layout : left-symmetric
        Chunk Size : 512K

Consistency Policy : bitmap

    Reshape Status : 0% complete
     Delta Devices : 1, (3->4)

              Name : jeong-server:0  (local to host jeong-server)
              UUID : cd20c299:f82ac683:c031d89a:3d4dd058
            Events : 35697

    Number   Major   Minor   RaidDevice State
       0       8        1        0      active sync   /dev/sda1
       1       8       17        1      active sync   /dev/sdb1
       3       8       49        2      active sync   /dev/sdd1
       4       8       33        3      active sync   /dev/sdc1

와 같이 뜬다. /proc/mdstat의 출력 결과도 달라져 있을 것이다:

$ cat /proc/mdstat
Personalities : [raid6] [raid5] [raid4] [linear] [multipath] [raid0] [raid1] [raid10]
md0 : active raid5 sdc1[4] sda1[0] sdd1[3] sdb1[1]
      7813769216 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/4] [UUUU]
      [>....................]  reshape =  0.2% (8173216/3906884608) finish=1298.4min speed=50042K/sec
      bitmap: 0/30 pages [0KB], 65536KB chunk

unused devices: <none>

레이드 멤버를 추가했다고 당장 용량이 늘어나지는 않고, 약 1300분=22시간 정도의 reshape 시간이 필요하다고 뜬다. 하루 정도 기다리면 용량이 늘어나 있을 것이다.

Resize filesystem

이건 22시간 기다린 후에 작성하겠음.
Reshape이 완료되어도 레이드의 크기는 늘어나 있지 않다.

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
...

/dev/md0        7.3T  4.8T  2.1T  70% /mnt/raid01
...

전체 용량이 8.0TB(7.3TiB)에서 4.0TB(3.6TiB) 증가한 12TB(11TiB)가 되어야 하지만 기존의 용량 그대로이다. (논리) 파티션의 크기는 늘어났으나 파일시스템이 그 크기를 활용하지 못하고 있다. 파티션을 최대한 활용하기 위해서는 resize2fs를 통해 파일 시스템의 크기를 확장해 주어야 한다. 마운트가 되어 있는 상태에서도 온라인 리사이징은 가능하다.

$ sudo resize2fs /dev/md0
resize2fs 1.45.5 (07-Jan-2020)
Filesystem at /dev/md0 is mounted on /mnt/raid01; on-line resizing required
old_desc_blocks = 932, new_desc_blocks = 1398
The filesystem on /dev/md0 is now 2930163456 (4k) blocks long.

이제 용량을 확인해보면,

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
...
/dev/md0         11T  4.8T  5.6T  47% /mnt/raid01
...

사이즈가 증가해 있는 것을 알 수 있다.

Impression

parted로 물리 디스크의 볼륨 레이블과 파티션을 생성하고, mdadm을 통해 레이드 구성을 관리하고, resize2fs 등을 통해 레이드 파티션 상의 파일 시스템을 관리할 수 있다.

다만 보드 상의 사타 포트 4개를 이제 다 사용했고, 아직 하드 베이는 두 칸이 비어있다. sata 연결의 추가 확보를 위해 안정적인 pci-e 확장 카드를 구해야 할 듯.

둘 째, 먼 후 일에 (서버 하드웨어 교체 주기를 고려하면 한 5년 정도 후에) 이 레이드 전체를 다른 시스템으로 마이그레이션을 할 날이 올 것인데, 아직 나는 그러한 경험이 없다. 확장카드까지 활용하여 레이드를 구성할 가능성을 고려하여 이 소프트웨어 방식의 레이드의 안전한 마이그레이션이 가능한지 조사를 해볼 필요가 있겠다.

References

카테고리: Linux

0개의 댓글

답글 남기기

Avatar placeholder