0

hello i am very new at linux and was reading a internal documentation on creating space. i came across this command can some one please explain what this command means dd if=/dev/zero bs=1G count=20 >> /OVS/Repositories/repo/.ACFS/snaps/vm_name/VirtualMachines/vm_name/System.img

what i understand from this command is i am giving a 20gb allocation to the System.img dont know if this is= correct

3

1 Answer 1

1

Let's break this into pieces:

dd if=/dev/zero bs=1G count=20 

The dd command copies data. The input data is from the device that generates an infinite number of zeros. The dd parameters say to use a block size of 1G and copy 20 blocks, so that would be 20G of zeros.

>> /OVS/Repositories/repo/.ACFS/snaps/vm_name/VirtualMachines/vm_name/System.img

The >> symbol saves output from the previous command to the following filename in append mode. If you used > by itself instead, it would either create a new file or truncate the existing file and start from the beginning as if it was a new file.

If this file didn't exist before, this would initialize it to a non-sparse 20G file of zeros.

If this already existed, you would be expanding it by 20G. Since this file appears to be a disk image (guessing from the filename), presumably your next step would be to expand the filesystem inside it to use the new space.

2
  • But >> passes the 20GB of zeros through the parent process and has it write the file. Read man dd, you can specify the output file, an offset, etc.
    – waltinator
    Nov 16, 2021 at 0:30
  • No, >> doesn't pass anything through the parent process. The parent process opens the file in append mode and then runs dd with that as stdout. There is no difference in performance from what you suggest.
    – user10489
    Nov 16, 2021 at 5:29

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.