here is example from our rhel server machine
lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdb 8:16 0 20G 0 disk /data/sdb
sdc 8:32 0 20G 0 disk /data/sdc
sdd 8:48 0 20G 0 disk /data/sdd
sde 8:64 0 20G 0 disk /data/sde
sdf 8:80 0 42G 0 disk
sdg 8:96 0 42G 0 disk
sdh 8:112 0 42G 0 disk
we want to Create a Disk Partitions for the other disks as sdf,sdg,sdh
, but all this process should be by bash script and we want to automate the process
first here is example how to create 2
partitions for sdf
disk ,
so in this example we create two partitions each one will get 10G
size
step 1 ( create partitions when each partition take 10G
)
parted /dev/sdf
GNU Parted 3.1
Using /dev/sdf
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel msdos <-- sending text (1)
(parted) mkpart primary 0 10024MB <-- sending text (2)
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? I <-- sending text (3)
(parted) mkpart primary 10024MB 20048MB <-- sending text (4)
(parted) quit <-- sending text (5)
Information: You may need to update /etc/fstab.
and now we get ( the expected results )
lsblk
sdf 8:80 0 42G 0 disk
├─sdf1 8:81 0 9.3G 0 part
└─sdf2 8:82 0 9.3G 0 part
can we automate the parted
process ? or maybe by other approach ( for example by fdisk
) ?
in order to use this automated process in python3/bash
script
Note - we not have expect
on our Linux machines
reference - https://www.tecmint.com/create-disk-partitions-in-linux/