[14:05] <Peanut> Hi folks - is there a way that I could use the busybox shell in the Ubuntu installer environment to put an MBR on a disk? I've got a failed disk in a mirror pair, and it turns out that the second half of the mirror isn't bootable although it (presumably) holds a good copy of all the data.
[14:08] <cjwatson> Peanut: you can do it with parted ('anna-install parted-udeb' if it isn't already there)
[14:09] <Peanut> cjwatson: ah, neat - I'll try that.
[14:15] <Peanut> Ah, parted is a different udeb than partman (tried it with partman, but that didn't quite want to do what I wanted it to do).
[14:16] <cjwatson> parted is a command-line UI to libparted, which partman uses
[14:17] <cjwatson> I suggest setting its units to sectors so that it doesn't try to get too clever
[14:18] <cjwatson> kpartx (kpartx-udeb) might help too
[14:19] <cjwatson> Actually, given your problem description, it's possible you'd be best off using sfdisk (fdisk-udeb) to dump the partition table from the first disk and restore it onto the second
[14:20] <cjwatson> sfdisk -d working-disk-device >sfdisk-out;  READ THE OUTPUT FILE VERY CAREFULLY;  sfdisk broken-disk-device <sfdisk-out
[14:21] <Peanut> cjwatson: thanks, thanks, I was just finding out that parted doesn't have an easy way to copy partitions from one drive to the other.
[14:22] <Peanut> And I've used cfdisk in the past when I had a prompt, but didn't know I could anna-install it in the network boot environment.
[14:24] <cjwatson> Might need to modify partition references in that file
[14:32] <xnox> also backup the broken disk, in it's current state.
[14:32] <xnox> just in case.
[14:32] <xnox> (partition table at least)
[14:41] <Peanut> Meh.. I copied over the partition table, then synched the mirrors.. but it just goes in a reboot loop when trying to boot from disk.
[14:41] <Peanut> Oh.. and I did a 'grub-install' as /etc/default/grub knows about both mirrors.
[14:42] <cjwatson> 15:19 <cjwatson> Actually, given your problem description, it's possible you'd be best off using sfdisk (fdisk-udeb) to dump the partition table from the first disk and restore it onto the second
[14:42] <cjwatson> 15:20 <cjwatson> sfdisk -d working-disk-device >sfdisk-out;  READ THE OUTPUT FILE VERY CAREFULLY;  sfdisk broken-disk-device <sfdisk-out
[14:42] <cjwatson> 15:21 <cjwatson> Might need to modify partition references in that file
[14:42] <cjwatson> Sorry, bad timing on disconnect
[14:43] <Peanut> Ah ok - I did read those things you said :-)
[14:55] <Peanut> What's the correct syntax to make grub-installer put GRUB on the MBR of /dev/sda ?
[14:56] <cjwatson> grub-installer or grub-install?  (they're different)
[14:56] <Peanut> The one from the boot environment - grub-installer
[14:57] <cjwatson> You don't want to use that ...
[14:57] <cjwatson> Not unless you're doing an install from scratch and using it as part of the menu-driven interface
[14:58] <Peanut> Ah ok, I'm not. I've used dd to verify that there's no grub on the bootsector of /dev/sda
[14:58] <cjwatson> Boot into rescue mode instead and use the "Reinstall GRUB boot loader" option
[14:58] <cjwatson> "Rescue a broken system" from the CD boot menu
[14:59] <Peanut> cjwatson: ah ok.. these machines have no CDrom, but I have a netboot d-i setup that I'm booting them into, without giving them a preseed file (that'd be a full re-install).
[15:02] <cjwatson> rescue/enable=true as a boot param, then
[15:03] <Peanut> Ah, that's how you get to that.. thanks.
[15:04]  * Peanut is getting very tempted to just copy the first 466 bytes from /dev/sdb onto /dev/sda though ;-)
[15:05] <Peanut> Because any attempt at running in-target grub-install fails as well, due to the chroot environment. So having that in all my late_run.sh turns out to have been quite useless.
[15:07] <cjwatson> Err, GRUB doesn't reside in just the first 466 bytes
[15:07] <cjwatson> Copying that is likely a very bad idea since sometimes there's a signature
[15:07] <cjwatson> (as in a disk ID, not a crypto sig)
[15:10] <Peanut> cjwatson: ah, ok. Both disks should now have identical contents within their partitions, and identical partition tables, so only the stage 1 of grub is missing. I'll try the rescue/enable=true.
[15:12] <cjwatson> A bit more than that actually (stage 1 is a GRUB Legacy concept, although it's roughly equivalent to boot.img in GRUB 2; https://www.gnu.org/software/grub/manual/grub.html#Images).  I expect you will be missing the core image too.
[15:12] <cjwatson> Since in the MBR layout that does not reside within a partition.
[15:14] <Peanut> This is a lucid64 system (grub 1.98) that I'm trying to fix.
[15:14] <cjwatson> GRUB 1.98 is GRUB 2.
[15:14] <cjwatson> GRUB Legacy got up to 0.97.
[15:15] <cjwatson> More accurately, I should say that GRUB 1.98 is from the GRUB 2 series.
[15:15] <cjwatson> For this purpose the URL above is accurate for 1.98.
[18:09] <Peanut> cjwatson: thanks for all the help, I got all my nodes back up and running again.
[18:52] <cjwatson> Great