最近看软连结跟硬连结的比较,有整理一下笔记资讯,对于硬连结的观念是都使用同一个
inode,省硬盘空间等等,但是对于”实务”上还是不是很了解大家平常都使用在那边?
再请大家给点指教,谢谢
[Linux笔记] 软连结与硬连结
# /与/home位于不同的partition
[email protected]:~/workspace$ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda1 7092728 5093676 1615720 76% /
none 4 0 4 0% /sys/fs/cgroup
udev 2013844 4 2013840 1% /dev
tmpfs 404788 1036 403752 1% /run
none 5120 0 5120 0% /run/lock
none 2023940 88 2023852 1% /run/shm
none 102400 24 102376 1% /run/user
/dev/sda3 17414428 1007348 15499356 7% /home
# 分别在/与~家目录建立档案与目录
[email protected]:~/workspace$ sudo touch /file1
[email protected]:~/workspace$ touch file2
[email protected]:~/workspace$ mkdir folder1
# 硬连结不支援跨partition
[email protected]:~/workspace$ ln /file1 hardfile1
ln: failed to create hard link ‘hardfile1’ => ‘/file1’: Invalid cross-devi
ce link
[email protected]:~/workspace$ ln -s /file1 softfile1
[email protected]:~/workspace$ ln file2 hardfile2
# 硬连结不支援目录
[email protected]:~/workspace$ ln folder1 hardfolder1
ln: ‘folder1’: hard link not allowed for directory
[email protected]:~/workspace$ ln -s folder1 softfolder1
# 软连结的档案inode不同(965, 667577),硬连结的档案inode相同(667572)
# 软连结的属性不同为变777(rwx),硬连结的属性相同(-rw-rw-r