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

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    
    <title>Raymond P. Burkholder - Things I Do - Storage</title>
    <link>https://blog.raymond.burkholder.net/</link>
    <description>In And Around Technology and The Arts</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.7.2 - http://www.s9y.org/</generator>
    <pubDate>Tue, 04 Jul 2023 16:58:42 GMT</pubDate>

    <image>
        <url>https://blog.raymond.burkholder.net/templates/bulletproof/img/s9y_banner_small.png</url>
        <title>RSS: Raymond P. Burkholder - Things I Do - Storage - In And Around Technology and The Arts</title>
        <link>https://blog.raymond.burkholder.net/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>Linux: recover a rm'd file still open</title>
    <link>https://blog.raymond.burkholder.net/index.php?/archives/1234-Linux-recover-a-rmd-file-still-open.html</link>
            <category>Storage</category>
    
    <comments>https://blog.raymond.burkholder.net/index.php?/archives/1234-Linux-recover-a-rmd-file-still-open.html#comments</comments>
    <wfw:comment>https://blog.raymond.burkholder.net/wfwcomment.php?cid=1234</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>https://blog.raymond.burkholder.net/rss.php?version=2.0&amp;type=comments&amp;cid=1234</wfw:commentRss>
    

    <author>nospam@example.com (Raymond P. Burkholder)</author>
    <content:encoded>
    &lt;p&gt;I had an application running which had an open file it was actively using.

&lt;p&gt;I accidentally performed an rm (remove) on the file rather than another I actually meant to remove.

&lt;p&gt;Due to Linux&#039;s method of linking files, even though the directory entry link to the file was removed, the file is still open and has an additional link via the application process pseudo directory.

&lt;p&gt;The process sub-directory is composed of the process id. The process id can be found with something like:

&lt;blockquote&gt;&lt;pre&gt;
$ pidof BasketTrading
2663042
&lt;/pre&gt;&lt;/blockquote&gt;

&lt;p&gt;The deleted file can then be found with:

&lt;blockquote&gt;&lt;pre&gt;
$ lsof -p 2663042 | grep deleted
BasketTra 2663042  rpb   18u      REG               0,46   2739200 29438986 /home/.../BasketTrading.db (deleted)
&lt;/pre&gt;&lt;/blockquote&gt;

&lt;p&gt;The 18u reflects the file descriptor used for the file.  This can be used to perform a simple copy of the file to an alternate location.  A link does not seem to fix it.  You may want to complete any outstanding writes to the file first.  But do not close it or the application.  If you do, the file will be unrecoverable.

&lt;blockquote&gt;&lt;pre&gt;
$ ls /proc/2663042/fd/18
/proc/2663042/fd/18
&lt;/pre&gt;&lt;/blockquote&gt;

&lt;blockquote&gt;&lt;pre&gt;
$ cp /proc/2663042/fd/18 /home/.../BasketTrading.db.rescue
&lt;/pre&gt;&lt;/blockquote&gt;
 
    </content:encoded>

    <pubDate>Sat, 01 Jul 2023 02:45:34 +0000</pubDate>
    <guid isPermaLink="false">https://blog.raymond.burkholder.net/index.php?/archives/1234-guid.html</guid>
    
</item>
<item>
    <title>Debian Linux chroot</title>
    <link>https://blog.raymond.burkholder.net/index.php?/archives/1014-Debian-Linux-chroot.html</link>
            <category>Storage</category>
    
    <comments>https://blog.raymond.burkholder.net/index.php?/archives/1014-Debian-Linux-chroot.html#comments</comments>
    <wfw:comment>https://blog.raymond.burkholder.net/wfwcomment.php?cid=1014</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>https://blog.raymond.burkholder.net/rss.php?version=2.0&amp;type=comments&amp;cid=1014</wfw:commentRss>
    

    <author>nospam@example.com (Raymond P. Burkholder)</author>
    <content:encoded>
    &lt;p&gt;When upgrading kernels, I have an issue with lack of space in /boot, so I need to manually remove files, and the rebuild them.  In the latest case, I managed to forget to run &#039;update-grub&#039; which rebuilds the grub menu.

&lt;p&gt;Upon reboot, the kernel aborted with an error along the lines of &#039;could not mount device(0,0).  This was because there was a missing &#039;initrd .... &#039; line in the grub menu.

&lt;p&gt;It didn&#039;t solve the problem, but I did learn a new sequence of commands.  After booting with a live cd:

&lt;blockquote&gt;&lt;pre&gt;
sudo mount /dev/nvme0n1p4 /mnt
sudo mount /dev/nvme0n1p2 /mnt/boot
sudo mount --bind /proc /mnt/proc
sudo mount --bind /dev /mnt/dev
sudo mount --bind /sys /mnt/sys
sudo mount --bind /dev/pts /mnt/dev/pts
chroot /mnt
&lt;/pre&gt;&lt;/blockquote&gt;

&lt;p&gt;The first mount mounts the root file system (I needed to look in /etc/fstab on the target to find that), and the second mounts my separate /boot partition.  The other three mounts mount operating system virtual file systems.  

&lt;p&gt;The chroot then provides an environment within the target file system for performing management functions without having actually booted into the drive.  This being the fundamental of containers.

&lt;p&gt;Under certain circumstances, after changes, the following may be required:

&lt;blockquote&gt;&lt;pre&gt;
update-grub2
&lt;/pre&gt;&lt;/blockquote&gt;

&lt;p&gt;2020/12/02 - Rather than using /dev/nvme... devices, it is possible to mount via other parameters.  By using the command &#039;blkid&#039;, one is able to obtain the device, UUID and PARTLABEL. The mount commands above could then be:

&lt;blockquote&gt;&lt;pre&gt;
# blkid
/dev/nvme0n1p2: UUID=&quot;a6c3ee33-993d-41e8-bc88-df9f7347588c&quot; BLOCK_SIZE=&quot;1024&quot; TYPE=&quot;ext3&quot; PARTLABEL=&quot;boot&quot; PARTUUID=&quot;64764385-ccc8-4a8b-9258-3d175f6e956e&quot;
/dev/nvme0n1p4: UUID=&quot;0c862707-3c94-4920-b253-83e2533f2813&quot; UUID_SUB=&quot;f067826b-d66d-4aa4-b4e5-255aa4bccb08&quot; BLOCK_SIZE=&quot;4096&quot; TYPE=&quot;btrfs&quot; PARTLABEL=&quot;root&quot; PARTUUID=&quot;d66c9cd9-0e56-4ee0-b577-742ced18de6c&quot;
/dev/nvme0n1p5: UUID=&quot;53289aac-6e1d-4f96-9d7c-cbcea3700c44&quot; UUID_SUB=&quot;53bfef2c-6eb0-4113-bc5c-988dd76ab0ee&quot; BLOCK_SIZE=&quot;4096&quot; TYPE=&quot;btrfs&quot; PARTLABEL=&quot;var&quot; PARTUUID=&quot;547ef81a-ce36-4fc0-831c-a7acae55161b&quot;

# mount PARTLABEL=root /mnt
# mount PARTLABEL=boot /mnt/boot
# mount PARTLABEL=var /mnt/var
&lt;/pre&gt;&lt;/blockquote&gt; 
    </content:encoded>

    <pubDate>Tue, 13 Aug 2019 03:58:03 +0000</pubDate>
    <guid isPermaLink="false">https://blog.raymond.burkholder.net/index.php?/archives/1014-guid.html</guid>
    
</item>

</channel>
</rss>
