LoginSignup
0
0

More than 3 years have passed since last update.

ハードリンクとシンボリックリンクのメモ

Posted at

それぞれ実行したときのdfの結果が気になったのでメモ。
仕様を考えると、当然の結果といえるが、検証が大事。

ハードリンクを作成する

dfの結果は変わらない。
inodeは同じで、元データが同じだから、増えないのだろう。

# ls -li base*
77 -rw-------. 2 root root 51313888  5月  3  2018 base
# df -h | grep boot
/dev/sda1                1014M  251M  764M   25% /boot
# ln base baseh
# ls -li base*
77 -rw-------. 3 root root 51313888  5月  3  2018 base
77 -rw-------. 3 root root 51313888  5月  3  2018 baseh
# df -h | grep boot
/dev/sda1                1014M  251M  764M   25% /boot

シンボリックリンクを作成する

dfの結果は変わらない。
リンクファイルの分だけ増えていると思われる。
ハードリンクの場合も、実は微妙に増えている??覚えていたら調べてみる。

# ln -s base bases
# ls -li base*
 77 -rw-------. 3 root root 51313888  5月  3  2018 base
 77 -rw-------. 3 root root 51313888  5月  3  2018 baseh
100 lrwxrwxrwx  1 root root        4  6月  1 16:10 bases -> base
# df -h | grep boot
/dev/sda1                1014M  251M  764M   25% /boot

コピーする

dfの結果は、コピーした分だけ増えている。

# cp base basec
# ls -li base*
 77 -rw-------. 3 root root 51313888  5月  3  2018 base
101 -rw-------  1 root root 51313888  6月  1 16:15 basec
 77 -rw-------. 3 root root 51313888  5月  3  2018 baseh
100 lrwxrwxrwx  1 root root        4  6月  1 16:10 bases -> base
# df -h | grep boot
/dev/sda1                1014M  300M  715M   30% /boot
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0