LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-11-2008, 09:11 PM   #16
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,331

Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357

If you haven't rebooted, your last-known partition info is in /proc/partitions. Just save that pseudo-file (it's actually memory) to a flashdrive or print it so you have some idea of your partition setup if you reboot and find your partition tables really gone.

Your partition table is part of your MBR (Master Boot Record) which in turn is part of "Track 0" (the first track on your harddrive). The MBR is the first sector (512 bytes) or track zero (which is 63 sectors -> 63x512 bytes).

So, to copy your MBR (which includes the partition table), do this:

dd bs=512 if=/dev/sda of=/tmp/first_disk_mbr.bin

You will have to adjust the above example where I used /dev/sda so that it points the disk you want to look at. DO NOT CONFUSE "if" (Input File) and "of" (Output File) otherwise you will lay waste to you MBR!!!

To copy all of Track 0, just modify the above command a little:

dd bs=512 count=63 if=/dev/sda of=/tmp/first_disk_track0.bin

Before I said your partition table was only 16 bytes long. Wrong! I don't know where that stupid thought popped into my head. It's 64 bytes long. Each RECORD within the partition table is 16 bytes long, and there are four recods total. Sorry about my brain-fart there. Don't know what I was thinking.

Your 512 byte long MBR is broken up like this:

first 446 bytes: boot code

next 64 bytes: partition table

last 2 bytes: Should be set to something specific (I forgot what, but it's always the same). I *think* Windows and some other tools might look at these two bytes, but I don't think Linux does.

I forgot the structure of a single partition record within the partition table, but I'm sure a Google search would reveal lot's of help in that area. You should be able to use "dd" to dump your MBR to a file, then use "od" to examine the 64 bytes of that that make up the partition table. By the way, did I remember to say DO NOT CONFUSE "if" and "of" ???!!!
 
Old 04-10-2009, 01:42 PM   #17
akelder
Member
 
Registered: Jan 2007
Distribution: debian on servers, ubuntu on desktops/laptops
Posts: 45

Original Poster
Rep: Reputation: 16
The solution ended up being the following:

Took one of the members of the RAID1 array, attached to the new system with working LVM. pvscan and vgscan showed the LVM on the single disk, activated with "vgchange -a y", mounted the logical volumes and moved off the data (this is where I also learned that keeping VG names unique between systems is handy when trying to access LVM on a different system with existing LVM setup). Still unclear as to why LVM was mad on the old box.

This was the easiest solution because that machine was using RAID1 and so each disk in the array had a copy of all the data. I since had to help someone who was using Linux MD RAID5 (yuck!) and had a motherboard failure. The fix there was to grab the RAID info from /etc/mdadm/mdadm.conf (he had wisely previously emailed himself that config along with output of "cat /proc/mdstat" and "mdadm -D /dev/md1"). Boot that system to a live cd (sysresccd.org is a life saver), recreate the array using the array info and move off the data.

Bottom line is, Linux MD Raid and LVM are awesome tools. Go Open Source. Yay.
 
Old 04-11-2009, 01:57 AM   #18
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,375

Rep: Reputation: 2755Reputation: 2755Reputation: 2755Reputation: 2755Reputation: 2755Reputation: 2755Reputation: 2755Reputation: 2755Reputation: 2755Reputation: 2755Reputation: 2755
Just FYI, nice diagram & explanation of MBR layout: http://en.wikipedia.org/wiki/Master_boot_record
 
  


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
programs just dissapeared ljiljan Mandriva 6 02-15-2006 05:18 AM
My Desktop dissapeared ALInux Linux - Software 2 08-24-2005 05:53 AM
Broadcast route dissapeared 84Monte-Carlo Linux - Networking 3 12-22-2004 02:30 AM
eth0 dissapeared digital21st Slackware 6 11-19-2004 02:10 PM
Files dissapeared RMSe17 Linux - Software 3 07-29-2004 05:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:09 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