LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 07-02-2006, 12:45 PM   #1
fof3
Member
 
Registered: Nov 2003
Distribution: Debian - Lenny
Posts: 174

Rep: Reputation: 30
Copying from /dev/sda to /dev/sdb


I have two scsi disks; exact in size and make. On sda there's a dual boot system - Windows XP, and Linux (debian).

Windows is expanding; with 4G free space. I want to transfer Linux to sdb; and let Windows do its thing.

I partitioned sdb, using Partition Magic; and I made the partition sizes a little greater than their corresponding ones on sda.

I created the file system on sdb with KNOPPIX 4.0.
I first tried "cp -pr /dev/sda2 /dev/sdb1" [sda1 is NTFS] and got "'/dev/sda2 ->' /dev/sdb1".

If the copy command won't do it what will? I had tried dd in the past, and got the error that there was no more space left on the device.
 
Old 07-02-2006, 01:01 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Can you please elaborate on the result of the cp? It really should
have worked (you could try -a instead).


Cheers,
Tink
 
Old 07-02-2006, 01:24 PM   #3
tnandy
Member
 
Registered: Oct 2003
Location: Tennessee
Distribution: Devuan 3.0 (Beowulf)
Posts: 217

Rep: Reputation: 18
You don't say what brand of SCSI disk it is, but most new IDE disks come with a software CD from the factory or utilities available for download from the manufacturer's website. This software allows such things such as partitioning and copying a partition from the old disk to the new disk. It does not care what the contents of the partition are. If your new SCSI drive came with a similar CD or you can find the utilities on the web, I would use those tools instead.
 
Old 07-02-2006, 01:29 PM   #4
pokemaster
Member
 
Registered: Apr 2005
Location: Massachusetts, USA
Distribution: debian,ubuntu,slackware
Posts: 110

Rep: Reputation: 17
haha, hey guys -- no big deal, you just copied one device and overwrote another....

you need to mount the filesystems and copy all the files.

i.e.
Code:
mkdir -p /mnt/sda1 && mkdir -p /mnt/sdb1
mount /dev/sda1 /mnt/sda1 && mount /dev/sdb1 /mnt/sdb1
cp -pr /mnt/sda1/* /mnt/sdb1/*
this will take a few minutes...
Code:
 umount /mnt/sda1 && umount /mnt/sdb1
and there you have it.

good luck!
 
Old 07-02-2006, 01:30 PM   #5
HappyTux
Senior Member
 
Registered: Mar 2003
Location: Nova Scotia, Canada
Distribution: Debian AMD64
Posts: 4,170

Rep: Reputation: 244Reputation: 244Reputation: 244
Here is what I usually would do when duplicating my install to my spare drive. First boot with knoppix 2 to get to a console root prompt then,

Code:
mount /dev/sda2 /mnt/sda2
mount /dev/sdb1 /mnt/sdb1
cp -Rp /mnt/sda2/* /mnt/sdb1/
vi /mnt/sdb1/etc/fstab        <----- Changing all sda2 to sdb1
vi /mnt/sdb1/etc/lilo.conf or /mnt/sdb1/boot/menu/grub.lst   <------ Making changes for new drive again
chroot /mnt/sdb1 /sbin/lilo -v    <----- or for grub
grub 
setup (hd?)
exit
Now for installing the lilo/grub it can get a little complicated unless you want to keep it on the drive you already have it on in which case when editing their config files only change the parts that refer where the kernel is located and just let it install itself into the MBR of the sda drive like it is now (it it?). If you still have problems the output of fdisk -l and seeing which of the config files you are using would be nice.
 
Old 07-02-2006, 01:33 PM   #6
pokemaster
Member
 
Registered: Apr 2005
Location: Massachusetts, USA
Distribution: debian,ubuntu,slackware
Posts: 110

Rep: Reputation: 17
ps. problem with the dd command is that using it will create identical partitions

Code:
 dd if=/dev/sda1 of=/dev/sdb1
will make sdb1 exactly like sda1 - right down to the size.

you can use dd, then resize the partition on sdb1, but this can get tricky.
 
Old 07-02-2006, 01:39 PM   #7
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,499
Blog Entries: 2

Rep: Reputation: 68
Since the partitions sizes aren't the same, copying a partition would not work. To use a partition as source/target, they must have the exactly same size.

You need to use a mount point as source and target. Mount /dev/sda2 as /mnt/source and /dev/sdb1 as /mnt/target and "cp -pr /mnt/source /mnt/target" will work just fine.

Of course, you need to create a filesystem on /dev/sdb1 first. This filesystem can be different than the one on /dev/sda2.
 
Old 07-03-2006, 05:45 PM   #8
fof3
Member
 
Registered: Nov 2003
Distribution: Debian - Lenny
Posts: 174

Original Poster
Rep: Reputation: 30
I created partitions on /sdb that are equal in size to those on /sda.

I created a filesystem on each partition of /sdb.

After having cd'd into each /sda mount point, I copied data using 'cp ./* mnt/sdb_'.

As I see it, what I need to do next is:

1.Edit /etc/fstab

2.Modify /etc/lilo.conf to reflect where root is on /sdb

3. Reboot, and expect the best.

Correct????
 
Old 07-04-2006, 06:19 AM   #9
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,499
Blog Entries: 2

Rep: Reputation: 68
Quote:
Originally Posted by fof3
Correct????
There is the boot manager (lilo/grub) issue to deal with.
1) The boot loader on /dev/sda must be not changed or overwriten by windows.
2) If the boot manager is lilo them the MBR must be updated to reflect the new boot dir. (lilo -v)

A working live CD would be valuable if anything goes wrong.
And don't delete the linux on /dev/sda before you are sure your system is working right on the new location.
Keep copies of the original /etc/lilo.conf and /etc/fstab just in case.

good luck !
 
  


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
USB drive... /dev/sda1 doesn't show unless I try mounting /dev/sda as vfat finite Linux - Hardware 8 03-10-2009 12:52 AM
forcing the order of /dev/sda /dev/sdb etc.. jdaniel Linux - Software 5 05-23-2006 07:41 AM
where did my SATA drive go? not /dev/hde or /dev/sda edman007 Linux - Hardware 1 01-16-2005 10:23 PM
Sandisk USB card Reader not linking /dev/sg0 to /dev/sda acidraven Linux - Hardware 1 06-19-2004 03:56 PM
USB Compact flash card reader hotplug creates /dev/sda but no /dev/sda1 -Mandrake 9.1 bibinono Linux - Hardware 2 08-11-2003 09:37 AM

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

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