Which method for cloning MBR disk with various file systems

If none of the more specific forums is the right place to ask

Which method for cloning MBR disk with various file systems

Postby michapma » 2017-12-08 09:44

After over ten years, it's time for a new desktop. The ten-year-old isn't dead, though, just... finely aged. I started with Etch, and it is the same installation. Such a fine machine deserves to continue to live!

I am moving the 250GB SSD to the new machine, however, so the old girl gets a new 1TB HDD. Of course she works with BIOS, so the partitions are all MBR. There are NTFS, reiserfs (hey, it was good in the day and I never migrated) and ext4 partitions. There are a couple of ways I can go about cloning:
  1. Clone with dd. Everything would be identical, but I would need to expand and move the partitions to take advantage of new space. I suspect even the UUID values might not need to be fixed, although if they aren't it isn't a huge deal to enter rescue mode and edit fstab files.
  2. Create backup copies with partimage and fsarchiver (and a Windows tool for NTFS), then create new partitions and extract the backup images. This allows me to get the right partition sizes from the start, although I would certainly have to boot in rescue mode, edit any UUID entries in fstab (for Debian stable, unstable and Ubuntu), and reinstall GRUB on the MBR.
  3. Same as the previous point, except use tar instead of dd, partimage or fsarchiver for the GNU/Linux partitions

What approach would you use? I suppose number 2 is the most convenient, but maybe I am missing a finer point. There will probably be a separate thread at some point if I can't manage my first install (and multi-boot) on a UEFI board.

Edit: Okay, so fsarchiver preserves the UUID (or tries to). It also supports reiserfs and can convert it when restoring, so no need for partimage.
User avatar
michapma
 
Posts: 539
Joined: 2008-05-04 20:49
Location: Prague

Re: Which method for cloning MBR disk with various file syst

Postby GarryRicketson » 2017-12-08 10:16

Me, I prefer and use dd,
but I would need to expand and move the partitions to take advantage of new space.

Is not a big issue, there are ways to work with that. In a nut shell , I create the first partition, a tiny bit bigger then the drive I am copying/cloning (to be safe),
later I format,utilize, partition extra space as needed.

