LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora
User Name
Password
Fedora This forum is for the discussion of the Fedora Project.

Notices


Reply
  Search this Thread
Old 12-01-2006, 12:48 AM   #1
skellert
LQ Newbie
 
Registered: Nov 2006
Posts: 9

Rep: Reputation: 0
Can't clone FC6 using tar-backup and restore


I've set up a working FC6 system which I am trying to clone onto some of my other machines. The problem is that the cloned systems are hanging during the boot process, even though the file system appears OK.

The procedure I'm following is as follows... This process has worked faultlessly for FC3/4/5 and I've done it *many* times on many different machines with different hardware without trouble.

1) Set up the FC6 system I want to clone. I custom-partition so that there's one "/" partition and a swap partition. "/" is formatted as ext3.

2) Boot knoppix on this machine. Mount the "/" partition and take a full tar backup onto a network partition.

3) Boot knoppix on the machine where I want to dump the clone and mount the network partition containing the cloned tarfile.

4) run fdisk to create "/" and a swap partition on /dev/hda. Format the "/" partition as ext3.

5) untar the tarfile off the network onto /dev/hda1 (the "/" partition).

6) run grub-install --root-directory=/mnt/hda1 /dev/hda

7) Reboot knoppix and the cloned fedora system should reboot happily - but it doesn't

During boot, the last few lines on the console read as follows:

blah blah blah
kjournald starting. Commit interval 5 seconds
EXT3-fs: recovery complete
EXT3-fs: mounted filesystem with ordered data mode.
Setting up other filesystems.
Setting up new root fs.
no fstab.sys, mounting internal defaults
Switching to new root and running init.
umounting old /dev
umounting old /proc
umounting old /sys
exec of init (/sbin/init) failed!!!: No such file or directory
Kernel panic - not syncing: Attempted to kill init!


And there it hangs...

The system from which I cloned displays exactly the same console output up until the "exec of init (/sbin/init) failed!!! (of course, it doesn't fail and continues)

For some reason, its not finding the "/" partition, but I'm sure "/" is there and its an identical clone of the source machine, including /sbin/init which apparently cannot be found. I'm betting there's something funny about the way I format the drive and restore the tarfile that breaks the way that FC6 boots, but which worked just fine under previous versions.

Any ideas or advice??? Is there another (better) way of cloning an FC5 system onto a different dimension hard drive?

(I've considered partimage, but my source disc is 40GB and I have several computers with smaller drives. Partimage won't restore to a smaller partition than the source. I think this is also the case with dd)
 
Old 12-01-2006, 02:05 AM   #2
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
But you could, as far as I know, use dd to create a smaller image than 40GB, which would fit to the new drive. I think you can pass a parameter to dd that tells how much you want to copy.

You could also try out cpio archiving, I might not know it's every difference to tar but one thing is that tar refuses to archive special files whereas cpio doesn't. It's worth a try at least.

Code:
man cpio
helps you use it. Basic functioning:
Code:
ls | cpio -ov > archive.cpio
would create a file archive.cpio which includes every file that ls command produced (as a list). So first you'll create a list of files, then you'll pipe it to cpio and direct to a file. You could also (as root)
Code:
cd /
find ./ -name * | cpio -ov > archive.cpio
which should, if I'm right, create a list of every single file under root partition and create a cpio archive from them (read man find to make sure or find more information).

