How to create disk partition using partition table

I am trying to add the below commands to create partition on the server but I get this error parted command not found. I use these commands in partition table template.

parted /dev/sdc --align=optimal --script –
mklabel gpt
mkpart primary ext4 0% 100%
set 1 raid on

parted /dev/sdd --align=optimal --script –
mklabel gpt
mkpart primary ext4 0% 100%
set 1 raid on

mdadm --create -f /dev/md3 --level=1 --raid-devices=2 /dev/sdc1 /dev/sdd1
mkfs.ext4 /dev/md3

MD_UUID=$(sudo mdadm --detail --scan | grep md3 | awk ‘{print $5}’)
echo “ARRAY /dev/md/3 level=raid1 num-devices=2 $MD_UUID” >> /etc/mdadm.conf

dracut -f

mkdir /data
VOL_UUID=$(sudo blkid -s UUID /dev/md3 -o value)
echo “UUID=$VOL_UUID /data ext4 defaults 1 1” >> /etc/fstab
mount /data

Kindly advice me on how to fix this issue.

Kind regards,

Bahram

are you using atemplate into Templates->Partition template or just some commands into the kickstart?

Try to set up the partition template and associate it to Hosts -> Operating System -> Your OS -> Partition table. A simple example: lvm +xfs with recommended swap, 10Gb for /home and the other space for /.

<%#
kind: ptable
name: Kickstart default thin 100GB
model: Ptable
oses:
- CentOS
- Fedora
- RedHat
- oVirt
- RHVH
%>
zerombr
clearpart --all --initlabel 
part /boot --fstype="xfs" --size=1024
part pv.0 --size=1 --grow
volgroup vg01 pv.0
logvol swap --fstype="swap" --name=lv_swap --vgname=vg01 --recommended
logvol /home --fstype="xfs" --name=lv_home --vgname=vg01 --size=10000
logvol / --fstype="xfs" --name=lv_root --vgname=vg01 --size=1 --grow

Hello Kraba,

Thank you very much for your reply. how to configure the raid? i have 4 SSD disks, each disk has 1.92TB and but when i’m configuring the raid it is not configuring correctly. I can see a lot of unallocated space/free space. Here is my partition template:

<%#
kind: ptable
name: Kickstart default
model: Ptable
oses:
- CentOS
- Fedora
- RedHat
%>
zerombr
clearpart --all --initlabel

# -- raid part for boot --
part raid.sda0 --size=512 --asprimary --ondisk=/dev/sda
part raid.sdb0 --size=512 --asprimary --ondisk=/dev/sdb

# -- raid part for root --
part raid.sda1 --size=81920 --grow --asprimary --ondisk=/dev/sda
part raid.sdb1 --size=81920 --grow --asprimary --ondisk=/dev/sdb

# -- raid part for swap --
part raid.sda2 --size=16384 --asprimary --ondisk=/dev/sda
part raid.sdb2 --size=16384 --asprimary --ondisk=/dev/sdb

# -- raid part for data --
part raid.sdc0 --asprimary --size=1 --grow --ondisk=/dev/sdc
part raid.sdd0 --asprimary --size=1 --grow --ondisk=/dev/sdd

part /data --fstype=ext4 --size=1 --grow --ondisk=/dev/sdc

# Raid device creation
raid /boot --fstype=ext4 --device=md0 --level=1 raid.sda0 raid.sdb0
raid /     --fstype=ext4 --device=md1 --level=1 raid.sda1 raid.sdb1
raid swap  --fstype=swap --device=md2 --level=1 raid.sda2 raid.sdb2

# Raid device creation
raid /data --fstype=ext4 --device=md3 --level=1 raid.sdc0 raid.sdd0

=====================================

parted /dev/sdd print free
Model: ATA SAMSUNG MZ7LH1T9 (scsi)
Disk /dev/sdd: 1920GB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type     File system  Flags
        32.3kB  1049kB  1016kB           Free Space
 1      1049kB  1920GB  1920GB  primary               raid
        1920GB  1920GB  352kB            Free Space
=====================================
parted /dev/sdc print free
Model: ATA SAMSUNG MZ7LH1T9 (scsi)
Disk /dev/sdc: 1920GB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type     File system  Flags
        32.3kB  1049kB  1016kB           Free Space
 1      1049kB  960GB   960GB   primary               raid
        960GB   1920GB  960GB            Free Space

=====================================
parted /dev/sda print free
Model: ATA SAMSUNG MZ7LH240 (scsi)
Disk /dev/sda: 240GB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type     File system  Flags
        32.3kB  1049kB  1016kB           Free Space
 1      1049kB  17.2GB  17.2GB  primary               raid
 2      17.2GB  17.7GB  537MB   primary               boot, raid
 3      17.7GB  240GB   222GB   primary               raid
        240GB   240GB   614kB            Free Space
==================================

arted /dev/sdb print free
Model: ATA SAMSUNG MZ7LH240 (scsi)
Disk /dev/sdb: 240GB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type     File system  Flags
        32.3kB  1049kB  1016kB           Free Space
 1      1049kB  17.2GB  17.2GB  primary               raid
 2      17.2GB  17.7GB  537MB   primary               boot, raid
 3      17.7GB  240GB   222GB   primary               raid
        240GB   240GB   614kB            Free Space

Thanks in advance for your help.

Kind regards,

Bahram

Why do you want to create multiple partitions across multiple RAID devices? What you want to do is to build one RAID partition that is the same size as your RAID drives. In your case 4x 2TB drive you can do almost all RAID options: RAID 5, 6 and 10 seem to be the best options for you, but this depends on your workload.

I would understand if you want to keep your /boot or swap out of the RAID but that’s not your case if I read that correctly. You want to put everything into RAID, then just create one big volume and parition that.

Few megabytes of free space is okay, that’s not a bug but feature (padding). However 900 GB that is probably misconfiguration. Stright up I see that you have --size=1 --grow --ondisk=/dev/sdc twice, therefore Anaconda decided to cut that at half because you asked it to (both grow = cut in half). This is likely on overlook, if you go for the more simple setup I recommend your configuration will be much more simple and readable.

1 Like

Great, feel free to share your final template so other users can benefit from it! Take care.

1 Like