0

I want to copy the casper-rw partition contents of one device OVER the the casper-rw partition of the other device, using GParted tool and here described procedure. (Note: casper-rw partition in the above mentioned configuration holds data and settings. That's the reason I want to copy the casper-rw partition).

I don't want to change the structure or size of the casper-rw partition on the destination device - all I want is to gain more room for that partition while preserving the settings and data already on the source (smaller) device.

My understanding is that the first step is to unallocate the destination casper-rw partition. The second step is to copy/paste the casper-rw source partition over the unallocated partition.

Now the questions:

  • How to unallocated the destination casper-rw partition?
  • Will the copy/paste procedure use all unallocated space - or I'll have to do more in order to add remaining space to the casper-rw partition?

Alternative solution:

Instead of using GParted, I can run (dry run):

sudo rsync -Havn

and then, if everything looks ok, no error message, eventually run

sudo rsync -Hav

to copy files and folders. I believe that

rsync

is not going to change the SIZE of the destination partition.

BlueSkies
  • 2,145
  • If you copy one partition to another you are basically replacing the destination partition with the source, so all the files folders contained therein get replaced as well as the UUID of the destination partition. Just copy (rsync) the necessary files and folders over from partition1 to partition2. – Paul Benson Nov 22 '19 at 18:07
  • @PaulBenson: Partition2 size is the size I want to have after copying the files - either using rsync or GParted. The destination device (USB stick) is larger than the source device and I'd like to have the extra space for casper-rw ("Partition2"). I'm not sure I can achieve it using GParted, that's why I'm describing the situation I'm facing. – BlueSkies Nov 22 '19 at 18:32
  • By Casper partition do you mean about making a Live Ubuntu drive here? Otherwise I'm not sure what you're trying to do here. Are you saying you have other data already on partition2? – Paul Benson Nov 22 '19 at 20:25
  • @PaulBenson: Yes – BlueSkies Nov 22 '19 at 20:52
  • Yes to both questions? Just to be clear, you have data on destination drive which you want to keep? – Paul Benson Nov 22 '19 at 22:50
  • @PaulBenson: Yes to both questions. The destination device is already Live Ubuntu & with persistent storage. And it already has other data on that partition, but I don't want to keep that data anymore. – BlueSkies Nov 22 '19 at 22:55

2 Answers2

1

I don't know if GParted would solve the problem (copy/paste partition without changing the size). But with the help of the rsync command I was able to copy all the files from the source partition to the destination partition while preserving the size of the destination partition. Specifically:

sudo rsync -Hav /media/ubuntu/casper-rw1/ /media/ubuntu/casper-rw2/

I'd recommend to precede it by "dry run" (the -n option) and save the output in a log file, in case the rsync command outputs error messages.

BlueSkies
  • 2,145
0

How to unallocate the destination casper-rw partition?

Using gparted delete the partition.

The old casper-rw partition in the destination USB will be gone and the space will in unallocated.

Will the copy/paste procedure use all unallocated space - or I'll have to do more in order to add remaining space to the casper-rw partition?

No

The copied casper-rw partition will be exactly the same size as it was in the old USB, small.

Use the Resize/Move feature of Gparted to expand the casper-rw partition to fill all the unallocated space in the bigger USB.

Alternatively use rsync

If you don't want to lose some of the data in the existing casper-rw partition in the bigger USB, then rsync is the best option.

Since you will be copying files and folders rather than partitions, the size of the partition in the bigger USB will remain the same.

The -H option you mentioned in the rsync command allows preserving of hard links. From the man page:

-H, --hard-links

This tells rsync to look for hard-linked files in the transfer and link together the corresponding files on the receiving side. Without this option, hard-linked files in the transfer are treated as though they were separate files.

When you are updating a non-empty destination, this option only ensures that files that are hard-linked together on the source are hard-linked together on the destination. It does NOT currently endeavor to break already existing hard links on the destination that do not exist between the source files. Note, however, that if one or more extra-linked files have content changes, they will become unlinked when updated (assuming you are not using the --inplace option).

I don't think there are any hard links in casper-rw unless you created them. I would leave it out as it conflicts with the -a option. Using -Hamay result in unpredictable results. I would also add -X so that extended attributes (if any) are copied as well.

sudo rsync -Xav /media/ubuntu/casper-rw1/ /media/ubuntu/casper-rw2/

Hope this helps

user68186
  • 33,360
  • @BlueSkies that's why you need to check the man. Look up what each of the options H, a, v, n does in the man. Windows does not have "hard links". I am not sure the casper-rw partition has any hard links to beging with. So, it may not do anything in your case. But this has nothing to do with this particular question. – user68186 Nov 23 '19 at 15:25
  • I am not familiar with terms sparse (option -S) and extended attributes (option -S). – BlueSkies Nov 23 '19 at 16:06
  • @BlueSkies Here is more on sparse files: https://gergap.wordpress.com/2013/08/10/rsync-and-sparse-files/ and extended attributes: https://linux-audit.com/using-xattrs-extended-attributes-on-linux/ Now I have read more about -H and these options and decided you don't need -H and -S in your case as casper-rw probably do not have any hard links and sparse files. I will change my answer. – user68186 Nov 23 '19 at 17:18