LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 01-07-2013, 02:30 AM   #1
Durque
LQ Newbie
 
Registered: Nov 2012
Distribution: OpenSuSE; Mint
Posts: 6

Rep: Reputation: Disabled
dual-boot messed up partition table?


Greetings
Being an advocate for LVM, I was called upon to help "fix things", and I soon realized I'm in over my head on this one.

User has already Opensuse (w/LVM) running and tried to install Windows on a unused hard drive as dual-boot. Install failed and LVM disappeared from boot. The system now just partly boots. Booting fails and stops when VG is not found and three LVs are not mounted. There is one VG, vg00, on one PV with three LVs. System has three hard drives.
I suspect the failed installation messed up partitioning badly. Such that a /dev/sda4 partition is missing. (System is temporarily running on liveCD)

Alas this is a very poorly documented system. Backup is way outdated. User accepts the risk of loosing all data. But thinks it's worth a try to exploit any chances of getting any data off the disk...

Here's the fdisk print out.

Code:
$ sudo fdisk -l

Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
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: 0x000c33e1

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1          10       71680   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2   *          10        1577    12587008   83  Linux
Partition 2 does not end on cylinder boundary.
/dev/sda3            1577        1838     2096128   82  Linux swap / Solaris
Partition 3 does not end on cylinder boundary.

Disk /dev/sdb: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
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: 0x000d461c

   Device Boot      Start         End      Blocks   Id  System

Disk /dev/sdc: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
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: 0x0005095f
   Device Boot      Start         End      Blocks   Id  System

Disk /dev/sdd: 16.2 GB, 16240345088 bytes
114 heads, 40 sectors/track, 6956 cylinders
Units = cylinders of 4560 * 512 = 2334720 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xc3072e18

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1   *           1        6957    15859692    c  W95 FAT32 (LBA)
mint@mint ~ $
To my knowledge /dev/sda1 is /boot and /dev/sda2 is /<root>.

Here's the LVM configuration (/etc/LVM)

Code:
mint@mint ~ $ sudo  ls -lR /mnt/opensuse/etc/lvm
/mnt/opensuse/etc/lvm:
total 24
drwxr-xr-x 2 root root  4096 2012-01-12 09:33 archive
drwxr-xr-x 2 root root  4096 2012-01-12 09:33 backup
-rw-r--r-- 1 root root 10937 2012-01-12 09:33 lvm.conf
drwxr-xr-x 2 root root  4096 2012-01-12 09:33 metadata

/mnt/opensuse/etc/lvm/archive:
total 48
-rw------- 1 root root 3345 2010-10-10 09:02 old_vg_00000.vg
-rw------- 1 root root 3312 2010-10-10 18:10 old_vg_00001.vg
-rw------- 1 root root 1763 2010-10-03 13:13 vg00_00009.vg
-rw------- 1 root root 1766 2010-10-03 13:30 vg00_00010.vg
-rw------- 1 root root 3314 2010-10-03 13:30 vg00_00011.vg
-rw------- 1 root root 3314 2010-10-03 13:30 vg00_00012.vg
-rw------- 1 root root 1766 2010-10-03 13:30 vg00_00013.vg
-rw------- 1 root root 1763 2010-10-03 13:30 vg00_00014.vg
-rw------- 1 root root 3311 2010-10-03 13:30 vg00_00015.vg
-rw------- 1 root root 3311 2010-10-03 13:30 vg00_00016.vg
-rw------- 1 root root 1763 2010-10-03 13:30 vg00_00017.vg
-rw------- 1 root root 1785 2011-09-11 10:35 vg00_00018.vg

/mnt/opensuse/etc/lvm/backup:
total 8
-rw------- 1 root root 3347 2010-10-10 18:10 old_vg
-rw------- 1 root root 1784 2011-09-11 10:35 vg00

/mnt/opensuse/etc/lvm/metadata:
total 0
mint@mint ~ $
I thought the LVM backup could be relevant.

Code:
mint@mint ~ $ sudo  cat /mnt/opensuse/etc/lvm/backup/vg00
# Generated by LVM2 version 2.02.67(2) (2010-06-04): Sun Sep 11 12:35:13 2011

contents = "Text Format Volume Group"
version = 1

description = "Created *after* executing '/sbin/lvextend -l +1280 /dev/vg00/lv_opt'"

creation_host = "durque"	# Linux durque 2.6.34.10-0.2-default #1 SMP 2011-07-20 18:48:56 +0200 i686
creation_time = 1315737313	# Sun Sep 11 12:35:13 2011