To unarchive a cpio archive file: first cd to the directory where you wish the contents to be unarchived (cpio has a switch to archive/unarchive the files so that they will get dropped back to exactly where they were on the copy-out'ed system): here we first move to root, then check out the contents of the archive (second line) and if it seems ok, the last line unarchives the contents.
Code:
cd /
cpio -ivt < /path/to/archive.cpio
cpio -iv < /path/to/archive.cpio
Try out and see if it works better (might not, but it's worth a try).
 
Old 12-01-2006, 03:25 PM   #3
skellert
LQ Newbie
 
Registered: Nov 2006
Posts: 9

Original Poster
Rep: Reputation: 0
Thanks for the suggestions. I believe that dd makes a literal sector by sector copy of the drive without discriminating between empty and used sectors. So you can't use dd to copy from a large partition onto a smaller one, and you run into trouble copying from a smaller partition to a larger one too. As I understand, dd is designed to copy between like-sized partitions.

cpio generated the same results as tar. That is, a restored backup of FC6 it doesn't boot this way either.

I've now also tried restoring a tar backup onto *the same* partition that it came from. This also doesn't work with FC6 but as mentioned before, works with previous fedora versions!

I'm suspecting the problem has something to do with a difference between the knoppix 5.0.1 and FC6 versions of either

fdisk
mke2fs
tar
grub-install (or grub in general).

Does anybody know anything about this?
 
Old 12-01-2006, 06:04 PM   #4
skellert
LQ Newbie
 
Registered: Nov 2006
Posts: 9

Original Poster
Rep: Reputation: 0
progress - but why?

I've made progress on my own problem... still confused.. Can anybody help point out why this works...

Instead of booting knoppix 5.0.1, I have booted the FC6 installation disc and used rescue mode.

When the FC6 rescue mode found my /dev/hda1 partition, I told it to mount read-only.

At the command prompt, I immediately unmounted the partition, and formatted using the same mke2fs command I issued under knoppix.

Then I mounted my network nfs partition holding my tar backup and the newly formatted /mnt/hda1

I untarred the FC6 backup off the network partition onto the hard drive - again using an identical command as I'd folloed under knoppix.

I then tried to grub-install, and found a bug in the FC6 rescue disk.... The grub-install script looks for grub in /sbin/grub, yet it's located at /usr/sbin/grub. After manually copying /usr/sbin/grub to /sbin/grub, I ran the identical grub-install command that I'd run under knoppix.

I then rebooted - and FC6 came up perfectly.

So there's a difference between mke2fs, tar or grub between knoppix-5.0.1 and FC6. Which one is it and what is it that is different that's causing the problem???
 
Old 12-06-2006, 10:18 PM   #5
skellert
LQ Newbie
 
Registered: Nov 2006
Posts: 9

Original Poster
Rep: Reputation: 0
Several days ago, I posted (above) that I'd made progress on restoring FC6 from a tar backup. Alas, it now looks as though this one occasion was a fluke. I have not been able to repeat it.

The symptoms are the same as noted before. When I tar up an FC6 installation, rebuild a hard drive using mke2fs and then untar back, the system won't boot. I've tried around ten more systems since my one success above, and all fail the same way. When I reformatted that one system that worked and tried again, it also failed using the same approach that worked before.

When I install FC6 off DVD, it works every time on all machines that fail to restore from tar backup.

I've got two old FC5 backups. Both of these untar and boot no problems on all machines.

I am now pretty sure its not grub. Grub seems to load the kernel and initrd OK every time. Its when changing over from the initrd filesystem to the hard drive that the boot hangs - allegedly not finding "/sbin/init".

I've been wondering whether the FC6 kernel has included some sort of mandatory selinux requirements that are not fulfuled when you simply do a mke2fs and restore from a security-unaware tarfile.

I also noticed that if I format the drive as an ext2 filesystem (ie don't use the -j parameter to mke2fs), then the FC6 boot craps out even earlier.

Any ideas?
 
Old 12-07-2006, 12:10 AM   #6
Mektub
LQ Newbie
 
Registered: Jan 2004
Location: Lisbon, Portugal
Distribution: Arch
Posts: 6

Rep: Reputation: 0
Quote:
Originally Posted by skellert
I am now pretty sure its not grub. Grub seems to load the kernel and initrd OK every time. Its when changing over from the initrd filesystem to the hard drive that the boot hangs - allegedly not finding "/sbin/init".

I've been wondering whether the FC6 kernel has included some sort of mandatory selinux requirements that are not fulfuled when you simply do a mke2fs and restore from a security-unaware tarfile.
I am doing a similar thing between 2 computers for testing purposes. I am using 'rsync', but that should'nt matter.

I use now FC6. I have selinux disabled, never tried it with selinux enabled.

The only times I had the 'kernel panic, not syncing' it was due to either a misconfigured '/etc/fstab' os a misconfigured '/boot/grub/menu.lst'.

Doenst look to be your problem, since you are cloning a /dev/hda1 to a /dev/hda1 in the new machine, which is not my case. I have to change '/etc/fstab' to mount the correct partitions, and in 'menu.lst' I have to take care of the lines 'root (hd?,?)' and 'kernel ....'.

Anyhow, since you restore thru knoppix, from knoppix do a 'chroot /mnt/hda1' and take a look at the new system.

A completely different problem are the hardware differences between the 2 machines and how the kernel modules are built.

A kernel will happily boot on a IDE disk, but it will fail on a USB disk (and probably SATA) if the usb kernel
driver is not built into the kernel or, if built as a module, in 'initrd'.

This will give a kernel panic, and it will not find '/bin'/init' because it can't mount the root file system.

To clone to a USB disk, I use:

'mkinitrd --preload=ehci-hcd --preload=usb-storage --preload=scsi_mod --preload=sd_mod \
/boot/initrd-2.6.18-1.2798.fc6-usb.img 2.6.18-1.2798.fc6'

Thats all I can think off
 
Old 12-07-2006, 01:56 AM   #7
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
It may just be an issue with the LABEL=/ thingy in /etc/fstab and /boot/grub/grub.conf .
I found that sometimes the copied system needs to have the /dev/hda1 ( or whatever ) instead of using LABEL=

At any rate, here's how I do it.
I make a gz file while still booted into my original system by using find and cpio. That saves me the step of booting up with a livecd.
Code:
mkdir /mnt/backup/fedora
(cd / ; find . -xdev | cpio -voc > /mnt/backup/fedora/linux.cpio.gz)
Then, I setup the nfs share
Code:
echo -e "/mnt/backup/fedora\t192.168.0.0/24(ro,sync,nohide) ## use tab, not spaces" >/etc/exports
exportfs -ra
service nfs restart
Now, I bootup the client system using CD#1 and typing linux rescue to get to the command prompt. I like to use CD#1 as it has good nic detection and doesn't load up a bunch of stuff. If you want to use Knoppix, just boot into runlevel three ( knoppix 3 ) .

Once booted up, I format the partition, mount it and the nfs share which is located on the machine 192.168.0.1 .
Code:
mkfs.ext3 /dev/hda1
mkdir /mnt/hda1 /mnt/local
mount /dev/hda1 /mnt/hda1
mount 192.168.0.1:/mnt/backup/fedora /mnt/local

# Check to see if the nfs share shows up ok.
cd /mnt/local
ls
Now, you can proceed to unzip the backup into your new system...
Code:
(cd /mnt/hda1 ; cpio -vicdm < /mnt/local/linux.cpio.gz)
After that is done, you need to change the hostname and empty existing ip/hw address info. This is done in the chroot environment.
Code:
chroot /mnt/hda1
mount -t proc /proc proc

# Change the hostname of the client machines. For example:
sed -i 's/sony/mudd1/' etc/sysconfig/network

# Check it
cat etc/sysconfig/network

# I empty these files because my original system has a static ip address.
# You may need to use system-config-network after booted into the new system.
>etc/sysconfig/network-scripts/ifcfg-eth0
>etc/sysconfig/network-scripts/ifcfg-eth1

# I edit the fstab and grub.conf using vi editor as indicated at the start of this post.

# Now, I exit the chroot environment and un-mount everything.
umount /proc
Ctrl d or type: exit
umount -a
Finally, I setup grub in the mbr.
At the prompt ( sh-3.1# ), it goes like this...
Code:
sh-3.1# grub
grub> find /sbin/init ### I do that just to see if grub can find my new system
grub> root (hd0,0)
grub> setup (hd0)
grub> quit
Reboot and try it. On the new system, it noticed a different video card and prompts me to reconfigure the xserver.
 
Old 12-07-2006, 03:17 AM   #8
vanstra
Member
 
Registered: Mar 2005
Distribution: Ubuntu 10.04 - CentOS 5.4
Posts: 40

Rep: Reputation: 15
Try using DAR.
DAR Tutorial
Works like a charme.
 
Old 03-28-2007, 04:48 PM   #9
ventana
LQ Newbie
 
Registered: Mar 2007
Posts: 2

Rep: Reputation: 0
Question

Quote:
Originally Posted by homey
It may just be an issue with the LABEL=/ thingy in /etc/fstab and /boot/grub/grub.conf .
I found that sometimes the copied system needs to have the /dev/hda1 ( or whatever ) instead of using LABEL=

At any rate, here's how I do it.
I make a gz file while still booted into my original system by using find and cpio. That saves me the step of booting up with a livecd.
Code:
mkdir /mnt/backup/fedora
(cd / ; find . -xdev | cpio -voc > /mnt/backup/fedora/linux.cpio.gz)
Then, I setup the nfs share
Code:
echo -e "/mnt/backup/fedora\t192.168.0.0/24(ro,sync,nohide) ## use tab, not spaces" >/etc/exports
exportfs -ra
service nfs restart
Now, I bootup the client system using CD#1 and typing linux rescue to get to the command prompt. I like to use CD#1 as it has good nic detection and doesn't load up a bunch of stuff. If you want to use Knoppix, just boot into runlevel three ( knoppix 3 ) .

Once booted up, I format the partition, mount it and the nfs share which is located on the machine 192.168.0.1 .
Code:
mkfs.ext3 /dev/hda1
mkdir /mnt/hda1 /mnt/local
mount /dev/hda1 /mnt/hda1
mount 192.168.0.1:/mnt/backup/fedora /mnt/local

# Check to see if the nfs share shows up ok.
cd /mnt/local
ls
Now, you can proceed to unzip the backup into your new system...
Code:
(cd /mnt/hda1 ; cpio -vicdm < /mnt/local/linux.cpio.gz)
After that is done, you need to change the hostname and empty existing ip/hw address info. This is done in the chroot environment.
Code:
chroot /mnt/hda1
mount -t proc /proc proc

# Change the hostname of the client machines. For example:
sed -i 's/sony/mudd1/' etc/sysconfig/network

# Check it
cat etc/sysconfig/network

# I empty these files because my original system has a static ip address.
# You may need to use system-config-network after booted into the new system.
>etc/sysconfig/network-scripts/ifcfg-eth0
>etc/sysconfig/network-scripts/ifcfg-eth1

# I edit the fstab and grub.conf using vi editor as indicated at the start of this post.

# Now, I exit the chroot environment and un-mount everything.
umount /proc
Ctrl d or type: exit
umount -a
Finally, I setup grub in the mbr.
At the prompt ( sh-3.1# ), it goes like this...
Code:
sh-3.1# grub
grub> find /sbin/init ### I do that just to see if grub can find my new system
grub> root (hd0,0)
grub> setup (hd0)
grub> quit
Reboot and try it. On the new system, it noticed a different video card and prompts me to reconfigure the xserver.

Unfortunately, I haven't had good luck with this process. The error I receive is as follows:

(cd / ; find . -xdev | cpio -voc > /mnt/backup/fedora/linux.cpio.gz)
.
.
.
./mnt
./mnt/backup
./mnt/backup/fedora
cpio: mnt/backup/fedora/linux.cpio.gz: field width not sufficient for storing file size

If anyone knows why this happens, please let me know.
 
Old 03-28-2007, 06:30 PM   #10
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Gads, I hate it when people dig up my old posts so everyone can see how stupid they are.

Fist off, the LABEL=/ part is because the partitions are actually labeled at install time. You can do that manually when you create a partition.
For example:
Code:
e2label /dev/hda1 /
Just be aware that if you already have a partition labeled as / you need to give the next one another label like /1 and reference it accordingly in the /etc/fstab.
If you want to label swap partitions, I do it like this...
Code:
swapoff -a
mkswap -c -v1 -L SWAP-sda3 /dev/hda3
swapon -a
For the cpio part, you might have good luck with the print0 like this...
(cd / ; find . -xdev print0 | cpio -voc > /mnt/win/backup/linux.cpio.gz)
 
Old 03-30-2007, 06:13 PM   #11
ventana
LQ Newbie
 
Registered: Mar 2007
Posts: 2

Rep: Reputation: 0
Figured I better check in with my progress as you were kind enough to reply.

Below is what I've tried:

To successfully use the command,
(cd / ; find . -mount | cpio -voc > /mnt/backup/fedora/linux.cpio.gz)

(mount same as xdev)

I had to nfs mount the directory /mnt/backup/fedora on the built system.
That appeared to have worked. Then everything thereafter also worked.

Thanks also for pointing out that the label may need to be /1 (it did).
Just used "e2label /dev/hda1 /1". The system now comes up, but I've
got some network issues I'll need to iron out.

Thanks again for all of your help. This looks like a winner.

Last edited by ventana; 03-30-2007 at 06:14 PM.
 
  


Reply

Tags
backup, boot, clone, fc6, grub, hang, restore, tar


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
Backup and Restore with TAR jay2809 Linux - Newbie 7 08-25-2004 04:47 PM
tar to restore backup -- goes to sleep?!? JZL240I-U Linux - Software 4 05-10-2004 02:55 AM
Backup & Restore plan using tar markcasazza Linux - Newbie 1 04-14-2004 01:11 PM
backup and restore using tar AZDAVE Linux - General 6 11-28-2003 08:40 PM
how can I restore a tar backup len snelly Linux - Newbie 1 04-30-2002 12:29 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora

All times are GMT -5. The time now is 10:20 PM.

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