Bcachefs: Difference between revisions

Onny (talk | contribs)
Usage: Change partition encryption password
Onny (talk | contribs)
Line 213: Line 213:
   after = [ "local-fs.target" ];
   after = [ "local-fs.target" ];
   wantedBy = [ "multi-user.target" ];
   wantedBy = [ "multi-user.target" ];
  environment = {
    DEVICE_PATH = "/dev/sda1";
    MOUNT_POINT = "/mnt";
  };
   script = ''
   script = ''
     #!${pkgs.runtimeShell} -e
     #!${pkgs.runtimeShell} -e
     ${pkgs.keyutils}/bin/keyctl link @u @s
     ${pkgs.keyutils}/bin/keyctl link @u @s
     while [ ! -b /dev/sda1 ]; do
 
       echo "Waiting for /dev/sda1 to become available..."
    # Check if the device path exists
     if [ ! -b "$DEVICE_PATH" ]; then
      echo "Error: Device path $DEVICE_PATH does not exist."
      exit 1
    fi
 
    # Check if the drive is already mounted
    if ${pkgs.util-linux}/bin/mountpoint -q "$MOUNT_POINT"; then
      echo "Drive already mounted at $MOUNT_POINT. Skipping..."
      exit 0
    fi
 
    # Wait for the device to become available
    while [ ! -b "$DEVICE_PATH" ]; do
       echo "Waiting for $DEVICE_PATH to become available..."
       sleep 5
       sleep 5
     done
     done
     ${pkgs.bcachefs-tools}/bin/bcachefs mount -f /etc/keyfile_test /dev/sda1 /mnt
 
    # Mount the device
     ${pkgs.bcachefs-tools}/bin/bcachefs mount -f /etc/keyfile_test "$DEVICE_PATH" "$MOUNT_POINT"
   '';
   '';
   serviceConfig = {
   serviceConfig = {