LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE
User Name
Password
SUSE / openSUSE This Forum is for the discussion of Suse Linux.

Notices


Reply
  Search this Thread
Old 01-21-2009, 04:42 AM   #1
OldAl
Member
 
Registered: Oct 2006
Location: Canberra, Australia
Distribution: ubuntu MATE LTS
Posts: 102

Rep: Reputation: 15
Moving all files from one partition to another.


Hi,
My main disk had some signs of imminent failure. So I installed another hdd and copied all files from /dev/sda2 to /dev/sdb2 with the commands
Code:
mount /dev/sdb2 /media/sdb2
mount /dev/sda2 /media/sda2
cp -RP /media/sda2/* /media/sdb2/
On /dev/sda2 installed is openSUSE10.3 OS, a lot of software and configuration files. AFAICS, all were copied OK to the new location. I then changed the fstab on OS in /media/sda2/etc/ to reflect the new root (other entries were OK). I then tried to boot to the new 2-nd disk. To my astonishment, it went on through the motions of booting, including the kdm (I do run a KDE desktop) signing screen, requesting the user password. Upon entering the password, it displayed at the top left corner a small window with the words:
Quote:
Could not start kstrtupconfig. Check your installation.
I know, it would be simple to re-install openSUSE10.3, but my mobo has NVIDIA chipset and it is a bit of a hassle to get the onboard video chip to display 1680x1050 screen - I do have a Benq FP222W LC 22" monitor. There are also lots of software downloaded and installed. Fortunately, all data is in a separate partition that has already been migrated to /dev/sdb. The CPU is an amd64-duo - quite adequate for what I do.

So where do I go from here?

Any and all advice will be gratefully received.
 
Old 01-21-2009, 05:33 AM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Use the -a option which is the same as -dpR. You want to preserve permissions and copy links instead of following them.

Another option is to use tar. The tar info manual has an example. (Section 4.6)
Code:
   For example, here is how you might copy a directory's contents from
one disk to another, while preserving the dates, modes, owners and
link-structure of all the files therein.  In this case, the transfer
medium is a "pipe", which is one a Unix redirection mechanism:

     $ (cd sourcedir; tar -cf - .) | (cd targetdir; tar -xf -)

You can avoid subshells by using `-C' option:

     $ tar -C sourcedir -cf - . | tar -C targetdir -xf -
You don't need to copy /tmp, /dev or /sys. Don't copy /proc or /mnt. List the base directories to copy in the cp or tar commands. Don't use "/".

So the tar command on the left could be "tar -C / -cf - /home /usr /boot /var /lib".

Last edited by jschiwal; 01-21-2009 at 05:37 AM.
 
Old 01-21-2009, 05:51 AM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,128

Rep: Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121
I do this sort of thing regularly - and I also prefer "cp -a ..."
However, I always do it from a liveCD, because then you don't have to worry about the pseudo filesystems - just copy the whole partition.
I tend to use a gentoo minimal CD because it is small (no GUI) so it loads fast, and has all the tools needed as well as bash, so a decent shell as well. Any liveCD will do although things like Knoppix tend to mount partitions as read only to protect you from shooting yourself in the foot.
 
Old 01-22-2009, 02:46 PM   #4
OldAl
Member
 
Registered: Oct 2006
Location: Canberra, Australia
Distribution: ubuntu MATE LTS
Posts: 102

Original Poster
Rep: Reputation: 15
Many thanks for both guru's who replied. Previously I've had help from jschiwal and found him always clear, informative and concise. I wish I knew how to "officially" express my thanks, so that it is reflected in the counter!
Quote:
Originally Posted by syg00 View Post
I do this sort of thing regularly - and I also prefer "cp -a ..."
However, I always do it from a liveCD,
Perhaps I have not explained myself clearly. It is not my intention to copy the contents of /dev/sda2 to the file system on /dev/sdb2 while booted to /dev/sda2. I have several Linux systems on my pc in different partitions, so I would boot to another partition first, then copy the contents across from inactive, but mounted two partitions, /dev/sda2 and /dev/sdb2.
How is this different from booting from a CD/DVD and then copying the contents? Like syg00, I also prefer cp -a {list} [destination] simply because I used it before. I know that many "old hands" prefer tar, mainly, I think, because they used it when unix (or GNULinux?) had less powerful cp command.

Thank you both - I will try to do the copying slowly and carefully and will come back to report the result, irrespective of success or failure.

Sincerely,
OldAl
in sweltering Canberra in mid-summer - but it has rained - so good to see the water coming down to revive the dying garden and hear the clap of thunder...
A.
 
Old 01-22-2009, 10:41 PM   #5
OldAl
Member
 
Registered: Oct 2006
Location: Canberra, Australia
Distribution: ubuntu MATE LTS
Posts: 102

Original Poster
Rep: Reputation: 15
jschiwal and syg00,
Quote:
Originally Posted by syg00 View Post
[...] Any liveCD will do although things like Knoppix tend to mount partitions as read only to protect you from shooting yourself in the foot.
Dip Ing Klaus Knopper knows what he is doing and if I did not have a "spare" Linux OS in another partition, I would have used Knoppix (as I had done in the past).
After a fair few trials, I did copy a fairly fresh installation from /dev/sda6 to /dev/sdb6, the latter being the new disk.
After mounting /dev/sda6 to /media/sda6, and /dev/sdb6 to /media/sdb6, did the following steps as root:
Code:
1. cp -a /media/sda6/*  /media/sdb6/
2. Edit the menu.lst on the boot floppy (/media/floppy/boot/grub/menu.lst)
3. Edit /media/sdb6/boot/grub/menu.lst
4. Edit /media/sdb6/etc/fstab
Then booted via modified boot floppy and logged in - smooth as silk! Changed the desktop background, so that there is a major graphical indication which partition is being used.
Good result - thank you both! I will come back to LinuxQuestions.org again and more frequently. Excellent outcome, because of your help.
 
Old 01-23-2009, 07:37 AM   #6
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,128

Rep: Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121
Quote:
Originally Posted by OldAl View Post
Previously I've had help from jschiwal and found him always clear, informative and concise. I wish I knew how to "officially" express my thanks, so that it is reflected in the counter!
Click the "thumbs up" icon on his (useful) post. This is an innovation jeremy has recently instituted.
Quote:
How is this different from booting from a CD/DVD and then copying the contents?
Not at all - the important point is to ensure the source isn't (actively) mounted on the driving system. Also avoids issues with the pseudo filesystems like /proc and /dev.
I always recommend a liveCD as it solves all these issues without further explanation.
 
Old 01-24-2009, 12:33 AM   #7
OldAl
Member
 
Registered: Oct 2006
Location: Canberra, Australia
Distribution: ubuntu MATE LTS
Posts: 102

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by syg00 View Post
Click the "thumbs up" icon on his (useful) post. [...]
I always recommend a liveCD as it solves all these issues without further explanation.
I agree with the above, but wanted to know (not just to agree). As I have a multiboot system, I think the copying is a little faster when all is done from a hdd. (I thanked "thumbs up to both of you, too.)
Thank you for taking care to reply!
 
  


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
really need help moving ntfs partition files on the same hard drive Fb1985 Linux - Newbie 2 11-19-2007 11:06 AM
moving files within one partition takes time in konqueror oskar Linux - General 0 04-22-2006 05:11 PM
moving files from windows partition to linux partition M O L8ingN2dust Linux - Newbie 11 01-08-2006 09:11 PM
WinXP Not Moving Files to Beginning of the Partition GNewbie General 6 12-06-2005 06:27 PM
Moving files to Windows partition... frkstein Linux - General 6 08-11-2002 01:01 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE

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