How can I clone a microSD card from a 32GB card to a 128GB card so that all saved/cached data is recognized on a Motorola/Lenovo Moto G5 Plus? I've tried using file explorer with hidden and system files viewable to copy across all files from the 32GB to 128GB microSD card but when I try to view offline videos in YouTube for example it's greyed out and I have to re-download.
This works on Linux and Android. On Android you need one of the following:
a) Two micro-SD card slots
b) One micro-SD card slot and one USB cardreader with a USB-OTG adapter
c) A USB hub with two USB cardreaders on a USB-OTG adapter

On Android Termux from the Play Store can be used for this, on Linux open a terminal.


Use lsblk to find out the drive names for your two SD cards.
Here I will assume sdd is your old SD card and sde the new one.
Clone the old card onto the new one 1:1: dd if=/dev/sdd of=/dev/sde bs=1M
Resize the partition with fdisk - Execute fdisk, then hit d to delete the partition (this won't actually delete any data!) and return to confirm. Then hit n to create a new partition. Select p for primary and then hit return three times to create the partition. Then hit w and return to write the changes.
Resize the new partition: resize2fs /dev/sde1


That's it. Please note that if you want to do this on your android device, you need root.