====== Linux replace boot disk ======
===== Move boot disk on PPC64LE linux partition =====
[root@lnxtest-101 ~]# cat /etc/redhat-release
Red Hat Enterprise Linux release 8.7 (Ootpa)
[root@lnxtest-101 ~]# uname -a
Linux lnxtest-101.police.etat.lu 4.18.0-425.3.1.el8.ppc64le #1 SMP Fri Sep 30 11:30:21 EDT 2022 ppc64le ppc64le ppc64le GNU/Linux
==== Step 1: make a disk snapshot on SVC ====
FIXME In the following procedure, be attentive to the disk name, some commands are disruptive
==== Step 2: add a new disk ====
The disk can be multipath or not
[root@lnxtest-101 ~]# multipath -ll
mpathd (360050768018186646800000000000e75) dm-1 IBM,2145
size=40G features='1 queue_if_no_path' hwhandler='1 alua' wp=rw
|-+- policy='service-time 0' prio=50 status=active
| |- 3:0:1:0 sdi 8:128 active ready running
| |- 4:0:1:0 sdm 8:192 active ready running
| |- 1:0:5:0 sdt 65:48 active ready running
| `- 2:0:5:0 sds 65:32 active ready running
`-+- policy='service-time 0' prio=10 status=enabled
|- 3:0:3:0 sdk 8:160 active ready running
|- 4:0:3:0 sdo 8:224 active ready running
|- 2:0:7:0 sdv 65:80 active ready running
`- 1:0:7:0 sdx 65:112 active ready running
mpathf (SIBM_3303_NVDISKfb563ae0cd77a45523162dc37ff302e1) dm-12 IBM,3303 NVDISK
size=40G features='1 queue_if_no_path' hwhandler='0' wp=rw
|-+- policy='service-time 0' prio=1 status=active
| `- 5:0:1:0 sdg 8:96 active ready running
`-+- policy='service-time 0' prio=1 status=enabled
`- 6:0:1:0 sdh 8:112 active ready running
[root@lnxtest-101 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
rootvg 1 7 0 wz--n- 39.00g 25.00g
[root@lnxtest-101 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/mapper/mpathd3 rootvg lvm2 a-- 39.00g 25.00g
[root@lnxtest-101 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/mpathd2 999M 586M 414M 59% /boot
/dev/mapper/rootvg-usr 3.0G 2.5G 587M 81% /usr
/dev/mapper/rootvg-tmp 1014M 40M 975M 4% /tmp
/dev/mapper/rootvg-var 3.0G 935M 2.1G 31% /var
/dev/mapper/rootvg-home 1014M 40M 975M 4% /home
[root@lnxtest-101 ~]# fdisk -l /dev/mapper/mpathd
Disk /dev/mapper/mpathd: 40 GiB, 42949672960 bytes, 83886080 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 32768 bytes / 32768 bytes
Disklabel type: dos
Disk identifier: 0xdd417826
Device Boot Start End Sectors Size Id Type
/dev/mapper/mpathd1 * 2048 22527 20480 10M 41 PPC PReP Boot
/dev/mapper/mpathd2 22528 2080767 2058240 1005M 83 Linux
/dev/mapper/mpathd3 2080768 83886079 81805312 39G 8e Linux LVM
==== Step 3: clone partition table on new disk ====
Yum cleanup before starting
[root@lnxtest-101 ~]# yum clean all
[root@lnxtest-101 ~]# multipath -ll | grep mpath
mpathd (360050768018186646800000000000e75) dm-1 IBM,2145
mpathf (SIBM_3303_NVDISKfb563ae0cd77a45523162dc37ff302e1) dm-12 IBM,3303 NVDISK
Clone partition table
[root@lnxtest-101 ~]# sfdisk -d /dev/mapper/mpathd | sfdisk --force /dev/mapper/mpathf
Checking that no-one is using this disk right now ... FAILED
This disk is currently in use - repartitioning is probably a bad idea.
Umount all file systems, and swapoff all swap partitions on this disk.
Use the --no-reread flag to suppress this check.
Disk /dev/mapper/mpathf: 40 GiB, 42949672960 bytes, 83886080 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
>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Script header accepted.
>>> Created a new DOS disklabel with disk identifier 0xdd417826.
/dev/mapper/mpathf-part1: Created a new partition 1 of type 'PPC PReP Boot' and of size 10 MiB.
/dev/mapper/mpathf-part2: Created a new partition 2 of type 'Linux' and of size 1005 MiB.
/dev/mapper/mpathf-part3: Created a new partition 3 of type 'Linux LVM' and of size 39 GiB.
/dev/mapper/mpathf-part4: Done.
New situation:
Disklabel type: dos
Disk identifier: 0xdd417826
Device Boot Start End Sectors Size Id Type
/dev/mapper/mpathf-part1 * 2048 22527 20480 10M 41 PPC PReP Boot
/dev/mapper/mpathf-part2 22528 2080767 2058240 1005M 83 Linux
/dev/mapper/mpathf-part3 2080768 83886079 81805312 39G 8e Linux LVM
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Invalid argument
The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).
Syncing disks.
Rescan partitions
[root@lnxtest-101 ~]# partprobe -s
[root@lnxtest-101 ~]# pvcreate /dev/mapper/mpathf3
Physical volume "/dev/mapper/mpathf3" successfully created.
[root@lnxtest-101 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
rootvg 1 7 0 wz--n- 39.00g 25.00g
==== Step 4: move LVM to new disk ====
Extend your rootvg
[root@lnxtest-101 ~]# vgextend rootvg /dev/mapper/mpathf3
Move data from one disk to another
[root@lnxtest-101 ~]# pvmove -b /dev/mapper/mpathd3 /dev/mapper/mpathf3
[root@lnxtest-101 ~]# lvs -a -o+devices
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert Devices
besclientlv rootvg -wI-ao---- 1.00g pvmove0(0)
home rootvg -wI-ao---- 1.00g pvmove0(0)
[pvmove0] rootvg p-C-aom--- 14.00g /dev/mapper/mpathd3 14.29 /dev/mapper/mpathd3(0),/dev/mapper/mpathf3(0)
[pvmove0] rootvg p-C-aom--- 14.00g /dev/mapper/mpathd3 14.29 /dev/mapper/mpathd3(512),/dev/mapper/mpathf3(512)
[pvmove0] rootvg p-C-aom--- 14.00g /dev/mapper/mpathd3 14.29 /dev/mapper/mpathd3(768),/dev/mapper/mpathf3(768)
[pvmove0] rootvg p-C-aom--- 14.00g /dev/mapper/mpathd3 14.29 /dev/mapper/mpathd3(1024),/dev/mapper/mpathf3(1024)
[pvmove0] rootvg p-C-aom--- 14.00g /dev/mapper/mpathd3 14.29 /dev/mapper/mpathd3(1792),/dev/mapper/mpathf3(1792)
[pvmove0] rootvg p-C-aom--- 14.00g /dev/mapper/mpathd3 14.29 /dev/mapper/mpathd3(2560),/dev/mapper/mpathf3(2560)
[pvmove0] rootvg p-C-aom--- 14.00g /dev/mapper/mpathd3 14.29 /dev/mapper/mpathd3(3328),/dev/mapper/mpathf3(3328)
root rootvg -wI-ao---- 3.00g pvmove0(0)
swap rootvg -wI-ao---- 2.00g pvmove0(0)
tmp rootvg -wI-ao---- 1.00g pvmove0(0)
usr rootvg -wI-ao---- 3.00g pvmove0(0)
var rootvg -wI-ao---- 3.00g pvmove0(0)
Check the end of the move process
[root@lnxtest-101 ~]# vgreduce rootvg /dev/mapper/mpathd3
Removed "/dev/mapper/mpathd3" from volume group "rootvg"
[root@lnxtest-101 ~]# pvremove /dev/mapper/mpathd3
LVM cleanup
[root@lnxtest-101 ~]# vgreduce rootvg /dev/mapper/mpathd3
Removed "/dev/mapper/mpathd3" from volume group "rootvg"
[root@lnxtest-101 ~]# pvremove /dev/mapper/mpathd3
==== Step 5: Copy boot sectors ====
Clone PPC PReP Boot partition:
[root@lnxtest-101 ~]# dd if=/dev/mapper/mpathd1 of=/dev/mapper/mpathf1 bs=512 conv=noerror,sync
20480+0 records in
20480+0 records out
10485760 bytes (10 MB, 10 MiB) copied, 0.58557 s, 17.9 MB/s
Clone /boot:
[root@lnxtest-101 ~]# umount /boot
[root@lnxtest-101 ~]# multipath -ll | grep mpath
mpathd (360050768018186646800000000000e75) dm-1 IBM,2145
mpathf (SIBM_3303_NVDISKfb563ae0cd77a45523162dc37ff302e1) dm-12 IBM,3303 NVDISK
[root@lnxtest-101 ~]# dd if=/dev/mapper/mpathd2 of=/dev/mapper/mpathf2 bs=512 conv=noerror,sync
2058240+0 records in
2058240+0 records out
1053818880 bytes (1.1 GB, 1005 MiB) copied, 65.658 s, 16.1 MB/s
[root@lnxtest-101 ~]# mount /boot
Copy boot sector:
[root@lnxtest-101 ~]# dd if=/dev/mapper/mpathd of=/dev/mapper/mpathf bs=1 count=512
512+0 records in
512+0 records out
512 bytes copied, 0.00110371 s, 464 kB/s
==== Step 6: Install GRUB in new disk ====
First test on the disk...failed, then on PreP partition:
[root@lnxtest-101 ~]# grub2-install /dev/mapper/mpathf
Installing for powerpc-ieee1275 platform.
grub2-install: error: the chosen partition is not a PReP partition.
[root@lnxtest-101 ~]# grub2-install /dev/mapper/mpathf1
Installing for powerpc-ieee1275 platform.
Installation finished. No error reported.
Check grub config, here virtual FC in the config
[root@lnxtest-101 ~]# cat /boot/grub2/grub.cfg
search --no-floppy --fs-uuid --set=root --hint-ieee1275='ieee1275//vdevice/vfc-client@30000006/disk@5005076810078be4,msdos2' 7895f8b3-3eda-4ff3-903f-58d08a3447d4
search --no-floppy --fs-uuid --set=root 7895f8b3-3eda-4ff3-903f-58d08a3447d4
search --no-floppy --fs-uuid --set=boot --hint-ieee1275='ieee1275//vdevice/vfc-client@30000006/disk@5005076810078be4,msdos2' 7895f8b3-3eda-4ff3-903f-58d08a3447d4
search --no-floppy --fs-uuid --set=boot 7895f8b3-3eda-4ff3-903f-58d08a3447d4
Rebuild grb config and boot sector
[root@lnxtest-101 ~]# dracut --regenerate-all --force
[root@lnxtest-101 ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Generating boot entries from BLS files...
done
Check grub config, now virtual SCSI in the config
[root@lnxtest-101 ~]# cat /boot/grub2/grub.cfg | grep flopp
search --no-floppy --fs-uuid --set=root --hint-ieee1275='ieee1275//vdevice/v-scsi@30000007/disk@8100000000000000,msdos2' 7895f8b3-3eda-4ff3-903f-58d08a3447d4
search --no-floppy --fs-uuid --set=root 7895f8b3-3eda-4ff3-903f-58d08a3447d4
search --no-floppy --fs-uuid --set=boot --hint-ieee1275='ieee1275//vdevice/v-scsi@30000007/disk@8100000000000000,msdos2' 7895f8b3-3eda-4ff3-903f-58d08a3447d4
search --no-floppy --fs-uuid --set=boot 7895f8b3-3eda-4ff3-903f-58d08a3447d4
Check grub config, now virtual SCSI in the config
[root@lnxtest-101 ~]# multipath -ll
...
mpathf (SIBM_3303_NVDISKfb563ae0cd77a45523162dc37ff302e1) dm-12 IBM,3303 NVDISK
size=40G features='1 queue_if_no_path' hwhandler='0' wp=rw
|-+- policy='service-time 0' prio=1 status=active
| `- 5:0:1:0 sdg 8:96 active ready running
`-+- policy='service-time 0' prio=1 status=enabled
`- 6:0:1:0 sdh 8:112 active ready running
Set the bootlist and reboot
[root@lnxtest-101 ~]# bootlist -m normal sdg sdh
[root@lnxtest-101 ~]# init 6