aboutsummaryrefslogtreecommitdiff
path: root/content/blog/miscellaneous/link-deleted-inode.md
blob: 171986f9d3f5ea33d14ecdea26a1ec51065dd5df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
---
title: "Link to a deleted inode"
date: 2018-03-05
description: How to restore a hardlink to a deleted inode
tags:
- linux
- unix
---

## The problem

Sometimes a file gets deleted by mistake, but thankfully it is still opened by some software.

## The solution

Get the inode number from `lsof` (or from `fstat` if you are on a modern system), then run something like the following :

```sh
debugfs -w /dev/mapper/vg-home -R 'link <16008> /some/path'
```

In this example 16008 is the inode number you want to link to (the < > are important, they tell debugfs you are manipulating an inode). Beware that **the path is relative to the root of the block device** you are restoring onto.