install_raspbian_on_f2fs_root

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
install_raspbian_on_f2fs_root [09.08.2020 18:27] Pascal Suterinstall_raspbian_on_f2fs_root [22.12.2020 18:33] (current) Pascal Suter
Line 38: Line 38:
 fi fi
  
-if ! kpartx -l $image  | grep -q "loop.p1 : 0"; then +if ! kpartx -l $image  | grep -q "loop.\+p1 : 0"; then 
     echo "ERROR"     echo "ERROR"
     echo "image $image not readable by kpartx or kpartx not found"     echo "image $image not readable by kpartx or kpartx not found"
Line 70: Line 70:
     echo "aborted"     echo "aborted"
 } }
-trap clean_up EXIT+trap clean_up EXIT SIGINT
  
 echo "make sure the card is unmounted" echo "make sure the card is unmounted"
Line 81: Line 81:
 echo "create new partitions" echo "create new partitions"
 parted -s $card mklabel msdos parted -s $card mklabel msdos
-parted -s $card mkpart primary 0% 256MB+parted -s $card mkpart primary fat32 0% 256MB
 parted -s $card mkpart primary 256MB 100% parted -s $card mkpart primary 256MB 100%
 partprobe $card partprobe $card
 sleep 2 sleep 2
 +
 +if echo "$card" | grep -q "mmcblk"; then 
 +    partbase="${card}p"
 +else
 +    partbase=$card
 +fi
  
 echo "format boot partition" echo "format boot partition"
-mkfs.vfat ${card}1+mkfs.vfat ${partbase}1
  
 echo "format os partition with f2fs" echo "format os partition with f2fs"
-mkfs.f2fs -f ${card}2+mkfs.f2fs -f ${partbase}2
  
 echo "create mountpoints and mount boot partition" echo "create mountpoints and mount boot partition"
 mkdir -p /tmp/{sd,img} mkdir -p /tmp/{sd,img}
-mount ${card}1 /tmp/sd+mount ${partbase}1 /tmp/sd
  
 echo "load image as loopback device and mount boot partition" echo "load image as loopback device and mount boot partition"
Line 106: Line 112:
  
 echo "adjust cmdline.txt" echo "adjust cmdline.txt"
-partuuidbase=$(blkid /dev/sdb | sed -e 's/^.*PTUUID="\([^"]*\)".*$/\1/')+partuuidbase=$(blkid $card | sed -e 's/^.*PTUUID="\([^"]*\)".*$/\1/')
 sed -i "s/\(PARTUUID=\)[^ ]*\(-02 \)/\1$partuuidbase\2/" /tmp/sd/cmdline.txt sed -i "s/\(PARTUUID=\)[^ ]*\(-02 \)/\1$partuuidbase\2/" /tmp/sd/cmdline.txt
-sed -i 's/init=[^ ]* / /' /tmp/sd/cmdline.txt+sed -i 's/init=[^ ]*//' /tmp/sd/cmdline.txt 
 +sed -i 's/ext4/f2fs/' /tmp/sd/cmdline.txt
  
 echo echo
Line 144: Line 151:
 umount /tmp/sd umount /tmp/sd
 umount /tmp/img umount /tmp/img
-mount ${card}2 /tmp/sd+mount ${partbase}2 /tmp/sd
 mount /dev/mapper/${loopdev}p2 /tmp/img mount /dev/mapper/${loopdev}p2 /tmp/img
  
Line 154: Line 161:
 sed -i "s/\(PARTUUID=\)[^ ]*\(-0[12] \)/\1$partuuidbase\2/" /tmp/sd/etc/fstab sed -i "s/\(PARTUUID=\)[^ ]*\(-0[12] \)/\1$partuuidbase\2/" /tmp/sd/etc/fstab
 sed -i 's/ext4/f2fs/' /tmp/sd/etc/fstab sed -i 's/ext4/f2fs/' /tmp/sd/etc/fstab
 +rm -f /tmp/sd/etc/rc3.d/S01resize2fs_once
  
 if [ $ssh -eq 1 ]; then if [ $ssh -eq 1 ]; then
Line 161: Line 169:
     touch {/tmp/sd/root/.ssh,/tmp/sd/home/pi/.ssh}/authorized_keys     touch {/tmp/sd/root/.ssh,/tmp/sd/home/pi/.ssh}/authorized_keys
     chmod 600 {/tmp/sd/root/.ssh,/tmp/sd/home/pi/.ssh}/authorized_keys     chmod 600 {/tmp/sd/root/.ssh,/tmp/sd/home/pi/.ssh}/authorized_keys
 +    chown -R 1000 /tmp/sd/home/pi/.ssh
     echo "done, to add your private key, boot the raspberry pi and login as user pi with password \"raspberry\" to add your public key to those files. make sure you don't forget to chagne the default password!"     echo "done, to add your private key, boot the raspberry pi and login as user pi with password \"raspberry\" to add your public key to those files. make sure you don't forget to chagne the default password!"
 fi fi
Line 179: Line 188:
 fi fi
 echo  echo 
-echo "okay, we are done, time to clean up! mind you, this can take some time as we weill have to wait for everything to be written to the SD card. do not abort!"+echo 'okay, we are done, time to clean up! mind you, this can take some time as we weill have to wait for everything to be written to the SD card. do not abort!'
 umount /tmp/sd umount /tmp/sd
 umount /tmp/img umount /tmp/img
Line 186: Line 195:
 echo  echo 
 echo "you are all set, you can now remove the sd card and put it into your raspberry, boot it up and start using it"  echo "you are all set, you can now remove the sd card and put it into your raspberry, boot it up and start using it" 
-echo "if you want to insert this card into your pc in the future to modify some things on it, I strongly recommend to disable gnomes automount temporarily, as it may mess up your f2fs filesystem"+echo 'if you want to insert this card into your pc in the future to modify some things on it, I strongly recommend to disable gnomes automount temporarily, as it may mess up your f2fs filesystem'
 echo "to do that you can simply run this command:" echo "to do that you can simply run this command:"
 echo "    gsettings set org.gnome.desktop.media-handling automount 'false'" echo "    gsettings set org.gnome.desktop.media-handling automount 'false'"
 echo "to re-enable simply use 'true' as value instead" echo "to re-enable simply use 'true' as value instead"
 +trap - EXIT
 </code> </code>
  
  • install_raspbian_on_f2fs_root.1596990462.txt.gz
  • Last modified: 09.08.2020 18:27
  • by Pascal Suter