2.7 KiB
2.7 KiB
Working procedure to clone and restore CoreOS disk from OKD Cluster
Step 1 - take a backup
sudo dd if=/dev/old of=/dev/backup status=progress
Step 2 - clone beginning of old disk to new
sudo dd if=/dev/old of=/dev/backup status=progress count=1000Mib
Step 3 - verify and modify disk partitions
list disk partitions
sgdisk -p /dev/new
if new disk is smaller than old disk and there is space on the xfs partition of the old disk, modify partitions of new disk
gdisk /dev/new
inside of gdisk commands
-v -> verify table
-p -> print table
-d -> select partition to delete partition
-n -> recreate partition with same partition number as deleted partition
For end sector, either specify the new end or just press Enter for maximum available When asked about partition type, enter the same type code (it will show the old one)
p - >to verify
w -> to write
make xfs file system for new partition
sudo mkfs.xfs -f /dev/new4
**Step 4 - copy old PARTUUID **
careful here get old patuuid:
sgdisk -i <partition_number> /dev/old_disk # Note the "Partition unique GUID"
get labels
sgdisk -p /dev/old_disk # Shows partition names in the table
blkid /dev/old_disk* # Shows PARTUUIDs and labels for all partitions
set it on new disk
sgdisk -u <partition_number>:<old_partuuid> /dev/sdc
partition name:
sgdisk -c <partition_number>:"<old_name>" /dev/sdc
verify all:
lsblk -o NAME,SIZE,PARTUUID,PARTLABEL /dev/old_disk
Step 5 - Mount disks and copy files from old to new disk
mount files before copy:
mkdir -p /mnt/new
mkdir -p /mnt/old
mount /dev/old4 /mnt/old
mount /dev/new4 /mnt/new
copy:
rsync -aAXHv --numeric-ids /source/ /destination/
Step 6 - Set correct UUID for new partition 4
to set correct uuid for partition 4
blkid /dev/old4
xfs_admin -U <old_uuid> /dev/new_partition
to set labels get it
sgdisk -i 4 /dev/sda | grep "Partition name"
set it
sgdisk -c 4:"<label_name>" /dev/sdc
or
(check existing with xfs_admin -l /dev/old_partition)
Use xfs_admin -L <label> /dev/new_partition
Step 7 - Verify
verify everything:
sgdisk -p /dev/sda # Old disk
sgdisk -p /dev/sdc # New disk
lsblk -o NAME,SIZE,PARTUUID,PARTLABEL /dev/sda
lsblk -o NAME,SIZE,PARTUUID,PARTLABEL /dev/sdc
blkid /dev/sda* | grep UUID=
blkid /dev/sdc* | grep UUID=
Step 8 - Unmount devices and Finalize job
unmount old devices
umount /mnt/new
umount /mnt/old
shutdown swap disk and verify it worked