OmniOS - Wymiana dysków

Wymiana dysków w macierzy RAID-1

Czasem zachodzi konieczność wymiany dysków w pracującej macierzy RAID. Potrzeba taka pojawia się w dwóch przypadkach: jeden z dysków ulega uszkodzeniu lub trzeba wymienić dyski na dyski o większej pojemności. W obu przypadkach wykonujemy podobne, prezentowane poniżej, czynności.

 

Sprawdzamy status macierzy, którą będziemy modyfikować. W zależności od rozpatrywanego wariantu status będzie się różnił. Poniżej jeden z dysków został wcześniej wyłączony.

root@test-builder:~# zpool status rpool
  pool: rpool
 state: DEGRADED
status: One or more devices has been taken offline by the administrator.
        Sufficient replicas exist for the pool to continue functioning in a
        degraded state.
action: Online the device using 'zpool online' or replace the device with
        'zpool replace'.
  scan: resilvered 113K in 0h0m with 0 errors on Thu Oct  8 19:31:26 2015
config:

        NAME          STATE     READ WRITE CKSUM
        rpool         DEGRADED     0     0     0
          mirror-0    DEGRADED     0     0     0
            c0t1d0s0  ONLINE       0     0     0
            c0t0d0s0  OFFLINE      0     0     0

errors: No known data errors
root@test-builder:~# _

Procedura wymiany dysków możemy wykonać na wiele sposobów. Mamy możliwość zastosowania polecenia replace w przypadku posiadania dysku rezerwowego (spare part). W moim przypadku, korzystając z faktu posiadania prostego mirroru, zwyczajnie usuwam z macierzy jeden z dysków i zastępuję go nowym urządzeniem budując macierz od nowa.

root@test-builder:~# zpool detach rpool c0t0d0s0
root@test-builder:~# zpool status rpool
  pool: rpool
 state: ONLINE
  scan: resilvered 113K in 0h0m with 0 errors on Thu Oct  8 19:31:26 2015
config:

        NAME        STATE     READ WRITE CKSUM
        rpool       ONLINE       0     0     0
          c0t1d0s0  ONLINE       0     0     0

errors: No known data errors
root@test-builder:~# _

Usuwam dysk z konfiguracji systemu.

root@test-builder:~# cfgadm -la
Ap_Id                          Type         Receptacle   Occupant     Condition
Slot128                        unknown      empty        unconfigured unknown
Slot132                        unknown      empty        unconfigured unknown
Slot133                        unknown      empty        unconfigured unknown
Slot134                        sata/hp      connected    configured   ok
Slot135                        etherne/hp   connected    configured   ok
sata2/0::dsk/c0t0d0            disk         connected    configured   ok
sata2/1::dsk/c0t1d0            disk         connected    configured   ok
sata2/2::dsk/c0t2d0            disk         connected    configured   ok
sata2/3::dsk/c0t3d0            disk         connected    configured   ok
sata2/4::dsk/c0t4d0            disk         connected    configured   ok
sata2/5::dsk/c0t5d0            disk         connected    configured   ok
sata3/0                        sata-port    empty        unconfigured ok
sata3/1                        sata-port    empty        unconfigured ok
usb4/1                         usb-hub      connected    configured   ok
usb4/1.1                       unknown      empty        unconfigured ok
usb4/1.2                       unknown      empty        unconfigured ok
usb4/1.3                       unknown      empty        unconfigured ok
usb4/1.4                       unknown      empty        unconfigured ok
usb4/1.5                       unknown      empty        unconfigured ok
usb4/1.6                       unknown      empty        unconfigured ok
usb4/2                         unknown      empty        unconfigured ok
usb5/1                         usb-hub      connected    configured   ok
usb5/1.1                       unknown      empty        unconfigured ok
usb5/1.2                       unknown      empty        unconfigured ok
usb5/1.3                       unknown      empty        unconfigured ok
usb5/1.4                       unknown      empty        unconfigured ok
usb5/1.5                       unknown      empty        unconfigured ok
usb5/1.6                       usb-device   connected    configured   ok
usb5/1.7                       unknown      empty        unconfigured ok
usb5/1.8                       unknown      empty        unconfigured ok
usb5/2                         unknown      empty        unconfigured ok
root@test-builder:~# _ 

root@test-builder:~# cfgadm -c unconfigure sata2/0
Unconfigure the device at: /devices/pci@0,0/pci1043,8383@1f,2:0
This operation will suspend activity on the SATA device
Continue (tak/nie)? tak
root@test-builder:~# _

Dokonuję w tym miejscu fizycznej zamiany dysków i następnie konfiguruję go w systemie.

root@test-builder:~# cfgadm -c configure sata2/0
root@test-builder:~# _

W przypadku wymiany dysków na większe w macierzy systemowej, musimy ręcznie skonfigurować partycje. Wykonujemy to poleceniem format, wcześniej jednak sprawdzamy bieżącą tablicę partycji na obu dyskach:

Dysk systemowy:

root@test-builder:~# prtvtoc /dev/rdsk/c0t1d0s2
* /dev/rdsk/c0t1d0s2 partition map
*
* Dimensions:
*     512 bytes/sector
*      63 sectors/track
*     255 tracks/cylinder
*   16065 sectors/cylinder
*    7295 cylinders
*    7293 accessible cylinders
*
* Flags:
*   1: unmountable
*  10: read-only
*
* Unallocated space:
*       First     Sector    Last
*       Sector     Count    Sector 
*           0     16065     16064
*
*                          First     Sector    Last
* Partition  Tag  Flags    Sector     Count    Sector  Mount Directory
       0      2    00      16065 117145980 117162044
       2      5    01          0 117194175 117194174
       8      1    01          0     16065     16064
root@test-builder:~# _

Dysk nowy:

root@test-builder:~# prtvtoc /dev/rdsk/c0t0d0s2
* /dev/rdsk/c0t0d0s2 partition map
*
* Dimensions:
*     512 bytes/sector
*      63 sectors/track
*     255 tracks/cylinder
*   16065 sectors/cylinder
*    9729 cylinders
*    9727 accessible cylinders
*
* Flags:
*   1: unmountable
*  10: read-only
*
* Unallocated space:
*       First     Sector    Last
*       Sector     Count    Sector 
*       16065 156248190 156264254
*
*                          First     Sector    Last
* Partition  Tag  Flags    Sector     Count    Sector  Mount Directory
       2      5    01          0 156264255 156264254
       8      1    01          0     16065     16064
root@test-builder:~# _

Inicjuję MBR na nowym dysku:

root@test-builder:~# fdisk -B c0t0d0p0
root@test-builder:~# _

Ręcznie tworzę partycję na nowym dysku, obejmującą swoim rozmiarem całą dostępną przestrzeń, analogicznie do informacji odczytanych z dysku systemowego.

root@test-builder:~# format
Searching for disks...done


AVAILABLE DISK SELECTIONS:
       0. c0t0d0 <ATA-WDCWD800BEVT-22-1A11 cyl 9727 alt 2 hd 255 sec 63>
          /pci@0,0/pci1043,8383@1f,2/disk@0,0
       1. c0t1d0 <ATA-ST96812AS-3.14 cyl 7293 alt 2 hd 255 sec 63>
          /pci@0,0/pci1043,8383@1f,2/disk@1,0
       2. c0t2d0 <ATA-ST96812AS-3.14-55.89GB>
          /pci@0,0/pci1043,8383@1f,2/disk@2,0
       3. c0t3d0 <ATA-ST96812AS-3.14-55.89GB>
          /pci@0,0/pci1043,8383@1f,2/disk@3,0
       4. c0t4d0 <ATA-ST96812AS-3.14-55.89GB>
          /pci@0,0/pci1043,8383@1f,2/disk@4,0
       5. c0t5d0 <ATA-ST96812AS-3.14-55.89GB>
          /pci@0,0/pci1043,8383@1f,2/disk@5,0
Specify disk (enter its number): 0
selecting c0t0d0
[disk formatted]
No Solaris fdisk partition found.


FORMAT MENU:
        disk       - select a disk
        type       - select (define) a disk type
        partition  - select (define) a partition table
        current    - describe the current disk
        format     - format and analyze the disk
        fdisk      - run the fdisk program
        repair     - repair a defective sector
        label      - write label to the disk
        analyze    - surface analysis
        defect     - defect list management
        backup     - search for backup labels
        verify     - read and display labels
        save       - save new disk/partition definitions
        inquiry    - show vendor, product and revision
        volname    - set 8-character volume name
        !<cmd>     - execute <cmd>, then return
        quit
format> part


PARTITION MENU:
        0      - change `0' partition
        1      - change `1' partition
        2      - change `2' partition
        3      - change `3' partition
        4      - change `4' partition
        5      - change `5' partition
        6      - change `6' partition
        7      - change `7' partition
        select - select a predefined table
        modify - modify a predefined partition table
        name   - name the current table
        print  - display the current table
        label  - write partition map and label to the disk
        !<cmd> - execute <cmd>, then return
        quit
partition> pr
Current partition table (original):
Total disk cylinders available: 9726 + 2 (reserved cylinders)

Part      Tag    Flag     Cylinders        Size            Blocks
  0 unassigned    wm       0               0         (0/0/0)            0
  1 unassigned    wm       0               0         (0/0/0)            0
  2     backup    wu       0 - 9725       74.50GB    (9726/0/0) 156248190
  3 unassigned    wm       0               0         (0/0/0)            0
  4 unassigned    wm       0               0         (0/0/0)            0
  5 unassigned    wm       0               0         (0/0/0)            0
  6 unassigned    wm       0               0         (0/0/0)            0
  7 unassigned    wm       0               0         (0/0/0)            0
  8       boot    wu       0 -    0        7.84MB    (1/0/0)        16065
  9 unassigned    wm       0               0         (0/0/0)            0

partition> 0
Part      Tag    Flag     Cylinders        Size            Blocks
  0 unassigned    wm       0               0         (0/0/0)            0

Enter partition id tag[unassigned]: root
Enter partition permission flags[wm]: 
Enter new starting cyl[1]: 
Enter partition size[0b, 0c, 1e, 0.00mb, 0.00gb]: 9724c
partition> pr
Current partition table (unnamed):
Total disk cylinders available: 9726 + 2 (reserved cylinders)

Part      Tag    Flag     Cylinders        Size            Blocks
  0       root    wm       1 - 9724       74.49GB    (9724/0/0) 156216060
  1 unassigned    wm       0               0         (0/0/0)            0
  2     backup    wu       0 - 9725       74.50GB    (9726/0/0) 156248190
  3 unassigned    wm       0               0         (0/0/0)            0
  4 unassigned    wm       0               0         (0/0/0)            0
  5 unassigned    wm       0               0         (0/0/0)            0
  6 unassigned    wm       0               0         (0/0/0)            0
  7 unassigned    wm       0               0         (0/0/0)            0
  8       boot    wu       0 -    0        7.84MB    (1/0/0)        16065
  9 unassigned    wm       0               0         (0/0/0)            0

partition> label
Ready to label disk, continue? yes

partition> q
partition> q
root@test-builder:~# _

Sprawdzamy tablicę partycji utworzoną na nowym dysku:

root@test-builder:~# prtvtoc /dev/rdsk/c0t0d0s2
* /dev/rdsk/c0t0d0s2 partition map
*
* Dimensions:
*     512 bytes/sector
*      63 sectors/track
*     255 tracks/cylinder
*   16065 sectors/cylinder
*    9728 cylinders
*    9726 accessible cylinders
*
* Flags:
*   1: unmountable
*  10: read-only
*
* Unallocated space:
*       First     Sector    Last
*       Sector     Count    Sector 
*           0     16065     16064
*
*                          First     Sector    Last
* Partition  Tag  Flags    Sector     Count    Sector  Mount Directory
       0      2    00      16065 156216060 156232124
       2      5    01          0 156248190 156248189
       8      1    01          0     16065     16064
root@test-builder:~# _

Dodaję nowy dysk do macierzy i czekam na ukończenie synchronizacji.

root@test-builder:~# zpool attach rpool c0t1d0s0 c0t0d0s0 
invalid vdev specification
use '-f' to override the following errors:
/dev/dsk/c0t0d0s0 overlaps with /dev/dsk/c0t0d0s2
root@test-builder:~# zpool attach -f rpool c0t1d0s0 c0t0d0s0 
Make sure to wait until resilver is done before rebooting.
root@test-builder:~# _

root@test-builder:~# zpool status rpool
  pool: rpool
 state: ONLINE
status: One or more devices is currently being resilvered.  The pool will
        continue to function, possibly in a degraded state.
action: Wait for the resilver to complete.
  scan: resilver in progress since Thu Oct  8 19:52:41 2015
    475M scanned out of 11,1G at 26,4M/s, 0h6m to go
    471M resilvered, 4,19% done
config:

        NAME          STATE     READ WRITE CKSUM
        rpool         ONLINE       0     0     0
          mirror-0    ONLINE       0     0     0
            c0t1d0s0  ONLINE       0     0     0
            c0t0d0s0  ONLINE       0     0     0  (resilvering)

errors: No known data errors
root@test-builder:~# _

Macierz ukończyła synchronizację i pracuje już optymalnie, na zakończenie odświeżam MBR

root@test-builder:~# zpool list rpool
NAME    SIZE  ALLOC   FREE  EXPANDSZ    CAP  DEDUP  HEALTH  ALTROOT
rpool  55,5G  11,1G  44,4G         -    19%  1.00x  ONLINE  -
root@test-builder:~# _

root@test-builder:~# installgrub /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c0t0d0s0


stage2 written to partition 0, 283 sectors starting at 50 (abs 16115)
stage1 written to partition 0 sector 0 (abs 16065)
 

W przypadku wymiany uszkodzonego dysku w tym miejscu procedura dobiegła końca. Jeżeli jednak naszym zadaniem było powiększenie dostępnej przestrzeni, to jesteśmy dopiero w połowie operacji.

Powiększenie macierzy

W tym miejscu opisanej procedury posiadamy macierz RAID-1 zbudowanej w oparciu o dwa dyski o różnych rozmiarach: 60GB i 80GB. Mamy możliwość łatwego rozszerzenia dostępnego miejsca poprzez wymianę dysku c0t1d0s0 na dysk o pojemności 80GB. 

Pierwszym krokiem dalszej procedury będzie zmiana konfiguracji macierzy polegającej na włączeniu możliwości automatycznego rozszerzenia dostępnego obszaru zgodnie z konfiguracją sprzętową.

root@test-builder:~# zpool set autoexpand=on rpool
root@test-builder:~# _

Usuwam mniejszy z dysków wykonując operacje analogiczne do tych, stosowanych w pierwszej połowie tej procedury.

root@test-builder:~# zpool offline rpool c0t1d0s0
root@test-builder:~# zpool status rpool
  pool: rpool
 state: DEGRADED
status: One or more devices has been taken offline by the administrator.
        Sufficient replicas exist for the pool to continue functioning in a
        degraded state.
action: Online the device using 'zpool online' or replace the device with
        'zpool replace'.
  scan: resilvered 11,1G in 0h8m with 0 errors on Thu Oct  8 20:00:55 2015
config:

        NAME          STATE     READ WRITE CKSUM
        rpool         DEGRADED     0     0     0
          mirror-0    DEGRADED     0     0     0
            c0t1d0s0  OFFLINE      0     0     0
            c0t0d0s0  ONLINE       0     0     0

errors: No known data errors
root@test-builder:~# zpool detach rpool c0t1d0s0
root@test-builder:~# _

root@test-builder:~# cfgadm -la
Ap_Id                          Type         Receptacle   Occupant     Condition
Slot128                        unknown      empty        unconfigured unknown
Slot132                        unknown      empty        unconfigured unknown
Slot133                        unknown      empty        unconfigured unknown
Slot134                        sata/hp      connected    configured   ok
Slot135                        etherne/hp   connected    configured   ok
sata2/0::dsk/c0t0d0            disk         connected    configured   ok
sata2/1::dsk/c0t1d0            disk         connected    configured   ok
sata2/2::dsk/c0t2d0            disk         connected    configured   ok
sata2/3::dsk/c0t3d0            disk         connected    configured   ok
sata2/4::dsk/c0t4d0            disk         connected    configured   ok
sata2/5::dsk/c0t5d0            disk         connected    configured   ok
sata3/0                        sata-port    empty        unconfigured ok
sata3/1                        sata-port    empty        unconfigured ok
usb4/1                         usb-hub      connected    configured   ok
usb4/1.1                       unknown      empty        unconfigured ok
usb4/1.2                       unknown      empty        unconfigured ok
usb4/1.3                       unknown      empty        unconfigured ok
usb4/1.4                       unknown      empty        unconfigured ok
usb4/1.5                       unknown      empty        unconfigured ok
usb4/1.6                       unknown      empty        unconfigured ok
usb4/2                         unknown      empty        unconfigured ok
usb5/1                         usb-hub      connected    configured   ok
usb5/1.1                       unknown      empty        unconfigured ok
usb5/1.2                       unknown      empty        unconfigured ok
usb5/1.3                       unknown      empty        unconfigured ok
usb5/1.4                       unknown      empty        unconfigured ok
usb5/1.5                       unknown      empty        unconfigured ok
usb5/1.6                       usb-device   connected    configured   ok
usb5/1.7                       unknown      empty        unconfigured ok
usb5/1.8                       unknown      empty        unconfigured ok
usb5/2                         unknown      empty        unconfigured ok
root@test-builder:~# _

root@test-builder:~# cfgadm -c unconfigure sata2/1
Unconfigure the device at: /devices/pci@0,0/pci1043,8383@1f,2:1
This operation will suspend activity on the SATA device
Continue (tak/nie)? tak
root@test-builder:~# _

Wymieniamy dysk.

root@test-builder:~# cfgadm -c configure sata2/1
root@test-builder:~# _

Korzystając z faktu, iż oba dyski są identyczne, zamiast ręcznego konfigurowania tablicy partycji, możemy skopiować ich definicję z dysku systemowego:

root@test-builder:~# prtvtoc /dev/rdsk/c0t0d0s2 | fmthard -s - /dev/rdsk/c0t1d0s2
fmthard:  New volume table of contents now in place.
root@test-builder:~# _

Następnie dodajemy dysk do macierzy i aktualizujemy MBR

root@test-builder:~# zpool attach rpool c0t0d0s0 c0t1d0s0
invalid vdev specification
use '-f' to override the following errors:
/dev/dsk/c0t1d0s0 overlaps with /dev/dsk/c0t1d0s2
root@test-builder:~# zpool attach -f rpool c0t0d0s0 c0t1d0s0
Make sure to wait until resilver is done before rebooting.
root@test-builder:~# _

root@test-builder:~# installgrub /boot/grub/stage1 /boot/grub/stage2 /dev/rdsk/c0t1d0s0
stage2 written to partition 0, 283 sectors starting at 50 (abs 16115)
stage1 written to partition 0 sector 0 (abs 16065)
root@test-builder:~# _

root@test-builder:~# zpool status rpool
  pool: rpool
 state: ONLINE
status: One or more devices is currently being resilvered.  The pool will
        continue to function, possibly in a degraded state.
action: Wait for the resilver to complete.
  scan: resilver in progress since Thu Oct  8 20:22:37 2015
    2,20G scanned out of 11,1G at 28,5M/s, 0h5m to go
    2,20G resilvered, 19,85% done
config:

        NAME          STATE     READ WRITE CKSUM
        rpool         ONLINE       0     0     0
          mirror-0    ONLINE       0     0     0
            c0t0d0s0  ONLINE       0     0     0
            c0t1d0s0  ONLINE       0     0     0  (resilvering)

errors: No known data errors
root@test-builder:~# _

Macierz działa optymalnie a dostępne miejsce zostało automatycznie powiększone do rozmiaru zdefiniowanej partycji:

root@test-builder:~# zpool list rpool
NAME    SIZE  ALLOC   FREE  EXPANDSZ    CAP  DEDUP  HEALTH  ALTROOT
rpool    74G  11,1G  62,9G         -    14%  1.00x  ONLINE  -
root@test-builder:~# _

Skomentuj ten artykuł
 Odśiweż, jeśli nie widzisz poprawnie kodu
wpisz kod weryfikacyjny(pola wymagane)

{cbcookies/messageBy using this site you accept the use of cookies for analysis, customized content and advertising. Korzystając z tej strony, musisz zaakceptować korzystanie z plików cookie do analizy, dostosowanych treści i reklam.}  Accept  More information