Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Cloning a disk: partclone?

613 views
Skip to first unread message

Tom Browder

unread,
Jan 19, 2023, 2:00:07 PM1/19/23
to
On my main PC, I would like to clone my boot drive onto another disk for 2 reasons:

1. Use a larger disk for the main drive
2. Create an emergency recovery disk

A new Debian package to me is "partclone". Questions:

+ Can that be used for both purposes?

+ Can it do a complete clone on an active disk? Or do I need a live CD or USB stick?

Thanks.

-Tom

Jeffrey Walton

unread,
Jan 19, 2023, 2:20:06 PM1/19/23
to
I can't speak to partclone. I've never used it.

I would use Clonezilla for the task. I've used Clonezilla a lot in the past.

Jeff

Charles Curley

unread,
Jan 19, 2023, 2:20:06 PM1/19/23
to
On Thu, 19 Jan 2023 12:49:57 -0600
Tom Browder <tom.b...@gmail.com> wrote:

> + Can it do a complete clone on an active disk? Or do I need a live
> CD or USB stick?

I wouldn't try backing up a live partition due to issues with
referential integrity. Suppose two interdependent files, A and B, change
during the backing up, like so:

A is backed up.
A and B are both changed.
B is backed up.

Your originals are fine, they both have the changes. But the backup is
broken: only one file has the changes.

The only exception to that is an LVM logical disk (or similar) where you
have taken a snapshot, and you back up the snapshot.

--
Does anybody read signatures any more?

https://charlescurley.com
https://charlescurley.com/blog/

Alexander V. Makartsev

unread,
Jan 19, 2023, 2:50:05 PM1/19/23
to
On 19.01.2023 23:49, Tom Browder wrote:
On my main PC, I would like to clone my boot drive onto another disk for 2 reasons:

1. Use a larger disk for the main drive
2. Create an emergency recovery disk

A new Debian package to me is "partclone". Questions:

+ Can that be used for both purposes?
Yes. Keep in mind, that it will clone partitions (with filesystems) separately, so you have to create partition table on destination drive manually.
Procedure will depend on what partition scheme your source drive uses: MBR or GPT.
In case of MBR, you will have to install bootloader on a destination drive after cloning.
In case of GPT, cloning the EFI partition should be enough to boot from a destination drive.



+ Can it do a complete clone on an active disk? Or do I need a live CD or USB stick?
No, it can't. Partitions have to be unmounted for partclone to work.
Since you will be creating LiveCD on USB stick and going offline anyway it might be better (easier) to use Clonezilla for this task.
Clonezilla is customizable, has curses GUI, uses partclone under the hood and also automates other things, like partition creation on a destination drive, bootloader installation, etc.


--
With kindest regards, Alexander.

⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀⠀⠀⠀

Tixy

unread,
Jan 19, 2023, 3:00:05 PM1/19/23
to
On Thu, 2023-01-19 at 20:34 +0100, DdB wrote:
> When i set up a similar job on my neighbor's home comp, i chose
> http://www.fsarchiver.org/
> Straightforward, yet flexible, can deal with resizing partition(s) and
> such. I use it from a live DVD, that is available thru grub menu, no
> media involved.

Surely it's also straightforward to just copy the data in the partition
then resize the filesystem...

cp /dev/sdX1 /dev/sdY1
resize2fs /dev/sdY1

Assuming you've already partitioned the target disk /dev/sdY to how you
want it. (And assuming the filesystem is ext2..ext4)

--
Tixy

Tixy

unread,
Jan 19, 2023, 3:10:05 PM1/19/23
to
On Thu, 2023-01-19 at 19:56 +0000, Tixy wrote:
>
> Surely it's also straightforward to just copy the data in the partition
> then resize the filesystem...
>
>  cp /dev/sdX1 /dev/sdY1
>  resize2fs /dev/sdY1
>
> Assuming you've already partitioned the target disk /dev/sdY to how you
> want it. (And assuming the filesystem is ext2..ext4)

Addendum: If you want to check the copy is successful (good idea) you
can

cmp /dev/sdX1 /dev/sdY1

before resizing it.

hede

unread,
Jan 20, 2023, 6:00:05 AM1/20/23
to
Am 19.01.2023 20:14, schrieb Charles Curley:
> On Thu, 19 Jan 2023 12:49:57 -0600
> Tom Browder <tom.b...@gmail.com> wrote:
>
>> + Can it do a complete clone on an active disk? Or do I need a live
>> CD or USB stick?
>
> I wouldn't try backing up a live partition due to issues with
> referential integrity. Suppose two interdependent files, A and B,
> change
> during the backing up, like so:
>
> A is backed up.
> A and B are both changed.
> B is backed up.
>
> Your originals are fine, they both have the changes. But the backup is
> broken: only one file has the changes.

That's true. Especially for a block based copy of mounted filesystems
there's a high risk of inconsistency, which results not only in broken
files but even not mountable filesystems. (i.e. something like a "dd" of
the /dev/sdX)

Copying files from some mounted filesystem, even some active root
partition, works for most cases. It's not exactly 100%, but there's a
high chance everything is fine. I did that several times right in the
live system and never got real problems. Even including databases
(SQL+ldap). Yes, it's absolutely preferred to boot the machine by some
external boot media for system cloning purposes, but if someone wants to
take the risk, chances are high it works.

It's reliable enough so that many backup solutions don't depend on
snapshots. And it works. Yet, backing up data _with_ using snapshots is
to be preferred.

> The only exception to that is an LVM logical disk (or similar) where
> you
> have taken a snapshot, and you back up the snapshot.

or any other snapshot mechanism like btrfs snapshots.

hede

Anssi Saari

unread,
Jan 20, 2023, 8:00:06 AM1/20/23
to
Tixy <ti...@yxit.co.uk> writes:

> Surely it's also straightforward to just copy the data in the partition
> then resize the filesystem...
>
> cp /dev/sdX1 /dev/sdY1
> resize2fs /dev/sdY1

Sure. Partclone, since the OP asked about that, can speed this up for a
partition since it's smart enough to not copy parts of the partition
that aren't in use.

Tixy

unread,
Jan 20, 2023, 12:40:06 PM1/20/23
to
Which apart from speed would probably be good if the target is an SSD,
as the disk does have to allocate flash memory for that unused data.
(I'm thinking of the discussion about SSDs we had here a few weeks
ago).

--
Tixy
0 new messages