0

I have a USB (8.0 GB, kingston) and inside it a Kali Linux image. I often used it in live mode w/ persistence, and I have some data there (plus config of the whole system) that I obviously don't want to lose. But, by some reasons, I have to dispose myself of that USB. My question is: Is there some way to back up everything, in a way that after getting another USB I could use the backup and reinstall it?

Many people suggesting dd command, I do not know if that works because of the way that persistence bootable USB are made: here

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
Deltab
  • 111

2 Answers2

1

To create an image from a drive

sudo dd iflag=fullblock if=/dev/sdx of=/path/to/new.iso status=progress

Alternatively, to create a USB drive from an image

sudo dd iflag=fullblock if=/path/to/iso of=/dev/sdx status=progress

Replace /dev/sdx with your USB drive, e.g. /dev/sdc.

WARNING: It is very important that you make certain you are using the correct drive. If you don't use the correct drive, you could lose your data. To check your currently mounted drives, use the command lsblk.

Note: Copying large files (1 GB or higher) can take a long time, be patient.

  • 1
    On Linux systems don't bother using dd for this kind of copy operation; use cat instead. It's easier and often faster (never slower). In your case the dd is desperately inefficient - and slow - because you're using the default (512b) block size. – Chris Davies Apr 06 '17 at 07:45
  • @roaima I have always used dd for such operations, in fact, I always assumed that cat would be slower, but thank you for explaining it to me :) – Michael Wilcox Apr 06 '17 at 07:57
  • See http://unix.stackexchange.com/a/9492/100397 for some facts backing up my claim. – Chris Davies Apr 06 '17 at 09:50
  • I did not knew I could use dd command for that, i had used dd before for creating the bootable USB. But now it seems there is a controversy here, I should use cat instead of dd? And if yes please edit the answer for others who might stumble here with the same question – Deltab Apr 06 '17 at 12:46
  • The confusion here lies in that roaima does not acknowledge that adding iflag=fullblock will have the same effect as using cat without losing the fine-grained control. – Tanami Apr 07 '17 at 02:38
  • @Tanami I have updated the post to reflect your suggestion, however I have no time to test the script, can you please verify it? – Michael Wilcox Apr 09 '17 at 09:21
  • Your edit is correct, you can also use the argument status=progress to see a transfer statistics bar. – Tanami Apr 11 '17 at 01:29
0

You can use dd to create a disk image of your Kali USB as it were.

And then you can write that disk image to another USB of equal or greater size to restore it.

The command must not be run from within the disk to be copied (so not inside Kali).


The command format is dd if=/dev/sdX of=/dst status=progress

Where sdX is the /dev device for the USB drive which has the Kali install on it.

And dst is where you want to put the image, i.e. (/home/user/kali.img)


dd is a very powerful command so you must double-check the if=/ and of=/ flags or else you may corrupt your main hard drive.

Tanami
  • 136
  • 7
  • 2
    On Linux systems don't bother using dd for this kind of copy operation; use cat instead. It's easier and often faster (never slower). In your case the dd is desperately inefficient - and slow - because you're using the default (512b) block size. See http://unix.stackexchange.com/a/9492/100397 for some facts backing up my claim. – Chris Davies Apr 06 '17 at 09:50
  • This is interesting but you should see http://yarchive.net/comp/linux/page_sizes.html – Tanami Apr 07 '17 at 02:36