Bird
0
0

You want to automate partition creation on /dev/sdb using fdisk in a script. Which method is correct?

hard📝 Application Q9 of 15
Linux CLI - Disk and Storage
You want to automate partition creation on /dev/sdb using fdisk in a script. Which method is correct?
AUse lsblk to create partitions
BRun fdisk interactively inside the script without input redirection
CUse a here-document to send fdisk commands: <code>fdisk /dev/sdb <<EOF n p 1 +20G w EOF</code>
DUse fdisk -l to create partitions
Step-by-Step Solution
Solution:
  1. Step 1: Understand scripting fdisk

    fdisk can accept commands via here-document to automate partition creation.
  2. Step 2: Evaluate other options

    Interactive fdisk needs manual input; lsblk and fdisk -l do not create partitions.
  3. Final Answer:

    Use a here-document to send fdisk commands -> Option C
  4. Quick Check:

    Here-documents automate fdisk commands [OK]
Quick Trick: Automate fdisk with here-documents in scripts [OK]
Common Mistakes:
  • Trying to create partitions with lsblk
  • Using fdisk -l which only lists partitions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Linux CLI Quizzes