From 7ad3f7462b0097439182a7c36998c7162d5540eb Mon Sep 17 00:00:00 2001 From: Hal Emmerich Date: Thu, 23 May 2019 00:19:32 -0500 Subject: [PATCH] Fixed filesystem corruption issues Fixed: filesystems were created with journaling disabled, now journaling is enabled filesystem was mounted rw on boot, which prevented fsck from running - changed to ro, which then gets mounted as rw by systemd using the fstab file - added a fstab for the external boot devices that tries both usb and sd card --- resources/BuildResources/cmdline | 2 +- resources/BuildResources/external_fstab | 3 +++ scripts/InstallScripts/InstallToInternal.sh | 5 +++-- scripts/buildFilesystem.sh | 6 +++++- 4 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 resources/BuildResources/external_fstab diff --git a/resources/BuildResources/cmdline b/resources/BuildResources/cmdline index 86857bd..0a63a51 100644 --- a/resources/BuildResources/cmdline +++ b/resources/BuildResources/cmdline @@ -1 +1 @@ -console=tty1 init=/sbin/init root=PARTUUID=%U/PARTNROFF=1 rootfstype=ext4 rootwait rw net.ifnames=0 +console=tty1 init=/sbin/init root=PARTUUID=%U/PARTNROFF=1 rootfstype=ext4 rootwait ro net.ifnames=0 diff --git a/resources/BuildResources/external_fstab b/resources/BuildResources/external_fstab new file mode 100644 index 0000000..479ce07 --- /dev/null +++ b/resources/BuildResources/external_fstab @@ -0,0 +1,3 @@ +#try both the sdcard and the usb as root +/dev/mmcblk2p2 / ext4 nofail,x-systemd.device-timeout=5s,defaults,noatime 0 1 +/dev/sda2 / ext4 nofail,x-systemd.device-timeout=5s,defaults,noatime 0 1 \ No newline at end of file diff --git a/scripts/InstallScripts/InstallToInternal.sh b/scripts/InstallScripts/InstallToInternal.sh index 6a17111..01de641 100755 --- a/scripts/InstallScripts/InstallToInternal.sh +++ b/scripts/InstallScripts/InstallToInternal.sh @@ -58,11 +58,12 @@ then echo Writing kernel partition dd if="$BOOT_DEVICE"1 of=/dev/mmcblk2p1 echo Writing Filesystem, this will take about 4 minutes... - mkfs.ext4 -F -b 1024 -m 0 -O ^has_journal /dev/mmcblk2p2 + mkfs.ext4 -F -b 1024 /dev/mmcblk2p2 mkdir -p /mnt/mmc/ mount /dev/mmcblk2p2 /mnt/mmc rsync -ah --info=progress2 --info=name0 --numeric-ids -x / /mnt/mmc/ - #Install a base fstab + #Remove the live-fstab and install a base fstab + rm /mnt/mmc/etc/fstab echo "/dev/mmcblk2p2 / ext4 defaults,noatime 0 1" > /mnt/mmc/etc/fstab umount /dev/mmcblk2p2 echo Running fsck diff --git a/scripts/buildFilesystem.sh b/scripts/buildFilesystem.sh index eabb140..59da871 100755 --- a/scripts/buildFilesystem.sh +++ b/scripts/buildFilesystem.sh @@ -75,7 +75,7 @@ create_image() { cgpt add -i 2 -t data -b $start -s $size -l Root $1 # $size is in 512 byte blocks while ext4 uses a block size of 1024 bytes losetup -P $2 $1 - mkfs.ext4 -F -b 1024 -m 0 -O ^has_journal ${2}p2 $(($size / 2)) + mkfs.ext4 -F -b 1024 -m 0 ${2}p2 $(($size / 2)) # mount the / partition mount -o noatime ${2}p2 $5 @@ -125,6 +125,10 @@ chroot $outmnt locale-gen chroot $outmnt apt update chroot $outmnt apt install -y initscripts udev kmod net-tools inetutils-ping traceroute iproute2 isc-dhcp-client wpasupplicant iw alsa-utils cgpt vim-tiny less psmisc netcat-openbsd ca-certificates bzip2 xz-utils ifupdown nano apt-utils git kpartx gdisk parted rsync +#add the live-boot fstab +cp -f $build_resources/external_fstab $outmnt/etc/fstab +chmod 644 /etc/fstab + #Cleanup to reduce install size chroot $outmnt apt-get autoremove --purge chroot $outmnt apt-get clean