LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 02-13-2019, 10:32 AM   #1
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,204

Rep: Reputation: 200Reputation: 200Reputation: 200
Transferring system to a new disk


I bought a new hard drive for my laptop. I can attach it via a USB-SATA adaptor. Does
Code:
 dd if=/dev/sda of=/dev/sdb
recreate all volumes? Or do I need to set up partitions with fdisk first? format them?
 
Old 02-13-2019, 03:24 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 17,766

Rep: Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815Reputation: 2815
That will do as you request - which may not be what you actually want. As in most things to do with computers.

The 2 disks will correspond - if the target is larger the extra space will be (initially) inaccessable. Any errors on the source will be replicated on the target.
"dd" should be the absolute last choice in "backup" tools unless doing forensic examination.

Much better to assign the new disk partition(s) as you see fit and use a filesystem aware tool to copy each in turn - rsync is a reasonable choice.
 
Old 02-13-2019, 03:28 PM   #3
jefro
Moderator
 
Registered: Mar 2008
Posts: 18,950

Rep: Reputation: 2850Reputation: 2850Reputation: 2850Reputation: 2850Reputation: 2850Reputation: 2850Reputation: 2850Reputation: 2850Reputation: 2850Reputation: 2850Reputation: 2850
If you wish to clone a drive you generally can't boot to it. Then you need to be POSITIVE that your /dev/sda is in fact the source and /sdb is destination.

I'd never try to clone a working system if I had a choice.

Booting to live cd/dvd/usb may alter the naming of the drives so when I say you need to be POSITIVE I mean it.

dd has no safeguards.

Clonezilla as well as many other copy programs and rsync if you use it properly may work more safely.
 
Old 02-13-2019, 04:29 PM   #4
linus72
LQ Guru
 
Registered: Jan 2009
Location: Gordonsville-AKA Mayberry-Virginia
Distribution: Slack14.2/Many
Posts: 5,427

Rep: Reputation: 434Reputation: 434Reputation: 434Reputation: 434Reputation: 434
Theres a pretty safe way to do this wihtout using dd, clonedisk, etc IF you can have both drives or partitions mounted, simply use, as root,
Code:
# cp -avf /* /mnt/sdxx
where / is your root partition and /mnt/sdxx is your target partition or drive

so, like today I wanted to move my slackware install from sda6 12gb to sda5 20gb
I logged into my sda6 slackware and mounted /dev/sda6 (already formatted ext4 earlier)
then used cp command above
Code:
# cp -avf /* /mnt/sda5
or if one drive is ext4 sdb1 and other is ext4 sda1 and you wanna copy to sdb1 from sda1
Code:
# cp -avf /mnt/sda1/* /mnt/sdb1
Then you will have to edit /etc/fstab and either /boot/grub/grub.cfg or /etc/lilo.conf
If installing grub or lilo make sure boot flag is activated in new partition using gparted then do update-grub.
Just make sure you check grub.cfg/lilo.conf and /etc/fstab and install grub/lilo before rebooting.

Last edited by linus72; 02-13-2019 at 04:33 PM.
 
Old 02-13-2019, 09:28 PM   #5
jefro
Moderator
 
Registered: Mar 2008
Posts: 18,950

Rep: Reputation: 2850Reputation: 2850Reputation: 2850Reputation: 2850Reputation: 2850Reputation: 2850Reputation: 2850Reputation: 2850Reputation: 2850Reputation: 2850Reputation: 2850
Just to point this out too. "do I need to set up partitions with fdisk first? format them?" If one used dd then they copy a drive (in this case example) bit by bit. It copies everything from beginning to end. Format and partitions will be (should be) identical.

Last edited by jefro; 02-13-2019 at 09:53 PM.
 
Old 02-14-2019, 06:38 AM   #6
jmgibson1981
Member
 
Registered: Jun 2015
Location: Tucson, AZ USA
Distribution: Debian
Posts: 337

Rep: Reputation: Disabled
This is one of my favorite uses for LVM. One doesn't just need to use it to span multiple disks. I use it on single drive machines both for snapshots, and upgrades as needed (although I haven't had to upgrade a drive yet as I'm running ssd's).
 
Old 02-19-2019, 11:28 PM   #7
rob.rice
Senior Member
 
Registered: Apr 2004
Distribution: slack what ever
Posts: 1,073

Rep: Reputation: 202Reputation: 202Reputation: 202
dd will crash the system when it tries to copy /proc and may crash the system when it tries to copy /sys I have copied my system several times by using cp and coping one directory at a time
but it's no faster than installing I did it to keep the extras I added to the system
 
Old 02-21-2019, 06:13 AM   #8
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 11,461
Blog Entries: 8

Rep: Reputation: 2991Reputation: 2991Reputation: 2991Reputation: 2991Reputation: 2991Reputation: 2991Reputation: 2991Reputation: 2991Reputation: 2991Reputation: 2991Reputation: 2991
strange, i've used dd to clone a disk to another one. however of course neither disk may be mounted, so i booted live first (may or may not apply to OP's situation).
and i have used the resulting system to boot. in fact i am using it now.
just had to regenerate grub and/or change one or two fstab entries... of course there's potential for more failure. different graphic drivers for example.
 
1 members found this post helpful.
Old 02-21-2019, 10:30 AM   #9
rtmistler
Moderator
 
Registered: Mar 2011
Location: MA, USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 7,637
Blog Entries: 13

Rep: Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159Reputation: 3159
I've done the dd command, similar to how Ondoho describes, I live boot the system and then perform dd from source to target.

Didn't do it to transfer a system, but instead to copy the entire system to a fresh new disk for a laptop where I was replacing the internal SSD with a larger one. Worked like a charm. Sounds like exactly what you're doing. Just do the dd command correctly, but also do it from a live boot.
 
  


Reply


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Transferring Slabs Of Data To External Disk HDD Full, Reconfiguring, How To? Novatian Linux Mint 5 08-15-2009 07:51 AM
transferring my deb 4 to a new disk Greebstreebling Debian 2 10-26-2007 08:17 PM
transferring files to other disk.. bschiett Linux - Newbie 3 03-24-2005 07:04 PM
Error transferring install image. You are probably Out of Disk Space gonzalo76 Fedora - Installation 4 09-04-2004 01:35 PM
Transferring installation to a new hard disk? mconsidine Linux - General 6 05-16-2004 09:14 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:57 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration