Skip to content

Instantly share code, notes, and snippets.

@tuxfight3r
Created March 6, 2017 16:01
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuxfight3r/c640ab9d8eb3806a22b989581bcbed43 to your computer and use it in GitHub Desktop.
Save tuxfight3r/c640ab9d8eb3806a22b989581bcbed43 to your computer and use it in GitHub Desktop.
use sfdisk to create scripted partitions
##create one big partition
echo ';' | sfdisk /dev/sdc
##create one big partition with specific partition type
#creates W95 FAT32 (LBA)
echo ',,c;' | sfdisk /dev/sdd
#creates lvm type
echo ',,8e;' | sfdisk /dev/sdd
##Three primary partitions: two of size 50MB and the rest:
sfdisk /dev/hda -uM << EOF
,50
,50
;
EOF
##A 1MB OS2 Boot Manager partition, a 50MB DOS partition, and three extended partitions (DOS D:, Linux swap, Linux):
sfdisk /dev/hda -uM << EOF
,1,a
,50,6
,,E
;
,20,4
,16,S
;
EOF
#Useful commands
sfdisk -l /dev/hda #list partitions
sfdisk -l -x /dev/hda #list extended partitions
sfdisk -T #list partition types
@mdiogene
Copy link

mdiogene commented Jan 2, 2020

Hello,
is it possible to use sfdisk to create an extended partition on a left free space on a disk ?

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment