date
int64
1,220B
1,719B
question_description
stringlengths
28
29.9k
accepted_answer
stringlengths
12
26.4k
question_title
stringlengths
14
159
1,286,221,328,000
I understand the reasoning why nearly every unix version doesn't allow hard-linking of directories (in fact HFS+ on OS X is the only one I know, but even that isn't made easy to do yourself). However, all file-systems in theory support hard-linked directories, as all directories contain at least one extra hard-link to...
Don't do this. If you want to have a backup system using hard links to save space, better to use rsync with --link-dest, which will hard link files appropriately to save space, without causing the problems that this causes (that is, hard linking between directories is a corruption of the filesystem, and will cause it ...
Forcibly create directory hard link(s)?
1,286,221,328,000
I have a 2.5 TB of data that I want to put in a 2TB hard drive to mail somewhere. It's not hopeless, as a very large fraction of the data consists of duplicate files. I am considering using jdupes with the -H option, which will replace duplicate files with hardlinks to a single file. Here's the problem: If I tar a di...
Probably a duplicate from Dereferencing hard links By default, a single copy of hardlinked data should be included in your archive.
How does tar deal with hardlinked files? [duplicate]
1,286,221,328,000
/path/to/fname#line1242 Is there a way to refer to a specific line number in a file as part of the pathname, or some way to package a link to a line number, which looks/behaves like a pathname? For example, giving the string above to another user of the same filesystem so that they can easily open my file "fname" and...
You could create a file called +view +1242 fname. Then calling vi or view on that file: view '+view +1242 fname' would open fname in view and put the cursor at the beginning of the 1242nd line (here assuming the vim implementation of vi/view). Or do: ln -s / '+view +1242 ' So you do: view '+view +1242 /etc/passwd' ...
Bash: Path or link to a line in a file?
1,286,221,328,000
I plan to keep all my movies in one giant folder, and then create other folders for the genres, while creating links for all the movies in the genre folder. This way I can organize movies into multiple genres without unnecessarily copying them. I've been planning to use hard links in this endeavor in order to create a...
Symbolic link files take more space. Hard linked files share the same inode; but a symbolic file is a pointer to the original (location). Despite that, there are two caveats for hard links: Not all file system support hard links. Hard links cannot be applied for folders. I guess you do not need to consider about the...
What is the difference in file size between Symbolic and Hard links?
1,286,221,328,000
Where does the *nix system store information about number of hard links to a specific inode? I can't find any information about that. Everywhere what a hard link is but rarely a bit more advanced information that touches inodes related stuff. An inode stores information about number of links but where does it get it f...
The hard link count is stored in the inode. It starts at 1 when the file is created, increases by 1 each time the link system call is successful, and decreases by 1 each time the unlink system call is successful. The only way to find all the hard links to the same file, i.e. to find all the pathnames leading to a give...
Where is information about hard/soft links stored?
1,286,221,328,000
If we have a file on a disk and create a hard link pointing to it then we have two references to the same data. If one link gets deleted it does not affect the other link as it is directly pointing to the data. If I have two links (A and B) pointing to file ABC and I move link A to another disk then I will have two c...
rsync is able to copy hard links for you. Check -H option: -H, --hard-links preserve hard links
How can you move hardlinks to another disk
1,286,221,328,000
The normal way to safely, atomically write a file X on Unix is: Write the new file contents to a temporary file Y. rename(2) Y to X In two steps it appears that we have done nothing but change X "in-place". It is protected against race conditions and unintentional data loss (where X is destroyed but Y is incomplete...
The issue You have a (mostly) exhaustive list of systems calls here. You will notice that there is no "replace the content of this inode" call. Modifying that content always implies: Opening the file to get a file descriptor. optional seek to the desired write offset Writing to the file. optional Truncating old data,...
Atomically write a file without changing inodes (preserve hard link)
1,286,221,328,000
I am using Mac OS X, but the command line. I want to make a link from my .profile file, to another file on my system so that updating one updates the other and vice versa. This article makes me think that a hard link is what I need. The command I have been using is: ln .profile ~/Newpath/.profile This kind of works,...
dubiousjim's comment pointed out my issue: I think git will break hard links every time you checkout a new copy of the file. EDIT: Yes, I just verified it will, even if the hard links are in a single repo
Why are hard links are not updated when modified with an editor
1,286,221,328,000
Let's say /A/B/c.sh is symbolic linked to /X/Y/c.sh. If c.sh has the command "./SOMETHING", '.' means /A/B/ or /X/Y/? How about the hard link?
. is actually the current working directory in either case; it has nothing to do with the directory holding the script: [/tmp] $ echo "realpath ." > test.sh && chmod +x test.sh [/tmp] $ /tmp/test.sh /tmp [/tmp] $ cd /usr/bin [/usr/bin] $ /tmp/test.sh /usr/bin
Symbolic link and hard link questions
1,286,221,328,000
I'm writing a function called restore that will copy a file from a backup directory to the current directory. I now need to create a hard link to restore so that it can be called as purge. How would I implement it so that I could use the if statement if [ "$0" = "purge" ] for when restore is called as purge? Here is m...
Do the hard link to the restore.sh: ln restore.sh link_to_restore.sh The content of the restore.sh file: #!/bin/bash if [ "$0" = "./link_to_restore.sh" ]; then echo foo elif [ "$0" = "./restore.sh" ]; then echo bar fi Testing $ ./restore.sh bar $ ./link_to_restore.sh foo
Calling a function by a second name (homework)
1,286,221,328,000
Is it possible (in classical ext4, and/or in any other filesystem) to create two files that point to the same content, such that if one file is modified, the content is duplicated and the two files become different? It would be very practical to save space on my hard drive. Context: I have some heavy videos that I sha...
Yes on a Copy On Write file systems (Btrfs, ZFS). git-annex is as close as you are likely to get on ext4. Note that you can mount --bind a LVM backed volume or a Btrfs file system over a folder in another file system.
Hardlink that "split" when a file changes
1,286,221,328,000
Does using rm on a symlink or a hard-link remove the source in addition to the link? Is there a good way to delete a hard-link or a symlink without deleting the source? And if there is a good way outside of rm, would it be a good idea to use this more frequently instead of rm?
rm always removes a link. If it's the last one, the space allocated to the file is reclaimed. However, removing a symlink doesn't affect its target, so it seems like you've been misled. If the file no longer has a name, how would you find it?
Safely remove a symlink or hardlink
1,286,221,328,000
For example: I have file a.txt and file b.txt. I want a link from a.txt to b.txt. If I open/read file a.txt, file b.txt should open/read. If I try something like ln -s a.txt b.txt I get an error because file b.txt exist. How can I create a link from a.txt to b.txt?
You need to remove file b.txt previously with command rm b.txt, then create symbolic link with your command ln -s a.txt b.txt. You could use hard link from b.txt to a.txt, then execute ln a.txt b.txt, both a.txt and b.txt would point the same file on hard drive and removing a.txt doesn't remove file, which could be re...
Create link between two existing files
1,286,221,328,000
Say I have the following setup : $ cat fileA textA $ cat fileB textB $ ln fileA myLink $ cat myLink # as expected textA I do not understand the following behaviour : $ cp fileB fileA $ cat myLink # expected ? textB I would have expected this outcome if I had written ln -s fileA myLink instead, but not here. I would...
There is no "following the link" with hardlinks - creating a hardlinks simply gives several different names to the same file (at low level, files are actually integer numbers - "inodes", and they have names just for user convenience)- there is no "original" and "copy" - they are the same. So it is completly the same ...
cp overwriting without overwriting hardlinks to destination
1,286,221,328,000
It is easy to convert a symlink into a hardlink with ln -f (example) It would also be easy to convert a hardlink (filenames link and original) back to a symbolic link to link->original in the case where you know both files and define yourself which one is the "original file". You could easily create a simple script co...
I created a script that will do this. The script converts all hard-links it finds in a source directory (first argument) that are the same as in the working directory (optional second argument) into symbolic links: https://gist.github.com/rubo77/7a9a83695a28412abbcd It has an option -n for a dry-run, that doesn't do a...
Convert a hardlink into a symbolic link
1,286,221,328,000
Additional Info Firstly, thank you for all the answers. So I re-ran the tests again to test the answer below that a directory/folder entry takes up 4KB and this was skewing my numbers, so this time by placing 20,000 files in a single directory and doing the cp -al to another directory. The results were very different...
cp -al usr link creates a bunch of hard links, but it also creates some directories. Directories can't be hard linked¹, so they're copied. Each hard link occupies the space of a directory entry, which needs to store at least the file's name and the inode number. Each directory occupies the space of a directory entry, ...
hardlinks seem to take several hundred bytes just for the link itself (not file data)
1,286,221,328,000
I have a bash script in two places and I can't remember how I created them. they have the same inode but none of them seem to link to another. is there a hard link but should not Links count for that inode become two? $ ls -l ~/bin/dropbox-backup -rwxr-xr-x 1 bak bak 676 Aug 14 09:32 dropbox-backup $ ls -l ~/Dropbox...
The files have the same inode and are on the same filesystem. You can see that in the output of stat: it reports Device: 806h/2054d Inode: 528738 for both files. All native unix filesystems report distinct inodes for distinct files (this may not be guaranteed for some remote or foreign filesystems). The two names for...
Files have the same inode but they don't link to each other
1,286,221,328,000
Whenever I use mcedit to edit a file that is hard linked somewhere and I want to save the file, the editor asks me if I want to remove the hard links. Is that common behavior on Linux or is mcedit "special" in doing so? Why would regular applications (not fsck or other admin tools) care about hard links?
When you want to modify a file, you have two options, each with its benefits and drawbacks. You can overwrite the file in place. This does not use any extra space, and conserves the hard links, permissions and any other attribute beyond the content of the existing file. The major drawback of doing this is that if any...
Why does mcedit recommend removing hardlinks when saving a file?
1,286,221,328,000
I use rsync to make backups: rsync -a --link-dest=PATHTO/$PREVIOUSBACKUP $SOURCE $CURRENTBACKUP This way I save space due to using hard links. The problem appears when I need to backup a huge file which is always changing (virtual machine image). Is it possible to hardlink not whole the image, but only it's changed p...
There are a number of things that could be done here. Note that none of them actually use hard links since they can only point to a full file. Using the btrfs filesystem opens up some very useful possibilities here. Note that btrfs is currently (most recent version is v3.13) still experimental. However, its COW (copy-...
“hard-linking” parts of a big file in which only a small part has changed
1,286,221,328,000
I wonder if storing the information about files in inodes instead of directly in the directory is worth the additional overhead. It may be well that I'm overestimating the overhead or overlooking some important thing, but that's why I'm asking. I see that something like "inodes" is necessary for hardlinks, but in case...
Hard links are besides the point. They are not the reason to have inodes. They're a byproduct: basically, any reasonable unix-like filesystem design (and even NTFS is close enough on this point) has hard links for free. The inode is where all the metadata of a file is stored: its modification time, its permissions, an...
What are inodes good for?
1,286,221,328,000
Example script: #!/bin/sh -e sudo useradd -m user_a sudo useradd -m user_b -g user_a sudo chmod g+w /home/user_a set +e sudo su user_a <<EOF cd umask 027 >> file_a >> file_b >> file_c ls -l file_* EOF sudo su user_b <<EOF cd umask 000 rm -f file_* ls -l ~user_a/ set -x mv ~user_a/file_a . cp ~user_a/file_b . ln ~u...
Which system are you running? On Linux, that behaviour is configurable, through /proc/sys/fs/protected_hardlinks (or sysctl fs.protected_hardlinks). The behaviour is described in proc(5): /proc/sys/fs/protected_hardlinks (since Linux 3.6) When the value in this file is 0, no restrictions are placed ...
Why can I not hardlink to a file I don't own even though I can move it?
1,286,221,328,000
I have many files in a folder. I want to concatenate all these files to a single file. For example cat * > final_file; But this will increase disk space and also will consume time. Is there is a way where I can hardlink/softlink all the files to final_file? For example ln * final_file.
With links, I'm afraid, this will not be possible. However, you could use a named pipe. Example: # create some dummy files echo alpha >a echo beta >b echo gamma >c # create named pipe mkfifo allfiles # concatenate files into pipe cat a b c >allfiles The last call will block until some process reads from the pipe ...
hardlink/softlink multiple file to one file
1,286,221,328,000
I use symbolic links quite often, but after moving the original file, I lose track of the symbolic link. I also use symbolic links for keeping track of some files in the same directory, but again, I lose track. Is there any way (tool/method) to keep track of the symbolic link no matter what change I make? Is the ha...
Concering your second question, if you make the symlink using a relative path and then move the whole directory structure, it still should work. Consider the following terminal session: ~$ mkdir test ~$ cd test/ ~/test$ mkdir test2 ~/test$ cd test2/ ~/test/test2$ touch testfile; echo "hello, world" > testfile ~/test/t...
Keep tracking of symbolic links?
1,286,221,328,000
I'm trying to manage my dotfiles under version control. My dotfiles repos contains a xfce-base folder, this folder contains the .config/xfce4/.../xy-setting.xml stuff. I can stow, or better, symlink to the correct place, everything works as expected. But, when I open one of the xfce settings editors (Window Manager, ...
You are correct that GNU Stow doesn't support hard-linking currently. However I think you're also correct in that hard-linking probably isn't any better a solution than symlinking, because if an external application will happily replace a symlink with a normal file then it can certainly also break a hard link (i.e. r...
dotfiles: can/should(?) gnu stow make hard links, so I can still use xfce settings gui programs
1,286,221,328,000
I'm aware that Linux does not allow hard-linking to a directory. I read somewhere, that this is to prevent unintentional loops (or graphs, instead of the more desirable tree structure) in the file-system. that some *nix systems do allow the root user to hard-link to directories. So, if we are on one such system (th...
Hard links to directories aren't fundamentally different to hard links for files. In fact, many filesystems do have hard links on directories, but only in a very disciplined way. In a filesystem that doesn't allow users to create hard links to directories, a directory's links are exactly the . entry in the directory ...
Linux: How does hard-linking to a directory work?
1,286,221,328,000
I want to create a backup of a single .tex file. I created the hard link to the file (which is not in Dropbox directory, lets say it is A) inside Dropbox directory. I did this so because I do not want to backup other auxiliary file created (eg. axu, .log, .bbl etc.) when compiling the tex file. I edit and compile the ...
Dropbox is probably using inotify or a variant thereof to watch for changes in the Dropbox directory. Because the change happens outside of the Dropbox directory, Dropbox doesn't see it. To get the desired effect, you might be able to use symlinks instead of hard-links. I'm not sure if there's any special reason it ...
Hardlinks in Dropbox not updated
1,286,221,328,000
I have a backup script which uses rsync -avz --link-dest=$oldbkp $source $newbkp at its core. The problem is that rsync a lot of times doesn't recognize that a file in $source hasn't changed and so it plainly copies it to $newbkp instead of hard linking it from $oldbkp. Another perplexing thing is that it is inconsist...
The problem is the following (from man rsync): ... The files must be identical in all preserved attributes (e.g. permissions, possibly ownership) in order for the files to be linked together. In your case, the permissions of the files are (from your examples) Access: (0644/-rw-r--r--) # hardlink failed (original...
rsync inconsistently fails to hardlink
1,286,221,328,000
I've noticed, if a file is renamed, lsof displays the new name. To test it out, created a python script: #!/bin/python import time f = open('foo.txt', 'w') while True: time.sleep(1) Saw that lsof follows the rename: $ python test_lsof.py & [1] 19698 $ lsof | grep foo | awk '{ print $2,$9 }' 19698 /home/bfernandez...
You are right in assuming that lsof uses the inode from the kernel's name cache. Under Linux platforms, the path name is provided by the Linux /proc file system. The handling of hard links is better explained in the FAQ: 3.3.4 Why doesn't lsof report the "correct" hard linked file path name? When lsof reports...
How does `lsof` keep track of open file descriptors' filenames?
1,286,221,328,000
Before I get 100s of answers that tell me it is impossible to hardlink directories in linux: yes, I know that. The file in question appeared in lost+fount after I checked the filesystem with e2fsck (its an ext4) and according to stat it /is/ a file with 2 hardlinks: # stat --format="File \"%n\" is a %F with %h hardlin...
Directories on ext4 file systems generally have at least 2 links. The entry in their parent directory and the . entry in themselves. See there for more details. Having said that, if the file system is inconsistent, you may very well have a directory linked in more than one place and the link count not to reflect it. F...
How can I delete a hardlink to a directory?
1,541,016,132,000
I have a backup containing folders for daily snapshots. To save space, identical files in different snapshots are deduplicated via hard links (generated by rsync). When I'm running out of space, one option is to delete older snapshots. But because of the hard links, it is hard to figure out how much space I would gain...
You could do it by hand with GNU find: find snapshot-dir -type d -printf '1 %b\n' -o -printf '%n %b %i\n' | awk '$1 == 1 || ++c[$3] == $1 {t+=$2;delete c[$3]} END{print t*512}' That counts the disk usage of files whose link count would go down to 0 after all the links found in the snapshot directory have been f...
unique contribution of folder to disk usage
1,541,016,132,000
Consider this test case: mkdir a echo 'blah' > a/test mkdir b echo 'blah' > b/test rsync -r --link-dest=/tmp/b /tmp/a/ /tmp/c As expected, rsync creates c/test a hardlink of b/test (note the refcount of 2): # ls -l c/test -rw-r--r-- 2 root root 16 Jan 6 19:43 test Now see this: rm -r c # start over touch b/test rs...
You are seeing the results of rsync's "quick check" algorithm which decides to transfer files based on their size and their timestamp. As detailed in man rsync: Rsync finds files that need to be transferred using a "quick check" algorithm (by default) that looks for files that have changed in size or in last...
rsync's --link-dest option does not link because of file time
1,541,016,132,000
I use Vim 8.2 to edit my files in my Ubuntu 18.04. When I open a file, do some changes and quit with Vim, the inode number of this file will be changed. As my understanding, it's because the backup mechanism of my Vim is enabled, so each edition will create a new file (.swp file) to replace the old one. A new file has...
It seems the setting backupcopy is auto (run :set backupcopy? in Vim to confirm). The main values are: yes make a copy of the file and overwrite the original one no rename the file and write a new one auto one of the previous, what works best […] The auto value is the middle way: When Vim sees that renaming file ...
Why didn't inode change anymore with a hard link
1,541,016,132,000
What's the difference between --link and --reflink=always? I use the following command as an mv substitute, and I am wondering if using --reflink is a better choice. command gcp -r --link --archive --verbose "${opts[@]}" "$@" # delete the sources manually
--link causes cp to create hard links instead of copying. Once the “copy” is complete, assuming it’s in the same file system (which is required for hard links), a single instance of the file is present on disk, with two or more directory entries pointing to it. This is the desired external state, i.e. the fact that se...
GNU cp: What's the difference between `--link` and `--reflink=always`?
1,541,016,132,000
Every article I find about web servers suggest creating a sites-available and sites-enabled directory within apache/nginx/etc. Then, using symbolic (soft) links, create a link from the available to the enabled folder. Why use symbolic links rather than hardlinks? With hardlinks, you can move the original file (rename ...
I don't see any advantage to hard links. With hardlinks, you can move the original file (rename it) as needed without needing to recreate the link. That strikes me as a bug rather than a feature. If you want to disable a site (for example because you've just noticed that it has a major security hole), with symbolic ...
Should I use hardlinks for my "sites-enabled" folder instead of softlinks?
1,541,016,132,000
Setup The following sequence of commands is setup for my question. root@cd330f76096d:/# cd root@cd330f76096d:~# ls root@cd330f76096d:~# mkdir -p my_dir/my_subdir root@cd330f76096d:~# ls -hAil total 12K 6175969 -rw-r--r-- 1 root root 3.1K Oct 15 2021 .bashrc 6175970 -rw-r--r-- 1 root root 161 Jul 9 2...
A pathname that find encounters (i.e., apart from the search paths given on the command line) cannot contain a . or .. component, so your command will never show these. Why? Because the POSIX standard says so (my emphasis): Each path operand shall be evaluated unaltered as it was provided, including all trailing <sl...
How does `ls` find hard links?
1,541,016,132,000
I have a kind of problem. I am trying to hard-link all my dotfiles [files that customize certain apps] in one folder for ease of use, called ~/dotfiles/ , but multiple programs that I have, have entire directories for that. Some are in .config, some just have a directory at the home folder, so I tried to check whethe...
You could use cp -al .??* ~/dotfiles/ and let it worry about all the complexity. Directories are created and files are linked
Simulating a hard-link to a directory [duplicate]
1,541,016,132,000
How does the relative paths work in ln (-s or not)? For example if I type ln -s foo bar/banana.txt what does this mean? What is foo relative to? Because it doesn't seem to be relative to the current path. Also is it different if I remove -s or not? I've tested it out and the result doesn't make sense to me, and the ma...
It's different with and without -s. With -s in: ln -s path/to/file some/dir/link path/to/file is set as the symlink target of some/dir/link (or some/dir/link/file if link was a directory). A symlink is a special type of file which /contains/ a path (can be any array of non-0 bytes, some systems even allow an empty st...
Paths in ln with hard links and soft links
1,541,016,132,000
Where do I find documentation of behavior of cp and rsync commands when the destination path shares the inode with another path? In other words, when I do $ cp [options] src dest $ rsync [options] src dest and when there is dest2 that is a hard link to the same inode as dest, do these commands modify the content at ...
cp’s behaviour is specificied by POSIX. -a isn’t specified by POSIX, but it implies -R which is. When copying a single file, without -R, and the target exists, A file descriptor for dest_file shall be obtained by performing actions equivalent to the open() function defined in the System Interfaces volume of POSIX.1-2...
Hard link as destination of cp and rsync
1,541,016,132,000
I realise that every file is a hard link. This is what I mean precisely: if an inode has more than one file pointing to it, how can I copy the inode so that every file is pointing to a separate inode with the same content? For example: echo "Example" > one ln one two How can I make the file two have the same content...
This can be achieved with the command find -samefile filename -exec sed -i ';;' {} \; or if you now the inode number of the file find -inum inode -exec sed -i ';;' {} \; Note both these commands only find the files with matching inodes in subdirectories of the current working directory. If you need to search all fil...
How can I convert a hard link to a normal file? [duplicate]
1,541,016,132,000
I've checked the manpages, the mount, the permissions ... (edit: combined history into one sequence as requested. Starting to seem a not-simple problem. Nothing new since last edit, just bundled up all pretty) ~/sandbox/6$ editfunc doit ~/sandbox/6$ -x doit + doit + find . + cp /bin/ln /bin/id . + sudo chown jthill:j...
Found it: If sysctl fs/protected_hardlinks is set, hard links by someone not the owner (and without CAP_FOWNER), must be: not special not setuid not executable setgid both readable and writable according to fs/namei.c. Some guy on SO wanted to have a dropbox folder people could add to but not see into (I think t...
setgid binary doesn't have permission, mount's right, I'm missing something, but what, please?
1,541,016,132,000
Consider the following transcript of a user-namespaced shell running with root privileges (UID 0 within the namespace, unprivileged outside): # cat /proc/$$/status | grep CapEff CapEff: 0000003cfdfeffff # ls -al total 8 drwxrwxrwx 2 root root 4096 Sep 16 22:09 . drwxr-xr-x 21 root root 4096 Sep 16 22:08 .. -r...
The behavior described in the question was a bug, which has been fixed in the upcoming Linux 4.4.
Why can't a UID 0 process hardlink to SUID files in a user namespace?
1,541,016,132,000
Why the hard link doesn't corrupt if we remove the original file? If I remove the original file then the softlink gets corrupt but hard link doesn't so why it does't corrupt
It is because hardlinks are essentially references to the same file, and there's no "original" file in terms of hardlinks. They point to same data structure on the disk (the inode that contains next to all metadata of the file). Whereas softlinks point to filename and not the data structure describing the file.
Why hard link doesn't corrupt if we remove the original file? [duplicate]
1,541,016,132,000
When I executed the command both commands gave the same output. I created a soft link and a hard link for a file but still both commands gave the same output. Is there a difference between find -H and find -L?
find is not going to treat hard links specially except insofar as the -links test is concerned.  Symbolic links to files are going to be treated very similarly, too. I would read the find man page to you, but I assume that you've already read it.  Man pages are written in a cryptic language that is hard for beginners ...
What is the difference between "find -H" and "find -L" command?
1,541,016,132,000
I am using Ubuntu Linux and, just for fun, I want to create a hardlink to a directory (as seen here). Because I'm just doing this for fun, I'm not looking for any sort of pre-developed directory-hardlinking software that someone else wrote, I want to know how to do it myself. So, how do I directly, manually, modify an...
That depends on the filesystem. For ext4, you can do this with debugfs as follows: dennis@lightning:/tmp$ dd if=/dev/zero of=ext4.img bs=1M count=100 104857600 bytes (105 MB) copied, 0.645009 s, 163 MB/s dennis@lightning:/tmp$ mkfs.ext4 ext4.img mke2fs 1.42.5 (29-Jul-2012) ext4.img is not a block special device. Proc...
How do I manually modify an inode?
1,541,016,132,000
I'm working on an assignment for my college course, and one of the questions asks for the command used to create a hard link from one file to another so that they point to the same inode. We were linked a .pdf file to refer to, but it doesn't explain said process. Is it any different from creating a standard hard link...
Hard links are not "between" the files, there's one inode, with >1 entries in various directories all pointing to that one inode. ls -i should show the inodes, then experiment around with ln (hard link) and ln -s (soft or symbolic): $ touch afile $ ln -s afile symbolic $ ln afile bfile $ ls -1 -i afile symbolic bfile ...
Two hard linked files share inode
1,541,016,132,000
Say I have a directory with these permissions: drwxrwx--- Inside this directory, a file with these permissions: -rw-rw-rw- Is the file readable/writable by everyone or not ? If not, how secure is this access restriction? What if a random user makes a link to my file inside his home directory? Could he access the fil...
Yes, a file in a directory is only accessible to users who have the execute permission on the directory. It's like leaving jewelry in an unlocked drawer inside a locked house: the jewelry is under lock. A random user cannot create a hard link to a file, only the owner file. If the file has multiple hard links, some of...
Is a -rw-rw-rw- file really inaccessible inside a drwxrwx--- directory?
1,541,016,132,000
I know how hard links and symlinks work and I know why hard links can't be used for directories but in this case, is it some kind of exception? For example I do: ls -al Documents total 8 drwxr-xr-x 2 piotr piotr 4096 cze 28 11:19 . drwxrwx--- 17 piotr piotr 4096 lip 2 16:41 .. . is a hard link to Documents itself ...
As someone said in a comment on the question, just because hard links to directories aren't permitted (i.e., by the ln command), does not mean they are not possible. The superuser can actually use the "-d" or "-F" option to the ln command to force the creation of a hard link to a directory (though the man page says i...
Why . and .. are hard links to directories while in *nix systems hard links are not allowed for directories?
1,541,016,132,000
I am trying to write a shell script to create link for file from my dotfiles repo to my home folder. I want to use hard link if possible because it cannot be broken when moving it to somewhere in the same filesystem with HOME. But if I clone the dotfiles to another filesystem, I have to use symlink instead. So, how ...
ln source target 2>/dev/null || ln -s source target 2>/dev/null || exit 1 or, slightly more "interactively" (chattier), if ! ln source target 2>/dev/null; then echo 'failed to create hard link, trying symbolic link instead' >&2 if ! ln -s source target 2>/dev/null; then echo 'that failed too, bailing ...
Create hard link if possible, else use symlink
1,541,016,132,000
I used cp -uav to update a copy of a git repo, including uncommitted files. Why did it say it's removing files? It looks like this: $ cp -uav repos copy removed 'copy/repos/h/.git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391' removed 'copy/repos/h/.git/objects/3b/b3f834dd037db9298b10d71e0cd7383000fa1c' removed '...
I can reproduce the above messages as follows: mkdir test; cd test mkdir repos; cd repos mkdir g; cd g git init touch a git add a git commit -m test cd .. git clone g h cd .. mkdir copy cp -ua repos copy cp -uav repos copy The running the cp -ua command under strace will show that it is indeed removing (unlink) th...
Why did `cp -uav` of a git repo show "removed" for some files?
1,541,016,132,000
It is relatively common to use a "hard link tree" to create a second backup of a folder that is effectively just a copy of the files that have changed since the original backup. For example, rsync has a command line option --link-dest to achieve this. My question is whether there is an easy way to see the extra disk s...
After some more experimentation, it seems du is more "clever" than I expected. If you give it the two trees as arguments, then it displays the size of the second tree relative to the first: du -sh backup-Jan backup-Feb 242G backup-Jan 24G backup-Feb Where if you just give it the second tree, it shows the whole...
Determine extra size of hard link tree
1,541,016,132,000
I noticed that the rule /usr/sbin/shutdown -- gen_context(system_u:object_r:shutdown_exec_t,s0) labels /usr/sbin/shutdown shutdown_exec_t when /usr/sbin is a directory. But it doesn't restore the same label when /usr/sbin is a symbolic link to bin and shutdown is in /usr/bin. Why? If /usr/sbin is a symbolic link to...
restorecon doesn't handle symbolic links just the way it handles files. According to the manual page (a little old, so useful as a starting point): Note restorecon does not follow symbolic links. This was observed in a bug report, Bug 825221: restorecon disregards custom rules for sym links, with these pertinent...
How does restorecon handle links?
1,541,016,132,000
I currently am using Xamarin Studio, which has a bug in this version. It adds 2 parameters to an executable, which causes the output to flood with error messages, slowing down the build time from a minute to at least 10 minutes. Is there a way I can move the original executable and create a bash script or a link, whic...
The canonical way is a loop shaped like: #! /bin/sh - for i do # loop over the positional parameters case $i in --notices|--warnings) ;; *) set -- "$@" "$i" # append to the end of the positional parameter # list if neither --notices nor --warnings esac shift # remove from the head...
link to an executable and remove some parameters
1,541,016,132,000
I want a very simple example of how can a hard link break the file system structure. I saw somewhere that people say it's because of loops, however, I can make a loop with a soft link and so I still want to know what makes hard link break the file system?
It's hard links to directories that can break the filesystem structure. Hard links to other types of files aren't a problem. For example: mkdir foo ln foo foo/self rmdir foo rmdir foo doesn't actually remove the directory since it has a remaining link — the self entry inside foo itself. foo has become detached from t...
Can a hard link break the file system structure?
1,541,016,132,000
On openSUSE Tumbleweed 20210606 with kernel GNU/Linux 5.12.9-1-default I tried making a hard link of file from /cust to ~/backup: df /cust && df ~/backup && ln -P /cust/customization.tar ~/backup/ and get a result with error message: Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda3 70652313...
ln without options creates a hard link as documented in the manual page for link, especially the section explaining error EXDEV, which contains the remark link() does not work across different mount points, even if the same filesystem is mounted on both Although I realize that the paragraph below does not address th...
about ln command : condition of cross-device
1,541,016,132,000
A follow-up from this question. My further reading on Docker storage drivers revealed that the overlay driver merges all the image layers into lower layers using a hard link implementation which cause excessive inode utilization. Can someone explain this? As far as I know, creating hard links does not create a new ino...
OverlayFS is a union filesystem, and there are two storage drivers at the Docker level that make use of it: the original/older version named overlay and the newer version named overlay2. In OverlayFS, there is a lower-level directory which is exposed as read-only. On top of this directory is the upper-level directory,...
Overlay storage driver internals
1,541,016,132,000
I am searching for a simple way to perform a full system scan using clamav on a machine that also has Timeshift based snapshooting enabled. As suggested by this answer on the Ubuntu site, I was using a command like: clamscan -r --bell -i -exclude-dir="^/sys" / (note: the -exclude-dir="^/sys" param was suggested to me...
Hard links to files are indistinguishable from what you call "real files" - it's actually same file which lies in two directories. Best solution in your case would be just to add one more -exclude-dir="^/timeshift" parameter to the clamscan command.
Using clamav efficiently when timeshift snapshots are present
1,541,016,132,000
How can I achieve this files & folders permissions scenario: Consider these folder: Folder A: 640 root apache /var/www/A/ Folder www: 640 root apache /var/www/ and this linux user: id user1: uid=1000(user1) gid=1000(user1) groups=1000(user1) I want to allow linux user user1 read/write access JUST to folder A, BUT don'...
I'm assuming you want to give user1 access to /var/www/A because you visit the content managed by user1 via http://your.domain/A? Why not have apache redirect the content to a directory under the users home directory? Alias /A/ /path/to/users/homedir/A This will achieve the result and not have to change group/user ow...
FS permission scenario
1,541,016,132,000
I'm transitioning a large fileset from a filesystem with a high _PC_LINK_MAX (maximum number of hardlinks per inode) to a lower one. In particular, I'm messing about with Amazon EFS, which has a maximum of 175, as stated here. So I'd like to have the input be a set of files with link counts as high as 250 rejiggered...
The situation is tricky. Imagine the maximum links is 5 and you have 12 files a01 to a12 all hard-linked together. You need to split out a01..a05 and a06..a10 and a11..a12, where a06 and a07 etc are still hard-linked together, but not to a01. Here's a bash script using rsync that runs on an example source directory (s...
handy script to reduce hardlink count?
1,532,588,432,000
As we all know, the ln command creates a link, with the default being a hard link and the -s option creating a symlink. The general syntax is ln [-s] OLD NEW, where OLD is the file you are linking to and NEW is the new file you are creating. Hard links can not be created for directories, as a hard link could be create...
Read your man page: Question 1 = 1st Form, this is because in linux all items are considered files, even directories. As an example, use your text editor to "open" /etc/, ie: nano -w /etc/ nano will politely tell you /etc/ is a directory Since it's technically legal to create never ending symlinks. In the old days...
Seemingly Inconsistent Behavior for "ln" & "ln -s"
1,532,588,432,000
Imagine I have a file something/a.txt, which I hardlink from b.txt. Now, if I cp b.txt c.txt, is c.txt a hard link to a.txt, or is it a copy of the contents of a.txt?
Hardlinks are a completely different concept from other kinds of links or references. A hardlink is another name to the same inode (a bit simplified: the file contents and metadata). E.g. if you hardlink a.txt from b.txt, both names a.txt and b.txt are equal names to the same file. After hardlinking you cannot disting...
What happens when you copy a hardlink?
1,532,588,432,000
I'm using rsync to backup some of my files: rsync -aEN --delete --link-dest="$CURR/" "$SOURCE/" "$NEW/" The --link-dest option works fine with most files, but not with symlinks. When I was writing a clean-up script for old backups, I noticed that unchanged symlinks are not hard-linked, but rather copied. Now I'm wonde...
The filesystem on macOS (HFS+) does not support hard links to symbolic links: $ touch file $ ls -l file -rw-r--r-- 1 kk staff 0 Jun 17 18:35 file $ ln -s file slink $ ls -l file slink -rw-r--r-- 1 kk staff 0 Jun 17 18:35 file lrwxr-xr-x 1 kk staff 4 Jun 17 18:36 slink -> file The following would ordinarily create a ...
rsync --link-dest not working as expected with symlinks
1,532,588,432,000
I understand why hard links on directories are dangerous (loops, problems for rmdir because of the parent-directory-link) and have read the other questions on that topic. And so I assumed that hard links on directories apart from . and .. are not used. And yet I see the following on CentOS 5 & 6: # ls -id /etc/init.d/...
That's soft-link, not hard link. Symbolic links point to other files. Opening a symbolic link will open the file that the link points to. Removing a symbolic link with rm will remove the symbolic link itself, but not the actual file. This is indicated by the letter l at the beginning of the permissions lrwxrwxrwx. 1 ...
Is /etc/init.d hard-linked on CentOS?
1,532,588,432,000
I want, only using "basic" commands (for maximum portability) (i.e., something that would work on AIX / Linux / etc., not just something using a recent nicety ^^), to find all the files (symlinks, hardlinks and combinations thereof) pointing to a specific file/dir. Be careful to not rush to answer find / -ls | grep ....
ls has a -L option that will effectively chase symlinks and show the perms, owner, inode, etc. of the ultimate object. [It does this by doing stat(target) instead of lstat(target)]. For best results, run as root or as someone who has read access to relevant mounted filesystems. So in your case, try the following: find...
thoroughly find all links (hard and symlinks, and any combination thereof) leading to a file/dir [duplicate]
1,532,588,432,000
I've seen people on the internet talk about using hardlinks to force files to stay on disk as a backup, even if they're deleted in their original location. Would this work for a directory too? Why or why not? Assume that I'm using an ext4 filesystem, if it matters, but I'd also be interested in answers for other (UNIX...
It would not work. A hard link does not preserve the contents of files, just the pointer to those contents. So in case of files, file modifications are not preserved, and for directories that means changes in the contents of directories would not be preserved either. As (down under) each file is deleted individually. ...
If I hardlink to a directory, will the contents be "preserved" as if I hard-linked to every file?
1,532,588,432,000
I've tried setting up a script to hardlink my files to my box.com account (as it's a backup of my music library). As I want to run it automatically to sync my music across several devices, I wanted to use rsync as I'm on Mac OS X 10.7.4 (if anyone cares). The script I came up with however only copies the files instead...
According to the rsync man page section for --link-dest=DIR, If DIR is a relative path, it is relative to the destination directory. I am guessing that you assumed it would be relative to the current working directory. You probably meant to write: rsync -azluPhmt --progress --link-dest="$PWD/iTunes" …
rsync hardlink attempt copies
1,532,588,432,000
This is regarding generic UFS. From what I understand when an absolute path is given (eg: /home/userU/file.txt) the disk is accessed for each directory and the file. Hence in this case the disk is accessed 4 times 1 For /, 1 for home/, 1 for /userU, 1 for file.txt My questions are If a hard link /hL is given, point...
Background Say we have the following directory setup: $ ll total 0 -rw-r--r-- 2 root root 0 Jul 29 23:36 afile.txt -rw-r--r-- 2 root root 0 Jul 29 23:36 hL lrwxrwxrwx 1 root root 9 Jul 30 01:22 sL -> afile.txt Now let's look at your 2 questions. Questions If a hard link /hL is given, pointing to the inode of the a...
How many times is the disk accessed?
1,532,588,432,000
I am a new Linux user learning from Arch Linux and recently Linux From Scratch (7.7). I set up a new installation of AL to be my LFS host; I manually (and also with the provided bash script) checked prerequisite packages on my host. In my case, I am confident I resolved all discrepancies except for linking /usr/bin/ya...
When you did the ls -il /usr/bin, you were listing file names and matching inode numbers. In this context, it's probably best to think of "file name" as separate from "inode", and to think of the inode as the file. The "inode" is typically an on-disk data structure containing metadata (permissons, ownership, creation ...
Can files with different inum be hard linked?
1,532,588,432,000
On my Linux machine, I have the following file: drwxr-xr-x 2 jsgdr Unix_31 4096 Dec 2 17:46 jsgdr How to change the permission 2 to 4 so that I will this: drwxr-xr-x 4 jsgdr Unix_31 4096 Dec 2 17:46 jsgdr
The number you are talking about doesn't refer to the permissions. mkdir demo cd demo ls -ld drwxr-xr-x 2 root root 4096 Dec 2 10:21 . So, the number 2 here refers to, the entry for that directory in its parent directory; the directory's own entry for . However, if you want to see 4, you could see it when, mkdir s...
Change file hard link count
1,532,588,432,000
My question begins with: Do I actually have hard links on my disk at all (except for "." and ".." of course)? I'm not sure how I would find that out? If no, the question is already answered. If yes, I'd like to adjust my backup routine (currently using rsync -a) to preserve my hard links. I've seen the option -H, but ...
If you have a standard distribution you will have few hard links , so you generally don't need to worry too much. /bin, sbin, /lib/modules, and /usr have a bunch of hard links so if you are backing them up you may want to use the -H option. Backup directories may also contain hard links. Otherwise, you shouldn't ha...
Backing up hard links (rsync)?
1,532,588,432,000
what is the best way to mirror an entire directory, say original/, to a new directory, say mirror/, which has the structure mirror/data/ and mirror/tree/, such that every file in the directory original/ or in any of its subdirectories is hardlinked to a file in mirror/data whose filename is a unique identifier of it...
It's not so difficult to implement. On a GNU system (for ln -r and sha1sum -z) and with zsh: mkdir -p mirror/{data,tree} && find original -type f -exec sha1sum -z {} + | while IFS= read -rd '' rec; do sum=$rec[1,40] file=$rec[43,-1] ln -f -- $file mirror/data/$sum && mkdir -p -- mirror/tree/$...
mirror a directory tree by hard links for file contents and symlinks for directory structure
1,532,588,432,000
I have an example to better illustrate what I'm talking about: $ touch tas $ ln -s /etc/leviathan_pass/leviathan3 /tmp/l2/tas ln: failed to create symbolic link '/tmp/l2/tas': File exists Basically I can only symlink if the file I want to link doesn't exist. I understand this issue when talking about hard links - th...
The command ln won’t clobber existing files by default. You can use ln -sf TARGET LINK_NAME to force overwriting the destination path (LINK_NAME) with a symlink. You can use ln -f TARGET LINK_NAME to overwrite LINK_NAME with a hard link to, your explanation doesn’t make any sense about inode conflict. It just repla...
Why can't I symlink a preexisting file to a target file? [duplicate]
1,532,588,432,000
So, I have a file, for this instance we shall call it $HOME/Documents/hello.txt. I will write some text inside it: Hello, welcome to my text file And I will hard-link this file here: $HOME/Documents/Backup/hello.txt. Okay, great, this is now hard-linked. If I write to the original file, the hard-link will be updated:...
As mosvy already said in this comment, most editors do the edits in a copy of the original file which they replace (delete) later. While this increases security, it breaks hard links. However, some editors like for example GNU Emacs can be configured to perform file edits in place, which means that they directly alter...
What to do when hard link is lost because of my text editor
1,532,588,432,000
To save space and time I copied a large project tree on a network drive as hard links, i.e. cp -a -r --link proj proj_B (background: it's huge, needs to be rebuilt from two incompatible environments, and doesn't have good support for specifying intermediate and product locations. So this was a quick hack to get a reb...
I wouldn't use hard links. Some editors break hard links when they save files, others don't, and some can be configured. However, preserving hard links when saving a file implies that the file is written in place, which means that if the system crashes during the write, you will be left with an incomplete file. This i...
Sharing a project tree between environments
1,532,588,432,000
How do you write a bash one-liner that will find binary files with identical contents, permissions, and owner on the same ext4 file-system, from the current working directory recursively, and replace all files with older access times with hard links to the latest accessed file and report saved disk space in kibibytes?...
hardlink may not satisfy all requirements for this, but it can be used for what it is, to make the hardlinks. It can accept file arguments, not only directories, and it seems it is always linking a group of identical files to the first in order. Also it will ignore zero size files. fdupes selects exactly what needed, ...
Finding duplicate files using bash script
1,532,588,432,000
I had an interview, where the interviewer asked what operations raise the link count of a file, besides ln and its underlying syscall, I didn't know. He stated that opening a file will increase the link count by one to prevent deletion of an opened file. I did not agree that he is correct, why would vi need the temp ...
He's wrong.  The only thing that increases a file's link count is the link system call.  (Or editing the raw file system with a hex editor.)
What operations raise link count
1,532,588,432,000
I am new to mlbackup/rsync and the concept of hard links, so I am a little confused after creating a backup data set via mlbackup. So here's the scenario: I am backing up "folder A" to "folder B". Inside "folder A", I have file "X", "Y", and "Z"; each file is 5mb therefore "folder A" is 15mb in size. I run mlbackup an...
That is the expected behavior. The Finder does not check if files are hardlinks or real files and just adds the sizes. You do get the correct sizes with du as you already discovered. You can copy the backup folder to an external volume that way, but it will grow in size to what the Finder shows you as it is not capabl...
mlbackup / rsync / hard links data size
1,520,307,090,000
I've read this link, now I simply want to know why there are lots of hard link in /usr. For example, in my Ubuntu server, installed git, I found the command git here: /usr/bin/git. I execute ls -l /usr/bin/git and get the output as below: -rwxr-xr-x 119 root root 11178080 Mar 6 03:48 /usr/bin/git As you see, there ...
The git links have nothing to do with the PATH, they’re a space-saving measure. Generally speaking, in most cases for “installed” software, hard links are preferable to symbolic links when possible, because they’re more efficient and resilient. You’ll see quite a few binaries in /usr/bin with hard links, including per...
Why are there lots of hard links in /usr [closed]
1,520,307,090,000
My error: ln "99700.fa821246f01ef7f3d86a503e33de5753b50640d69de790fd3db5a5dc31ffa45d1dc64a93f950379ee432aa27cbb0593e6e50ddbb6f8a7e279afaf90cec961233.png" /home/anon/foo.png # ^ works fine ^ ln "99700.fa821246f01ef7f3d86a503e33de5753b50640d69de790fd3db5a5dc31ffa45d1dc64a93f950379ee432aa27cbb0593e6e50ddbb6f8a7...
Your data indicates that /tmp is a separate filesystem (tmpfs): 142 29 0:37 / /tmp rw,nosuid,nodev shared:63 - tmpfs tmpfs rw,size=8019684k,nr_inodes=409600,inode64 You can disable this behaviour by: sudo systemctl mask tmp.mount In which case /tmp will belong to your root filesystem. You'll have to reboot.
On xfs, why can't I hardlink to /tmp/, giving the error "Invalid cross-device link" when my fstab indicates tmp is on the same partition?
1,520,307,090,000
Does anyone know how to specify the file type of a hard link? Is this even possible? For example, I want to link to an HTML file (with content type text/html) in my website directory, so I used ln path/to/html/file.html path/to/file/in/my/website/directory.html, but the file type is detected as XML (via file path/to/...
A hard link means you simply add a second name for exactly the same file. Afterwards you cannot decide which name was first. File names do not have a file type or content-type like text/html. The content type is something you web server makes up. It usually does so by looking at the extension of the file name. Have a ...
How to specify the file type in a hard link [closed]
1,520,307,090,000
I'm controlling a Linux based NAS through SSH on a Windows computer. What I'm trying to do is use the cp -al command to rapidly copy folders from one directory to another, hardlinking all the files inside. Currently what I do is I list the directory with ls, then I highlight it with my mouse, copy it with right click...
So, first of all, you clearly are trying to work as if you had a proper file manager. That's not a crime, and you should use one :) Traditionally, Midnight Commander is the tool you should use, mc; chances are you can directly install it on your NAS, even! In this day and age, ranger (you say you're on debian, so sudo...
What is the fastest way of copying long paths for the cp command? [duplicate]
1,520,307,090,000
This page on inodes has been exceptional help in grasping the surface-level concept of file systems. On the same page, the author has inserted this snippet demonstrating that each file or directory has at least 2 names (and hard links): /tmp/junk$ ls -id .. 327681 .. /tmp/junk$ cd .. /tmp$ ls -id . 327681 . We can s...
The initial number of hard links is 1 for a file and 2 for a directory (the first link is its name in the parent folder, and the second hard link is .). The link count for a directory goes up by one each time a subdirectory is created in it (due to .. in each subdirectory). This count can be easily viewed with ls -l. ...
Can every file really own at least 2 names (and thus 2 hard links)?
1,520,307,090,000
Can one force ln not to follow a soft link in its first argument? For example, in the following I would like hard to be a hard link to the soft link soft: $ mkdir dir $ ln -s dir soft $ ln soft hard ln: soft: Is a directory I know about ln -h, but this only prevents ln from following soft links in the second argumen...
By default on your system, ln resolves the source fully if it is a symbolic link. There is a standard option, -P, that prevents it from doing this: $ mkdir dir $ ln -s dir soft $ ls -l total 4 drwxr-xr-x 2 myself wheel 512 Sep 21 22:39 dir lrwxr-xr-x 1 myself wheel 3 Sep 21 22:39 soft -> dir $ ln -P soft har...
Hard link to soft link
1,520,307,090,000
I have a large directory structure that has many hard links from the first hard link which lives in a different directory structure. For example dir1 has the following structure : [dir1]$ tree . ├── dir_inside │ ├── file1 │ └── file2 └── other_dir ├── file1 └── file2 Now lets suppose dir2 exists outside d...
I think you misunderstand the concept of a hard link. A file[name] is a pointer to an inode, a hard link is exactly the same. There is no reference to the original file. du cannot know if a file was created as a hard link from another file. du can only filter if multiple pointers to an inode appear in a single du call...
du counts hard links only once but hard links have the same size as the first hard link?
1,520,307,090,000
I have a few questions regarding links in UNIX Can I say Soft links in UNIX are analogous to shortcuts in windows? Difference between copying and hard-linking? Can anyone give me a use-case where I should prefer hard-linking over copying? I'm so messed up right now. Any help is highly appreciated
The basic thing is, that copying makes a copy of the file, and linking (soft or hard) does not. As an abstraction model, think of your directory as a table with: filename where the file is content of the file --------------------------------------------------------- a.txt sector 13456 abcd ...
Linking and Copying
1,520,307,090,000
I got a weird hardlink at centos 6.5 vps server. It's man made, I assume, but I'm not the one who did it. df tells some info. [root@root]# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/simfs 209715200 128660820 81054380 62% / none 4194304 4 4194300 1% /dev none ...
You have two mounted filesystems with similar characteristics: same device name, same disk usage. These are very likely to be, in fact, the same device. This can happen if you mount the same network filesystem in different locations, for example. Given that this is a local filesystem, as sourcejedi identified in a com...
Simfs hardlinks whereabouts
1,520,307,090,000
I run grep some-string -r . &. While it is running in bkg, I cd to another directory. It seems that grep interprets the hard link . differently then. What happens before and after I change the current directory? Will both the original and the new directories not be searched completely? I wonder if . as a command line ...
Each process has its own "current working directory", which can't be changed from outside the process. So when you do grep some-string -r . & your shell starts grep in the background, and grep's current working directory is initialised to the same value as the shell's at that moment. grep's definition of . here is it...
. as a command line argument to a command running in background
1,520,307,090,000
I have a work laptop that I will soon have to return to my employer. Having foreseen this, I ordered a second internal disk and mounted it at /home/<user> so that I can just pull it out and mount it in the next machine without having to go through the whole ritual of copying files, etc. However, I've created a few pro...
So, you have a hard disk, formatted with a filesystem, in which there are hard links (confined within the filesystem, of course). If you remove this hard disk from a system and mount it in another system, it will continue working exactly as before, provided that both systems recognize correctly the filesystem. If it's...
Hard links on a mounted disk
1,520,307,090,000
This is something I imagine I might have to submit a patch or feature request for, but I'd like to know if it is possible to create a hardlink to a file, that when that hardlink which was not the original file is editted, that it would be copied first before it was actually editted? Which major filesystem would this a...
After you create a hard link to a file, there are just two links to one file. While you may remember which link was first and which was second, the filesystem doesn't. So it is just possible for an editor to determine whether there is more than one link to a file or not. An editor may or may not preserve the link when...
How can I have it so, that when hardlinks which are not the original, are editted, that they would first be copied then editted?
1,520,307,090,000
I have a daily rsync script backing up my data on an external hard drive at /mnt/X (root of hard drive). I am using --link-dest to use hard links and avoid duplicating data. I need to move all my daily backups from /mnt/X to /mnt/X/backups without loosing the hard links. Later I will need to change the script to backu...
You don't have to do anything special. Simply, mv /mnt/X/* to /mnt/X/backups/ (You will get an error about not being able to move backups to itself). A hard link is basically an inode number. Files that are hard-linked have the same inode number. However you move them around within the same file-system, the inode nu...
Move daily backup directories (made by rsync) to another directory in the same partition
1,520,307,090,000
we have the following folders / links /files under /usr/hdp/2.6.0.3-8/zookeeper folder -rw-r--r--. 1 root root 794542 Apr 1 2017 zookeeper-3.4.6.2.6.0.3-8.jar drwxr-xr-x. 6 root root 4096 Mar 28 2018 doc drwxr-xr-x. 3 root root 17 Mar 28 2018 etc drwxr-xr-x. 2 root root 4096 Mar 28 2018 lib drwxr-xr-x. 3 ...
You are probably looking for the much used -a option of rsync: -a, --archive archive mode; equals -rlptgoD (no -H,-A,-X) Which will provide what you need: -r, --recursive recurse into directories -l, --links copy symlinks as symlinks -p, --perms ...
what is the right approach to copy folder content that include links
1,520,307,090,000
I have a NAS devices, and I've mounted 2 shared folders from this one device. QNAP Ubuntu 18.04 fstab config: //192.168.0.10/Media /media/QNAP_Media cifs credentials=/home/user/.smbcredentials,iocharset=utf8,vers=3.0 0 0 //192.168.0.10/Rdownload /media/QNAP_Rdownload cifs credentials=/home/user/.smbcredentials,iocha...
You cannot hardlink between different underlying devices. See if softlinks work.
Invalid cross-device linked. Multiple shares from the same NAS
1,520,307,090,000
I have a user account at my local library (they use openslx), in which I can store files. My actual home folder is "mounted" (I'm not sure how) in /home/[my_userID]/PERSISTENT instead of /home/[my_userID]. After logging in, an xterm window is started, the window manager is openbox. With logging out, everything not sto...
After some time, I've figured out that I could use symbolic links to speed up the configuration thing at least. rm -dfr .cache .config .local&&ln -fs PERSISTENT/.bash_aliases PERSISTENT/.bash_history PERSISTENT/.bash_logout PERSISTENT/.cache PERSISTENT/.config PERSISTENT/.ICEauthority PERSISTENT/.local PERSISTENT/.ssh...
Link files and directories, in target directory, with cross-device links
1,520,307,090,000
If someone uses the command "cp -alr" on a directory located in a non-path preserving merged pool will it always create a directory on the same disk with all of its contents as hard links? For example, if we created a merged pool with category.create=mfs and on the following directory tree we run "cp -alr /romance/Tit...
The specific details on how rename and link work are in the docs. If you're not using path preservation then it clones the path on the same branch (if needed) and performs the rename or link.
Hard links with MergerFS
1,520,307,090,000
I discovered the pax command recently, and was amazed at how efficient it is when copying locally from one SSD to another, for instance. For local backup, I'm contemplating replacing a rsync solution with pax, however pax seems to be missing the --link-dest option that is so convenient for incremental backups (creati...
The pax program is not useful for incremental backups. The new POSIX.1-2001 extended headers for the tar format (called "pax"-format) that have been taken from the Solaris TAR enhancements from 1997 however are a really good base for incremental backups since this concept allows to be enhanced to archive all possible ...
pax command for incremental backup with hard links similar to rsync
1,390,858,111,000
I've got my Toshiba laptop (Satellite A300) connected to my TV via HDMI. Using VLC 2.2.6, video works just fine. Currently, I'm trying to output sound to the TV's speakers. aplay -l shows the HDMI playback device as the third one: **** List of PLAYBACK Hardware Devices **** card 0: Intel [HDA Intel], device 0: ALC268 ...
With pavucontrol (GUI) Turns out, I had to switch the profile of "Built-in Audio" to HDMI. I can do that with pavucontrol, install it with pacman -S pavucontrol. Now, sound works perfectly on the TV speakers. Since pavucontrol uses PulseAudio, this has to be installed as well: pacman -S pulseaudio. After restarting (...
Sound via HDMI on Arch Linux
1,390,858,111,000
I am trying to use the HDMI output on a PC (HP ZBook) with Debian (stretch). I have configured Bumblebee, it works well (glxinfo and optirun glxinfo report the expected information, and I tested complicated GLSL shaders that also work as expected). Now I would like to be able to plug a videoprojector on the HDMI. I ha...
Yes, found out ! To activate VIRTUAL output of the intel driver, you need to create a 20-intel.conf file in the Xorg configuration directory (/usr/share/X11/xorg.conf.d under Debian stretch, found out by reading /var/log/Xorg.0.log) Section "Device" Identifier "intelgpu0" Driver "intel" Option "VirtualHead...
Do not manage to activate HDMI on a laptop (that has optimus / bumblebee)
1,390,858,111,000
I have my machine connected over HDMI to a receiver. But when I try to use more than two channels with PulseAudio, I only get two. pacmd list cards shows the card, but does not show an HDMI profile with more than two channels. I have confirmed that 7.1 sound works via ALSA: pasuspender -- speaker-test -D hdmi -c 8 -m ...
In PulseAudio, each sound card has a profile set associated with it. A profile set contains multiple profiles, and those are the profiles that you see when listing the cards (or when looking in the various PulseAudio GUIs). There is a default profile, which primarily contains things useful for analog sound output. Th...
How do I configure PulseAudio for 7.1 Surround Sound over HDMI?
1,390,858,111,000
I have a notebook running Kubuntu Precise (12.04) which I occasionally use for watching videos. When I do, I plug in an HDMI cable connected to an A/V receiver with an HDMI monitor attached to it. When I watch videos this way, I still need to use the notebook display when I'm interacting with the system to control pl...
You should probably simply use kscreen instead, which should solve all your issues. It will remember the settings of a previously connected screen and will restore them, once you connect it again. If you still have such issues while still using kscreen, it should be worth a bug report. As Kubuntu 12.04 is quite old, y...
How to write bash script to configure my displays when HDMI is plugged in or unplugged
1,390,858,111,000
I have a Monitor connected to my machine through HDMI. Now if anyone were to switch off the Monitor, through either the Soft Buttons on it, or by removing it's Power Cord, I wish to be notified and run a Shell Script. I tried many ways to identify when a monitor is switched on or off (It's always connected). The only...
I don't see anything wrong with parsing the output of ddccontrol. DDC is the right way to get the information you want. Unlike with VGA, where DDC was created, the HDMI connector was designed to include DDC from the start. They even went back and modified the DDC standard to add more features for HDMI, calling it E-DD...
Detect if HDMI Monitor is switched off
1,390,858,111,000
OS: GNOME 3.30.2 on Debian GNU/Linux 10 (64-bit) My laptop has no output from the HDMI port. The monitor shows "NO INPUT DETECTED". Previously I had Kubuntu installed and before that I had windows 10, Both worked fine, which means this is not a hardware issue. I have tried: Using the package "ARandR" to scan for new ...
You have a laptop with two GPUs, using Nvidia's "Optimus" technology. The low-power CPU-integrated Intel iGPU is physically wired to output to the laptop's internal display, while the HDMI output is wired to the more powerful Nvidia discrete GPU. The device ID 10de:1f91 indicates the Nvidia GPU is GeForce GTX 1650 Mob...
Debian 10 [Buster]: HDMI Input Not detected