mount and umount commands. Mounting file systems

If you need to connect/mount a hard disk with NTFS or ext2, ext3 file system to a computer based on Linux operating system, then you are reading the right article.

Why do it by hand when modern Linux desktop systems do it automatically?

There are some cases where the system linux cannot automatically mount/mount the disk due to some logical disk failures, viruses that infect NTFS/FAT partitions, or because of something else anomalous. To do this, real system administrators do it by hand. And they do it with the mount command.

The Linux mount command is a very flexible tool in the hands of a system administrator. You can use the mount command to mount a network drive, a hard disk partition, or a USB drive.

This article is not a complete, exhaustive description of the mount command (a complete description of the mount command can be found by running the command man mount in the console), but strive to do so. The article on the description of the mount command is constantly being finalized and modified. All suggestions for the article can be left in the comments.

Devices that are this moment connected to the computer, you can see by typing in the console:

This command shows all devices that are connected. They may not be mounted, but connected. On the screen you will see something like this:

Disk /dev/sda: 40.0 GB, 40020664320 bytes
255 heads, 63 sectors/track, 4865 cylinders

Disk identifier: 0x815aa99a Partition table entries not in disk order
Disk /dev/sdb: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x973248ad

Load Device Start End Blocks Id System
/dev/sdb1 * 1 9729 78148161 83 Linux

Disk /dev/sdc: 1027 MB, 1027604480 bytes
32 heads, 62 sectors/track, 1011 cylinders
Units = cylinders of 1984 * 512 = 1015808 bytes
Disk identifier: 0x6f20736b

From the listing above, you can see that the following is connected to the operating system:

  1. two hard drives: /dev/sda - operating system and /dev/sdb - "file dump"
  2. removable USB media: /dev/sdc
Viewing mounted devices is carried out with the command:

After that, you can see on the screen:

/dev/sda1 on / type reiserfs (rw,relatime,notail) tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
/proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
varrun on /var/run type tmpfs (rw,nosuid,mode=0755)
varlock on /var/lock type tmpfs (rw,noexec,nosuid,nodev,mode=1777)
udev on /dev type tmpfs (rw,mode=0755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
fusectl on /sys/fs/fuse/connections type fusectl (rw)
lrm on /lib/modules/2.6.27-14-generic/volatile type tmpfs (rw,mode=755)
/dev/sda3 on /home type ext3 (rw,relatime)
securityfs on /sys/kernel/security type securityfs (rw)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
gvfs-fuse-daemon on /home/user/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=user)
/dev/sdc on /media/USBFlash type vfat (rw,nosuid,nodev,uhelper=hal, shortname=mixed,uid=1000,utf8, umask=077,flush)

  • the first line says that the root FS is reiserfs file system with mount options: read and write access (rw)
  • /dev/sda3 is the /home disk partition
  • /dev/sdc is a mounted removable USB device
