Physical Devices  «Prev 

Mounting and unmounting using Linux

Here are the instructions for this simulation:
During the process of mounting and unmounting in Linux, which physical devices are mounted.
  1. You are logged in as a superuser. Type
    mount -t ext2 /dev/fd0 /mnt
    to mount the fd0 (floppy disk) filesystem onto the /mnt directory.1
  2. 1You are using /mnt as the mount-point for your floppy disk. Type mount to verify that you have mounted /dev/fd0 on /mnt.
  3. 1 Notice that /dev/fd0 is now mounted on /mnt type ext2 (rw). You can unmount /mnt using the umount command. But first, let’s look at what occurs if you attempt to unmount a directory that is active. To test this, change to the /mnt directory.
  4. Try to unmount the directory by typing
    umount /mnt
  5. You received a "device is busy" message. Type /usr/sbin/fuser -v -m /mnt to learn exactly why you received this message.
  6. You can see that you (root) are currently accessing the /mnt directory. This is why the c indicator is listed beneath the ACCESS entry. Now that you have tested this, use your floppy disk to back up the files in your /etc directory. First, change to the /etc directory.
  7. Type cp * /mnt to copy all files in the /etc directory to the floppy disk.
  8. Note that you have copied only the files in the /etc directory. This is why you received messages that cp is omitting directories. Type ls –l /mnt to list all the files on the floppy disk mount point (/mnt).
  9. Remember that you are in the /etc directory. Use the umount command to unmount the /mnt directory.
  10. Consider what would occur if you were to mount a filesystem at a mount-point that is actually a populated directory. Contrary to what you might think, the files are not erased. However, the files and filesystem that exist in the already-populated directory will be covered up by the files and filesystem on the device mounted on it. To test this, you will create a subdirectory of your home directory named mntpt. You will then create two files in the /home/user1/mntpt directory, and then mount the floppy system over the mntpt directory. First, change to the /home/user1 directory.
  11. Create a subdirectory named mntpt.
  12. Change to the mntpt subdirectory.
  13. Use the touch command to create an empty file named xfile.
  14. Use the touch command again to create a second empty file named yfile.
  15. Use the touch command to create a third empty file named zfile.
  16. Type ls –l to list the contents of the /mntpt directory.
  17. You must get out of the /home/user1/mntpt directory, or you will not be able to mount it. It is common to run into problems in this regard, especially if you want to mount a directory that you are accessing in another shell. Change to the /root directory so you can mount /dev/fd0 onto the

  18. Type mount -t ext2 /dev/fd0 /home/user1/mntpt to mount /dev/fd0 onto the /home/user1/mntpt directory.
  19. Type ls -l /home/user1/mntpt to list the contents of the mntpt directory.
  20. You can now see the contents of the floppy disk, rather than the files named xfile, yfile, and zfile. This is because you used the mntpt directory as a mount point for your floppy disk. Now, type
    umount /home/user1/mntpt

    to unmount the /home/user1/mntpt directory.
  21. Type ls -l /home/user1/mntpt to list the directory again.
  22. Notice that you see the three files you created earlier, rather than the files contained within the /etc directory. This is because you are no longer mounting
    with your floppy device.