Browse Source

fixed failed mkfs

toastie89 1 year ago
parent
commit
a8b49162cd
1 changed files with 9 additions and 12 deletions
  1. 9 12
      bootstrap-bookworm.sh

+ 9 - 12
bootstrap-bookworm.sh

@@ -80,12 +80,6 @@ then
   mklabel msdos \
   mkpart primary ext4 512M 100% toggle 1 boot \
   print
-  
-  # Inform OS about partition table change
-  partprobe $disk --summary
-
-  # Format disks -- pkg: e2fsprogs dosfstools and to file system check
-  mkfs.ext4 --verbose $disk1 && e2fsck $disk1
 fi
 
 if [ "$partition" = "efi-crypt" ]
@@ -109,14 +103,13 @@ then
   print
   
   # Inform OS about partition table change
-  partprobe $disk --summary
+  partprobe $disk && sleep 1
   
-  # Format disks -- pkg: e2fsprogs dosfstools and to file system check
-  mkfs.fat  --verbose -F 32 -n EFIBOOT $disk0 && fsck $disk0
-  mkfs.ext4 --verbose  $disk1 && fsck $disk1
+  # Format EFI disk -- pkg: e2fsprogs dosfstools and to file system check
+  mkfs.fat  -v -F 32 -n EFIBOOT $disk0 && fsck $disk0
 
   # Prepare mount points and mount
-  mkdir $mnt"/boot/efi"
+  mkdir -p $mnt"/boot/efi"
   mount $disk0 $mnt"/boot/efi"
   echo "$disk0        /boot/efi/                vfat rw 0 0" >> $mnt/etc/fstab
 fi
@@ -127,6 +120,9 @@ dd if=/dev/zero of=$swapfile bs=1M count=1024 status=progress # create 1GB  file
 chmod 600 $swapfile #restric permissions
 mkswap $swapfile #format file
 
+# Format OS disk -- pkg: e2fsprogs dosfstools and to file system check
+mkfs.ext4 -v -F               $disk1 && fsck $disk1
+
 # Prepare mount points and mount
 mkdir -p $mnt
 mount $disk1 $mnt
@@ -310,7 +306,8 @@ unmount(){
 ! mountpoint -q $mnt/dev/pts || umount $mnt/dev/pts
 ! mountpoint -q $mnt/dev     || umount $mnt/dev
 ! mountpoint -q $mnt/root    || umount $mnt/root
-! mountpoint -q $mnt         || umount $mnt
+! mountpoint -q $disk0       || umount $disk0
+! mountpoint -q $disk1       || umount $disk1
 # Delete mount-point if empty and not mounted
 [ -z "$(ls -A /mnt/)" ] &&  ! mountpoint -q $mnt  && rm -R $mnt
 }