Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

partition disk programmatically from cli #17

Open
endorama opened this issue Aug 28, 2018 · 0 comments
Open

partition disk programmatically from cli #17

endorama opened this issue Aug 28, 2018 · 0 comments

Comments

@endorama
Copy link
Owner

endorama commented Aug 28, 2018

source: https://unix.stackexchange.com/questions/200582/scripteable-gpt-partitions-using-parted

solution

parted user manual

  • replace /dev/sdb with your device.
  • start from MiB
  • end to -1MiB
# parted /dev/sdb --script -- unit MiB print free
Model: QEMU QEMU HARDDISK (scsi)
Disk /dev/sdb: 204800MiB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 
# parted /dev/sdb --align optimal --script -- mklabel gpt mkpart primary ext4 1MiB 204799MiB

Disk is partitioned now:

# parted /dev/sdb --script -- unit MiB print free                                                    
Model: QEMU QEMU HARDDISK (scsi)
Disk /dev/sdb: 204800MiB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start      End        Size       File system  Name     Flags
        0.02MiB    1.00MiB    0.98MiB    Free Space
 1      1.00MiB    204799MiB  204798MiB               primary
        204799MiB  204800MiB  0.98MiB    Free Space
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant