🌻Infrastructure And OperationsRathouseDisk-Replacement-June2024

# STATE AFTER REPLACEMENT:

DISK BAY 3: Intel PHYF209300LX3P8EGN
DISK BAY 2: Intel PHYF209106Y93P8EGN
DISK BAY 1: Inland  22062712800355
DISK BAY 0: Inland  24010919300014

root@rathouse:~# lsblk
NAME      MAJ:MIN RM   SIZE RO TYPE   MOUNTPOINTS
sda         8:0    0 111.8G  0 disk   
├─sda1      8:1    0   485M  0 part   
└─sda2      8:2    0  93.1G  0 part   
  └─md0     9:0    0  93.1G  0 raid1  /
sdb         8:16   0 119.2G  0 disk   
├─sdb1      8:17   0   487M  0 part   /boot/efi
├─sdb2      8:18   0  93.1G  0 part   
│ └─md0     9:0    0  93.1G  0 raid1  /
└─sdb3      8:19   0   7.5G  0 part   
sdc         8:32   0   3.5T  0 disk   
└─sdc1      8:33   0   3.4T  0 part   
  └─md127   9:127  0   3.4T  0 raid10 /tank
sdd         8:48   0   3.5T  0 disk   
└─sdd1      8:49   0   3.4T  0 part   
  └─md127   9:127  0   3.4T  0 raid10 /tank

root@rathouse:~# smartctl -a /dev/sda
smartctl 7.3 2022-02-28 r5338 [x86_64-linux-6.1.0-22-amd64] (local build)
Copyright (C) 2002-22, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family:     Phison Driven OEM SSDs
Device Model:     SATA SSD
Serial Number:    24010919300014
....
....


#################################

Making sure the EFI / bootloader should be all good:

# look at current EFI boot settings
efibootmgr -v

# lets say the currently selected boot device is the one that has to be removed.
# in order to run grub-install on the new disk, we have to first unmount the current EFI boot partition
umount /boot/efi


mount /dev/sdb1 /boot/efi

# now that the correct EFI boot partition is mounted at /boot/efi, we can run grub-install
grub-install /dev/sdb

# check our work. Note that this REPLACES the previous boot option instead of adding a new one. 
efibootmgr -v

# further checking our work:
ls /boot/efi
ls /boot/efi/EFI

# for info about how to add an additional  boot entry, see 
# https://www.linuxbabe.com/command-line/how-to-use-linux-efibootmgr-examples#add-uefi-boot-entry


##################################

# remove the failed disk from the mdraid array

mdadm --manage /dev/md0 --fail /dev/sdb2
mdadm --manage /dev/md0 --remove /dev/sdb2

# different useful ways to list disks
fdisk -l
blkid -o list
lsblk


# get sector sizes  for the partion you need to make
fdisk -l

# partition the new disk.

parted /dev/sda mklabel gpt
parted -a opt /dev/sda mkpart primary fat32 2048s 995327s
parted -a opt /dev/sda mkpart primary ext4 995328s 196306943s


# add new disk to mdraid array
mdadm /dev/md0 --add /dev/sda2

# watch progress bar 

cat /proc/mdstat
cat /proc/mdstat
cat /proc/mdstat