Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Cloning a Windows drive in Debian.

If none of the specific sub-forums seem right for your thread, ask here.
Post Reply
Message
Author
Naron
Posts: 28
Joined: 2011-08-29 11:48
Has thanked: 2 times
Been thanked: 1 time

Cloning a Windows drive in Debian.

#1 Post by Naron »

Greetings to all.
I have a system with 2 HDDs: one with Debian 10 installed on it and on the other there was installed Windows 8.1 so Debian and Windows are completely separated. And I want to clone the Windows data (because I don't want to make a backup of the entire Windows drive and reinstall everything) from the current HDD (500 GB) to a larger drive (3 TB) and I understand that I can use the dd command in Debian to accomplish this but I'm not sure that it is indeed possible.
So, it's possible to do this and are there any special precautions when using dd in this case?

CwF
Global Moderator
Global Moderator
Posts: 2681
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 41 times
Been thanked: 196 times

Re: Cloning a Windows drive in Debian.

#2 Post by CwF »

I would recommend using qemu-utils, a dd+ designed to do this for all OS's. Install is small and gives you:

Code: Select all

# qemu-img convert -c-p-O qcow2 /dev/sdb windows.qcow2
where # denotes root rights.
/dev/sdb is your windows drive, by-label, or other can be used.
windows.qcow2 is the image name and full path in the COMPRESSIBLE qcow2 format, the -c switch

Before you do it, clean windows as much as possible and defrag the drive (to mark for compressibility), yes even on an SSD...like it matters...once a qcow2 holding a ntfs, virt-sparsify can mark trim sectors "--in-place". All done correctly the image size will be data size. Use the same to write it back to a device.

Code: Select all

# qemu-img convert -p -O raw windows.qcow2  /dev/sdb
Done it many times.

Naron
Posts: 28
Joined: 2011-08-29 11:48
Has thanked: 2 times
Been thanked: 1 time

Re: Cloning a Windows drive in Debian.

#3 Post by Naron »

Thanks for the suggestion but could you please elaborate on this?
I never used these tools so I'm not sure how to follow your steps. And if this assumes that I have free space on my Debian drive to temporarily store that Windows qcow2 image (even if it's compressed) then unfortunately is not the case. My Debian drive is even smaller than that of Windows' (250 GB and it's nearly full. I do plan to upgrade it too somewhere in the future).
In short, I would like to better understand what your method involves.

CwF
Global Moderator
Global Moderator
Posts: 2681
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 41 times
Been thanked: 196 times

Re: Cloning a Windows drive in Debian.

#4 Post by CwF »

Sure.
Yes, I do use an extra storage drive for image storage, a drive under debian control. My method is to image to this storage drive, and then image to a device from that storage drive. Then all the advantages are available.

You may have already made typical choices that make my method hard. Primarily, excessively large everything partitions. Since both OS's can link to extra storage, mount a drive under a folder, etc, I always keep the booting partition small. So there is a bunch of how-to in there, before we get to back up or migration strategies. There are many things to do to clean up an installation, I'll skip all that.

If you have the WIN 500GB almost full, then the qcow2 would be almost that big, and take a few hours, and maybe not be worth it. It would take a change in your ways to use this, but would save the agony once you need to move your 3GB WIN drive to something even bigger next time, kill that pattern NOW!

IF - you get the boot portion of your windows down to a manageable size, then the image (qcow2) you make and store on the debian drive (or supplementary drive) is a transient and a backup. At any time you can write that out to a new device. You can keep more than one, and you can back it up to a backup qcow2 at any time. I even have a second debian that can mount that storage disk to backup the debian in the same way. I keep a few spare SSD's and rotate them, so a known good is always offline.

The 'DATA' is all separate, and can use the technique. I have 'data sets' that are within many gigs, so I use qcow2 as their format, another method that will confuse people, so I'll skip that too.

If you intend to stay at 2 spinners only, and will replace the 500 with a 3TB, I assume you intend to dd to the 3GB and then expand to fill it. Typical, straight forward, and I wouldn't do it. It will complicate your future. I would consider the space you have, the number of sata(?) ports you have, and consider trying to get the OS's onto two SSD's. If you have room for the two spinners still, great, use them as storage only maybe one linked for each OS.

I'm skipping around, may be confusing, so bottom line. I use no other backup or image software ever, they're superfluous. To me, ssd's and disk are cheap, get a few extras.

+1 for keeping the OS's on separate drives. Multiboot single drives are only for laptop people. who can't make up their minds.

My largest debians are 120GB, non compressible LVM LUKS, a common ssd size. My windows images are smaller, 30GB and compress to ~18GB, so I have a few dupes, a good thing. My debians I use for vm's and can write to a device for OS or hardware testing, are 8.4GB full size, compressed to 1.3+ GB. Very easy to manage. On average I have more disk offline than on, another bonus.

Naron
Posts: 28
Joined: 2011-08-29 11:48
Has thanked: 2 times
Been thanked: 1 time

Re: Cloning a Windows drive in Debian.

#5 Post by Naron »

I now understand your method a bit better and it seems interesting. My initial plan was to clone the 500 GB Windows drive to the larger 3 TB drive then to clone Debian's 250 GB drive to the former 500 GB Windows drive. Essentially a swap + a new drive.
Yes, my partitions in both Windows and Debian are quite large because I'm too lazy to set up a partition scheme.
If you intend to stay at 2 spinners only, and will replace the 500 with a 3TB, I assume you intend to dd to the 3GB and then expand to fill it. Typical, straight forward, and I wouldn't do it. It will complicate your future. I would consider the space you have, the number of sata(?) ports you have, and consider trying to get the OS's onto two SSD's. If you have room for the two spinners still, great, use them as storage only maybe one linked for each OS.
Yes, that was the plan as I said. My motherboard has 6 SATA ports and my case allows for 4 HDDs and 3 SSDs but there is the problem, I cannot afford to purchase more HDDs or SSDs right now.
So, I don't know if I could use your method or a variant of it.

CwF
Global Moderator
Global Moderator
Posts: 2681
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 41 times
Been thanked: 196 times

Re: Cloning a Windows drive in Debian.

#6 Post by CwF »

Actually I don't like partitions. Their only use to me is an encrypted disk with swap, those 120GB images I mentioned. I use a full device as one partition always. I resist a part for this and a part for that of a single disk, simply adds undue complexity. You can add a disk and mount it as "My Documents" or "Program Files" under windows, and the same ~/Videos under debians, etc. Makes data backups easy, yes that whole disk...

Maybe, sidestep your plan and make the next storage purchase a SSD. I would be greedy for performance over space.
Generally, there is little reason for a spinner. I have two uses; full time 24/7/365 video either security or tivo, and the biggest thing I own filled with qcow2's. In between it's all ssd's. If not a video drive, it's nice to turn spinners off. In my mind something isn't a backup until you turn it off.

My concept is all these are the same. If you can organize it into a bootable thing, it can be a disk, or a file, or mounted in a directory. Similarly, if you can organize a data set into a directory, it can be made into a disk, or a single file. If we organize in this way, then it scales into better things transparently. So skipping partitions as also a choice, Device=Directory=File. And smaller, or tidier ones are cheaper!

Post Reply