Linux - NewbieThis 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
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.
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.
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).
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.
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.
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 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.
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)
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=/.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.