Creating partitions non-interactively (parted)
by czezz from LinuxQuestions.org on (#52S7E)
This is the way I have created 3 partitions with non-interactively method.
Code:parted /dev/sda --script mklabel gpt
parted -a optimal /dev/sda --script mkpart primary ext4 2048 500MB
parted -a optimal /dev/sda --script mkpart primary ext4 500MB 3000MB
parted -a optimal /dev/sda --script mkpart primary ext4 3000MB 100%Questions:
1. How can I specify type of partition. By default it is "Linux filesystem" and I want to set it to: Linux LVM.
2. In between partitions there are wasted sectors. Is there any better way to specify and align partition? (although -a optimal is used)
Code:root@slackware:~# fdisk -l /dev/sda
Disk /dev/sda: 4 GiB, 4294967296 bytes, 8388608 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 5F843811-7D38-44C8-A32F-52ABE6A6B7A3
Device Start End Sectors Size Type
/dev/sda1 2048 976895 974848 476M Linux filesystem
/dev/sda2 976896 5859327 4882432 2.3G Linux filesystem
/dev/sda3 5859328 8386559 2527232 1.2G Linux filesystem


Code:parted /dev/sda --script mklabel gpt
parted -a optimal /dev/sda --script mkpart primary ext4 2048 500MB
parted -a optimal /dev/sda --script mkpart primary ext4 500MB 3000MB
parted -a optimal /dev/sda --script mkpart primary ext4 3000MB 100%Questions:
1. How can I specify type of partition. By default it is "Linux filesystem" and I want to set it to: Linux LVM.
2. In between partitions there are wasted sectors. Is there any better way to specify and align partition? (although -a optimal is used)
Code:root@slackware:~# fdisk -l /dev/sda
Disk /dev/sda: 4 GiB, 4294967296 bytes, 8388608 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 5F843811-7D38-44C8-A32F-52ABE6A6B7A3
Device Start End Sectors Size Type
/dev/sda1 2048 976895 974848 476M Linux filesystem
/dev/sda2 976896 5859327 4882432 2.3G Linux filesystem
/dev/sda3 5859328 8386559 2527232 1.2G Linux filesystem