Find the answer to your Linux question:
Results 1 to 8 of 8
Hey there I unmounted a partition /home from my system. Went into the /home/ and created a dir ( I supposed that it will give me some wierd error but ...
  1. #1
    Linux User vickey_20's Avatar
    Join Date
    Mar 2009
    Location
    Mumbai, India
    Posts
    493

    where are the file created on an umounted partition

    Hey there
    I unmounted a partition /home from my system. Went into the /home/ and created a dir ( I supposed that it will give me some wierd error but it didn't) xyz.
    Now i can work with xyz like a normal directory but when i remount the /home this directory disappears. Again on unmounting and accessing the /home dir i see the xyz residing like making me look like a fool. I cant figure out where it went and form where it came back???
    Only if I could understand the man pages
    Registered Linux user #492640
    OS: RHEL4,5 ,RH 9,Ubuntu

  2. #2
    Super Moderator devils casper's Avatar
    Join Date
    Jun 2006
    Location
    Chandigarh, India
    Posts
    24,316
    When you mount any partition, its mount point ( folder ) act as access point of that partition and whenever you create any thing there, it is created in actual partition only.

    When you unmount partition, its mount point (folder) act as a simple folder under filesystem only.

    xyz dir has been created in folder /home but when you mount partition in the same folder, it act as access route to the partition. xyz is still there but not visible because you have connected its parent folder (/home) to another location, i.e. partition.
    It is amazing what you can accomplish if you do not care who gets the credit.
    New Users: Read This First

  3. #3
    Linux User vickey_20's Avatar
    Join Date
    Mar 2009
    Location
    Mumbai, India
    Posts
    493

    Then were is xyz

    Ok you cleared my concepts but where is xyz folder when /home is mounted??
    Only if I could understand the man pages
    Registered Linux user #492640
    OS: RHEL4,5 ,RH 9,Ubuntu

  4. #4
    Linux Guru
    Join Date
    Nov 2007
    Location
    Córdoba (Spain)
    Posts
    1,513
    Quote Originally Posted by vickey_20 View Post
    Ok you cleared my concepts but where is xyz folder when /home is mounted??
    It's still there in whatever partition that the /home directory (mind I said "directory", not "partition") was created. Usually that's the partition that's mounted on /

    But you can't reach these files unless you umount /home. Mount points are not different of any other directory, they are not special in any way. You could create a directory in your home to store games, for example:

    Code:
    mkdir /home/i92guboj/games
    Then you store games inside that directory. Now for some weird reason you decide to mount your usb pendrive into /home/i92guboj/games. While it's mounted you will see the contents of the pendrive under /home/i92guboj/games. As soon as you umount that directory the games will still be there, in whatever partition your home directory resides. You can use any arbitrary directory as a mount point at any given moment.

    Of course it wouldn't be good to mount your photo cam under /bin, because then everything under /bin will not be reachable until you umount /bin. But guess what, the "umount" command itself lives under /bin so you couldn't reach it either

  5. #5
    Linux User vickey_20's Avatar
    Join Date
    Mar 2009
    Location
    Mumbai, India
    Posts
    493

    OK got the concept

    Ok mounting is like an access point , the place you mount it , form there you can access it. But if you mount on to something will already contains something , it gets over written and cant be accessed till the time you unmount it again. This also means that a partition can be mounted on as many different locations as wanted without any problem. But I'm confused as in , If I create a file in an unmounted partition for ex /home ( which has been unmounted) then where does the file gets stored and on which partition????
    ------------------------------------------------------------------------------------------------------------------------------------
    Also I tried to find the file I created on the umounted partition but it failed when the partition was mounted( as searching when the partition was unmounted would easily get me the file location).
    -------------------------------------------------------------------------------------------------------------------------------------
    SO does this mean that when I mount on an access point the files present inside the access point become hidden????
    Only if I could understand the man pages
    Registered Linux user #492640
    OS: RHEL4,5 ,RH 9,Ubuntu

  6. #6
    Linux Guru
    Join Date
    Nov 2007
    Location
    Córdoba (Spain)
    Posts
    1,513
    Quote Originally Posted by vickey_20 View Post
    Ok mounting is like an access point , the place you mount it , form there you can access it. But if you mount on to something will already contains something , it gets over written and cant be accessed till the time you unmount it again. This also means that a partition can be mounted on as many different locations as wanted without any problem. But I'm confused as in , If I create a file in an unmounted partition for ex /home ( which has been unmounted) then where does the file gets stored and on which partition????
    In whatever partition contains the /home directory. That will be usually whatever is mounted in /. The file will be stored inside a directory that lives in the / partition. And it will not be accessible if you mount something at /home/

    Also I tried to find the file I created on the umounted partition but it failed when the partition was mounted( as searching when the partition was unmounted would easily get me the file location).
    What I said above. When you store things into a directory which is not mounted, the file is stored in the partition where the directory lives. When you mount another partition into that directory the contents of the directory is not magically merged into the newly mounted partition. That would create an authentic mess.

    SO does this mean that when I mount on an access point the files present inside the access point become hidden????
    Yes.

  7. #7
    Linux Guru Jonathan183's Avatar
    Join Date
    Oct 2007
    Posts
    2,941
    The info posted above is true ... but the file is still there and you can actually access it as well if you ln to it before the mount . Example you can try ...
    create a folder to put a file in
    Code:
    sudo mkdir /media/mytest
    then create a text file in it
    Code:
    sudo echo "This is a test file for mount" > /media/mytest/test-file1
    sudo chown your_regular_user_name /media/mytest/test-file1
    cd
    ln /media/mytest/test-file1 my-link1
    now check you can access the file
    Code:
    cat ~/my-link1
    Now mount a partition to the /media/mytest folder ... in my case hda5 (but any partition will do)
    Code:
    sudo mount /dev/hda5 /media/mytest -o ro
    now
    Code:
    ls /media/mytest -l
    you should get the contents of the mounted partition and
    Code:
    cat /media/mytest/test-file1
    should return no such file or directory ...
    now try
    Code:
    cat ~/my-link1
    and it should return the file contents

  8. #8
    Linux User vickey_20's Avatar
    Join Date
    Mar 2009
    Location
    Mumbai, India
    Posts
    493

    Cool

    Quote Originally Posted by Jonathan183 View Post
    The info posted above is true ... but the file is still there and you can actually access it as well if you ln to it before the mount . Example you can try ...
    create a folder to put a file in
    Code:
    sudo mkdir /media/mytest
    then create a text file in it
    Code:
    sudo echo "This is a test file for mount" > /media/mytest/test-file1
    sudo chown your_regular_user_name /media/mytest/test-file1
    cd
    ln /media/mytest/test-file1 my-link1
    now check you can access the file
    Code:
    cat ~/my-link1
    Now mount a partition to the /media/mytest folder ... in my case hda5 (but any partition will do)
    Code:
    sudo mount /dev/hda5 /media/mytest -o ro
    now
    Code:
    ls /media/mytest -l
    you should get the contents of the mounted partition and
    Code:
    cat /media/mytest/test-file1
    should return no such file or directory ...
    now try
    Code:
    cat ~/my-link1
    and it should return the file contents
    Nice thinking there
    The hard link made to the file works out perfectly but not the softlink.
    Only if I could understand the man pages
    Registered Linux user #492640
    OS: RHEL4,5 ,RH 9,Ubuntu

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...