LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   formatted boot partition (https://www.linuxquestions.org/questions/linux-newbie-8/formatted-boot-partition-4175523105/)

blackRonin 10-23-2014 02:34 AM

formatted boot partition
 
Hello

I formatted /dev/sda1 - boot partition by mistake.

Now, after reboot, i have only grub cli.

What to do, to restore /boot ?

//edit

I'm trying restore my empty /boot partition using kali live on usb
(My os on hdd is centos, but i have not same os on live usb :/ )

After booting kali live i did:
mount /dev/mapper/vg_centosx220-lv_root /mnt/myroot
mount /dev/sda1 /mnt/myroot/boot
mount ‐‐bind /dev /mnt/myroot/dev
mount ‐‐bind /proc /mnt/myroot/proc
mount ‐‐bind /sys /mnt/myroot/sys
cp -L /etc/resolve.conf /mnt/myroot/etc/resolve.conf

then
chroot /mnt/myroot
gave me error: bash: tty: command not found
after ctrl+D
chroot /mnt/myroot /bin/bash
gave me same error.

Neighter apt-get or yum not work in chroot
(I don't have initrd.img in chroot)

I think on kali there is grub2 and on centos i had 0.97
I have not grub-install package on kali nor to install (apt-get install grub-install)

Please help.

Is this possible to fix that using kali on usb ?

yancek 10-23-2014 07:36 AM

It will work better if you use your CentOS installation medium. Did you create the directory /mnt/myroot before starting this? Also, if your initrd is gone then I imagine the kernel is gone also.

blackRonin 10-23-2014 07:40 AM

Yes, i have those folders.

I have /boot on separate partition /dev/sda1, and it's empty (only have lost and foud folder)

yancek 10-23-2014 11:08 AM

Quote:

I have /boot on separate partition /dev/sda1, and it's empty (only have lost and foud folder)
So all of the Grub boot files are gone as well as the kernel and initrd so even if you were able to reinstall Grub Legacy or Grub2, it still won't boot without those files. Do you still have your CentOS install CD?

EDDY1 10-23-2014 03:01 PM

What partition is / on?
Would it be on /dev/sda2?
If so that's, the partition you /mnt/myroot.
At present if you were to cd to /mnt/myroot you wouldn't see anything except proc sys and so on. Where as if you mount the / partition you would see your /etc /usr and so on, unless they are on separate paritotions & in that case you would need to mount them also.

blackRonin 10-23-2014 10:32 PM

Sorry, i gave you bad info.(1st post corrected)
Root partition / is on lv (/dev/mapper/vg_centosx220-lv_root)

Thanks for the tip /usr was also on separated lv - forgot to mount that so i have now:

Code:

root@kali:~# lsblk
NAME                            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                                8:0    0 298.1G  0 disk
├─sda1                            8:1    0  200M  0 part /mnt/myroot/boot
└─sda2                            8:2    0 297.9G  0 part
  ├─vg_centosx220-lv_var (dm-0)  254:0    0  6.8G  0 lvm  /mnt/myroot/var
  ├─vg_centosx220-lv_root (dm-1) 254:1    0    25G  0 lvm  /mnt/myroot
  ├─vg_centosx220-lv_home (dm-2) 254:2    0 249.7G  0 lvm 
  ├─vg_centosx220-lv_swap (dm-3) 254:3    0    8G  0 lvm 
  ├─vg_centosx220-lv_tmp (dm-4)  254:4    0  500M  0 lvm 
  └─vg_centosx220-lv_usr (dm-5)  254:5    0    8G  0 lvm  /mnt/myroot/usr
sdb                                8:16  1  7.3G  0 disk
├─sdb1                            8:17  1  2.8G  0 part /lib/live/mount/medium
└─sdb2                            8:18  1  1.9G  0 part
loop0                              7:0    0  2.6G  1 loop /lib/live/mount/rootfs/filesystem.squashfs

Now in chroot i have centos commands (yum etc)

I checked existed newest kernel
Code:

root@kali:/# rpm -V kernel-2.6.32-431.29.2.el6.x86_64
missing    /boot/.vmlinuz-2.6.32-431.29.2.el6.x86_64.hmac
missing    /boot/System.map-2.6.32-431.29.2.el6.x86_64
missing    /boot/config-2.6.32-431.29.2.el6.x86_64
missing    /boot/symvers-2.6.32-431.29.2.el6.x86_64.gz
missing    /boot/vmlinuz-2.6.32-431.29.2.el6.x86_64

So i reinstalled it
Code:

root@kali:/# yum reinstall kernel-2.6.32-431.29.2.el6.x86_64
But i stucked in grub-install i tried:
Code:

root@kali:/# grub-install /dev/sda
Probing devices to guess BIOS drives. This may take a long time.
Could not find device for /boot
root@kali:/# grub-install /dev/sda1
Could not find device for /boot

What to do now ?
Btw. do i need install initrd ?

yancek 10-23-2014 10:51 PM

Quote:

root@kali:/# grub-install /dev/sda
No need to do that as you already have Grub installed to the mbr/sda. It's the /boot partition that is messed up and yes, you need to install an initrd. With Grub Legacy, you need the stage1 and stage2 files in /boot or you will get an error. See the link to the Grub Manual below, at the bottom of the page it explains the grub-install when you have a root partition. The problem is, there is no grub.conf file and this will not create it.

https://www.gnu.org/software/grub/ma...2dinstall.html

A simple sample grub.conf file at the link below:

http://wiki.centos.org/HowTos/GrubInstallation

blackRonin 10-24-2014 12:24 AM

So i need create grub.conf ?

What will be grub designation for root / partition if it's lv ? ( i showed you lsblk before). (hd0,1) ?

Till now i typed to grub.conf:

default=0
timeout=10

title CentOS 6.5
root (hd0,1) ??
kernel /boot/vmlinuz-2.6.32-431.29.2.el6.x86_64 ro root=/dev/sda2?? rhgb noquiet
initrd /boot/initramfs-2.6.32-431.29.2.el6.x86_64.img

I don't understand bolded parts

Is this will be good grub.conf ?

yancek 10-24-2014 10:06 AM

In the second link I posted above, read section 5.1 about the entries if you have a separate boot partition. According to that, your root line should be: root (hd0,0) since that is where the kernel and initrd are.

The part at the end of the kernel line should be: root=/dev/sda2

if the rest of the filesystem is on sda2. That's the way I understand it. Make a note of any changes you make so you know what you have done. I don't use CentOS or a separate boot partition but the page above makes sense.

blackRonin 10-26-2014 02:57 AM

i switched root=/dev/sda2 to /dev/mapper/vg_centosx220-lv_root, because after reboot i had somekind drakut problem.

After reboot, i saw problems with checking filesystems

i typed fsck -fp /dev/mapper/vg_centosx220-lv_var
but it didn't helped after reboot.

So i had to uncomment this (and few more filesystems) in /etc/fstab

Then i got another problem with:
fsck.ext4: Unable To Resolve UUID

so i switched uuid to /dev/sda1 near /boot partition.

But now , after long booting (inj plymount)

I see only Centos 6 grafic, and nothing else.

yancek 10-26-2014 08:19 AM

It would be helpful if you were more specific about what 'problem' you have whether it is with dracut or uuid. Someone might recognize it. I don't use CentOS and have never used LVM so don't really know what you need there. You might try googling the problem specific to Red Hat/CentOS or posting more details here.

blackRonin 10-28-2014 05:18 AM

Problem solved.

Once again i typed uuid for my device, and it worked well/

I think maybe uuid changed itself.


All times are GMT -5. The time now is 10:20 AM.