Member Avatar for Member #1133358

I have Kali live with persistence and quite a few hours worth of tweaks in a bulky 15Gb USB although I'm using less than 5Gb overall. I just got a tiny, 8Gb USB memory, is there a way to migrate it all to the 8Gb one?
By that I mean that the 8Gb will be fully operating with all the customizations I did to Kali inside the 15Gb USB stick.

Thank you

Dani AI

Generated

As hinted, cloning is one route, but the simplest, safest way when the target is smaller is: re-create a bootable Kali on the 8GB stick from the ISO, create a (smaller) persistence partition on the remainder, and copy only the persistence data across. That avoids fiddling with boot sectors or copying unused blocks and is the method the Kali docs themselves show for making a persistent live USB. (See Kali "Adding Persistence".) (kali.org)

Practical workflow (run from a separate live system so the source USB is not mounted as root):

# inspect how much persistence data you actually have
lsblk
sudo mkdir /mnt/src /mnt/dest
sudo mount /dev/sdX3 /mnt/src     # sdX3 = your old persistence partition
sudo du -sh /mnt/src

# write the Kali ISO to the new USB (wipes target)
sudo dd if=kali-linux-*-live-amd64.iso of=/dev/sdY bs=4M status=progress conv=fsync

# create an ext4 partition on remaining space, label it "persistence",
# create /mnt/dest/persistence.conf with the single line: "/ union"
# then copy persistence data (preserve perms/xattrs/ACLs)
sudo mount /dev/sdY3 /mnt/dest
sudo rsync -aHAX --numeric-ids --exclude={"/proc/*","/sys/*","/dev/*","/tmp/*","/run/*"} /mnt/src/ /mnt/dest/
sync; sudo umount /mnt/src /mnt/dest

Use rsync with -aHAX to preserve ownership, links, xattrs and ACLs when moving a whole filesystem. If you prefer to shrink the source filesystem and do a full block clone, you must shrink the ext4 filesystem first (run e2fsck and then resize2fs on the unmounted partition), or use GParted to resize before running Clonezilla in expert mode. Clonezilla has an advanced option to ignore destination size, but it only works if the partition data actually fits — shrinking first is the safe approach. (manpages.debian.org)

Important cautions: always have a backup, double-check device names (dd will destroy the wrong disk), never shrink a mounted filesystem, and leave some headroom (a few hundred MB) when sizing the new persistence partition. If the new stick won’t boot after a manual partition copy you may need to reinstall the bootloader or simply re-create the USB from the ISO then rsync the persistence data — that is usually faster and less error-prone. (gparted.org)

Recommended Answers

All 4 Replies

Member Avatar for Member #1133358

What about the partitions sizes? The new USB is 7Gb smaller.

Member Avatar for Member #1133358

Nevermind, I was thinking that manually resizing the partitions before cloning would screw it up but apparently not.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.