vg00 {
	id = "CKvXPy-1gA8-x4v4-1Q0G-zR16-0IVZ-8YBIXU"
	seqno = 5
	status = ["RESIZEABLE", "READ", "WRITE"]
	flags = []
	extent_size = 8192		# 4 Megabytes
	max_lv = 0
	max_pv = 0

	physical_volumes {

		pv0 {
			id = "bf4yVy-k8Ue-V9PI-27V1-JumP-ETLU-J4eeuD"
			device = "/dev/sda4"	# Hint only

			status = ["ALLOCATABLE"]
			flags = []
			dev_size = 126789632	# 60.458 Gigabytes
			pe_start = 384
			pe_count = 15477	# 60.457 Gigabytes
		}
	}

	logical_volumes {

		lv_felles {
			id = "XU2oCn-6TcG-8252-j7Re-juCS-s3XN-HCd4jr"
			status = ["READ", "WRITE", "VISIBLE"]
			flags = []
			segment_count = 1

			segment1 {
				start_extent = 0
				extent_count = 3956	# 15.4531 Gigabytes

				type = "striped"
				stripe_count = 1	# linear

				stripes = [
					"pv0", 0
				]
			}
		}

		lv_home {
			id = "yEBZfc-5zyj-9n8T-moct-pzqL-C20A-ksYLcg"
			status = ["READ", "WRITE", "VISIBLE"]
			flags = []
			segment_count = 1

			segment1 {
				start_extent = 0
				extent_count = 3840	# 15 Gigabytes

				type = "striped"
				stripe_count = 1	# linear

				stripes = [
					"pv0", 3956
				]
			}
		}
		lv_opt {
			id = "qOoKrN-y1Ci-J12x-ZPaD-gFfe-KAMY-e510TM"
			status = ["READ", "WRITE", "VISIBLE"]
			flags = []
			segment_count = 1

			segment1 {
				start_extent = 0
				extent_count = 5120	# 20 Gigabytes

				type = "striped"
				stripe_count = 1	# linear

				stripes = [
					"pv0", 7796
				]
			}
		}
	}
}
mint@mint ~ $
Here's /etc/fstab.
Code:
mint@mint ~ $ sudo cat /mnt/opensuse/etc/fstab
# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
/dev/disk/by-id/ata-ST380215A_5QZ0A66D-part3 swap                 swap       defaults              0 0
/dev/disk/by-id/ata-ST380215A_5QZ0A66D-part2 /                    ext4       acl,user_xattr        1 1
/dev/disk/by-id/ata-ST380215A_5QZ0A66D-part1 /boot                ext4       acl,user_xattr        1 2
/dev/vg00/lv_home    /home                ext4       acl,user_xattr        1 2
/dev/vg00/lv_felles  /mnt/felles          ext4       defaults              1 2
/dev/vg00/lv_opt     /opt                 ext4       acl,user_xattr        1 2
proc                 /proc                proc       defaults              0 0
sysfs                /sys                 sysfs      noauto                0 0
debugfs              /sys/kernel/debug    debugfs    noauto                0 0
usbfs                /proc/bus/usb        usbfs      noauto                0 0
devpts               /dev/pts             devpts     mode=0620,gid=5       0 0
#UUID=23b07c85-4984-4b31-b849-889bcca7874c	/boot	ext4	defaults	1	2
mint@mint ~ $
How to get LV's back?

I can see there is a sector number in the archived configuration file (/etc/lvm/backup/vg00).

To restore the missing partition, can I use the sector number listed in "/etc/lvm/backup/vg00"? If so how?

BTW:
I spent some time to figure out which category to post this. Not sure if this one is the right one.
 
Old 01-07-2013, 11:18 AM   #2
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
It's probably just a matter of re-creating sda4. Please post the output from "fdisk -lu /dev/sda" to show the partitioning in exact sector units.

