Skip to content

Commit 5e1f47b

Browse files
Shishir Mahajanrh-atomic-bot
authored andcommitted
Use parted (If available) to partition disk, else fallback to sfdisk.
Signed-off-by: Shishir Mahajan <shishir.mahajan@redhat.com> Closes: #191 Approved by: rhvgoyal
1 parent 948e2fa commit 5e1f47b

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

docker-storage-setup.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -706,9 +706,8 @@ scan_disks() {
706706
echo $new_disks
707707
}
708708

709-
create_partition() {
709+
create_partition_sfdisk(){
710710
local dev="$1" size
711-
712711
# Use a single partition of a whole device
713712
# TODO:
714713
# * Consider gpt, or unpartitioned volumes
@@ -720,6 +719,21 @@ unit: sectors
720719
721720
${dev}1 : start= 2048, size= ${size}, Id=8e
722721
EOF
722+
}
723+
724+
create_partition_parted(){
725+
local dev="$1"
726+
parted $dev --script mklabel msdos mkpart primary 0% 100% set 1 lvm on
727+
}
728+
729+
create_partition() {
730+
local dev="$1"
731+
732+
if [ -x "/usr/sbin/parted" ]; then
733+
create_partition_parted $dev
734+
else
735+
create_partition_sfdisk $dev
736+
fi
723737

724738
# Sometimes on slow storage it takes a while for partition device to
725739
# become available. Wait for device node to show up.

0 commit comments

Comments
 (0)