[Bug 2081163] Re: fix fsck.xfs run by different shells when fsck.mode=force is set

gerald.yang 2081163 at bugs.launchpad.net
Thu Oct 17 09:42:07 UTC 2024


update debdiff.focal based on Heitor's suggestions

** Attachment added: "debdiff.focal"
   https://bugs.launchpad.net/ubuntu/+source/xfsprogs/+bug/2081163/+attachment/5828898/+files/debdiff.focal

-- 
You received this bug notification because you are a member of Ubuntu
Sponsors, which is subscribed to the bug report.
https://bugs.launchpad.net/bugs/2081163

Title:
  fix fsck.xfs run by different shells when fsck.mode=force is set

Status in xfsprogs package in Ubuntu:
  In Progress
Status in xfsprogs source package in Focal:
  In Progress
Status in xfsprogs source package in Jammy:
  In Progress
Status in xfsprogs source package in Noble:
  In Progress
Status in xfsprogs source package in Oracular:
  In Progress

Bug description:
  [Impact]
  When fsck.mode=force is specified in the kernel command line, fsck.xfs
  is executed during the boot process. However, when the default shell is
  not bash, $PS1 should be a different value, consider the following script:
  cat ps1.sh
  echo "$PS1"

  run ps1.sh with different shells:
  ash ./ps1.sh
  $
  bash ./ps1.sh

  dash ./ps1.sh
  $
  ksh ./ps1.sh

  zsh ./ps1.sh

  On systems like Ubuntu, where dash is the default shell during the boot
  process to improve startup speed. This results in FORCE being incorrectly
  set to false and then xfs_repair is not invoked:
  if [ -n "$PS1" -o -t 0 ]; then
           FORCE=false
  fi

  Other distros may encounter this issue too if the default shell is set
  to anoother shell.

  Check "-t 0" is enough to determine if we are in interactive mode, and
  xfs_repair is invoked as expected regardless of the shell used.

  [Test Case]
  1. install Ubuntu Focal with two disks (one for the system, the other for test xfs partition)
  2. create partition and xfs file system on the second drive (in my case it is /dev/vdb (the disk), /dev/vdb1 (the xfs partition))
  3. create mount point dir (ie, /data) and add appropriate line to the /etc/fstab, ie:
  /dev/vdb1 /data xfs defaults 0 2
  4. sudo mount --all to test the above, next: sudo umount /data
  5. break the xfs fs on /dev/vdb1:
  sudo xfs_db -x -c blockget -c "blocktrash -s 512109 -n 1000" /dev/vdb1
  6. verify it's broken:
  sudo mount --all
  7. add the "fsck.mode=force" to the kernel boot option in grub (/etc/default/grub):
  GRUB_CMDLINE_LINUX_DEFAULT="console=tty1 console=ttyS0 fsck.mode=force"
  8. sudo update-grub
  9. reboot the system and make sure xfs is repaired

  [Where things could go wrong]
  The patche removes $PS1 check, the "-t 0" is already enough to determine if it's in interactive mode, no need to check $PS1, this won't cause other issues.

  This has been merged into upstream:
  https://git.kernel.org/pub/scm/fs/xfs/xfsprogs-dev.git/commit/?h=for-next&id=19dde7fac0f38af2990e367ef4dd8ec512920c12

  [ Original Bug Report ]
  https://bugs.launchpad.net/ubuntu/+source/xfsprogs/+bug/2071474

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/xfsprogs/+bug/2081163/+subscriptions




More information about the Ubuntu-sponsors mailing list