[SOLVED] Recovering from possibly corrupted (by pvcreate) boot partition
Red HatThis forum is for the discussion of Red Hat Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Recovering from possibly corrupted (by pvcreate) boot partition
I had a dual boot system where I partitioned the HD: ~30 GB for Ubuntu 11.4 and ~47 GB for CentOS 6.5. I wanted to make a separate logical partition for /tmp and /home on the CentOS side. However, when I entered
Code:
sudo vgs
I got
Code:
No volume groups found
When I entered
Code:
sudo fdisk -l
I got
Code:
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x8b8e8b8e
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 5953 9730 30336001 5 Extended
/dev/sda3 64 5953 47300608 83 Linux
/dev/sda5 5953 9600 29296640 83 Linux
/dev/sda6 9601 9730 1038336 82 Linux swap / Solaris
Partition table entries are not in disk order
I entered
Code:
$ sudo pvcreate /dev/sda1
Physical volume "/dev/sda1" successfully created
Now, after doing further reading, it appears that this has likely corrupted the boot partition. The computer still appears to be working fine but I am worried it will not boot up if I have to reboot it. I did see instructions here about repairing a corrupted boot partition here. Is that what I need to do or could I just copy files from the installation DVD to /boot? I was able to explore the /boot directory using places:Computer.
So your CentOS system is ok as it didn't mount /dev/sda1.
It may still not be bootable, depending on what system was the "owner" of the MBR. I'd be guessing Ubuntu as it's generally better at finding other operating systems than RHEL/Centos was last I looked. From CentOS, go here, and do as it says and post the RESULTS.txt so we can see the boot layout.
So your CentOS system is ok as it didn't mount /dev/sda1.
It may still not be bootable, depending on what system was the "owner" of the MBR. I'd be guessing Ubuntu as it's generally better at finding other operating systems than RHEL/Centos was last I looked.
I meant to say that I was running CentOS when I ran pvcreate.
Quote:
Originally Posted by syg00
From CentOS, go here, and do as it says and post the RESULTS.txt so we can see the boot layout.
Code:
$ cat RESULTS.txt
Boot Info Script 0.61 [1 April 2012]
============================= Boot Info Summary: ===============================
=> Grub Legacy0.97 is installed in the MBR of /dev/sda and looks at sector
26647216 on boot drive #1 for the stage2 file. A stage2 file is at this
location on /dev/sda. Stage2 looks on partition #3 for
/boot/grub/grub.conf..
sda1: __________________________________________________________________________
File system: LVM2_member
Boot sector type: -
Boot sector info:
sda2: __________________________________________________________________________
File system: Extended Partition
Boot sector type: Unknown
Boot sector info:
sda5: __________________________________________________________________________
File system: LVM2_member
Boot sector type: -
Boot sector info:
sda6: __________________________________________________________________________
File system: swap
Boot sector type: -
Boot sector info:
sda3: __________________________________________________________________________
File system: ext4
Boot sector type: -
Boot sector info:
Operating System: CentOS release 6.5 (Final)
Kernel on an
Boot files: /boot/grub/menu.lst /boot/grub/grub.conf /etc/fstab
============================ Drive/Partition Info: =============================
Drive: sda _____________________________________________________________________
Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders, total 156301488 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
Partition Boot Start Sector End Sector # of Sectors Id System
/dev/sda1 * 2,048 1,026,047 1,024,000 83 Linux
/dev/sda2 95,629,310 156,301,311 60,672,002 5 Extended
/dev/sda5 95,629,312 154,222,591 58,593,280 83 Linux
/dev/sda6 154,224,640 156,301,311 2,076,672 82 Linux swap / Solaris
/dev/sda3 1,026,048 95,627,263 94,601,216 83 Linux
"blkid" output: ________________________________________________________________
Device UUID TYPE LABEL
/dev/sda1 3w4BJc-az4w-yY6t-3CkS-2p2l-xDRI-AkfctS LVM2_member
/dev/sda3 ccc57a57-71bd-4dc7-9e03-2101d0c7250a ext4
/dev/sda5 Y3ggGF-hVjw-PF5Y-ai9h-jNjN-R8aF-3taxPO LVM2_member
/dev/sda6 bdfe2d90-d3c5-44b7-926a-ee5bd1fb1858 swap
================================ Mount points: =================================
Device Mount_Point Type Options
/dev/sda3 / ext4 (rw)
========================== sda3/boot/grub/grub.conf: ===========================
--------------------------------------------------------------------------------
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You do not have a /boot partition. This means that
# all kernel and initrd paths are relative to /, eg.
# root (hd0,2)
# kernel /boot/vmlinuz-version ro root=/dev/sda3
# initrd /boot/initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,2)/boot/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.32-431.17.1.el6.i686)
root (hd0,2)
kernel /boot/vmlinuz-2.6.32-431.17.1.el6.i686 ro root=UUID=ccc57a57-71bd-4dc7-9e03-2101d0c7250a nomodeset rd_NO_LUKS KEYBOARDTYPE=pc KEYTABLE=us LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_NO_LVM rd_NO_DM rhgb quiet
initrd /boot/initramfs-2.6.32-431.17.1.el6.i686.img
title CentOS (2.6.32-431.11.2.el6.i686)
root (hd0,2)
kernel /boot/vmlinuz-2.6.32-431.11.2.el6.i686 ro root=UUID=ccc57a57-71bd-4dc7-9e03-2101d0c7250a nomodeset rd_NO_LUKS KEYBOARDTYPE=pc KEYTABLE=us LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_NO_LVM rd_NO_DM rhgb quiet
initrd /boot/initramfs-2.6.32-431.11.2.el6.i686.img
title CentOS (2.6.32-431.el6.i686)
root (hd0,2)
kernel /boot/vmlinuz-2.6.32-431.el6.i686 ro root=UUID=ccc57a57-71bd-4dc7-9e03-2101d0c7250a nomodeset rd_NO_LUKS KEYBOARDTYPE=pc KEYTABLE=us LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_NO_LVM rd_NO_DM rhgb quiet
initrd /boot/initramfs-2.6.32-431.el6.i686.img
--------------------------------------------------------------------------------
=============================== sda3/etc/fstab: ================================
--------------------------------------------------------------------------------
#
# /etc/fstab
# Created by anaconda on Tue Mar 25 19:01:40 2014
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=ccc57a57-71bd-4dc7-9e03-2101d0c7250a / ext4 defaults 1 1
UUID=bdfe2d90-d3c5-44b7-926a-ee5bd1fb1858 swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
--------------------------------------------------------------------------------
=================== sda3: Location of files loaded by Grub: ====================
GiB - GB File Fragment(s)
12.643165588 = 13.575495680 boot/grub/grub.conf 1
12.643165588 = 13.575495680 boot/grub/menu.lst 1
12.706501007 = 13.643501568 boot/grub/stage2 1
1.090335846 = 1.170739200 boot/initramfs-2.6.32-431.11.2.el6.i686.img 1
2.043476105 = 2.194165760 boot/initramfs-2.6.32-431.17.1.el6.i686.img 2
1.402793884 = 1.506238464 boot/initramfs-2.6.32-431.el6.i686.img 1
12.867988586 = 13.816897536 boot/vmlinuz-2.6.32-431.11.2.el6.i686 1
12.766685486 = 13.708124160 boot/vmlinuz-2.6.32-431.17.1.el6.i686 1
12.730445862 = 13.669212160 boot/vmlinuz-2.6.32-431.el6.i686 1
======================== Unknown MBRs/Boot Sectors/etc: ========================
Unknown BootLoader on sda2
00000000 95 aa e4 34 06 68 5e 2c 07 a8 6f 8d 28 ce ee c1 |...4.h^,..o.(...|
00000010 93 b2 b7 6f 17 a6 6c 8f 66 48 45 bb 1c ec 0f 63 |...o..l.fHE....c|
00000020 9e 1b 3a c4 44 e6 47 a1 62 32 d3 88 93 28 f3 0e |..:.D.G.b2...(..|
00000030 50 c2 cc f7 6a 15 fb c3 d4 2f 47 a5 89 c9 94 ea |P...j..../G.....|
00000040 16 40 58 35 e0 f9 20 e1 94 fa e3 2a 95 fd 01 4a |.@X5.. ....*...J|
00000050 ca b6 5e 2a 29 a7 ae 17 93 d9 4f 41 a1 cd 99 df |..^*).....OA....|
00000060 0c e9 a5 40 a1 c9 71 f6 50 d9 1f 70 a6 e3 98 c7 |...@..q.P..p....|
00000070 99 fe 0b e8 89 be 8a 39 a2 62 9a 70 a6 6b 76 42 |.......9.b.p.kvB|
00000080 ba a0 50 71 4e ca 93 4b 34 be 5e ae fb 0d 98 76 |..PqN..K4.^....v|
00000090 6d 01 98 76 67 b2 dc f0 19 0c 4a 79 23 46 55 01 |m..vg.....Jy#FU.|
000000a0 0e 53 f4 6b 19 81 59 eb 86 79 d6 31 0f 9b 6d 77 |.S.k..Y..y.1..mw|
000000b0 10 a4 6f 59 da 6a 41 94 aa 02 1c 9e fb 67 bb 3c |..oY.jA......g.<|
000000c0 55 f1 6d d2 8c 45 68 11 90 0b 88 30 03 ee f5 54 |U.m..Eh....0...T|
000000d0 55 80 c3 a8 3a bb 71 54 2f 8e 84 7a ed 31 0f 9a |U...:.qT/..z.1..|
000000e0 f5 a1 70 c0 19 74 25 3a 1a a8 d8 23 ac 19 a0 be |..p..t%:...#....|
000000f0 cf 66 5b 33 8b 7e 7f 08 f5 ce f8 06 ad bc ab 99 |.f[3.~..........|
00000100 61 ff a5 35 8e a5 a8 2d 06 f6 f7 c6 14 31 19 1f |a..5...-.....1..|
00000110 51 26 9c 12 0e fa 00 66 57 03 f2 0b 1d cb 36 6c |Q&.....fW.....6l|
00000120 94 d9 01 a6 af 16 a3 c9 ef e8 c5 58 b2 6b 15 a4 |...........X.k..|
00000130 80 d9 90 fe 53 a5 2a db 80 b6 c7 65 4d e7 db 16 |....S.*....eM...|
00000140 88 91 94 27 16 8b d1 94 ad d0 d7 53 7e 0f 81 74 |...'.......S~..t|
00000150 c8 47 95 68 15 6d 7f 94 8a 78 f2 5c 8c 43 58 2b |.G.h.m...x.\.CX+|
00000160 de fe 27 e8 19 69 5f ad 64 61 45 17 1b cd 88 05 |..'..i_.daE.....|
00000170 23 b2 6e 81 43 16 30 ac 0c 1a f7 cb 98 d1 61 cd |#.n.C.0.......a.|
00000180 1c 6c 81 85 36 f7 c3 93 bc 94 2e 4f e7 18 ff 99 |.l..6......O....|
00000190 28 c6 73 ce 63 3a ee c7 97 8b c9 9c d7 98 b8 ea |(.s.c:..........|
000001a0 b8 c7 c9 5e 4a 45 cc 15 78 94 19 31 4e e1 85 ea |...^JE..x..1N...|
000001b0 2e 6a 6d 3d bb 4c aa e0 87 21 d6 0b fb 72 00 fe |.jm=.L...!...r..|
000001c0 ff ff 83 fe ff ff 02 00 00 00 00 10 7e 03 00 fe |............~...|
000001d0 ff ff 05 fe ff ff 82 15 7e 03 80 b2 1f 00 00 00 |........~.......|
000001e0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000001f0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa |..............U.|
00000200
=============================== StdErr Messages: ===============================
mdadm: No arrays found in config file or automatically
$
So your CentOS system is ok as it didn't mount /dev/sda1.
It may still not be bootable, depending on what system was the "owner" of the MBR. I'd be guessing Ubuntu as it's generally better at finding other operating systems than RHEL/Centos was last I looked. From CentOS, go here, and do as it says and post the RESULTS.txt so we can see the boot layout.
Sorry. I forgot to mention that I ran pvcreate on the Ubuntu partition as well and can no longer access it from CentOS.
Code:
$ sudo pvcreate /dev/sda1
Physical volume "/dev/sda1" successfully created
$ sudo pvcreate /dev/sda2
dev_is_mpath: failed to get device for 8:2
dev_is_mpath: failed to get device for 8:2
Device /dev/sda2 not found (or ignored by filtering).
$ sudo pvcreate /dev/sda3
Can't open /dev/sda3 exclusively. Mounted filesystem?
$ sudo pvcreate /dev/sda5
dev_is_mpath: failed to get device for 8:5
Physical volume "/dev/sda5" successfully created
$ sudo pvcreate /dev/sda6
dev_is_mpath: failed to get device for 8:6
Can't open /dev/sda6 exclusively. Mounted filesystem?
So as stated it appears that you didn't damage CentOS and it only consists of sda3 and sda6 (swap). I assume that Ubuntu was the other partition(s) and those were probably corrupted when you ran the pvcreate command. ( I see that you already figured that one out)
Did you want to keep Ubuntu? Did you want to create a LVM or just additional logical partitions? It appears that the disk does not have any free space and if you want to create additional logical partitions your going to have to shrink sda3.
So you are deliberately trying to corrupt your running system ?. Not much point trying to help.
Looking at that bootinfo, your system should be bootable. How long it stays that way is likely debatable.
My previous post was about what I did early Monday morning in Australia. That was before I realized that pvcreate was destructive. I should have included that info. in my initial post but did not think it was relevant until the discussion turned to the Ubuntu partition and I noticed that sda5 was an LVM2_member.
So as stated it appears that you didn't damage CentOS and it only consists of sda3 and sda6 (swap). I assume that Ubuntu was the other partition(s) and those were probably corrupted when you ran the pvcreate command. ( I see that you already figured that one out)
Did you want to keep Ubuntu? Did you want to create a LVM or just additional logical partitions? It appears that the disk does not have any free space and if you want to create additional logical partitions your going to have to shrink sda3.
Ubuntu is what I had been using before I installed CentOS. My computer is c. 2001 and does not handle any versions of Ubuntu later than 11.4. I suspect it doesn't handle lighdm but I may be wrong. Ubuntu had been sharing the disk with Windows XP. I replaced the Win XP part with Centos 6.5. I had been keeping Ubuntu just in case I needed a file that I had forgotten to back up.
I wanted to create an LVM because I ran the Lynis audit and it suggested having a separate partition for /tmp and for /home. I thought that the best thing would be to put them into their own logical volumes. I am very new to LVMs having first heard of them a week or two ago so my decisions have not been optimal. Another computer, with Centos 6.5 installed, already have LVM set up so I was able to shrink one of the logical volumes and make another logical volume for /temp.
Could I set up the new logical volumes on the old Ubuntu partition?
Thanks,
OH
Last edited by OtagoHarbour; 06-03-2014 at 09:45 PM.
Yes. One advantage with LVM is that the space of both partitions can be combined. CentOS does have a GUI management tool called system-config-lvm to make things easier.
pvcreate will have overwritten the first 8 KB of any filesystem where it ran successfully. For ext2/3/4 filesystems, e2fsck should be able to recover from that by using a backup super block.
Code:
e2fsck /dev/sda1
e2fsck /dev/sda5
FYI, there is no simple way to convert a partition with an existing filesystem to an LVM member. Stop trying.
pvcreate will have overwritten the first 8 KB of any filesystem where it ran successfully. For ext2/3/4 filesystems, e2fsck should be able to recover from that by using a backup super block.
Code:
e2fsck /dev/sda1
e2fsck /dev/sda5
I ran those commands (with sudo). Initially I got a bunch of messages like
Code:
Free inodes count wrong for group #200 (8176, counted=5651).
Fix<y>?
I hit return every time to accept the defaults. Now I get
However, I no longer see the Ubuntu system under the Places menu. It used to be under Computer (as something like 29 GB File System) but now there is nothing under Computer.
Quote:
Originally Posted by rknichols
FYI, there is no simple way to convert a partition with an existing filesystem to an LVM member. Stop trying.
Should I give up on making a separate partition for /tmp? I think that Lynis suggested it to prevent a hacker from filling up my HD and making it unusable. Are there other ways to prevent his or could it be avoided with the right security?
Re-run those e2fsck commands, but this time include the "-f" option to force a check even though the super block appears clean. You didn't need that option the first time because the filesystem was obviously broken (missing super block).
If the filesystem is OK, I'm not sure why your GUI file manager wouldn't see it. What does "sudo blkid" now report for /dev/sda5? You might just need to log out and back in again to get the list to refresh.
If you want to make a separate partition for /tmp, you will need to use a tool like gparted to shrink one of your existing partitions to make space for a new one. You will need to boot from a rescue disk to do that since some of the operations cannot be done on a mounted filesystem. I recommend SystemRescueCD for that. Note that rearranging partitions is always a dangerous operation and should only be done with a full backup available.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.