I am using these commands in Linux Kali but I keep getting an error when I run the second command: "No such file or directory found."

read start _ < <(du -bcm kali-linux-1.0.8.amd64.iso | tail -1); echo $start
parted /dev/sdb mkpart primary $start $end

These are some commands out of a larger set of commands I am using to try to get persistence. I do not actually know what any of these mean.

My request is for an explanation of what each command does so I can fix my errors.

2 Answers 2

read start _

This assigns the first word (according to $IFS) of the input line to the variable start.

du -bcm kali-linux-1.0.8.amd64.iso | tail -1

is a strange way for getting the size of the file, rounded up to the next megabyte.

parted /dev/sdb mkpart primary $start $end

creates a partition on sdb which begins after the space necessary for the iso file (assuming the default unit for parted is megabyte which I have not checked) and ends at 7GB.

  • The name of the iso file should be the name of the iso of the operating system, right? I spell it correctly but I keep getting the same error. Aug 6, 2017 at 19:26
  • 1
    @InterestedLearner Maybe you should finally tell us these errors... Aug 6, 2017 at 19:33

Sorry for the necroposting but just found myself faced with same. So this may complement the instructions in the Kali page:

  • Each command is in its own line

  • end=7gb define the end variable as 7gb;

  • read start _ < <(du -bcm kali-linux-1.0.8.amd64.iso | tail -1); echo $start

Here's the crux of the problem: you download the Kali iso and you have to create the persistence partition from the directory where the iso you downloaded is, so the new partition gets its start defined by the end of the ISO, which you copied byte-by-byte to the USB:

du -bcm kali-linux-1.0.8.amd64.iso disk usage of the ISO file, in bytes, complete, and 1 megabyte block size;

tail -1 the previous command gives a couple of lines as a result, like:

3269    kali-linux-2019.2-i386.iso
3269    total

but we only care about the number before total, so first we strip the last (second) line and get:

3269 total

read start _ does the final trick: reads that line until the first space or first tab or first new line, the default internal field separators, stops there (underscore), and assigns that word to the variable start.

echo $start fixes that number as the $start variable, since we didn't define with an equal sign.

  • parted /dev/sdb mkpart primary $start $end

This is the part that does the actual job of creating the partition, from the size in megabytes of the ISO files (3269mb, about 3gb) to the 7gb mark. That's the part that will become your persistence partition. Say you're ok with the program picking the start block, even if you lose some megabytes.

Remember to change sdX to the correct letter for your system. It's usually a lot higher than b (I have it in g, d and e) and I think they should avoid using b in examples, since many of us have two hard drives.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.