(Since this is very much Linux related, I've asked that it be moved to a more appropriate forum.)
 
1 members found this post helpful.
Old 01-07-2013, 06:32 PM   #3
Durque
LQ Newbie
 
Registered: Nov 2012
Distribution: OpenSuSE; Mint
Posts: 6

Original Poster
Rep: Reputation: Disabled
Code:
mint ~ # fdisk -lu /dev/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
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000c33e1

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048      145407       71680   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2   *      145408    25319423    12587008   83  Linux
Partition 2 does not end on cylinder boundary.
/dev/sda3        25319424    29511679     2096128   82  Linux swap / Solaris
Partition 3 does not end on cylinder boundary.
mint ~ #
Alternatively

Code:
mint ~ #  sfdisk -uS -l /dev/sda

Disk /dev/sda: 9729 cylinders, 255 heads, 63 sectors/track
Units = sectors of 512 bytes, counting from 0

   Device Boot    Start       End   #sectors  Id  System
/dev/sda1          2048    145407     143360  83  Linux
		end: (c,h,s) expected (9,13,4) found (9,148,4)
/dev/sda2   *    145408  25319423   25174016  83  Linux
		start: (c,h,s) expected (9,13,5) found (9,148,5)
		end: (c,h,s) expected (1023,254,63) found (1023,135,39)
/dev/sda3      25319424  29511679    4192256  82  Linux swap / Solaris
		start: (c,h,s) expected (1023,254,63) found (1023,135,40)
		end: (c,h,s) expected (1023,254,63) found (1023,199,23)
/dev/sda4             0         -          0   0  Empty
mint ~ #

Last edited by Durque; 01-07-2013 at 06:39 PM.
 
Old 01-07-2013, 09:39 PM   #4
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
The space following partition 4 on the disk (156301488-29511679 = 126789809 sectors) is just a little larger than the size of pv0 (dev_size = 126789632). I was hoping to see an exact match, but I would try running "fdisk -u /dev/sda" and creating, in sector address mode, a partition starting right after sda3 (sector 29511680) and extending to the end of the disk. (Note that creating/deleting primary partitions with fdisk is 100% safe. The only writes that occur are to the partition table in the MBR.) Set the partition type to 8e "Linux LVM" (not that it really matters), and see if then running pvscan doesn't make your volume group reappear.

Failing that, I would download one of the live CDs that includes testdisk (my own favorite is System Rescue CD) and see if testdisk can locate your LVM Physical Volume.
 
1 members found this post helpful.
Old 01-08-2013, 03:08 AM   #5
Durque
LQ Newbie
 
Registered: Nov 2012
Distribution: OpenSuSE; Mint
Posts: 6

Original Poster
Rep: Reputation: Disabled
Excellent. I will try that later today. I suspect the reason for no exact match in sectors is due to rounding of numbers. It might me that the partition is created using rounded GigaBytes.

I've used testdisk some time ago for fixing Grub/MBR. If it comes to recovering partitions I hope I can get some pointers? Should I then continue this thread or start a new?
 
Old 01-08-2013, 08:48 AM   #6
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
If you have questions about testdisk in general, it's probably best to start a new thread. For details about solving this particular problem, keep it here to keep the thread together. My own experience with testdisk is very limited as I've never had to use it for a real problem, but it looks like a fair number of people are following this thread so you'll probably get some answers right here.
 
1 members found this post helpful.
Old 01-09-2013, 06:17 PM   #7
Durque
LQ Newbie
 
Registered: Nov 2012
Distribution: OpenSuSE; Mint
Posts: 6

Original Poster
Rep: Reputation: Disabled
Thumbs up

Got it! Here's the log
Code:
mint ~ # fdisk -u /dev/sda

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c').

Command (m for help):n
Command action
   e   extended
   p   primary partition (1-4)
p
Selected partition 4
First sector (63-156301487, default 63): 29511680
Last sector, +sectors or +size{K,M,G} (29511680-156301487, default 156301487): 
Using default value 156301487

Command (m for help):
 t
Partition number (1-4): 4
Hex code (type L to list codes): 8e
Changed system type of partition 4 to 8e (Linux LVM)

Command (m for help): p

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
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000c33e1

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048      145407       71680   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2   *      145408    25319423    12587008   83  Linux
Partition 2 does not end on cylinder boundary.
/dev/sda3        25319424    29511679     2096128   82  Linux swap / Solaris
Partition 3 does not end on cylinder boundary.
/dev/sda4        29511680   156301487    63394904   8e  Linux LVM

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
mint ~ # pvscan
  No matching physical volumes found
I then did a shutdown, removed LiveCD, rebooted, and everything worked strait off.
The VG was found, the lV's was found (and fsck-ed; no bugs) and mount.

User is extremely happy.

Thanx rknichols
 
  


Reply



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
Dual Boot windows messed up partition table and bootloader Abraxis Linux - Newbie 3 04-26-2009 04:45 PM
Partition Table Recovery in Linux/XP Dual Boot PC kumarnine Linux - Software 3 04-19-2006 10:50 PM
Messed up partition table and Windows' partition boot sector pyromithrandir Linux - General 32 04-08-2006 12:26 PM
Dual Boot Partition Table inescapeableus Linux - Software 1 10-23-2004 04:44 PM
HELP machine won't boot (partition table messed up???) nfisk Linux - General 7 02-02-2003 05:12 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:57 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
Open Source Consulting | Domain Registration