The same result can be achieved by looking at the contents of the /etc/mtab file (on some Linux systems, the file is /etc/mnt/tab)
  • hummingbird
    27 March, 09:27

    after I entered this command: sudo chmod -R 0777 /home/roza/Desktop There were no error messages in Debian, but in Mint, during boot, a message appears with the following content:

    The user's $HOME/.dmrc file has incorrect permissions and is ignored. This prevents the session and default language from being saved. This file must be owned by a user and the file must have permission 0644. The user's home folder ($HOME) must be owned by the user and must not be writable by other users.

    Then everything freezes for a few seconds and the desktop opens. And here I can’t use either sudo or just su - the terminal swears not in Russian. Is it possible to restore the rights to ($HOME). Can I do this using the Mint live disk?

  • Mut@NT
    29 March, 12:13

    Hummingbird: Then everything freezes for a few seconds and the desktop opens. And here I can’t use either sudo or just su - the terminal swears not in Russian. Is it possible to restore the rights to ($HOME). Can I do this using the Mint live disk?

    Well, try to return the rights back:
    sudo chmod -R 0644 /home/roza/Desktop

    And the owner:
    sudo chown -R YOUR_LOGIN_IN_MINT /home/roza/Desktop

  • hummingbird
    April 2, 08:43
  • Mut@NT
    April 3, 13:39

    Hummingbird: All the same, nothing happened :(. In general, I reinstalled the partition with mint. The main thing is that I learned how to mount partitions (I understood how it is done, then it’s easier) And I also learned a lesson for myself - you need to distribute rights very carefully. In any case, thanks!

    P.S. The main thing is that you have learned something))

  • Alex Under Construction
    19 May, 08:41

    Thank you.
    A couple of extras.
    1. For example, my hard disk partition did not want to be mounted after connecting to a Windows machine that was infected with viruses. It so happened that the virus threw autorun.exe into the root of my partition and Linux did not want to mount this partition because of this.
    I didn’t want to mount it not because of autorun.exe, but because most likely the Windows were extinguished “incorrectly” and the byte about checking the integrity of the file system remained on ntfs. In this regard, ntfs3g without “force” is afraid to mount such a file system, so as not to damage it.
    2. Since there is a section about “ SMB”, It would be worth mentioning CIFS.
    And as an example, give something like:
    mount -t cifs -o username=domain\user //remote-win2k3-server/C$ /mnt/smb/

  • unimportant
    May 20, 15:26
  • Tonik
    24 May, 03:04
  • Mut@NT
    26 May, 17:27

    Alex Under Construction: Thank you. A couple of additions. 1. For example, my hard disk partition did not want to be mounted after connecting to a Windows machine that was infected with viruses. It so happened that the virus threw autorun.exe into the root of my partition and Linux did not want to mount this partition because of this. I didn’t want to mount it not because of autorun.exe, but because most likely the Windows were extinguished “incorrectly” and the byte about checking the integrity of the file system remained on ntfs. In this regard, ntfs3g without “force” is afraid to mount such a file system, so as not to damage it. 2. Since there is a section about “SMB”, it would be worth mentioning CIFS. And as an example, give something like: mount -t cifs -o username=domain\user //remote-win2k3-server/C$ /mnt/smb/

    Not important: It would be nice if NFS mount was also described

    Thanks for the comment. I'll make additions.

    tonic: But the article helped me. Elementary! - I forgot how to mount ... I quickly ran through the article, and remembered. Thanks a lot to the author!

    Come back often :)

  • Denis
    11 June, 11:47

    Thank you for the article,
    och. intelligibly

  • Ludmila
    July 9, 13:05

    # sudo mount -t smbfs -o username=vasja,password=pupkin //pupkin_v/Video /home/user/video
    does not work, gives help
    usage: ……
    I work in ubuntu. you need to connect the shared windows folder
    Maybe the team is wrong?

  • Mut@NT
    July 9, 22:11

    Ludmila:# sudo mount -t smbfs -o username=vasja,password=pupkin //pupkin_v/Video /home/user/video doesn't work, gives help usage: …… working in ubuntu. you need to connect the shared windows folder Maybe the command is wrong?

    Line
    username=vasja,password=pupkin
    must be replaced with the required parameters. If you connect on behalf of a guest, then you need to be careful there, there are nuances and differences between the Russian and English Windows OS

  • Andrey
    31 August, 10:04

    In ubuntu you need this:
    mount -t cifs -o username=tridge,password=foobar //fjall/test /mnt/smb/fjall

  • CJ
    14 September, 20:28

    cj@Monster:~$ sudo umount /dev/sda1
    umount: /:device is busy. (In some useful cases info about processes that use the device is found by lsof(8) or fuser(1))
    cj@Monster:~$ df -h
    File system Size Use Ext Use% is mounted on
    /dev/sdb1 26G 9.1G 16G 37% /
    none 1.7G 416K 1.7G 1% /dev
    none 1.7G 0 1.7G 0% /dev/shm
    none 1.7G 200K 1.7G 1% /var/run
    none 1.7G 0 1.7G 0% /var/lock
    none 1.7G 0 1.7G 0% /lib/init/rw
    /dev/sdb6 33G 15G 19G 45% /media/4403D3D754B7C8F5
    /dev/sdb5 30G 22G 8.1G 74% /media/Win7
    /dev/sda5 50G 8.9G 41G 18% /media/Other
    /dev/sdc1 373G 372G 946M 100% /media/STORAGE
    /dev/sdb7 94G 88G 5.5G 95% /media/MUSIC & GAMES
    /dev/sda1 26G 9.1G 16G 37% /

  • Vladimir
    15 September, 09:46
  • Mut@NT
    19 September, 20:14

    CJ: The /dev/sda1 drive needs to be mounted, but it claims to be already mounted at “/”, even though Ubuntu's system partition is mounted at that point. Tell me what to do, I'm already tormented :(

    You can show the output of the command:
    sudo fdisk -l

    Vladimir:
    The only remark is the use errors tsya / tsya.-TSYA or -TSYA? Thanks again.:)

    It could be ;) Will need to get the attention of your editor ;)

  • Taras
    27 September, 06:59
  • Mut@NT
    30 September, 06:46

    Taras: The samba mount command does not work.

    What exactly does not work in it?

  • Roman
    November 2, 20:41

    And if the file system is LWM2, and Linux Mint swears?!
    i.e. the command sudo mount -t lwm2 /dev/sdb /home/user/Video is not accepted.

  • zzzubr
    November 2, 22:52

    Mut@NT: sudo mount -t ext3 -o rw /dev/hda3 /home/roza/Desktop
    So? So the mount point is /home/roza/Desktop?

    If everything is mounted for you and the /dev/hda3 file system is visible, but you do not have enough rights, then you just need to add these rights:
    sudo chmod -R 0777 /home/roza/Desktop

    mmm ... it seems to me .. that it was not a very good way ... it would be more correct to enter from the root, because in this way you gave rights to everyone and everything ... and this is not good ...

    IMHO! although they say that there are a million articles, anyway, the article is good) though there are not enough examples ... I would like to see some non-standard chtoli applications ... because everything is easier to digest by examples)
    November 29, 20:33

  • Mut@NT
    5 December, 19:34

    max: It was Windows, the hard drive was divided into 4 logical disks (c, d, e, f). I installed ubuntu 10.04 on the “c” drive, thereby demolishing Windows. Now there is no access and I can not see the rest of the logical drives. Please tell me what to do to get access to them?

  • Ihor
    6 December, 14:41

    >
    >

  • Mut@NT
    14 December, 10:48

    ihor:> Mounting hard disk partitions
    > ... You can take any mount point.
    It seems that in the Big Red Book (I also heard “from Nemeth”) it says: “... it is desirable that there are no files in the folder where you mount, because they will not be visible.”

    Well, it goes without saying.

  • cartoon
    7 January, 22:06

    Mounted iso image

    # sudo mount -t iso9660 -o loop /home/op/iso/1.iso /home/op/disk

    Writes Russian file names with krakozyabry.

  • umnik
    29 March, 16:15

    there are a lot of articles and books, but I see it humanly written, so to speak, on the fingers shown and told for the first time, many thanks to the author, I found a bit for myself, but I couldn’t understand and find this bit for several years. The author is worthy of respect, if such an article fell into my hands about 7 years ago, when I started to surf the expanses of Linux, I would be very happy.

    All told

  • Zlobik
    18 August, 08:09

    Can you please tell me how to clean the mount tails? Thank you.

  • neon
    12 January, 23:29

    A funny thing happened to me here. Tried to make a bootable USB flash drive. formatted the flash with the mkfs command, then according to the recommendations of some “advanced” users. installed the gparted application, gave the flash drive a bootable (active) flag ... And after that miracles began:
    1. the problem is that the mount & umount commands have disappeared
    2. The team was restored, but there is another trouble. when mounting a partition (no matter with which system), the fs is connected in read mode, it is not possible to change access rights. The system simply does not respond to these command keys and says everything is in order, the operation was successful.

    Conclusion I can pick up files from any medium, I can’t give files. I read the article with fstab. Rewrote the file by hand. Didn't make any more changes to it. But an attempt to mount a disk with write and execute permissions still failed. After I demolished gparted and rebooted the system, the fstab file I edited began to work correctly and the mount commands were restored.

    Attention to the question: What is the reason for this behavior of gparted and how did he do it? Well, how to deal with this without deleting gparted?

  • Agatha
    21 January, 23:07

    Great, intelligible articles: this one, “.. SWAP in Linux”, “..what is fstab?”!
    Dear author, please write a couple more, covering such topics as: partitioning, disk partitioning, merging partitions, transferring home to another partition.
    It would be a great collection!

  • Alexander
    7 April, 00:35

    Is it possible to somehow get the source code of this miracle program

  • sbp
    29 June, 01:27

    Tell me what to do?
    Installed Ubuntu12.04 a week ago. After some careless actions, the system crashed. There is 250GB of information on the disk. LiveCD HD sees, but does not start (gives an error). And there is no way to connect it. Here is the result (even in this variant) −
    root@ubuntu:~# sudo mount -t ext4 -o force /dev/sda1 /
    mount: wrong fs type, bad option, bad superblock on /dev/sda1, missing codepage or helper program, or other error helpful information can be found in syslog - try dmesg | tail or something like that

    I tried to restore the system performance according to the recommendations from the sites, but to no avail. When booting from disk, indicates that the boot manager did not detect an operating system.
    Tell me what to do ?, where to "run" ?.

  • cinema
    25 October, 23:50

    Good afternoon. There is a server for a film projector on linux. differs from the usual ones in that it has a Digital Cinema program for showing films through a projector. The motherboard recently died, changed, put another one. Everything has been reloaded. Now the server does not see the portable SATA hard drive. it is connected using a sled to transfer movies to the server (1 movie weighs from 90 to 300 GB). Tell me, plz, through the mount command, can I make it so that he would see it? (power is supplied to the disk, all loops are connected, but it still does not see the disk)

  • If you need to connect/mount a hard disk with NTFS or ext2, ext3 file system to a computer based on Linux operating system, then you are reading the right article.

    Why do it by hand when modern Linux desktop systems do it automatically?


    There are some cases where the system linux cannot automatically mount/mount the disk due to some logical disk failures, viruses that infect NTFS/FAT partitions, or because of something else anomalous. To do this, real system administrators do it by hand. And they do it with the mount command.

    The Linux mount command is a very flexible tool in the hands of a system administrator. You can use the mount command to mount a network drive, a hard disk partition, or a USB drive.

    This article is not a complete, exhaustive description of the mount command (a complete description of the mount command can be found by running the command man mount in the console), but strive to do so. The article on the description of the mount command is constantly being finalized and modified. All suggestions for the article can be left in the comments.

    Devices that are currently connected to the computer can be viewed by typing in the console:

    This command shows all devices that are connected. They may not be mounted, but connected. On the screen you will see something like this:

    Disk /dev/sda: 40.0 GB, 40020664320 bytes
    255 heads, 63 sectors/track, 4865 cylinders

    Disk identifier: 0x815aa99a

    Partition table entries not in disk order
    Disk /dev/sdb: 80.0 GB, 80026361856 bytes
    255 heads, 63 sectors/track, 9729 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Disk identifier: 0x973248ad

    Load Device Start End Blocks Id System
    /dev/sdb1 * 1 9729 78148161 83 Linux

    Disk /dev/sdc: 1027 MB, 1027604480 bytes
    32 heads, 62 sectors/track, 1011 cylinders
    Units = cylinders of 1984 * 512 = 1015808 bytes
    Disk identifier: 0x6f20736b

    From the listing above, you can see that the following is connected to the operating system:

    1. two hard drives: /dev/sda - operating system and /dev/sdb - "file dump"
    2. removable USB media: /dev/sdc

    Viewing mounted devices is carried out with the command:

    After that, you can see on the screen:

    /dev/sda1 on / type reiserfs (rw,relatime,notail) tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
    /proc on /proc type proc (rw,noexec,nosuid,nodev)
    sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
    varrun on /var/run type tmpfs (rw,nosuid,mode=0755)
    varlock on /var/lock type tmpfs (rw,noexec,nosuid,nodev,mode=1777)
    udev on /dev type tmpfs (rw,mode=0755)
    tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
    devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
    fusectl on /sys/fs/fuse/connections type fusectl (rw)
    lrm on /lib/modules/2.6.27-14-generic/volatile type tmpfs (rw,mode=755)
    /dev/sda3 on /home type ext3 (rw,relatime)
    securityfs on /sys/kernel/security type securityfs (rw)
    binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
    gvfs-fuse-daemon on /home/user/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=user)
    /dev/sdc on /media/USBFlash type vfat (rw,nosuid,nodev,uhelper=hal, shortname=mixed,uid=1000,utf8, umask=077,flush)

    • the first line says that the root FS is reiserfs file system with mount options: read and write access (rw)
    • /dev/sda3 is the /home disk partition
    • /dev/sdc is a mounted removable USB device

    Mounting hard disk partitions

    Top

    From the above example, you can see that the /dev/sdb hard drive is connected but not mounted. Mount the /dev/sdb1 hard disk partition to the /dev/sda disk. Select a mount point, for example - /home/user/Video. You can take any mount point.

    # sudo mount /dev/sdb1 /home/ user/Video

    where user is the name of your username.

    Everything is very simple, first the mount command is written, then what needs to be attached is written (the number shows the partition number, we have only one), and then where to attach it. Almost always this is enough. The disk, with the mount command, is mounted to the specified folder. In some cases, when there are logical errors on the partitions of the connected hard disk, you must additionally specify the file system type. In this case, we have ext3.

    # sudo mount -t ext3 /dev/sdb1 /home/ user/Video

    This parameter can also take the following values:

    • -t ntfs or -t ntfs-3g
    • -t vfat
    • -t iso9660

    Respectively for NTFS, FAT and CD-ROM file systems. The latter is needed only for connecting CD / DVD-ROM devices and the .iso disk image.

    To manually set access parameters to a mounted partition, specify the parameter:

    • -o rw
    • -o ro

    The first allows reading and writing, the second only reading. Well, for example, like this:

    # sudo mount -t ext3 -o rw /dev/sdb1 /home/user/Video

    Additional options that help in some cases:

    # sudo mount -t ext3 -o rw,iocharset=utf8,codepage=866 /dev/sdb1 /home/user/Video

    The first explicitly sets the encoding of the system locale, in our case it is utf8 (it has its own for different distributions, but more often utf8), and the other adds support for the Russian language.

    If, nevertheless, the hard drive refuses to be mounted in the Linux operating system, then you can mount it manually. Parameter -o force allows you to force mount hard disk partitions in Linux. Well, for example, like this:

    # sudo mount -t ext3 -o force /dev/sdb1 /home/user/Video

    For example, I had a hard disk partition that did not want to be mounted after connecting to a Windows machine that was infected with viruses. It so happened that the virus threw autorun.exe into the root of my partition and Linux did not want to mount this partition because of this. The above mount command option helped to mount the infected partition. Then the virus was successfully removed manually.

    There is a unique opportunity in Linux to specify a folder mirror, which receives all the rights and actions available on the folder. Let's say the /dev/sdb1 partition is also used to store documents. Mirror it in /home/user/Documents:

    # sudo mount --bind /home/user/Videos /home/user/Documents

    The action of the mount --bind command is similar to DOS subst.

    You can view full information (available disk space, free space) about mounted devices with the command:

    Unmounting devices is done with the command:

    # sudo umount /dev/sdb1

    or

    # sudo umount /home/user/Video

    Mounting CD/DVD-ROMs

    Top

    If you need to mount a CD/DVD-ROM, then mounting the CD/DVD-ROM is done in exactly the same way, using the same mount command that was given above:

    # sudo mount -t iso9660 -o ro /dev/cdrom /cd

    Only when mounting a CD-ROMyou need to specify the iso9660 file system type.

    Now that the file system is created, you can mount the partition. Initially, it will be empty, because. the system did not have access to the file system to add files to it. The command to mount filesystems is mount, its syntax is as follows:

    Option -t is used to indicate the type of file system that is supposed to be on the partition. Here are the file systems that you will encounter most often: ext2FS (GNU/Linux file system) or ext3FS (an enhanced version of ext2FS with journaling capabilities), VFAT (for all DOS/Windows partitions) ® : FAT 12, 16 or 32) and ISO9660 (CD-ROM's file system). If you don't specify any type,mount will try to determine on its own which filesystem is on the partition by reading the superblock.

    Option -o is used to specify one or more mount options. The options applicable to individual file systems will depend on the file system being used. See the mount(8) manual page for more information.

    Now that you've mounted your new partition, it's time to copy the entire directory into it./usr :

    So to unmount our new partition, we can type:

    This command disables the device and, if possible, closes all open handles for that device. You can usually eject a disk with the command eject<точка монтирования|устройство> . Well... if the team eject couldn't do anything and you don't want to reboot, use lazy unmount.

    Due to the fact that this section will "become" our catalog/usr , we need to inform the system about it. To do this, we will edit the file/etc/fstab . It makes it possible to automate the mounting of certain filesystems, especially when the system boots. It contains lines describing file systems, their mount points, and other options. Here is an example of such a file:

    /dev/hda1 / ext2 defaults 1 1 /dev/hda5 /home ext2 defaults 1 2 /dev/hda6 swap swap defaults 0 0 /dev/hdc /mnt/cdrom auto umask=0,user,noauto,ro,exec,users 0 0 none /mnt/floppy supermount dev=/dev/fd0,fs=ext2:vfat,--,sync,umask=0 0 0 none /proc proc defaults 0 0 none /dev/pts devpts mode=0622 0 0

    Each line consists of:

    • the device containing the file system;
    • mount points;
    • file system type;
    • mount options;
    • flag for backup utilitydump ;
    • order of checking the file system by means of fsck (FileSystem Check).

    Alwaysthere is an entry for the root file system. Sections swap are special so they are not visible in the tree structure, and the mount point field for these partitions always contains the keyword swap . As for the file system/proc , it will be described in more detail in Chapter 10,/proc file system . Another special file system is/dev/pts .

    At the moment we have moved the entire hierarchy/usr to /dev/hdb1 , and now we need this partition to be mounted as/usr during system boot. To do this, add the following item to the file/etc/fstab :

    /dev/hdb1 /usr ext2 defaults 1 2

    Now the partition will be mounted on every boot and checked for errors if necessary.

    There are two special options: noauto and user . noauto option specifies that the filesystem should not be mounted at boot, but only mounted when you want to. Option user indicates that any user will be able to mount or unmount this file system. These two options are commonly used for CD-ROM drives and disk drives. There are many more options, but for the file/etc/fstab there is a page man (fstab(5)), which you can read for more information.

    One of the advantages of using/etc/fstab is a simplification of the command syntaxmount

    Linux uses the mount/umount commands to mount/unmount a file system.

    mount command syntax

    Mount [-lhV] mount -a [-fFnrsvw] [-t vfstype] [-O optlist] mount [-fnrsvw] [-o option[,option]...] device|dir mount [-fnrsvw] [-t vfstype] [-o options] device|dir

    umount command syntax

    umount [-hV] umount -a [-dflnrv] [-t vfstype] [-O options] umount [-dflnrv] (dir|device)...

    Descriptionmount

    All files in Linux are organized into a file system. These files can be distributed across different media (virtual, physical or network). The mount command mounts a device and allows files stored on it to be attached to a shared directory tree.

    Usually the mount command is written like this

    Mount

    Or specify the type of file system

    Mount -t type_fs device dir

    in this way we tell the kernel to attach the device's file system (by specifying its type instead of type) to the dir directory.

    If we only know the directory or device, for example

    Mount /dir

    mount looks for a mount point entry in /etc/fstab and tries to mount it.

    Descriptionumount

    This command separates the device's file system from the general file system. Unmounting is not possible if the media's file system is busy, such as when a process is running, a swap file is in use, or you are currently on a mount point on the same file system.

    Files /etc/fstab and /etc/mtab

    Umount -a [-t type] [-O optlist]

    specifies that all filesystems mentioned in fstab (of the appropriate type/options) should be unmounted and stopped (except those with the noauto option specified).

    When mounting the file system mentioned in fstab and mtab, only the device or mount point needs to be specified. Mounted file systems are stored in etc /mtab.

    Not root alone

    Typically, only the superuser has permission to mount a file system. However, when the string contains the word user, the normal user can also mount.

    Let's write this command

    /dev/cdrom /cd iso9660 ro,user,noauto,unhide

    each user can mount an iso9660 file system on a CD-ROM using the command

    Mount /dev/cdrom

    Mount /cd

    The bind command lets you mount part of the file system to a different directory without removing the original mount point.

    The syntax of this command

    Mount --bind olddir newdir

    or use the key

    Mount -B olddir newdir

    After issuing this command, the contents of the olddir directory will be available in both directories. You can also mount individual files this way:

    Mount --bind foo foo

    Moving a Mounted File System

    Linux has the ability to automatically move mounted files. This is done by the team

    Mount --move olddir newdir

    Mount -M olddir newdir

    now the contents of the olddir directory will appear in newdir as well. The mount point will be the olddir directory.

    Basic Keys

    A - mounts all filesystems that are mentioned in the /etc/tab file (except those marked as "noauto" or previously mounted);

    D - everything except the mount system call itself. When you add the -v switch, the system tries to figure out what mount is actually trying to do;

    F - mounting a damaged partition, which is unsafe / canceling the recording of all questions if mounting is carried out in read mode;

    N - mount files not mentioned in /etc/mtab;

    R - mount the file system in read-only mode;

    W, --rw - mount the filesystem by default in read/write mode.

    To unmount, just specify the mount point, device name, and the -a/-A option. For forced unmounting of the system, you need to enter the -f switch. However, it is not recommended to do this, as this can damage data in the file system and disrupt the operation of the OS.

    If you need to connect/mount a hard disk with NTFS or ext2, ext3 file system to a computer based on Linux operating system, then you are reading the right article.

    Why do it by hand when modern Linux desktop systems do it automatically?

    There are some cases where the system linux cannot automatically mount/mount the disk due to some logical disk failures, viruses that infect NTFS/FAT partitions, or because of something else anomalous. To do this, real system administrators do it by hand. And they do it with the mount command.

    The Linux mount command is a very flexible tool in the hands of a system administrator. You can use the mount command to mount a network drive, a hard disk partition, or a USB drive.

    This article is not a complete, exhaustive description of the mount command (a complete description of the mount command can be found by running the command man mount in the console), but strive to do so. The article on the description of the mount command is constantly being finalized and modified. All suggestions for the article can be left in the comments.

    Devices that are currently connected to the computer can be viewed by typing in the console:

    This command shows all devices that are connected. They may not be mounted, but connected. On the screen you will see something like this:

    Disk /dev/sda: 40.0 GB, 40020664320 bytes
    255 heads, 63 sectors/track, 4865 cylinders

    Disk identifier: 0x815aa99a Partition table entries not in disk order
    Disk /dev/sdb: 80.0 GB, 80026361856 bytes
    255 heads, 63 sectors/track, 9729 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Disk identifier: 0x973248ad

    Load Device Start End Blocks Id System
    /dev/sdb1 * 1 9729 78148161 83 Linux

    Disk /dev/sdc: 1027 MB, 1027604480 bytes
    32 heads, 62 sectors/track, 1011 cylinders
    Units = cylinders of 1984 * 512 = 1015808 bytes
    Disk identifier: 0x6f20736b

    From the listing above, you can see that the following is connected to the operating system:

    1. two hard drives: /dev/sda - operating system and /dev/sdb - "file dump"
    2. removable USB media: /dev/sdc
    Viewing mounted devices is carried out with the command:

    After that, you can see on the screen:

    /dev/sda1 on / type reiserfs (rw,relatime,notail) tmpfs on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
    /proc on /proc type proc (rw,noexec,nosuid,nodev)
    sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
    varrun on /var/run type tmpfs (rw,nosuid,mode=0755)
    varlock on /var/lock type tmpfs (rw,noexec,nosuid,nodev,mode=1777)
    udev on /dev type tmpfs (rw,mode=0755)
    tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
    devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620)
    fusectl on /sys/fs/fuse/connections type fusectl (rw)
    lrm on /lib/modules/2.6.27-14-generic/volatile type tmpfs (rw,mode=755)
    /dev/sda3 on /home type ext3 (rw,relatime)
    securityfs on /sys/kernel/security type securityfs (rw)
    binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
    gvfs-fuse-daemon on /home/user/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=user)
    /dev/sdc on /media/USBFlash type vfat (rw,nosuid,nodev,uhelper=hal, shortname=mixed,uid=1000,utf8, umask=077,flush)

    • the first line says that the root FS is reiserfs file system with mount options: read and write access (rw)
    • /dev/sda3 is the /home disk partition
    • /dev/sdc is a mounted removable USB device
    The same result can be achieved by looking at the contents of the /etc/mtab file (on some Linux systems, the file is /etc/mnt/tab)
  • hummingbird
    27 March, 09:27

    after I entered this command: sudo chmod -R 0777 /home/roza/Desktop There were no error messages in Debian, but in Mint, during boot, a message appears with the following content:

    The user's $HOME/.dmrc file has incorrect permissions and is ignored. This prevents the session and default language from being saved. This file must be owned by a user and the file must have permission 0644. The user's home folder ($HOME) must be owned by the user and must not be writable by other users.

    Then everything freezes for a few seconds and the desktop opens. And here I can’t use either sudo or just su - the terminal swears not in Russian. Is it possible to restore the rights to ($HOME). Can I do this using the Mint live disk?

  • Mut@NT
    29 March, 12:13

    Hummingbird: Then everything freezes for a few seconds and the desktop opens. And here I can’t use either sudo or just su - the terminal swears not in Russian. Is it possible to restore the rights to ($HOME). Can I do this using the Mint live disk?

    Well, try to return the rights back:
    sudo chmod -R 0644 /home/roza/Desktop

    And the owner:
    sudo chown -R YOUR_LOGIN_IN_MINT /home/roza/Desktop

  • hummingbird
    April 2, 08:43
  • Mut@NT
    April 3, 13:39

    Hummingbird: All the same, nothing happened :(. In general, I reinstalled the partition with mint. The main thing is that I learned how to mount partitions (I understood how it is done, then it’s easier) And I also learned a lesson for myself - you need to distribute rights very carefully. In any case, thanks!

    P.S. The main thing is that you have learned something))

  • Alex Under Construction
    19 May, 08:41

    Thank you.
    A couple of extras.
    1. For example, my hard disk partition did not want to be mounted after connecting to a Windows machine that was infected with viruses. It so happened that the virus threw autorun.exe into the root of my partition and Linux did not want to mount this partition because of this.
    I didn’t want to mount it not because of autorun.exe, but because most likely the Windows were extinguished “incorrectly” and the byte about checking the integrity of the file system remained on ntfs. In this regard, ntfs3g without “force” is afraid to mount such a file system, so as not to damage it.
    2. Since there is a section about “ SMB”, It would be worth mentioning CIFS.
    And as an example, give something like:
    mount -t cifs -o username=domain\user //remote-win2k3-server/C$ /mnt/smb/

  • unimportant
    May 20, 15:26
  • Tonik
    24 May, 03:04
  • Mut@NT
    26 May, 17:27

    Alex Under Construction: Thank you. A couple of additions. 1. For example, my hard disk partition did not want to be mounted after connecting to a Windows machine that was infected with viruses. It so happened that the virus threw autorun.exe into the root of my partition and Linux did not want to mount this partition because of this. I didn’t want to mount it not because of autorun.exe, but because most likely the Windows were extinguished “incorrectly” and the byte about checking the integrity of the file system remained on ntfs. In this regard, ntfs3g without “force” is afraid to mount such a file system, so as not to damage it. 2. Since there is a section about “SMB”, it would be worth mentioning CIFS. And as an example, give something like: mount -t cifs -o username=domain\user //remote-win2k3-server/C$ /mnt/smb/

    Not important: It would be nice if NFS mount was also described

    Thanks for the comment. I'll make additions.

    tonic: But the article helped me. Elementary! - I forgot how to mount ... I quickly ran through the article, and remembered. Thanks a lot to the author!

    Come back often :)

  • Denis
    11 June, 11:47

    Thank you for the article,
    och. intelligibly

  • Ludmila
    July 9, 13:05

    # sudo mount -t smbfs -o username=vasja,password=pupkin //pupkin_v/Video /home/user/video
    does not work, gives help
    usage: ……
    I work in ubuntu. you need to connect the shared windows folder
    Maybe the team is wrong?

  • Mut@NT
    July 9, 22:11

    Ludmila:# sudo mount -t smbfs -o username=vasja,password=pupkin //pupkin_v/Video /home/user/video doesn't work, gives help usage: …… working in ubuntu. you need to connect the shared windows folder Maybe the command is wrong?

    Line
    username=vasja,password=pupkin
    must be replaced with the required parameters. If you connect on behalf of a guest, then you need to be careful there, there are nuances and differences between the Russian and English Windows OS

  • Andrey
    31 August, 10:04

    In ubuntu you need this:
    mount -t cifs -o username=tridge,password=foobar //fjall/test /mnt/smb/fjall

  • CJ
    14 September, 20:28

    cj@Monster:~$ sudo umount /dev/sda1
    umount: /:device is busy. (In some useful cases info about processes that use the device is found by lsof(8) or fuser(1))
    cj@Monster:~$ df -h
    File system Size Use Ext Use% is mounted on
    /dev/sdb1 26G 9.1G 16G 37% /
    none 1.7G 416K 1.7G 1% /dev
    none 1.7G 0 1.7G 0% /dev/shm
    none 1.7G 200K 1.7G 1% /var/run
    none 1.7G 0 1.7G 0% /var/lock
    none 1.7G 0 1.7G 0% /lib/init/rw
    /dev/sdb6 33G 15G 19G 45% /media/4403D3D754B7C8F5
    /dev/sdb5 30G 22G 8.1G 74% /media/Win7
    /dev/sda5 50G 8.9G 41G 18% /media/Other
    /dev/sdc1 373G 372G 946M 100% /media/STORAGE
    /dev/sdb7 94G 88G 5.5G 95% /media/MUSIC & GAMES
    /dev/sda1 26G 9.1G 16G 37% /

  • Vladimir
    15 September, 09:46
  • Mut@NT
    19 September, 20:14

    CJ: The /dev/sda1 drive needs to be mounted, but it claims to be already mounted at “/”, even though Ubuntu's system partition is mounted at that point. Tell me what to do, I'm already tormented :(

    You can show the output of the command:
    sudo fdisk -l

    Vladimir:
    The only remark is the use errors tsya / tsya.-TSYA or -TSYA? Thanks again.:)

    It could be ;) Will need to get the attention of your editor ;)

  • Taras
    27 September, 06:59
  • Mut@NT
    30 September, 06:46

    Taras: The samba mount command does not work.

    What exactly does not work in it?

  • Roman
    November 2, 20:41

    And if the file system is LWM2, and Linux Mint swears?!
    i.e. the command sudo mount -t lwm2 /dev/sdb /home/user/Video is not accepted.

  • zzzubr
    November 2, 22:52

    Mut@NT: sudo mount -t ext3 -o rw /dev/hda3 /home/roza/Desktop
    So? So the mount point is /home/roza/Desktop?

    If everything is mounted for you and the /dev/hda3 file system is visible, but you do not have enough rights, then you just need to add these rights:
    sudo chmod -R 0777 /home/roza/Desktop

    mmm ... it seems to me .. that it was not a very good way ... it would be more correct to enter from the root, because in this way you gave rights to everyone and everything ... and this is not good ...

    IMHO! although they say that there are a million articles, anyway, the article is good) though there are not enough examples ... I would like to see some non-standard chtoli applications ... because everything is easier to digest by examples)
    November 29, 20:33

  • Mut@NT
    5 December, 19:34

    max: It was Windows, the hard drive was divided into 4 logical disks (c, d, e, f). I installed ubuntu 10.04 on the “c” drive, thereby demolishing Windows. Now there is no access and I can not see the rest of the logical drives. Please tell me what to do to get access to them?

  • Ihor
    6 December, 14:41

    >
    >

  • Mut@NT
    14 December, 10:48

    ihor:> Mounting hard disk partitions
    > ... You can take any mount point.
    It seems that in the Big Red Book (I also heard “from Nemeth”) it says: “... it is desirable that there are no files in the folder where you mount, because they will not be visible.”

    Well, it goes without saying.

  • cartoon
    7 January, 22:06

    Mounted iso image

    # sudo mount -t iso9660 -o loop /home/op/iso/1.iso /home/op/disk

    Writes Russian file names with krakozyabry.

  • umnik
    29 March, 16:15

    there are a lot of articles and books, but I see it humanly written, so to speak, on the fingers shown and told for the first time, many thanks to the author, I found a bit for myself, but I couldn’t understand and find this bit for several years. The author is worthy of respect, if such an article fell into my hands about 7 years ago, when I started to surf the expanses of Linux, I would be very happy.

    All told

  • Zlobik
    18 August, 08:09

    Can you please tell me how to clean the mount tails? Thank you.

  • neon
    12 January, 23:29

    A funny thing happened to me here. Tried to make a bootable USB flash drive. formatted the flash with the mkfs command, then according to the recommendations of some “advanced” users. installed the gparted application, gave the flash drive a bootable (active) flag ... And after that miracles began:
    1. the problem is that the mount & umount commands have disappeared
    2. The team was restored, but there is another trouble. when mounting a partition (no matter with which system), the fs is connected in read mode, it is not possible to change access rights. The system simply does not respond to these command keys and says everything is in order, the operation was successful.

    Conclusion I can pick up files from any medium, I can’t give files. I read the article with fstab. Rewrote the file by hand. Didn't make any more changes to it. But an attempt to mount a disk with write and execute permissions still failed. After I demolished gparted and rebooted the system, the fstab file I edited began to work correctly and the mount commands were restored.

    Attention to the question: What is the reason for this behavior of gparted and how did he do it? Well, how to deal with this without deleting gparted?

  • Agatha
    21 January, 23:07

    Great, intelligible articles: this one, “.. SWAP in Linux”, “..what is fstab?”!
    Dear author, please write a couple more, covering such topics as: partitioning, disk partitioning, merging partitions, transferring home to another partition.
    It would be a great collection!

  • Alexander
    7 April, 00:35

    Is it possible to somehow get the source code of this miracle program

  • sbp
    29 June, 01:27

    Tell me what to do?
    Installed Ubuntu12.04 a week ago. After some careless actions, the system crashed. There is 250GB of information on the disk. LiveCD HD sees, but does not start (gives an error). And there is no way to connect it. Here is the result (even in this variant) −
    root@ubuntu:~# sudo mount -t ext4 -o force /dev/sda1 /
    mount: wrong fs type, bad option, bad superblock on /dev/sda1, missing codepage or helper program, or other error In some cases, useful information can be found in the syslog - try dmesg | tail or something like that

    I tried to restore the system performance according to the recommendations from the sites, but to no avail. When booting from disk, indicates that the boot manager did not detect an operating system.
    Tell me what to do ?, where to "run" ?.

  • cinema
    25 October, 23:50

    Good afternoon. There is a server for a film projector on linux. differs from the usual ones in that it has a Digital Cinema program for showing films through a projector. The motherboard recently died, changed, put another one. Everything has been reloaded. Now the server does not see the portable SATA hard drive. it is connected using a sled to transfer movies to the server (1 movie weighs from 90 to 300 GB). Tell me, plz, through the mount command, can I make it so that he would see it? (power is supplied to the disk, all loops are connected, but it still does not see the disk)