LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-23-2014, 03:34 AM   #1
blackRonin
Member
 
Registered: Jun 2014
Distribution: CentOS 6.5
Posts: 65

Rep: Reputation: Disabled
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 ?

Last edited by blackRonin; 10-23-2014 at 11:21 PM.
 
Old 10-23-2014, 08:36 AM   #2
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: PCLinux, Slackware
Posts: 6,871

Rep: Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249
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.
 
Old 10-23-2014, 08:40 AM   #3
blackRonin
Member
 
Registered: Jun 2014
Distribution: CentOS 6.5
Posts: 65

Original Poster
Rep: Reputation: Disabled
Yes, i have those folders.

I have /boot on separate partition /dev/sda1, and it's empty (only have lost and foud folder)
 
Old 10-23-2014, 12:08 PM   #4
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: PCLinux, Slackware
Posts: 6,871

Rep: Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249
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?
 
Old 10-23-2014, 04:01 PM   #5
EDDY1
LQ Addict
 
Registered: Mar 2010
Location: Oakland,Ca
Distribution: wins7, Debian wheezy
Posts: 6,838

Rep: Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649
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.

Last edited by EDDY1; 10-23-2014 at 04:08 PM.
 
Old 10-23-2014, 11:32 PM   #6
blackRonin
Member
 
Registered: Jun 2014
Distribution: CentOS 6.5
Posts: 65

Original Poster
Rep: Reputation: Disabled
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 ?
 
Old 10-23-2014, 11:51 PM   #7
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: PCLinux, Slackware
Posts: 6,871

Rep: Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249
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
 
Old 10-24-2014, 01:24 AM   #8
blackRonin
Member
 
Registered: Jun 2014
Distribution: CentOS 6.5
Posts: 65

Original Poster
Rep: Reputation: Disabled
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 ?

Last edited by blackRonin; 10-24-2014 at 03:44 AM.
 
Old 10-24-2014, 11:06 AM   #9
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: PCLinux, Slackware
Posts: 6,871

Rep: Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249
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.
 
Old 10-26-2014, 03:57 AM   #10
blackRonin
Member
 
Registered: Jun 2014
Distribution: CentOS 6.5
Posts: 65

Original Poster
Rep: Reputation: Disabled
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.
 
Old 10-26-2014, 09:19 AM   #11
yancek
LQ Guru
 
Registered: Apr 2008
Distribution: PCLinux, Slackware
Posts: 6,871

Rep: Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249Reputation: 1249
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.
 
Old 10-28-2014, 06:18 AM   #12
blackRonin
Member
 
Registered: Jun 2014
Distribution: CentOS 6.5
Posts: 65

Original Poster
Rep: Reputation: Disabled
Problem solved.

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

I think maybe uuid changed itself.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Recover Formatted Partition astro.alireza Linux - Software 3 07-19-2013 07:58 AM
Dual boot, Linux partition formatted but not booting into Windows. chandan766 Linux - Newbie 5 08-11-2011 09:42 PM
[SOLVED] Just formatted partition (ext4) is 5.4% used!? 512upload Ubuntu 16 11-14-2010 12:00 PM
Recovering formatted partition TowiKromo Linux - Laptop and Netbook 1 11-10-2006 04:21 PM
partition formatted on each new installation? timsch75 Linux - Newbie 2 03-01-2004 12:28 PM


All times are GMT -5. The time now is 08:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration