Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] how to properly restore/rsync a Gentoo system
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
Vieri
l33t
l33t


Joined: 18 Dec 2005
Posts: 921

PostPosted: Thu Nov 05, 2020 2:14 pm    Post subject: [SOLVED] how to properly restore/rsync a Gentoo system Reply with quote

Hi,

I'd like to boot a machine with a Gentoo live CD/USB, and then "fully" rsync a running remote system (meaning that even the boot and efi partitions should be rsync'ed).

I have a working script for this, and it seems to be OK if the target is a single disk. However, I'm having issues when trying to use RAID1.

The remote running system is a recent Gentoo OS with GRUB and EFI, as well as 2 HDs in RAID1.

From the live CD/USB, I partition the 2 target disks, set up RAID, then rsync from remote to local boot, boot/efi and root (/).
From the live CD/USB I also rewrite the target etc/mdadm.conf by running

Code:
mdadm --detail --scan


Note that I'm rsync'ing everything in boot so the kernels and initramfs are exactly the same.

Finally, I install GRUB on the target disks.
I can boot the new system, but it fails to mount root because it doesn't find /dev/md/5 in my case.
So I'm presented with a shell in which I see nothing under /dev/md*.
Also, if I run mdadm, it doesn't find any RAID devices.

I can of course specify eg. /dev/sda5 or /dev/sdb5 to resume the booting process.

However, I'd like to know why the MD devices are not visible in this initramfs.

If I reboot with the live CD/USB, I can see the RAID set.

So, how can I debug this?
Do I need to rebuild the initramfs in the rsync'ed system?


Last edited by Vieri on Fri Nov 13, 2020 1:23 pm; edited 1 time in total
Back to top
View user's profile Send private message
Vieri
l33t
l33t


Joined: 18 Dec 2005
Posts: 921

PostPosted: Fri Nov 06, 2020 8:47 am    Post subject: Reply with quote

When I enter the busybox shell environment on booting the restored system, I run:

Code:

mdadm --examine /dev/sda5
mdadm --examine /dev/sdb5


Both show that there are 2 devices in RAID1. No errors or odd messages.

However, running the following doesn't yield anything:

Code:
mdadm --assemble --scan


Both cat /proc/mdstat and mdadm --detail --scan show no disks in the set.

The only way I can activate the root RAID1 set is by running the following manually:

Code:
mdadm --assemble /dev/md/5 /dev/sda5 /dev/sdb5


and /proc/mdstat looks OK.

Of course, etc/mdadm.conf in the initramfs contains the UUIDs of the "online" system, not the target system that I'm trying to boot.

Is this the reason why it's failing to auto assemble the RAID sets at boot time?

I wonder if I can unpack, edit, repack the initramfs file from my Gentoo live CD/USB environment so I can edit just the mdadm.conf file without having to run genkernel again to generate the initramfs file.
Back to top
View user's profile Send private message
Vieri
l33t
l33t


Joined: 18 Dec 2005
Posts: 921

PostPosted: Fri Nov 06, 2020 10:16 am    Post subject: Reply with quote

I will try to run the following from my live CD/USB environment on the target system after chrooting into it:

Code:
mdadm --detail --scan > /etc/mdadm.conf
genkernel --install --no-ramdisk-modules --mdadm-config=/etc/mdadm.conf initramfs


I hope this sounds reasonable.
Back to top
View user's profile Send private message
figueroa
Advocate
Advocate


Joined: 14 Aug 2005
Posts: 3020
Location: Edge of marsh USA

PostPosted: Sat Nov 07, 2020 4:12 am    Post subject: Reply with quote

Maybe you need to manually tweak the grub.cfg. And, is the boot flag set on the partition?
_________________
Andy Figueroa
hp pavilion hpe h8-1260t/2AB5; spinning rust x3
i7-2600 @ 3.40GHz; 16 gb; Radeon HD 7570
amd64/23.0/split-usr/desktop (stable), OpenRC, -systemd -pulseaudio -uefi
Back to top
View user's profile Send private message
Vieri
l33t
l33t


Joined: 18 Dec 2005
Posts: 921

PostPosted: Tue Nov 10, 2020 9:41 am    Post subject: Reply with quote

There's something I can't understand about mdadm and the way the device numbering works.

When I create the RAID set I use commands such as this one:

Code:
mdadm --create --run --verbose ${TARGET_DEVICE_RAID}5${MD_SUFFIX} --name=ROOT --level=mirror --raid-devices=2 --metadata=0.90 --assume-clean ${TARGET_DEVICE}5 ${TARGET_DEVICE_2}5


I do that for ROOT, BOOT, SWAP amd BIOS.
So this means I have the choice of using either UUIDs or names, right?

So this is how I generate my mdadm.conf file:

Code:
ARRAY /dev/md/1 metadata=0.90 name=BIOS
ARRAY /dev/md/3 metadata=0.90 name=BOOT
ARRAY /dev/md/4 metadata=0.90 name=SWAP
ARRAY /dev/md/5 metadata=0.90 name=ROOT


I place that into the initramfs image because this is the command I run:

Code:
genkernel --install --mdadm --mdadm-config=/etc/mdadm.conf initramfs


Now, when I boot this ramdisk from grub, it fails to find /dev/md/5 as root. If I enter the busybox shell, I can cat /etc/mdadm.conf and confirm that it's as expected.

If I run the following command:

Code:
mdadm --examine --scan


I get my arrays listed but with "incorrect" device numbers, eg.:

Code:
ARRAY /dev/md1 UUID=xxx
ARRAY /dev/md125 UUID=xxxx
etc.


How do I make sure that mdadm picks up the "name" information properly?

Also, is the content of my /etc/mdadm.conf complete if it only contains the ARRAY lines?
I'm asking because it seems that other distros use variables such as AUTOSTART=true.

If I run the following command with /etc/mdadm.conf containing the name=* definitions as posted above:

Code:
mdadm --assemble --scan


then I get nothing (no RAID sets created).

However, if run:

Code:
mdadm --examine --scan > /etc/mdadm.conf
mdadm --assemble --scan


then all of the RAID sets are created but not as I want them to be (random /dev/md* numbering).

So I guess the one and only question is why name=* does not work in my system...
Back to top
View user's profile Send private message
Vieri
l33t
l33t


Joined: 18 Dec 2005
Posts: 921

PostPosted: Fri Nov 13, 2020 1:22 pm    Post subject: Reply with quote

I'm posting here just in case someone else also goes mad with mdadm.

First of all, forget "names" with mdadm metadata v. 0.90. Not supported. They are supported starting v. 1.2. Still, it might be necessary to use the hostname such as hostname:raidname or specify the special keyword "any" (--homehost=any).

So, for metadata 0.90, I had to rebuild mdadm.conf with the UUIDs and specifically set /dev/md/{1,2,3,4,5}.

Then I ran this within jailed root:

Code:
genkernel --install --mdadm --mdadm-config=/etc/mdadm.conf initramfs


I can now properly boot with the RAID sets.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum