You are not logged in.

#1 2016-04-28 12:09:21

ruidc
Member
Registered: 2014-10-16
Posts: 9

help with grub boot partition restore

Hi guys & gals,

i'm hoping someone can help me...
i broke my grub boot partition, but have managed to boot into my Arch system using Super Grub2 disk.
I am trying to reinstall grub on the partition, following the wiki instructions, but get a grub error:

chattr -i /boot/grub/i386-pc/core.img
mymachine # grub-install --target=i386-pc --debug --force /dev/sda2

grub-install: error: unable to identify a filesystem in hostdisk//dev/sda; safety check can't be performed.

I suspect this is because i've got my partition marked as swap, despite having the right type code:

parted
GNU Parted 3.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Model: VMware Virtual disk (scsi)
Disk /dev/sda: 365GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system     Name                 Flags
 2      17.4kB  1049kB  1031kB  linux-swap(v1)  BIOS boot partition  bios_grub
 1      1049kB  365GB   365GB                   Linux LVM            lvm


lsblk
NAME                    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
fd0                       2:0    1     4K  0 disk
sda                       8:0    0   340G  0 disk
├─sda1                    8:1    0   340G  0 part
│ ├─VolGroup00-lvolboot 254:0    0   300M  0 lvm  /boot
│ ├─VolGroup00-lvolroot 254:1    0    20G  0 lvm  /
│ ├─VolGroup00-lvolswap 254:2    0     2G  0 lvm  [SWAP]
│ ├─VolGroup00-lvolvar  254:3    0    20G  0 lvm  /var
│ └─VolGroup00-lvolhome 254:4    0 297.7G  0 lvm  /home
└─sda2                    8:2    0  1007K  0 part
sr0                      11:0    1  13.1M  0 rom

this is a GPT+BIOS system with LVM2 and GRUB2.

Can anyone offer suggestions as to how i can get past this grub error? or bypass it by somehow writing the image to sda2?

... alternatively, i have a 2-day old backup of the partition (before i updated to latest kernel) how can i clone just that partition onto my broken system?

Thanks in advance.
RDC

Last edited by ruidc (2016-04-28 12:10:02)

Offline

#2 2016-04-28 13:14:52

frostschutz
Member
Registered: 2013-11-15
Posts: 1,417

Re: help with grub boot partition restore

grub-install to /dev/sda, not /dev/sda2. It will locate /boot and bios_grub partition by itself. Preferably do this from inside chroot (chroot environment should include /, /boot, /usr, and bind mounts for /proc /dev /sys /run ...)

How did you get a swap header on sda2, get rid of it (swapoff -a, remove swap entry from fstab if it's there, dd if=/dev/zero of=/dev/sda2).

What's with the chattr i? Don't do that. Setting silly attributes on grub files solves zero problems and causes tons of em.

Last edited by frostschutz (2016-04-28 13:18:09)

Offline

#3 2016-04-28 13:29:12

Starfish
Member
From: Germany
Registered: 2015-10-21
Posts: 134

Re: help with grub boot partition restore

I would try to turn off the "false" swap partition via

swapoff /dev/sdax

then delete the partition (which is in your case number 2), create a new one in the same sector, mount it to /boot/ and set a boot flag. I do not know how long this takes with parted, but with gdisk its a few minutes.

EDIT: posted this before seeing the comment by frostschutz

Last edited by Starfish (2016-04-28 13:31:54)


"Yesterday is history, tomorrow is a mystery, but today is a gift. That is why it is called the present." - Master Oogway

Offline

#4 2016-04-28 13:32:51

ruidc
Member
Registered: 2014-10-16
Posts: 9

Re: help with grub boot partition restore

Thanks for your reply...

How did you get a swap header on sda2

because i was stupid earlier this week and set swap space there which is what overwrote the partition contents.
re: chattr, that's because i was following what i thought i did in the first place to set grub to boot from the partition as per https://wiki.archlinux.org/index.php/GR … nless_disk

I have done your dd command in the hope that it would make my previous grub-install work, but alas it did not.
I'll wait for the weekend to take backups and snapshots before doing grub-install to /dev/sda without partition. Given i have booted into the system vis Super Grub2 disk, and it is running, i presume i should not need to chroot, or what is the advantage of doing so?

Thanks,
RDC

Offline

Board footer

Powered by FluxBB