Advertisement
v1ral_ITS

Erase all, create single partition ( terminal )

Feb 7th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.71 KB | None | 0 0
  1.  
  2.  
  3. sfdisk CLI non-interactive method
  4.  
  5. echo 'start=2048, type=83' | sudo sfdisk /dev/sdX
  6. sudo mkfs.ext4 /dev/sdX1
  7.  
  8. erases all data, and creates a single partition that takes up all USB with an ext4 filesystem.
  9.  
  10. Choose X based on the output of:
  11.  
  12. sudo lsblk
  13. sudo fdisk -l
  14.  
  15. For more detailed description of sfdisk see: https://superuser.com/questions/332252/creating-and-formating-a-partition-using-a-bash-script/1132834#1132834
  16.  
  17. fdisk automation
  18.  
  19. It is also possible to do the same as above with:
  20.  
  21. printf 'o\nn\np\n1\n\n\nw\n' | sudo fdisk /dev/sdX
  22.  
  23. but this method is less maintainable than sfdisk, which was designed for Scripting fdisk, specially if you want to create more complex partition tables.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement