Merge branch 'f2fs-support' into 'master'

Add f2fs support

Closes #34

See merge request manjaro-arm/applications/manjaro-arm-installer!5
This commit is contained in:
Dan Johansen 2021-10-10 06:42:10 +00:00
commit 1786e5309e
2 changed files with 55 additions and 29 deletions

View File

@ -19,6 +19,7 @@ This script is "interactive". Meaning that it asks you questions when run to cus
* dosfstools * dosfstools
* polkit * polkit
* btrfs-progs (for btrfs filesystem support) * btrfs-progs (for btrfs filesystem support)
* f2fs-tools (for f2fs filesystem support)
* cryptsetup (for encryption support) * cryptsetup (for encryption support)
## Installing and using from Manjaro (x64 and ARM) repositories: ## Installing and using from Manjaro (x64 and ARM) repositories:

View File

@ -48,7 +48,7 @@ if [ "$EUID" -ne 0 ]; then
fi fi
# Sanity checks for dependencies # Sanity checks for dependencies
declare -a DEPENDENCIES=("git" "parted" "systemd-nspawn" "wget" "dialog" "bsdtar" "openssl" "awk" "btrfs" "mkfs.vfat" "mkfs.btrfs" "cryptsetup") declare -a DEPENDENCIES=("git" "parted" "systemd-nspawn" "wget" "dialog" "bsdtar" "openssl" "awk" "btrfs" "mkfs.vfat" "mkfs.btrfs" "mkfs.f2fs" "cryptsetup")
for i in "${DEPENDENCIES[@]}"; do for i in "${DEPENDENCIES[@]}"; do
if ! [[ -f "/bin/$i" || -f "/sbin/$i" || -f "/usr/bin/$i" || -f "/usr/sbin/$i" ]] ; then if ! [[ -f "/bin/$i" || -f "/sbin/$i" || -f "/usr/bin/$i" || -f "/usr/sbin/$i" ]] ; then
@ -219,27 +219,37 @@ create_install() {
cp $TMPDIR/root/usr/share/applications/corestuff.desktop $TMPDIR/root/etc/xdg/autostart/ cp $TMPDIR/root/usr/share/applications/corestuff.desktop $TMPDIR/root/etc/xdg/autostart/
fi fi
if [[ "$FSTYPE" = "btrfs" ]]; then case "$FSTYPE" in
btrfs)
info "Adding btrfs support to system..." info "Adding btrfs support to system..."
if [ -f $TMPDIR/boot/extlinux/extlinux.conf ]; then
sed -i 's/APPEND/& rootflags=subvol=@/' $TMPDIR/boot/extlinux/extlinux.conf
elif [ -f $TMPDIR/boot/boot.ini ]; then
sed -i 's/setenv bootargs "/&rootflags=subvol=@ /' $TMPDIR/boot/boot.ini
elif [ -f $TMPDIR/boot/uEnv.ini ]; then
sed -i 's/setenv bootargs "/&rootflags=subvol=@ /' $TMPDIR/boot/uEnv.ini
elif [ -f $TMPDIR/boot/cmdline.txt ]; then
sed -i 's/^/rootflags=subvol=@ rootfstype=btrfs /' $TMPDIR/boot/cmdline.txt
elif [ -f $TMPDIR/boot/boot.txt ]; then
sed -i 's/setenv bootargs/& rootflags=subvol=@/' $TMPDIR/boot/boot.txt
$NSPAWN $TMPDIR/root mkimage -A arm -O linux -T script -C none -n "U-Boot boot script" -d /boot/boot.txt /boot/boot.scr
fi
echo "LABEL=ROOT_MNJRO / btrfs subvol=@,compress=zstd,defaults,noatime 0 0" >> $TMPDIR/root/etc/fstab echo "LABEL=ROOT_MNJRO / btrfs subvol=@,compress=zstd,defaults,noatime 0 0" >> $TMPDIR/root/etc/fstab
echo "LABEL=ROOT_MNJRO /home btrfs subvol=@home,compress=zstd,defaults,noatime 0 0" >> $TMPDIR/root/etc/fstab echo "LABEL=ROOT_MNJRO /home btrfs subvol=@home,compress=zstd,defaults,noatime 0 0" >> $TMPDIR/root/etc/fstab
sed -i '/^MODULES/{s/)/ btrfs)/}' $TMPDIR/root/etc/mkinitcpio.conf sed -i '/^MODULES/{s/)/ btrfs)/}' $TMPDIR/root/etc/mkinitcpio.conf
$NSPAWN $TMPDIR/root mkinitcpio -P 1> /dev/null 2>&1 $NSPAWN $TMPDIR/root mkinitcpio -P 1> /dev/null 2>&1
if [ -f $TMPDIR/root/boot/extlinux/extlinux.conf ]; then ;;
sed -i 's/APPEND/& rootflags=subvol=@/' $TMPDIR/root/boot/extlinux/extlinux.conf f2fs)
elif [ -f $TMPDIR/root/boot/boot.ini ]; then info "Adding f2fs support to system..."
sed -i 's/setenv bootargs "/&rootflags=subvol=@ /' $TMPDIR/root/boot/boot.ini $NSPAWN $TMPDIR/root pacman -S f2fs-tools --noconfirm 1> /dev/null 2>&1
elif [ -f $TMPDIR/root/boot/uEnv.ini ]; then echo "LABEL=ROOT_MNJRO / f2fs defaults,noatime,compress_algorithm=zstd 0 0" >> $TMPDIR/root/etc/fstab
sed -i 's/setenv bootargs "/&rootflags=subvol=@ /' $TMPDIR/root/boot/uEnv.ini sed -i '/^MODULES/{s/)/ f2fs)/}' $TMPDIR/root/etc/mkinitcpio.conf
elif [ -f $TMPDIR/root/boot/cmdline.txt ]; then $NSPAWN $TMPDIR/root mkinitcpio -P 1> /dev/null 2>&1
#sed -i 's/root=LABEL=ROOT_MNJRO/& rootflags=subvol=@/' $TMPDIR/root/boot/cmdline.txt ;;
sed -i 's/^/rootflags=subvol=@ rootfstype=btrfs /g' $TMPDIR/root/boot/cmdline.txt *)
#elif [ -f $TMPDIR/root/boot/boot.txt ]; then info "Adding ext4 support to system..."
# sed -i 's/setenv bootargs/& rootflags=subvol=@/' $TMPDIR/root/boot/boot.txt ;;
# $NSPAWN $TMPDIR/root mkimage -A arm -O linux -T script -C none -n "U-Boot boot script" -d /boot/boot.txt /boot/boot.scr esac
fi
fi
if [[ "$CRYPT" = "yes" ]]; then if [[ "$CRYPT" = "yes" ]]; then
@ -308,6 +318,17 @@ prepare_card () {
mount -o compress=zstd,subvol=@home "${SDCARD}${SDDEV}2" $TMPDIR/root/home mount -o compress=zstd,subvol=@home "${SDCARD}${SDDEV}2" $TMPDIR/root/home
mount ${SDCARD}${SDDEV}1 $TMPDIR/boot mount ${SDCARD}${SDDEV}1 $TMPDIR/boot
;; ;;
f2fs)
parted -s $SDCARD mkpart primary f2fs "${END_SECTOR}s" 100% 1> /dev/null 2>&1
partprobe $SDCARD 1> /dev/null 2>&1
mkfs.vfat "${SDCARD}${SDDEV}1" -n BOOT_MNJRO 1> /dev/null 2>&1
mkfs.f2fs -f -l ROOT_MNJRO -O extra_attr,inode_checksum,sb_checksum,compression "${SDCARD}${SDDEV}2" 1> /dev/null 2>&1
mkdir -p $TMPDIR/root
mkdir -p $TMPDIR/boot
mount ${SDCARD}${SDDEV}1 $TMPDIR/boot
mount ${SDCARD}${SDDEV}2 $TMPDIR/root
;;
ext4) ext4)
parted -s $SDCARD mkpart primary ext4 "${END_SECTOR}s" 100% 1> /dev/null 2>&1 parted -s $SDCARD mkpart primary ext4 "${END_SECTOR}s" 100% 1> /dev/null 2>&1
partprobe $SDCARD 1> /dev/null 2>&1 partprobe $SDCARD 1> /dev/null 2>&1
@ -392,11 +413,14 @@ cleanup () {
fi fi
sync sync
if [[ "$FSTYPE" = "btrfs" ]]; then case "$FSTYPE" in
btrfs|f2fs)
sed -i "s/LABEL=ROOT_MNJRO/PARTUUID=$ROOT_PARTUUID/g" $TMPDIR/root/etc/fstab sed -i "s/LABEL=ROOT_MNJRO/PARTUUID=$ROOT_PARTUUID/g" $TMPDIR/root/etc/fstab
else ;;
*)
echo "PARTUUID=$ROOT_PARTUUID / $FSTYPE defaults 0 1" >> $TMPDIR/root/etc/fstab echo "PARTUUID=$ROOT_PARTUUID / $FSTYPE defaults 0 1" >> $TMPDIR/root/etc/fstab
fi ;;
esac
#clean up #clean up
if [[ "$FSTYPE" = "btrfs" ]]; then if [[ "$FSTYPE" = "btrfs" ]]; then
umount $TMPDIR/root/home umount $TMPDIR/root/home
@ -624,8 +648,9 @@ fi
if [ ! -z "$SDCARD" ]; then if [ ! -z "$SDCARD" ]; then
FSTYPE=$(dialog --clear --title "Manjaro ARM Installer v${VERSION}" \ FSTYPE=$(dialog --clear --title "Manjaro ARM Installer v${VERSION}" \
--menu "Choose a filesystem:" 10 90 10 \ --menu "Choose a filesystem:" 10 90 10 \
"ext4" "Regular ext4 filesystem" \ "ext4" "Regular ext4 filesystem for the root partition" \
"btrfs" "Uses btrfs for root partition and makes / and /home subvolumes" \ "btrfs" "Uses btrfs for root partition and makes / and /home subvolumes" \
"f2fs" "Use f2fs for the root partition" \
3>&1 1>&2 2>&3 3>&-) 3>&1 1>&2 2>&3 3>&-)
else else
@ -633,7 +658,7 @@ else
exit 1 exit 1
fi fi
if [[ "$DEVICE" = "pbpro" ]] || [[ "$DEVICE" = "rockpro64" ]] || [[ "$DEVICE" = "rockpi4b" ]] || [[ "$DEVICE" = "rockpi4c" ]] && [[ "$FSTYPE" != "btrfs" ]]; then if [[ "$DEVICE" = "pbpro" ]] || [[ "$DEVICE" = "rockpro64" ]] || [[ "$DEVICE" = "rockpi4b" ]] || [[ "$DEVICE" = "rockpi4c" ]] && [[ "$FSTYPE" != "btrfs" ]] && [[ "$FSTYPE" != "f2fs" ]]; then
CRYPT=$(dialog --clear --title "Manjaro ARM Installer v${VERSION}" \ CRYPT=$(dialog --clear --title "Manjaro ARM Installer v${VERSION}" \
--menu "[Experimental!] Do you want encryption on root partition?" 10 90 10 \ --menu "[Experimental!] Do you want encryption on root partition?" 10 90 10 \
"no" "No, thanks" \ "no" "No, thanks" \