LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 08-15-2011, 08:59 AM   #1
johnnynet3828
LQ Newbie
 
Registered: Aug 2011
Posts: 7

Rep: Reputation: Disabled
Smile How to clone 80GByte hard-disk to 40GByte hard-disk on Red-hat 9.0 ?


Hi all,

As per subject, how can this be done ?
I tried

1) create partition ie fdisk
2) make file systems on /dev/hdb1 & /dev/hdb2
3) use dump & restore
4) use dd to transfer MBR from source (80GByte) to destination
(40GByte)

but when boot up from 40GByte hdd, the GRUB cannot be started.
Also i have taken into consideration the size differences.

Thanks in advance .

Regards
johnny
 
Old 08-15-2011, 09:09 AM   #2
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Red Hat 9 is way out of date and totally unsupported, so I wouldn't bother with that at all and install a supported version.

But anyways:
1. Boot from a live-CD.
2. Create partitions on the new disk.
3. Copy the files from the old partitions to the respective new ones.
4. Mount all the new partitions to a complete tree, including /dev, /sys and /proc.
5. Chroot into that tree and install Grub to the MBR.
6. Power off, detach the old disk and boot.
 
1 members found this post helpful.
Old 08-15-2011, 11:00 PM   #3
johnnynet3828
LQ Newbie
 
Registered: Aug 2011
Posts: 7

Original Poster
Rep: Reputation: Disabled
Hi ,

Thanks on the info.
The application runs on Redhat 9.0

Where to find GRUB and how to install on the MBR ?

Rgds
johnny
 
Old 08-16-2011, 04:19 AM   #4
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Grub should already be installed on your system. To install it on the MBR just do
Code:
grub-install /dev/hda
as root, after you chrooted into the system.
 
1 members found this post helpful.
Old 08-16-2011, 09:27 AM   #5
johnnynet3828
LQ Newbie
 
Registered: Aug 2011
Posts: 7

Original Poster
Rep: Reputation: Disabled
Thanks a million.
Will try this out.

regards
johnny
 
Old 08-17-2011, 07:31 AM   #6
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 137Reputation: 137
Quote:
Originally Posted by johnnynet3828 View Post
Hi ,

Thanks on the info.
The application runs on Redhat 9.0

Where to find GRUB and how to install on the MBR ?

Rgds
johnny
As already was said RedHat 9.0 is quite old. You may have a very hard time to find hardware where RH9.0 will run.
In this case you may resort to installing RH9.0 in VM (VMWare, VirtualBox, qemu - whatever)

Another option - use statifier (http://statifier.sf.net) or Ermine (http://magicErmine.com) to convert your application into self-containing executable. This executable should be able to run on virtually any Linux distribution without any dependencies
 
Old 08-17-2011, 09:51 AM   #7
johnnynet3828
LQ Newbie
 
Registered: Aug 2011
Posts: 7

Original Poster
Rep: Reputation: Disabled
Hi Valery,
Thanks on your idea.
Will work this out.

Hi TobiSGD,

"grub-install /dev/hdb" = works
Unfortunately, when boot up on the hard-disk , "GRUB Hard Disk Error'

Regards
johnny
 
Old 08-20-2011, 10:22 AM   #8
johnnynet3828
LQ Newbie
 
Registered: Aug 2011
Posts: 7

Original Poster
Rep: Reputation: Disabled
Hi Folks,

when cloning same partition size , we use
" dd if=/dev/hda1 of=/dev/hdb1 bs=4096 conv=notrunc,noerror " = no error

how to clone bigger partition size to smaller partition size
" dd if=/dev/hda2 of=/dev/hdb2 bs=4096 conv=notrunc,noerror " = inadequate space

appreciate any suggestions how to solve this command = dd

thanks/regards
johnny
 
Old 08-20-2011, 10:45 AM   #9
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
You can't do that with dd, simple as that.
 
Old 08-20-2011, 10:56 AM   #10
johnnynet3828
LQ Newbie
 
Registered: Aug 2011
Posts: 7

Original Poster
Rep: Reputation: Disabled
Additional info,

The usable data on the larger partition does not exceed the size of the smaller partition.

I tried " dump & restore " = when booted up ,error = "mkrootdev: label / not found".

What other command is able to do the job ?

Thanks/rgds
 
Old 08-20-2011, 02:37 PM   #11
jefro
Moderator
 
Registered: Mar 2008
Posts: 21,982

Rep: Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626Reputation: 3626
Wonder if tar would work?
 
1 members found this post helpful.
Old 08-22-2011, 05:42 AM   #12
InNomineLibertas
LQ Newbie
 
Registered: Nov 2010
Location: planet earth, sol quadrant
Posts: 15

Rep: Reputation: 1
I don't recall the incantations off the top of my head, but I should think a combination of 'find' and 'cpio' would be capable of doing it.

To keep things safe, use the instructions for zero-terminated names, so that any "funny" filenames won't be able to hurt the process.

Good luck - and please report back, regardless what the result looks like.
 
Old 08-22-2011, 06:17 AM   #13
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 113Reputation: 113
Actually one can do it with dd "if" the partition table of the 80Gn disk uses space no bigger than 40Gb. I have done this a lot of times.

If the systen has been cloned the grub-install must be told where the Grub located. Normally it is in hda1, say then boot up any Linux Live CD, create a mount point, mount hda1and the do the grub-install
Code:
su
mkdir  /mnt/hda1
mount /dev/hda1 /mnt/hda1
grub-install --root-directory=/mnt/hda1 /dev/hda
A Fedora Live CD can also be used to restore Grub as described in Task B6 of Just booting tips in my signature.

I use the following commands to "move" one partition hda1 to another hdb1. hda1 is the one to read from and hdb1 is the one to write on, assuming hdb1 has been formatted previously
Code:
mkdir /mnt/hda1
mkdir /mnt/hdb1
mount /dev/hda1 /mnt/hda1
mount /dev/hdb1 /mnt/hdb1
cd /mnt/hda1
tar cf - . | (Cd /mnt/sdb1; tar xf -)
The hdb1 can be different size and have different filing system to hda1. I litertally move every Linux this way and then fix the boot loader as described previously.

Just a warning : If Red Hat has Selinux installed it would not like a change of partition number. After migration the Selinux may have to be disabled. Most server-grade distro has this rigidity built in.

A Linux don't normally need to be cloned and the file copying procedure is adequate. Howver if the operating system itself is being copied then dd should be used because filing copying prcedure could copy mounted folders also.

Last edited by saikee; 08-22-2011 at 06:30 AM.
 
1 members found this post helpful.
Old 08-22-2011, 06:52 AM   #14
InNomineLibertas
LQ Newbie
 
Registered: Nov 2010
Location: planet earth, sol quadrant
Posts: 15

Rep: Reputation: 1
Come to think of it, I should comment a little more fully:

The problem with using dd on your partitions, is that dd reads every byte available, _INCLUDING_ the blank ones you don't need, and then, of course, it wants to also write all that it has read. Which means it tries to stuff the second HD with everything, both data and the intermingled free space.

The command-pair of 'find' and 'cpio', on the other hand, copies files, links and directories - and ignores unallocated space. Hence, you need only find the space for what's actually stored in your filesystem(s). The "downside" of this, is that the filesystems have to be mounted when you copy, since it traverses the file system as such, rather than treating a partition as a stream of bytes, such as 'dd' can do.

I have also looked up some documentation, and it looks to me like the following incantation should work (but: NO GUARANTEES!):

'find -depth -print0 /some/directory |cpio -0admpV /target/directory'

To clarify, for readers: "print0" and "-0" contain zeroes, not capital Os.

One word about output: The instruction "V" tells cpio to print one "." for each file processed. This way, you get a visual progress report, but safeguards the terminal against possible effects of "funny" filenames...

UPDATE: The intervening poster reminded me of something: To avoid filesystems mounted downstream of the source directory, add '-mount' to the arguments for the find command (in front of 'print0' - the program is slightly finicky about order order ;-)

Last edited by InNomineLibertas; 08-22-2011 at 06:57 AM. Reason: Additional info
 
1 members found this post helpful.
Old 08-23-2011, 09:11 AM   #15
johnnynet3828
LQ Newbie
 
Registered: Aug 2011
Posts: 7

Original Poster
Rep: Reputation: Disabled
Hi folks,

Tried the following steps

mount /dev/hda2 /
mount /dev/hdb2 /hdb2

tar cvf - / | (Cd /hdb2; tar xpf -)

when booted up ,error = "mkrootdev: label / not found" which is similar to dump & restore

Will tried out the cpio command as suggested.

Many thanks/rgds
 
  


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
clone hard disk with: cat /dev/sda >/media/disk/backup deathalele Linux - Security 3 04-17-2009 12:29 AM
how to install red hat on sata hard disk sdzubair76 Linux - Newbie 1 03-20-2009 02:03 AM
can red hat nine be installed on SATA hard disk buddhika_sgj Linux - Software 2 09-30-2006 02:51 PM
installation of red hat 9 from hard disk shams Linux - Software 2 07-12-2006 09:06 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

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