Skip to content

Commit 5529711

Browse files
antohamilegionus
andcommitted
kickstart: add growfs for ext4, xfs, f2fs
Link: https://lore.altlinux.org/make-initrd/Z0MhY4IuM2wt5WAe@example.org/ Co-authored-by: Alexey Gladkov <gladkov.alexey@gmail.com> Signed-off-by: Anton Midyukov <antohami@altlinux.org>
1 parent b7a351f commit 5529711

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

features/kickstart/config.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ $(call feature-requires,devmapper luks lvm mdadm modules-filesystem system-glibc
33

44
KICKSTART_PROGS = sfdisk wipefs blkid findmnt mkswap mount mountpoint chroot \
55
rsync wget tar unzip cpio env sha256sum eject halt reboot \
6-
btrfs mkfs.btrfs mkfs.ext4 numfmt
6+
btrfs mkfs.btrfs mkfs.ext4 numfmt e2fsck resize2fs \
7+
xfs_growfs resize.f2fs
78

89
KICKSTART_PROGS_PATTERNS = \
910
*/lz4 \

features/kickstart/data/bin/kickstart-sh-storage

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,60 @@ ks_get_dev_id()
544544
printf '%s\n' "$1"
545545
}
546546

547+
ks_requires_ext4=("e2fsck resize2fs")
548+
ks_requires_xfs=("xfs_growfs")
549+
ks_requires_f2fs=("resize.f2fs")
550+
ks_growfs()
551+
{
552+
local PROG
553+
local fs="" requires="" ret=0
554+
555+
PROG="kickstart"
556+
message "command: ${FUNCNAME[0]} $*"
557+
558+
fs="$(blkid --output value --match-tag TYPE -c /dev/null "$1")" ||
559+
return 0
560+
561+
case "$fs" in
562+
ext*) requires="ks_growfs_ext4" ;;
563+
xfs) requires="ks_growfs_xfs" ;;
564+
f2fs) requires="ks_growfs_f2fs" ;;
565+
*)
566+
# resize unsupported.
567+
return 0
568+
;;
569+
esac
570+
571+
ks_check_requires "$requires" ||
572+
return 1
573+
574+
verbose "Increase filesystem to partition size: $1"
575+
576+
case "$fs" in
577+
ext*)
578+
e2fsck -f "$1" && resize2fs "$1" ||
579+
ret=1
580+
;;
581+
xfs)
582+
mount -n -o rw,X-mount.mkdir \
583+
"$1" \
584+
"$ks_datadir/xfs.dir"
585+
xfs_growfs \
586+
"$ks_datadir/xfs.dir" ||
587+
ret=1
588+
umount -f \
589+
"$ks_datadir/xfs.dir"
590+
;;
591+
f2fs)
592+
resize.f2fs "$1" ||
593+
ret=1
594+
;;
595+
esac
596+
597+
return $ret
598+
}
599+
600+
547601
ks_requires_part=("numfmt" "sfdisk")
548602
part()
549603
{
@@ -833,6 +887,7 @@ part()
833887

834888
printf ', %s\n' "$size" |
835889
sfdisk -q -N "$partnum" "/dev/$dev"
890+
ks_growfs "/dev/$dev$partnum"
836891
fi
837892

838893
if [ -n "$encrypted" ]; then

0 commit comments

Comments
 (0)