Can two files on two separate filesystems share the same inode number? [duplicate]

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
17
down vote

favorite
1













This question already has an answer here:



  • Why do the directories /home, /usr, /var, etc. all have the same inode number (2)?

    2 answers



If I run a command like this one:



find / -inum 12582925


Is there a chance that this will list two files on separate mounted filesystems (from separate partitions) that happen to have been assigned the same number? Is the inode number unique on a single filesystem, or across all mounted filesystems?










share|improve this question













marked as duplicate by Jeff Schaller, schily, Thomas, Isaac, G-Man Aug 26 at 18:48


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















    up vote
    17
    down vote

    favorite
    1













    This question already has an answer here:



    • Why do the directories /home, /usr, /var, etc. all have the same inode number (2)?

      2 answers



    If I run a command like this one:



    find / -inum 12582925


    Is there a chance that this will list two files on separate mounted filesystems (from separate partitions) that happen to have been assigned the same number? Is the inode number unique on a single filesystem, or across all mounted filesystems?










    share|improve this question













    marked as duplicate by Jeff Schaller, schily, Thomas, Isaac, G-Man Aug 26 at 18:48


    This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
















      up vote
      17
      down vote

      favorite
      1









      up vote
      17
      down vote

      favorite
      1






      1






      This question already has an answer here:



      • Why do the directories /home, /usr, /var, etc. all have the same inode number (2)?

        2 answers



      If I run a command like this one:



      find / -inum 12582925


      Is there a chance that this will list two files on separate mounted filesystems (from separate partitions) that happen to have been assigned the same number? Is the inode number unique on a single filesystem, or across all mounted filesystems?










      share|improve this question














      This question already has an answer here:



      • Why do the directories /home, /usr, /var, etc. all have the same inode number (2)?

        2 answers



      If I run a command like this one:



      find / -inum 12582925


      Is there a chance that this will list two files on separate mounted filesystems (from separate partitions) that happen to have been assigned the same number? Is the inode number unique on a single filesystem, or across all mounted filesystems?





      This question already has an answer here:



      • Why do the directories /home, /usr, /var, etc. all have the same inode number (2)?

        2 answers







      filesystems inode






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Aug 23 at 12:41









      Flimm

      1,30541827




      1,30541827




      marked as duplicate by Jeff Schaller, schily, Thomas, Isaac, G-Man Aug 26 at 18:48


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






      marked as duplicate by Jeff Schaller, schily, Thomas, Isaac, G-Man Aug 26 at 18:48


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          39
          down vote



          accepted










          An inode number is only unique on a single file system. One example you’ll run into quickly is the root inode on ext2/3/4 file systems, which is 2:



          $ ls -id / /home
          2 / 2 /home


          If you run (assuming GNU find)



          find / -printf "%i %pn" | sort -n | less


          on a system with multiple file systems you’ll see many, many duplicate inode numbers (although you need to take the output with a pinch of salt since it will also include hard links).



          When you’re looking for a file by inode number, you can use find’s -xdev option to limit its search to the file system containing the start path, if you have a single start path:



          find / -xdev -inum 12582925


          will only find files with inode number 12582925 on the root file system. (-xdev also works with multiple start paths, but then its usefulness is reduced in this particular case.)



          It's the combination of inode number and device number (st_dev and st_ino in the stat structure, %D %i in GNU find's -printf) that identifies a file uniquely (on a given system). If two directory entries have the same inode and dev number, they refer to the same file (though possibly through two different mounts of a same file system for bind mounts).



          Some find implementations also have a -samefile predicate that will find files with the same device and inode number. Most [/test implementations also have a -ef operator to check that two files paths refer to the same file (after symlink resolution though).






          share|improve this answer





























            up vote
            4
            down vote













            Yes, the same inode number may appear at a different filesystem. If you want to specify the exact, you not only need the inode number (st_ino) but also the device where the inode resides (st_dev, itself formed by dev_major —the general class of device— and dev_minor —the specific instance—).



            The couple (st_dev, st_ino) will identify a specific file (at least if you don't unmount the filesystem where this inode resides).



            As stated on inode(7):




            Device where inode resides



            Each inode (as well as the associated file) resides in a filesystem that is hosted on a device. That device is identified by the combination of its major ID (which identifies the general class of device) and minor ID (which identifies a specific instance in the general class).



            Inode number



            Each file in a filesystem has a unique inode number. Inode numbers are guaranteed to be unique only within a filesystem (i.e., the same inode numbers
            may be used by different filesystems
            , which is the reason that hard links may not cross filesystem boundaries).







            share|improve this answer




















            • If inodes weren't only unique to the filesystem, you couldn't safely move filesystems from one computer to another (which you can do, by physically moving a drive from one machine to another, or -- in VMware -- detaching a LUN from one VM and attaching it to another).
              – RonJohn
              Aug 24 at 19:07

















            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            39
            down vote



            accepted










            An inode number is only unique on a single file system. One example you’ll run into quickly is the root inode on ext2/3/4 file systems, which is 2:



            $ ls -id / /home
            2 / 2 /home


            If you run (assuming GNU find)



            find / -printf "%i %pn" | sort -n | less


            on a system with multiple file systems you’ll see many, many duplicate inode numbers (although you need to take the output with a pinch of salt since it will also include hard links).



            When you’re looking for a file by inode number, you can use find’s -xdev option to limit its search to the file system containing the start path, if you have a single start path:



            find / -xdev -inum 12582925


            will only find files with inode number 12582925 on the root file system. (-xdev also works with multiple start paths, but then its usefulness is reduced in this particular case.)



            It's the combination of inode number and device number (st_dev and st_ino in the stat structure, %D %i in GNU find's -printf) that identifies a file uniquely (on a given system). If two directory entries have the same inode and dev number, they refer to the same file (though possibly through two different mounts of a same file system for bind mounts).



            Some find implementations also have a -samefile predicate that will find files with the same device and inode number. Most [/test implementations also have a -ef operator to check that two files paths refer to the same file (after symlink resolution though).






            share|improve this answer


























              up vote
              39
              down vote



              accepted










              An inode number is only unique on a single file system. One example you’ll run into quickly is the root inode on ext2/3/4 file systems, which is 2:



              $ ls -id / /home
              2 / 2 /home


              If you run (assuming GNU find)



              find / -printf "%i %pn" | sort -n | less


              on a system with multiple file systems you’ll see many, many duplicate inode numbers (although you need to take the output with a pinch of salt since it will also include hard links).



              When you’re looking for a file by inode number, you can use find’s -xdev option to limit its search to the file system containing the start path, if you have a single start path:



              find / -xdev -inum 12582925


              will only find files with inode number 12582925 on the root file system. (-xdev also works with multiple start paths, but then its usefulness is reduced in this particular case.)



              It's the combination of inode number and device number (st_dev and st_ino in the stat structure, %D %i in GNU find's -printf) that identifies a file uniquely (on a given system). If two directory entries have the same inode and dev number, they refer to the same file (though possibly through two different mounts of a same file system for bind mounts).



              Some find implementations also have a -samefile predicate that will find files with the same device and inode number. Most [/test implementations also have a -ef operator to check that two files paths refer to the same file (after symlink resolution though).






              share|improve this answer
























                up vote
                39
                down vote



                accepted







                up vote
                39
                down vote



                accepted






                An inode number is only unique on a single file system. One example you’ll run into quickly is the root inode on ext2/3/4 file systems, which is 2:



                $ ls -id / /home
                2 / 2 /home


                If you run (assuming GNU find)



                find / -printf "%i %pn" | sort -n | less


                on a system with multiple file systems you’ll see many, many duplicate inode numbers (although you need to take the output with a pinch of salt since it will also include hard links).



                When you’re looking for a file by inode number, you can use find’s -xdev option to limit its search to the file system containing the start path, if you have a single start path:



                find / -xdev -inum 12582925


                will only find files with inode number 12582925 on the root file system. (-xdev also works with multiple start paths, but then its usefulness is reduced in this particular case.)



                It's the combination of inode number and device number (st_dev and st_ino in the stat structure, %D %i in GNU find's -printf) that identifies a file uniquely (on a given system). If two directory entries have the same inode and dev number, they refer to the same file (though possibly through two different mounts of a same file system for bind mounts).



                Some find implementations also have a -samefile predicate that will find files with the same device and inode number. Most [/test implementations also have a -ef operator to check that two files paths refer to the same file (after symlink resolution though).






                share|improve this answer














                An inode number is only unique on a single file system. One example you’ll run into quickly is the root inode on ext2/3/4 file systems, which is 2:



                $ ls -id / /home
                2 / 2 /home


                If you run (assuming GNU find)



                find / -printf "%i %pn" | sort -n | less


                on a system with multiple file systems you’ll see many, many duplicate inode numbers (although you need to take the output with a pinch of salt since it will also include hard links).



                When you’re looking for a file by inode number, you can use find’s -xdev option to limit its search to the file system containing the start path, if you have a single start path:



                find / -xdev -inum 12582925


                will only find files with inode number 12582925 on the root file system. (-xdev also works with multiple start paths, but then its usefulness is reduced in this particular case.)



                It's the combination of inode number and device number (st_dev and st_ino in the stat structure, %D %i in GNU find's -printf) that identifies a file uniquely (on a given system). If two directory entries have the same inode and dev number, they refer to the same file (though possibly through two different mounts of a same file system for bind mounts).



                Some find implementations also have a -samefile predicate that will find files with the same device and inode number. Most [/test implementations also have a -ef operator to check that two files paths refer to the same file (after symlink resolution though).







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Aug 23 at 14:51









                Stéphane Chazelas

                285k53525864




                285k53525864










                answered Aug 23 at 12:47









                Stephen Kitt

                146k22320386




                146k22320386






















                    up vote
                    4
                    down vote













                    Yes, the same inode number may appear at a different filesystem. If you want to specify the exact, you not only need the inode number (st_ino) but also the device where the inode resides (st_dev, itself formed by dev_major —the general class of device— and dev_minor —the specific instance—).



                    The couple (st_dev, st_ino) will identify a specific file (at least if you don't unmount the filesystem where this inode resides).



                    As stated on inode(7):




                    Device where inode resides



                    Each inode (as well as the associated file) resides in a filesystem that is hosted on a device. That device is identified by the combination of its major ID (which identifies the general class of device) and minor ID (which identifies a specific instance in the general class).



                    Inode number



                    Each file in a filesystem has a unique inode number. Inode numbers are guaranteed to be unique only within a filesystem (i.e., the same inode numbers
                    may be used by different filesystems
                    , which is the reason that hard links may not cross filesystem boundaries).







                    share|improve this answer




















                    • If inodes weren't only unique to the filesystem, you couldn't safely move filesystems from one computer to another (which you can do, by physically moving a drive from one machine to another, or -- in VMware -- detaching a LUN from one VM and attaching it to another).
                      – RonJohn
                      Aug 24 at 19:07














                    up vote
                    4
                    down vote













                    Yes, the same inode number may appear at a different filesystem. If you want to specify the exact, you not only need the inode number (st_ino) but also the device where the inode resides (st_dev, itself formed by dev_major —the general class of device— and dev_minor —the specific instance—).



                    The couple (st_dev, st_ino) will identify a specific file (at least if you don't unmount the filesystem where this inode resides).



                    As stated on inode(7):




                    Device where inode resides



                    Each inode (as well as the associated file) resides in a filesystem that is hosted on a device. That device is identified by the combination of its major ID (which identifies the general class of device) and minor ID (which identifies a specific instance in the general class).



                    Inode number



                    Each file in a filesystem has a unique inode number. Inode numbers are guaranteed to be unique only within a filesystem (i.e., the same inode numbers
                    may be used by different filesystems
                    , which is the reason that hard links may not cross filesystem boundaries).







                    share|improve this answer




















                    • If inodes weren't only unique to the filesystem, you couldn't safely move filesystems from one computer to another (which you can do, by physically moving a drive from one machine to another, or -- in VMware -- detaching a LUN from one VM and attaching it to another).
                      – RonJohn
                      Aug 24 at 19:07












                    up vote
                    4
                    down vote










                    up vote
                    4
                    down vote









                    Yes, the same inode number may appear at a different filesystem. If you want to specify the exact, you not only need the inode number (st_ino) but also the device where the inode resides (st_dev, itself formed by dev_major —the general class of device— and dev_minor —the specific instance—).



                    The couple (st_dev, st_ino) will identify a specific file (at least if you don't unmount the filesystem where this inode resides).



                    As stated on inode(7):




                    Device where inode resides



                    Each inode (as well as the associated file) resides in a filesystem that is hosted on a device. That device is identified by the combination of its major ID (which identifies the general class of device) and minor ID (which identifies a specific instance in the general class).



                    Inode number



                    Each file in a filesystem has a unique inode number. Inode numbers are guaranteed to be unique only within a filesystem (i.e., the same inode numbers
                    may be used by different filesystems
                    , which is the reason that hard links may not cross filesystem boundaries).







                    share|improve this answer












                    Yes, the same inode number may appear at a different filesystem. If you want to specify the exact, you not only need the inode number (st_ino) but also the device where the inode resides (st_dev, itself formed by dev_major —the general class of device— and dev_minor —the specific instance—).



                    The couple (st_dev, st_ino) will identify a specific file (at least if you don't unmount the filesystem where this inode resides).



                    As stated on inode(7):




                    Device where inode resides



                    Each inode (as well as the associated file) resides in a filesystem that is hosted on a device. That device is identified by the combination of its major ID (which identifies the general class of device) and minor ID (which identifies a specific instance in the general class).



                    Inode number



                    Each file in a filesystem has a unique inode number. Inode numbers are guaranteed to be unique only within a filesystem (i.e., the same inode numbers
                    may be used by different filesystems
                    , which is the reason that hard links may not cross filesystem boundaries).








                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Aug 23 at 22:07









                    Ángel

                    1,358512




                    1,358512











                    • If inodes weren't only unique to the filesystem, you couldn't safely move filesystems from one computer to another (which you can do, by physically moving a drive from one machine to another, or -- in VMware -- detaching a LUN from one VM and attaching it to another).
                      – RonJohn
                      Aug 24 at 19:07
















                    • If inodes weren't only unique to the filesystem, you couldn't safely move filesystems from one computer to another (which you can do, by physically moving a drive from one machine to another, or -- in VMware -- detaching a LUN from one VM and attaching it to another).
                      – RonJohn
                      Aug 24 at 19:07















                    If inodes weren't only unique to the filesystem, you couldn't safely move filesystems from one computer to another (which you can do, by physically moving a drive from one machine to another, or -- in VMware -- detaching a LUN from one VM and attaching it to another).
                    – RonJohn
                    Aug 24 at 19:07




                    If inodes weren't only unique to the filesystem, you couldn't safely move filesystems from one computer to another (which you can do, by physically moving a drive from one machine to another, or -- in VMware -- detaching a LUN from one VM and attaching it to another).
                    – RonJohn
                    Aug 24 at 19:07


                    Popular posts from this blog

                    How to check contact read email or not when send email to Individual?

                    Displaying single band from multi-band raster using QGIS

                    How many registers does an x86_64 CPU actually have?