LinuxQuestions.org
Help answer threads with 0 replies.
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 02-07-2007, 12:32 AM   #1
wahming
Member
 
Registered: Jan 2007
Posts: 133

Rep: Reputation: 15
dd fresh install to separate partition


I'm tired of reinstalling linux on my sandbox pc. Would it be feasible to create a /boot partition, create 2 more equal-sized partitions, use one of them as /, and use dd to backup the / partition to the other? Upon screwing up /, I could then boot to the backup and restore / to the fresh install. Am I missing some other factor?

Edit - anybody who got confused by the convoluted post above, raise your hands.

Last edited by wahming; 02-07-2007 at 12:54 AM.
 
Old 02-07-2007, 01:43 AM   #2
SciYro
Senior Member
 
Registered: Oct 2003
Location: hopefully not here
Distribution: Gentoo
Posts: 2,038

Rep: Reputation: 51
it should be possible, and it should work, but only if the partition sizes match perfectly. If this isent possible, another solution is to tarball the entire / directory tree, store it somewhere safe, and when you need to recover, boot in, reformat /, then unpack the tarball, then run "lilo" to reset the bootloader (if you use another bootloader, just make sure it will boot what you unpacked).
 
Old 02-07-2007, 01:49 AM   #3
wahming
Member
 
Registered: Jan 2007
Posts: 133

Original Poster
Rep: Reputation: 15
Trying it out right now. At least I have something to try the next time I crash the sandbox.

Btw, dd if=/dev/hda2 of=/dev/hda3 isn't going to screw up the partition table, is it? Not sure if the EBR's are actually located on the drives themselves.
 
Old 02-07-2007, 02:04 AM   #4
Electro
LQ Guru
 
Registered: Jan 2002
Posts: 6,042

Rep: Reputation: Disabled
If both drives are similar models and brands, using dd could work. To do it correctly, I suggest the following.
dd if=/dev/hda of=/dev/hdc conv=sync,notrunc bs=512

This will do a sector by sector copy. Though it will not work if the drives are different. I recommend using dar to create mirror copy of your files. Unfortunately, you will have to create the partitions and mount them on your own.
 
Old 02-07-2007, 02:10 AM   #5
SciYro
Senior Member
 
Registered: Oct 2003
Location: hopefully not here
Distribution: Gentoo
Posts: 2,038

Rep: Reputation: 51
I believe the partition table is located within the boot sector, in any case, i dont think Linux exports that info thru /dev/hda*, /dev/hda and you can mess with partition tables
 
Old 02-07-2007, 02:12 AM   #6
wahming
Member
 
Registered: Jan 2007
Posts: 133

Original Poster
Rep: Reputation: 15
Right, thanks for the help
 
Old 02-07-2007, 07:31 AM   #7
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by SciYro
I believe the partition table is located within the boot sector, in any case, i dont think Linux exports that info thru /dev/hda*, /dev/hda and you can mess with partition tables
I think it's like this: The mbr--which includes the **primary** partition table-- is the first sector of the drive. Then each partition has a "boot sector" which can contain more boot code + the partition tables for logical partitions.
 
Old 02-07-2007, 07:33 AM   #8
wahming
Member
 
Registered: Jan 2007
Posts: 133

Original Poster
Rep: Reputation: 15
I got that much. I just wanted to know if the dd command would copy the "partition boot sector" as well. I gather not, from SciYro's response.
 
Old 02-07-2007, 07:51 AM   #9
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Just when you think you understand things.....My system has 63-sector gaps between all the logical partitions, but no gaps between the primaries.

So if I use dd to copy a primary, I get the boot sector, but not if copying a logical????

Someone bring me back my Apple-II....
 
Old 02-07-2007, 07:57 AM   #10
wahming
Member
 
Registered: Jan 2007
Posts: 133

Original Poster
Rep: Reputation: 15
Well, you could copy the extended partition - that'd give you all your boot sectors minus the three primary ones =D

Also a whole ton of data/junk, oh well
 
Old 02-07-2007, 11:16 AM   #11
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by wahming
Well, you could copy the extended partition - that'd give you all your boot sectors minus the three primary ones =D

Also a whole ton of data/junk, oh well
Does anyone know if this actually works? You can't normally access an extended--eg you cannot mount it.
 
Old 02-07-2007, 11:22 AM   #12
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by pixellany
Just when you think you understand things.....My system has 63-sector gaps between all the logical partitions, but no gaps between the primaries.

So if I use dd to copy a primary, I get the boot sector, but not if copying a logical????

Someone bring me back my Apple-II....

OK!!! partial answer

At the front of the disk are 63 sectors (before the 1st primary partition)
The first sector is the mbr and has the stage1 boot code + the primary partition table.

Then--in front of every logical partition, there is another 63 sectors, with the first one containing a two entry partition table:
the first one points to the logical partition (63 sectors down)
the second one points to the next 63-sector segment preceding the next logical

If there is boot code in a partition, it appears to go inside the actual partition, and not in the 63-sector dividers.

So--yes--copying a partition will capture the partition boot sector (but not the mbr)
 
Old 02-07-2007, 08:00 PM   #13
wahming
Member
 
Registered: Jan 2007
Posts: 133

Original Poster
Rep: Reputation: 15
The dd process I suggested, "dd if=/dev/hda2 of=/dev/hda3" appears to be a bad idea. Linux now refuses to boot without moaning about filesystem errors and what not. hda3 is listed in fstab as LABEL=/backup, but dd has apparently changed its label to LABEL=/. This has resulted in TWO root filesystems (far as Linux is concerned) causing it to panic and reboot at startup.

Solution - enter rescue mode, edit /etc/fstab and /boot/grub.conf to look for /dev/hda2 instead of LABEL=/.
 
Old 02-08-2007, 08:04 PM   #14
wahming
Member
 
Registered: Jan 2007
Posts: 133

Original Poster
Rep: Reputation: 15
Update- the restore process worked like a charm. 1 thing - I had to boot into the restore partition (hda3) before I could overwrite hda2. Skipping that step led to a corrupted hda2.
 
  


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
Grub install with separate boot partition oomfoofoo Slackware - Installation 3 12-29-2006 11:04 AM
Fresh install of SUSE, windows partition is mounted but no GRUB entry irunfast1000 Linux - General 1 10-12-2006 03:49 PM
invalid partition table - fresh install mpelts Linux - General 3 08-29-2006 07:33 AM
FastTrak Raid causing Buffer I/O Error on fresh FC2 install on a separate IDE drive abunn Linux - Hardware 3 10-21-2004 12:22 PM
fresh install (fresh headache) powadha Slackware 2 03-06-2004 01:03 PM

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

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