2. I have never tried, no Windows , nor network sharing with other windows
system, no NTFS, no need. My experience with MS products,Windows and tools was they just don't work well,... and often not at all. Would be another
topic, but I did make a attempt with MS, and it's products years ago, around late or mid 80's (don't remember exactly),..I stayed with MS dos, until we had FreeDos working, then that was the end of me using MS products, I ended up also using Linux, as well
as unix, linux played a a big roll in the development of FreeDos, ..sorry that is
another topic as well,....I

3. I have made some attempts, and did not work out,.. it is ok for directories, with sub directories with just normal files, but system files needed to run the OS or some programs , just don't work out good. It is great for packages of source code though as well.

There are quite a few members here using some methods you have not mentioned, newer, but personally I have not tried those. DD is slow but reliable, I stick with that.
================= comment==========
I started with Etch, and it is the same installation. Such a fine machine deserves to continue to live!

This is great, and a real classic, just goes to show how reliable the older Debian versions are,..
User avatar
GarryRicketson
 
Posts: 4872
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: Which method for cloning MBR disk with various file syst

Postby michapma » 2017-12-08 11:22

Thanks for your answer.
GarryRicketson wrote:Me, I prefer and use dd,
but I would need to expand and move the partitions to take advantage of new space.

Is not a big issue, there are ways to work with that. In a nut shell , I create the first partition, a tiny bit bigger then the drive I am copying/cloning (to be safe),
later I format,utilize, partition extra space as needed.

I was thinking of using dd to partition the disks, like this:
Code: Select all
# dd if=/dev/sdX of=/dev/sdY bs=4M conv=noerror,sync status=progress

...or whatever blocksize turns out to be appropriate. If I have to dd each partition, I think fsarchiver would be more my speed. Since I now realized that it even preserves UUID, I don't see much advantage to the dd approach.

GarryRicketson wrote:2. I have never tried, no Windows , nor network sharing with other windows
system, no NTFS, no need. My experience with MS products,Windows and tools was they just don't work well,... and often not at all. Would be another
topic, but I did make a attempt with MS, and it's products years ago, around late or mid 80's (don't remember exactly),..I stayed with MS dos, until we had FreeDos working, then that was the end of me using MS products, I ended up also using Linux, as well
as unix, linux played a a big roll in the development of FreeDos, ..sorry that is
another topic as well,....I

I need to use Windows at work, and I'm hooked on some flight sims and other games. :oops:
There is also the occasional Windows-specific software; classic example updating GPS-device maps. For everything else, it's Debian. Ubuntu and other distros are just fun to play around in.

GarryRicketson wrote:3. I have made some attempts, and did not work out,.. it is ok for directories, with sub directories with just normal files, but system files needed to run the OS or some programs , just don't work out good. It is great for packages of source code though as well.

Yeah, tar does not preserve all file aspects. I've used it for system backup, but I wrote this thinking of restoring into a new file system. Since fsarchiver supports this, I am not thinking of tar.

GarryRicketson wrote:There are quite a few members here using some methods you have not mentioned, newer, but personally I have not tried those. DD is slow but reliable, I stick with that.

I've used Clonezilla in the past, and saw on another site someone recommending software RAID or LVM to mirror contents, but that is more complex than I need. What kinds of things were you thinking of? Links?

GarryRicketson wrote:
I started with Etch, and it is the same installation. Such a fine machine deserves to continue to live!

This is great, and a real classic, just goes to show how reliable the older Debian versions are,..

I wasn't very clear... by same installation I mean I have dist-upgraded but haven't reinstalled. She is currently running Stretch. But Etch, those were the days. 8)
User avatar
michapma
 
Posts: 539
Joined: 2008-05-04 20:49
Location: Prague

Re: Which method for cloning MBR disk with various file syst

Postby GarryRicketson » 2017-12-08 11:46

What kinds of things were you thinking of? Links?

Snapshots, and I have seen some mention of BTRFS.
This is one, it might not apply for your situation though,...
http://forums.debian.net/viewtopic.php?f=16&t=119159&
===============
I don't have anything really handy, at the moment, I am sure though some
other members that do, will jump in here later to day though.

--- edit---off topic---
I'm a liar, a little,... I forget a lot, it was so long ago, But the Dos editer, Qbasic, and QB45, were MS products, and they worked pretty good, also on FreeDos,..
Any way
But Etch, those were the days.
Indeed, I hadn't tried
Debian yet, was using Knoppix at that time, but in any event those were the days.
User avatar
GarryRicketson
 
Posts: 4872
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: Which method for cloning MBR disk with various file syst

Postby Segfault » 2017-12-08 13:13

Wow, how complicated can it be. See, I never thought migration like this could be something to think twice about. I simply hook up both drives to a computer and use cp -a to copy everything over - after preparing the partitions and filesystems of course. Always worked for me. I guess I lack imagination. I didn't use a black robe and candles either. :(
Segfault
 
Posts: 664
Joined: 2005-09-24 12:24

Re: Which method for cloning MBR disk with various file syst

Postby GarryRicketson » 2017-12-08 13:28

I didn't use a black robe and candles either.

But it so much more fun that way, add some music, dancing and a few chants :mrgreen:

Seriously, thanks , sounds simple and would be good as well,
after preparing the partitions and filesystems of course.


cp

cp [options] file1 file2 cp [options] files directory

Copy file1 to file2, or copy one or more files to the same names under directory. If the destination is an existing file, the file is overwritten; if the destination is an existing directory, the file is copied into the directory (the directory is not overwritten).
Options
-a, --archive

Preserve attributes of original files where possible. The same as -dpr.
User avatar
GarryRicketson
 
Posts: 4872
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: Which method for cloning MBR disk with various file syst

Postby Segfault » 2017-12-08 13:56

Well, in case of MBR boot the bootloader needs to be installed again. It is rather simple procedure, too. I just chroot and run whatever command is needed to install the loader.
With UEFI the drive is ready to use.
I do not use UUID to define partitions, I use labels, again, to keep it simple. Typing a label into fstab is easier than PARTUUID/UUID.
Segfault
 
Posts: 664
Joined: 2005-09-24 12:24

Re: Which method for cloning MBR disk with various file syst

Postby michapma » 2017-12-11 11:10

Segfault wrote:Wow, how complicated can it be. See, I never thought migration like this could be something to think twice about. I simply hook up both drives to a computer and use cp -a to copy everything over - after preparing the partitions and filesystems of course. Always worked for me. I guess I lack imagination. I didn't use a black robe and candles either. :(

I decided on fsarchiver and it worked. Not ideally, though... It did preserve the UUID of restored partitions, which I do use in fstab as well as labels, even though I checked everything manually and could have just reset them all anyway. What it did not do is properly create a new filesystem upon restoring into the new partitions. I ended up with the same ext2 for /boot and reiserfs for /. No big deal, but I was disappointed. I know why: though I did use a candle, I forgot the robe and cat sacrifice.

Had I seen this message (i.e., read my own thread) before doing the migration, I would have tried out cp -a just for the experience. Thanks for the tip, I could save some $$ on candles next time.
User avatar
michapma
 
Posts: 539
Joined: 2008-05-04 20:49
Location: Prague

Re: Which method for cloning MBR disk with various file syst

Postby michapma » 2017-12-11 11:16

GarryRicketson wrote:
What kinds of things were you thinking of? Links?

Snapshots, and I have seen some mention of BTRFS.
This is one, it might not apply for your situation though,...
http://forums.debian.net/viewtopic.php?f=16&t=119159&


Yeah, that would be too much learning, I am still chomping at the bit to get my new system up and running. :D

This weekend, thanks to real life, I have only managed to migrate the system partitions and the data I want to keep on the old computer to its new 1TB drive, as well as test that everything is running, which is mostly correcting fstab files and installing GRUB to the MBR. I do still need to use it a while to make sure everything is copacetic before wiping the SSD for the new system. (Of course I will archive everything on an external drive first, but still.)
User avatar
michapma
 
Posts: 539
Joined: 2008-05-04 20:49
Location: Prague

Re: Which method for cloning MBR disk with various file syst

Postby GarryRicketson » 2017-12-11 11:24

Agree, which is why I never really paid much attention to it all, nor saved
any links,.... probably should not have even mentioned it.
I have not ever tried the cp -a , but it does sound like a fairly easy , simple
method as well as 'dd'.
User avatar
GarryRicketson
 
Posts: 4872
Joined: 2015-01-20 22:16
Location: Durango, Mexico

Re: Which method for cloning MBR disk with various file syst

Postby Segfault » 2017-12-11 13:22

dd - you are stuck with filesystem type; it takes long time because the empty space is copied, too; you need to mess with resizing if you want to change the size of destination partition
cp -a - destination filesystem and size does not depend on source; much faster because only data is copied

There may be cases when ddrescue should be preferred, but generally I'd say plain copy has advantages.

P. S. If you really are in love with your MBR you can transfer it with dd, it would be the first 446 bytes. Rest of the 512 byte boot sector is the partition table.
Segfault
 
Posts: 664
Joined: 2005-09-24 12:24


Return to General Questions

Who is online

Users browsing this forum: Morales1235 and 5 guests

fashionable