<?xml version="1.0" encoding="UTF-8" ?>

<bugzilla version="5.2"
          urlbase="https://bugzilla.altlinux.org/"
          
          maintainer="jenya@basealt.ru"
>

    <bug>
          <bug_id>13691</bug_id>
          
          <creation_ts>2007-12-13 18:20:18 +0300</creation_ts>
          <short_desc>halt script does not detach loop devices</short_desc>
          <delta_ts>2026-09-09 19:12:49 +0300</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>4</classification_id>
          <classification>Development</classification>
          <product>Sisyphus</product>
          <component>startup</component>
          <version>unstable</version>
          <rep_platform>all</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>led</reporter>
          <assigned_to name="Alexey Gladkov">legion</assigned_to>
          <cc>evg</cc>
    
    <cc>glebfm</cc>
    
    <cc>ldv</cc>
    
    <cc>legion</cc>
    
    <cc>mike</cc>
          
          <qa_contact>qa-sisyphus</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>59474</commentid>
    <comment_count>0</comment_count>
    <who name="">led</who>
    <bug_when>2007-12-13 18:20:19 +0300</bug_when>
    <thetext>Скрипт %_initdir/halt размонтирует loop-устройства, но не освобождает 
задействованые /dev/loop* устройствами файлы. При том, что loop-устройства не 
обязательно были смонтированны (например, использовались как swap). Таким 
образом, на этапе перемонтирования файловой системы, на которой эти файлы 
находятся, в ro происходит ошибка и система выключается с файловой системой (в 
том числе и /) всё ещё смонтированной в rw.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>59758</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Shigorin">mike</who>
    <bug_when>2007-12-20 02:10:49 +0300</bug_when>
    <thetext>Мож патчик нарисуешь?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>297694</commentid>
    <comment_count>2</comment_count>
    <who name="Anton Farygin">rider</who>
    <bug_when>2026-09-09 19:12:49 +0300</bug_when>
    <thetext>Актуально для загрузки через sysvinit: в startup 0.9.9.17-alt1 скрипт halt размонтирует loop-файловые системы, но losetup не вызывает вовсе, поэтому loop-устройства с ещё занятыми файлами (например swap-файл) мешают перемонтировать их раздел в ro.

Патч добавляет отцепление незанятых loop-устройств перед remount,ro (занятые останутся, `losetup -D` их не трогает):

--- a/rc.d/init.d/halt
+++ b/rc.d/init.d/halt
@@ -185,6 +185,12 @@
 	$cryptdisks_early_exe stop
 fi
 
+# Detach loop devices that are no longer in use: their backing files may
+# live on a filesystem which is about to be remounted read-only, and a
+# still attached loop device (a swap file, for example) makes that fail.
+[ ! -x /sbin/losetup ] ||
+	action &apos;Detaching loop devices:&apos; /sbin/losetup -D ||:
+
 # Unmount and remount read-only anything that&apos;s left mounted.
 action &apos;Remounting remaining filesystems (if any) read-only:&apos; \
 	umount -afnr -t noproc,nosysfs,notmpfs,nodevfs,nodevtmpfs,nousbfs,norpc_pipefs,nonfsd

Под systemd этим занимается systemd-shutdown, скрипт halt в выключении не участвует. Прогнать halt на живой машине не могу — патч примерный; проверены синтаксис (bash -n) и поведение `losetup -D` при отсутствии устройств (rc=0).</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>