Mounting a disk in Ubuntu. Automatically mounting partitions with ntfs when booting ubuntu
And now about the problem that is inherent in all Debian distributions (Ubuntu included).
If resources are mounted using the above method, then when you reboot or shut down the system, you will see the following message:
1.CIFS VFS: No Response for Cmd
This is due to the fact that first all services are disabled (S20sendsigs), and then an attempt is made to unmount network resources (S31umountnfs.sh). But the services are already disabled. I encountered this problem back in Ubuntu 8.04. It remains in Ubuntu 9.04.
To eliminate it, you need to edit the run levels, namely rc0 and rc6. To do this, run the commands:
cd /etc/rc0.d
The same actions must be done in the rc6.d directory
cd /etc/rc6.d
sudo mv S31umountnfs.sh S19umountnfs.sh
Now, when you shut down or reboot the system, network resources are first unmounted, and then services are disabled.
mount
Material from Wikipedia - the free encyclopedia
Usage
mount /dev/cdrom /mnt/cdrom Device /dev/cdrom mounted in directory /mnt/cdrom, if it exists. Starting from the moment of mounting until the user unmounts the file system (or something else is mounted there) in the directory /mnt/cdrom will contain the device directory tree /dev/cdrom; those files and subdirectories that were previously located in /mnt/cdrom, will be saved, but will not be available until the device is unmounted /dev/cdrom.Unmounting with umount
To unmount, just specify the mount point or device name.umount /dev/cdrom
Mounting USB drives
For the common case where the USB drive has a FAT32 file system, the mount command looks like this:mount -t vfat -o codepage=866,iocharset=utf8 /dev/sda1 /mnt The codepage parameter is necessary so that the names of the created files are displayed correctly in older operating systems (for example, DOS). If the distribution uses something other than UTF-8 as the system locale encoding, then it must be specified in the iocharset parameter like this:
mount -t vfat -o codepage=866,iocharset=koi8-r /dev/sda1 /mnt The actual encoding used can be determined by running the locale command.
Useful options when mounting Flash drives are sync and flush. The first causes the write buffer to be permanently flushed to the disk, so that data is not lost when the flash disk is removed without being unmounted. A side effect of this mounting is a significant decrease in recording speed. The second option (available only in newer Linux kernels) causes the buffer to be flushed to disk after the last file has been written. This also helps preserve data if the disk is removed without unmounting, but does not lead to a drop in writing speed.
Mounting NTFS disks/partitions
mount -t ntfs -o noatime,users,rw,fmask=111,dmask=000,locale=ru_RU.UTF-8 /dev/sda1 /mnt/win_xpMounting disk images
If you have a disk image in the form of an iso file, then to mount it you need to specify the -o loop parameter and, usually, the file system type -t iso9660 (optional) (file.iso is the name of the image file, and /mnt/iso is the dot mount):mount -o loop -t iso9660 file.iso /mnt/iso Mounting images in non-iso formats will require converting to an iso image or using an emulator. To convert, you can use the command line utilities (see below) or the kiso GUI utility. Mounting disk images in Linux
bin/cue images
To convert a bin/cue image to an iso image, you can use the bchunk converter:bchunk image.bin image.cue image.iso
Mounting NFS network drives
mount 172.22.2.1:/mnt/iso/ /mnt/iso/Mounting SMB network drives
An example of mounting network SMB resources:mount -t smbfs -o username=user,password=pass //server/dir /mnt/localdir/ mount -t cifs -o username=user,password=pass //server/dir /mnt/localdir/ (The smbfs utility has been replaced in the linux kernel to a compatible cifs.) notes:
- "-t cifs" can sometimes be omitted if the name of the mounted device is "//server/dir"
- if for authorization it is necessary to specify the user's domain name, then in the parameters of the mount command it is specified as "-o username=domain\\user", however, when specifying the resource to be mounted in /etc/fstab, the user name is specified as "domain/user":
Mounting FTP servers
curlftpfs -v -o iocharset=UTF-8 ftp://user: [email protected]/ /mnt/ftpMounting a file system directory from another computer via ssh
The Fuse kernel module (adopted into the official kernel branch since 2.6) allows unprivileged users to mount various file systems.To work, you need to add the user to the fuse group, you can do it like this:
usermod -G -a fuse user or
adduser user fuse or manually editing the /etc/group. It is also necessary that the fuse kernel module be loaded:
modprobe fuse After this, you can mount the directory of another computer using sshfs:
sshfs user@udalenniy_server:/tmp ~/udalennaya_papka To unmount you need to enter the command:
fusermount -u ~/udalennaya_papka
Mount options
If necessary, you can specify additional mount parameters when executing the mount command.-t File system type
Usually, when mounted, it is determined automatically or taken from the configuration file (see below). But in some cases you need to specify the file system type explicitly. For example, when mounting a DVD with the UDF file system.mount /dev/cdrom /mnt/dvd -t udf If you specify the wrong file system type, the mount command will generate an error message
mount: wrong fs type, bad option, bad superblock on /dev/cdrom, missing codepage or other error In some cases useful info is found in syslog - try dmesg | tail or so and advises you to look at the end of the system message file.
Unable to identify CD-ROM format. If the mount is successful, it will usually indicate that the CD is mounted (by default) in read-only mode.
mount: block device /dev/cdrom is write-protected, mounting read-only
-o Access Attributes
- Read-only (ro) or read-write (rw) access
- Allowing or prohibiting programs from running (noexec)
mount -t vfat -o rw,noexec,iocharset=utf8,codepage=866 /dev/sda1 /mnt/usb Example 2 (for example, mounting an ntfs partition with Windows XP installed):
mount -t ntfs -o noatime,users,rw,fmask=111,dmask=000,locale=ru_RU.UTF-8 /dev/sda1 /mnt/win_xp Example 3 (remount the device with read-write access (rw ))
mount -o remount,rw /dev/sda2
mount --bind
The mount command with the --bind switch or the short -B switch is used on Linux kernel systems (starting with 2.4.0) to create a directory synonym in the file system tree. For example, the command:mount --bind /mnt/cdrom/Files /var/ftp/cdrom will allow you to access files from /mnt/cdrom/Files via the path /var/ftp/cdrom, where /var/ftp/cdrom is some already existing (possibly empty) directory (its actual contents will not be available until unmounted). You can also write -o bind instead of a separate --bind option, which will have a similar effect. This also allows you to add a rule to the /etc/fstab file for mounting at system startup:
/olddir /newdir none bind An advantage of this method of creating directory links over symbolic links is the ability to bypass file system access restrictions imposed on processes running in a chroot environment or servers that use the chroot principle. For example, the FTP server proftpd makes symbolic links pointing to files and directories outside a specific directory unavailable. The action of the mount --bind command is similar to DOS's subst .
List of mounted file systems
Running the mount command without parameters displays a list of mounted file systems:/dev/md/5 on / type reiserfs (rw,noatime) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw,nosuid,nodev,noexec) udev on /dev type tmpfs (rw,nosuid) devpts on /dev/pts type devpts (rw,nosuid,noexec) /dev/md/4 on /files type xfs (rw,noatime) /dev/sda3 on /mnt/a type ext3 (rw,noatime) /dev/ sdd2 on /mnt/docs type reiserfs (rw,noatime) shm on /dev/shm type tmpfs (rw,noexec,nosuid,nodev) usbfs on /proc/bus/usb type usbfs (rw,noexec,nosuid,devmode=0664 ,devgid=85) binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev) nfsd on /proc/fs/nfs type nfsd (rw,noexec,nosuid,nodev) //ax2/i on /mnt/smb type smbfs (0) 172.22.2.1:/files on /mnt/files type nfs (rw,addr=172.22.2.1) This example shows many mounted file systems (FS).
- the first line states that the corresponding lines act as the root file system. Sample contents for this file:
## NOTE: If your BOOT partition is ReiserFS, add the notail option to opts. #/dev/BOOT /boot ext2 noauto,noatime 1 2 /dev/sda5 / reiserfs noatime 0 1 /dev/sda1 none swap sw 0 0 /dev/cdrom /mnt/cdrom iso9660 noauto,ro 0 0 #/dev/fd0 /mnt/floppy auto noauto 0 0 # NOTE: The next line is critical for boot! proc /proc proc defaults 0 0 # glibc 2.2 and above expects tmpfs to be mounted at /dev/shm for # POSIX shared memory (shm_open, shm_unlink). # (tmpfs is a dynamically expandable/shrinkable ramdisk, and will # use almost no memory if not populated with files) shm /dev/shm tmpfs nodev,nosuid,noexec 0 0 In the future, it will be possible to specify only the device name or dot in the mount command mount - all additional parameters will be taken from the configuration file. For example, for this configuration, the command mount /mnt/cdrom would be equivalent to running the command
mount /dev/cdrom /mnt/cdrom -t iso9660 -o noauto,ro Another purpose of the configuration file is to automatically mount file systems when the system boots. If you do not want to mount certain file systems, then you need to specify the noauto parameter for them in the configuration file.
If you need to connect/mount a hard drive with the NTFS or ext2, ext3 file system to a computer based on the Linux operating system, then you are reading the right article.
Why do it manually if modern Linux desktop systems do it automatically?
There are some cases when the system Linux cannot automatically mount/connect a disk due to some logical failures of the disk, viruses that infected NTFS/FAT partitions, or due to something else anomalous. To do this, real system administrators do it manually. And they do this with the mount command.
The mount command in Linux is a very flexible tool in the hands of a system administrator. You can use the mount command to mount a network drive, hard drive partition, or USB drive.
This article is not a complete, exhaustive description of the mount command (a full description of the mount command can be found by running the man mount command in the console), but it strives to do so. The article describing the mount command is constantly being updated and modified. You can leave all your suggestions regarding the article in the comments.
The 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 they are 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 are 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
Device Load 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:
- two hard drives: /dev/sda - operating system and /dev/sdb - “file trash”
- removable USB drive: /dev/sdc
After this 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 states that the root file system is the reiserfs file system with mount parameters: read and write access (rw)
- /dev/sda3 is the /home disk partition
- /dev/sdc is a mounted removable USB device
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 file $HOME/.dmrc has incorrect permissions and is ignored. This prevents the default session and language from being saved. The owner of this file must be the 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 now I can’t use either sudo or just su - the terminal is not swearing in Russian. Is it possible to restore rights to ($HOME). Maybe this can be done using a Mint live disk?
29 March, 12:13
Hummingbird: Then everything freezes for a few seconds and the desktop opens. And now I can’t use either sudo or just su - the terminal is not swearing in Russian. Is it possible to restore rights to ($HOME). Maybe this can be done using a 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
2 April, 08:43
3 April, 13:39
Hummingbird: Still, nothing worked :(. In general, I reinstalled the partition with Mint. The main thing is that I learned how to mount partitions (I understood how it’s done, then it’s easier) And I also learned a lesson for myself - you need to distribute rights very carefully. Thanks anyway!
P.S. The main thing is that you learned something))
19 May, 08:41
Thank you.
A couple of additions.
1. For example, my hard drive 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 at the root of my partition and because of this Linux did not want to mount this partition.
I didn’t want to mount it not because of autorun.exe, but because most likely the Windows were extinguished “incorrectly” and there was a byte on ntfs about checking the integrity of the file system. In this regard, ntfs3g without “force” is afraid to mount such a FS, 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/
20 May, 15:26
24 May, 03:04
26 May, 17:27
Alex Under Construction: Thank you. A couple of additions. 1. For example, my hard drive 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 at the root of my partition and because of this Linux did not want to mount this partition. I didn’t want to mount it not because of autorun.exe, but because most likely the Windows were extinguished “incorrectly” and there was a byte on ntfs about checking the integrity of the file system. In this regard, ntfs3g without “force” is afraid to mount such a FS, 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 mounting was also described
Thanks for the comment. I'll add some additions.
Tonik: And the article helped me. Elementary! – I forgot how to mount it... I quickly skimmed through the article and remembered. Thanks a lot to the author!
Come back often :)
11 June, 11:47
Thank you for the article,
very good intelligibly
9 July, 13:05
# sudo mount -t smbfs -o username=vasja,password=pupkin //pupkin_v/Video /home/user/video
doesn't work, gives help
usage: ……
I work in ubuntu. you need to connect the shared windows folder
Maybe the team is wrong?
9 July, 22:11
Lyudmila:# 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 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 are nuances and differences between Russian and English Windows OS
31 August, 10:04
In Ubuntu it should be like this:
mount -t cifs -o username=tridge,password=foobar //fjall/test /mnt/smb/fjall
14 September, 20:28
cj@Monster:~$ sudo umount /dev/sda1
umount: /: device is busy. (In some cases useful info about processes that use the device is found by lsof(8) or fuser(1))
cj@Monster:~$ df -h
File system Size Use Dost Use % 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% /
15 September, 09:46
19 September, 20:14
CJ: You need to mount the /dev/sda1 disk, but it claims that it is already mounted at the “/” point, although the Ubuntu system partition is mounted at this 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 errors in the use of tsya/tsya. -TSYA or -TSYA? Thanks again.:)
It could be ;) You'll need to bring it to your editor's attention ;)
27 September, 06:59
30 September, 06:46
Taras: The samba mount command does not work.
What exactly doesn't work in it?
2 November, 20:41
What if the file system is LWM2, and Linux Mint complains?!
that is, the command sudo mount -t lwm2 /dev/sdb /home/user/Video is not accepted.
2 November, 22:52
Mut@NT: sudo mount -t ext3 -o rw /dev/hda3 /home/roza/Desktop
So? That is, the mount point is /home/roza/Desktop?If everything is mounted for you and the file system /dev/hda3 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 this was not a very good way... it would be more correct to log in from root because this way you gave rights to everyone and everything... and this is not good...
IMHO! even though they say that there are a million articles, it’s still a good article) but there aren’t enough examples... I’d like to see some non-standard applications... because with examples everything is easier to understand)
29 November, 20:33
5 December, 19:34
max: It was Windows, the hard drive was divided into 4 logical drives (c,d,e,f). I installed ubuntu 10.04 on drive “c”, thereby destroying Windows. Now I have no access and can’t see the other logical drives. Please tell me what to do to get access to them?
6 December, 14:41
>
>
14 December, 10:48
Ihor:> Mounting hard disk partitions
> ...You can take any mount point.
It seems that the Big Red Book (I also heard “by Nemeth”) says: “... it is advisable that there are no files in the folder where you are mounting, because they will not be visible.”
Well, that goes without saying.
7 January, 22:06
Mounted the iso image
# sudo mount -t iso9660 -o loop /home/op/iso/1.iso /home/op/disk
He writes Russian file names in cryptic language.
29 March, 16:15
There are a lot of articles and books, but this is the first time I’ve seen something humanly written, so to speak, shown and told, to the author, I found a little something for myself, but I couldn’t understand this little bit for several years. The author is worthy of respect; if such an article had fallen into my hands 7 years ago, when I began to surf the expanses of Linux, I would have been very happy.
Everything has been told
18 August, 08:09
Please tell me how to clean the mount tails? Thank you.
12 January, 23:29
A funny thing happened to me here. I tried to make a bootable Windows flash drive. I formatted the flash drive with the mkfs command, then according to the recommendations of some “advanced” users. I installed the gparted application, gave the flash drive the bootable (active) flag... And after that, miracles began:
1. problem: mount & umount commands disappeared
2. We managed to restore the commands, but there’s another problem. When mounting a partition (no matter what system), the fs is connected in read mode, and access rights cannot be changed. The system simply does not respond to these command keys and says everything is fine, the operation was completed successfully.
Conclusion I can pick up files from any media, but I can’t give files away. I read the article from fstab. I rewrote the file manually. I didn't make any more changes to it. But an attempt to mount a disk with write and execute rights still ended in failure. After I removed gparted and rebooted the system, the fstab file I edited began to work correctly and the mount commands were restored.
Attention question: What is the reason for this behavior of gparted and how did it do it? Well, how to deal with this without deleting gparted?
21 January, 23:07
Excellent, intelligible articles: this one, “.. SWAP in Linux”, “.. what is fstab?”!
Dear author, please write a couple more, covering topics such as partitioning, disk partitioning, merging partitions, moving home to another partition.
That would be a great collection!
7 April, 00:35
Is it possible to somehow get the source code of this miracle program?
29 June, 01:27
Tell me what to do?
I installed Ubuntu 12.04 a week ago. After some careless actions, the system crashed. The disk contains 250GB of information. LiveCD HDD sees, but does not start (gives an error). And there is no way to connect it. Here is the result (even in this version) -
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 syslog - try dmesg | tail or something like that
I tried to restore the system using recommendations from websites, but to no avail. When booting from disk, indicates that the boot manager did not detect the operating system.
Tell me what to do?, where to “run”?
25 October, 23:50
Good afternoon. There is a server for a film projector on Linux. It differs from the usual ones in that it has a built-in Digital Cinema program for showing films through a projector. The motherboard recently died, they replaced it and installed another one. Everything was reloaded. Now the server does not see the portable SATA hard drive. it is connected using a sled to transfer films to the server (1 film weighs from 90 to 300 GB). Tell me, can I use the mount command so that he can see it? (power is supplied to the disk, all cables are connected, but still does not see the disk)
Let's look at how to mount a hard drive in Ubuntu. To do this, you need to perform three steps:
- Create a partition on your hard drive.
- Formatting the disk.
- Mounting a disk in the system.
We use the fdisk utility. You can view the list of disks connected to your computer with the command:
The command outputs text approximately as follows:
Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Disk identifier: 0x000bedde
Device Load Start End Blocks Id System
/dev/sda1 * 1 2497 20051968 83 Linux
/dev/sda2 2497 2611 916481 5 Extended
/dev/sda5 2497 2611 916480 82 Linux swap / Solaris
Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sdb does not have a valid partition table
We have two disks, sda and sdb. There are already three partitions on sda and sdb is not partitioned. To create partitions on sdb, run the command:
You will be prompted to enter `m` for help, enter it and see what options there are for working with the disk
Command Action
a boot flag toggle
b editing bsd disc label
c toggle the DOS compatibility flag
d delete partition
l list of known file system types
m display this menu
n adding a new partition
o creating a new empty DOS partition table
p partition table output
q exit without saving changes
s creating a new blank Sun disk label
t change the partition system id
u Changing screen/content units
v partition table check
w write partition table to disk and exit
x additional functionality (for experts only)
Enter `n`, that is, add a new section
Command (m for reference): n
Command Action
e extended
p main section (1-4)
Select the main one by pressing `p`
Section number (1-4):
We set the section number, no matter what, but for order it’s better than 1 (if it’s not busy, of course). This number means what your disk will be called sdb1 or sdb2, etc.
First cylinder (1-261, default 1):
Default value 1 is used
Last cylinder, +cylinders or +size(K,M,G) (1-261, default 261):
Default value 261 is used
Command (m for reference): w
The partition table has been changed!
Call ioctl() to reread the partition table.
Disks are synchronized.
We have created the section, now we need to format it. Let's use the command mkfs
Its format is simple mkfs.filesystem device
For example, we need to format our /dev/sdb1 V ext4, to do this, run the following command:
mkfs.ext4 /dev/sdb1
and wait for our disk to be formatted.
Now let's actually mount our disk. Let's do this using the command mount
mount -t ext4 /dev/sdb1 /usr/data
-t ext4- specify the file system of the connected disk
/dev/sdb1- Actually, the section itself that we are connecting
/usr/data- The mount point is the place where our partition is connected
You can unmount the disk with the command umount specifying the drive
umount /dev/sdb1
In order for the disk to be mounted on the system automatically after a reboot, you must register it in the /etc/fstab file. Go to a new line and add a line like this:
hard drive partition mount point file system mount options two auxiliary numbers. For example, to describe our partition /dev/sdb1 with the ext4 file system, add the following line:
/dev/sdb1 /usr/data ext4 defaults 1 2
Where, /dev/sdb1- our partition, disk, device, call it whatever you want
/usr/data- the mount point where the files from our disk will be
ext4- file system, on a mounted disk
defaults- all options are default. Read their description below
1 2 - Auxiliary numbers, also read the description below
Options table:
Option | Description |
defaults | Use default settings. That is, these: rw,suid,dev,exec,auto,nouser,async. |
rw/ro | Read-Write Allowed / Read-Only Allowed |
suid/nosuid | Enable/Disable operation of suid, and sgid bits |
dev/nodev | Interpret/do not interpret the special device block on the file system. |
exec/noexec | Allow execution of binary files located on this disk / Deny |
auto/noauto | The device will install automatically at boot / Will not |
nouser/user | Prohibition of mounting from everyone except root (nouser) / Allow mounting on behalf of any user |
async/sync | Writing and reading on the disk will be performed asynchronously / Synchronously |
Auxiliary numbers.
If you need to connect/mount a hard drive with the NTFS or ext2, ext3 file system to a computer based on the Linux operating system, then you are reading the right article.
Why do it manually if modern Linux desktop systems do it automatically?
There are some cases when the system Linux cannot automatically mount/connect a disk due to some logical failures of the disk, viruses that infected NTFS/FAT partitions, or due to something else anomalous. To do this, real system administrators do it manually. And they do this with the mount command.
The mount command in Linux is a very flexible tool in the hands of a system administrator. You can use the mount command to mount a network drive, hard drive partition, or USB drive.
This article is not a complete, exhaustive description of the mount command (a full description of the mount command can be found by running the man mount command in the console), but it strives to do so. The article describing the mount command is constantly being updated and modified. You can leave all your suggestions regarding the article in the comments.
The 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 they are 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 are 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
Device Load 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:
- two hard drives: /dev/sda - operating system and /dev/sdb - “file trash”
- removable USB drive: /dev/sdc
After this 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 states that the root file system is the reiserfs file system with mount parameters: read and write access (rw)
- /dev/sda3 is the /home disk partition
- /dev/sdc is a mounted removable USB device
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 file $HOME/.dmrc has incorrect permissions and is ignored. This prevents the default session and language from being saved. The owner of this file must be the 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 now I can’t use either sudo or just su - the terminal is not swearing in Russian. Is it possible to restore rights to ($HOME). Maybe this can be done using a Mint live disk?
29 March, 12:13
Hummingbird: Then everything freezes for a few seconds and the desktop opens. And now I can’t use either sudo or just su - the terminal is not swearing in Russian. Is it possible to restore rights to ($HOME). Maybe this can be done using a 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
2 April, 08:43
3 April, 13:39
Hummingbird: Still, nothing worked :(. In general, I reinstalled the partition with Mint. The main thing is that I learned how to mount partitions (I understood how it’s done, then it’s easier) And I also learned a lesson for myself - you need to distribute rights very carefully. Thanks anyway!
P.S. The main thing is that you learned something))
19 May, 08:41
Thank you.
A couple of additions.
1. For example, my hard drive 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 at the root of my partition and because of this Linux did not want to mount this partition.
I didn’t want to mount it not because of autorun.exe, but because most likely the Windows were extinguished “incorrectly” and there was a byte on ntfs about checking the integrity of the file system. In this regard, ntfs3g without “force” is afraid to mount such a FS, 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/
20 May, 15:26
24 May, 03:04
26 May, 17:27
Alex Under Construction: Thank you. A couple of additions. 1. For example, my hard drive 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 at the root of my partition and because of this Linux did not want to mount this partition. I didn’t want to mount it not because of autorun.exe, but because most likely the Windows were extinguished “incorrectly” and there was a byte on ntfs about checking the integrity of the file system. In this regard, ntfs3g without “force” is afraid to mount such a FS, 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 mounting was also described
Thanks for the comment. I'll add some additions.
Tonik: And the article helped me. Elementary! – I forgot how to mount it... I quickly skimmed through the article and remembered. Thanks a lot to the author!
Come back often :)
11 June, 11:47
Thank you for the article,
very good intelligibly
9 July, 13:05
# sudo mount -t smbfs -o username=vasja,password=pupkin //pupkin_v/Video /home/user/video
doesn't work, gives help
usage: ……
I work in ubuntu. you need to connect the shared windows folder
Maybe the team is wrong?
9 July, 22:11
Lyudmila:# 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 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 are nuances and differences between Russian and English Windows OS
31 August, 10:04
In Ubuntu it should be like this:
mount -t cifs -o username=tridge,password=foobar //fjall/test /mnt/smb/fjall
14 September, 20:28
cj@Monster:~$ sudo umount /dev/sda1
umount: /: device is busy. (In some cases useful info about processes that use the device is found by lsof(8) or fuser(1))
cj@Monster:~$ df -h
File system Size Use Dost Use % 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% /
15 September, 09:46
19 September, 20:14
CJ: You need to mount the /dev/sda1 disk, but it claims that it is already mounted at the “/” point, although the Ubuntu system partition is mounted at this 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 errors in the use of tsya/tsya. -TSYA or -TSYA? Thanks again.:)
It could be ;) You'll need to bring it to your editor's attention ;)
27 September, 06:59
30 September, 06:46
Taras: The samba mount command does not work.
What exactly doesn't work in it?
2 November, 20:41
What if the file system is LWM2, and Linux Mint complains?!
that is, the command sudo mount -t lwm2 /dev/sdb /home/user/Video is not accepted.
2 November, 22:52
Mut@NT: sudo mount -t ext3 -o rw /dev/hda3 /home/roza/Desktop
So? That is, the mount point is /home/roza/Desktop?If everything is mounted for you and the file system /dev/hda3 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 this was not a very good way... it would be more correct to log in from root because this way you gave rights to everyone and everything... and this is not good...
IMHO! even though they say that there are a million articles, it’s still a good article) but there aren’t enough examples... I’d like to see some non-standard applications... because with examples everything is easier to understand)
29 November, 20:33
5 December, 19:34
max: It was Windows, the hard drive was divided into 4 logical drives (c,d,e,f). I installed ubuntu 10.04 on drive “c”, thereby destroying Windows. Now I have no access and can’t see the other logical drives. Please tell me what to do to get access to them?
6 December, 14:41
>
>
14 December, 10:48
Ihor:> Mounting hard disk partitions
> ...You can take any mount point.
It seems that the Big Red Book (I also heard “by Nemeth”) says: “... it is advisable that there are no files in the folder where you are mounting, because they will not be visible.”
Well, that goes without saying.
7 January, 22:06
Mounted the iso image
# sudo mount -t iso9660 -o loop /home/op/iso/1.iso /home/op/disk
He writes Russian file names in cryptic language.
29 March, 16:15
There are a lot of articles and books, but this is the first time I’ve seen something humanly written, so to speak, shown and told, to the author, I found a little something for myself, but I couldn’t understand this little bit for several years. The author is worthy of respect; if such an article had fallen into my hands 7 years ago, when I began to surf the expanses of Linux, I would have been very happy.
Everything has been told
18 August, 08:09
Please tell me how to clean the mount tails? Thank you.
12 January, 23:29
A funny thing happened to me here. I tried to make a bootable Windows flash drive. I formatted the flash drive with the mkfs command, then according to the recommendations of some “advanced” users. I installed the gparted application, gave the flash drive the bootable (active) flag... And after that, miracles began:
1. problem: mount & umount commands disappeared
2. We managed to restore the commands, but there’s another problem. When mounting a partition (no matter what system), the fs is connected in read mode, and access rights cannot be changed. The system simply does not respond to these command keys and says everything is fine, the operation was completed successfully.
Conclusion I can pick up files from any media, but I can’t give files away. I read the article from fstab. I rewrote the file manually. I didn't make any more changes to it. But an attempt to mount a disk with write and execute rights still ended in failure. After I removed gparted and rebooted the system, the fstab file I edited began to work correctly and the mount commands were restored.
Attention question: What is the reason for this behavior of gparted and how did it do it? Well, how to deal with this without deleting gparted?
21 January, 23:07
Excellent, intelligible articles: this one, “.. SWAP in Linux”, “.. what is fstab?”!
Dear author, please write a couple more, covering topics such as partitioning, disk partitioning, merging partitions, moving home to another partition.
That would be a great collection!
7 April, 00:35
Is it possible to somehow get the source code of this miracle program?
29 June, 01:27
Tell me what to do?
I installed Ubuntu 12.04 a week ago. After some careless actions, the system crashed. The disk contains 250GB of information. LiveCD HDD sees, but does not start (gives an error). And there is no way to connect it. Here is the result (even in this version) -
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 syslog - try dmesg | tail or something like that
I tried to restore the system using recommendations from websites, but to no avail. When booting from disk, indicates that the boot manager did not detect the operating system.
Tell me what to do?, where to “run”?
25 October, 23:50
Good afternoon. There is a server for a film projector on Linux. It differs from the usual ones in that it has a built-in Digital Cinema program for showing films through a projector. The motherboard recently died, they replaced it and installed another one. Everything was reloaded. Now the server does not see the portable SATA hard drive. it is connected using a sled to transfer films to the server (1 film weighs from 90 to 300 GB). Tell me, can I use the mount command so that he can see it? (power is supplied to the disk, all cables are connected, but still does not see the disk)
Welcome back my hackers!
One "misunderstanding" Linux that users constantly encounter Windows, is the concept of "mounting" devices and disks. In the world Windows drives and devices are automatically "mounted" without any effort on the part of the user and without even realizing that this is happening. Well, maybe suspicions about this are creeping in. Most users Windows know how to disconnect a flash drive before removing it from a computer, but usually think of this process as “ejecting.”
Team mount dates back to the prehistoric era of computing (from the 1970s), when computer operators physically mounted tape drives onto behemoth-like giant computers the size of gyms. These drives stored data (since hard drives had not yet been invented) and the operator had to tell the machine that he was mounting a tape before it could be read.
Windows typically automatically mounts Plug and Play drives and devices so users don't have to worry about mounting them. The system assigns each disk or device a letter designation of its mount point, for example, C:, D:, E:, etc.
In later distributions Linux Automatic mounting is often supported, but a true administrator needs to understand the process and know the command mount, since they will someday need to mount a device or drive that is not automatically mounted. This situation occurs every day in the work of any ordinary system administrator. Linux and especially in the work of cybercrime investigators or hackers.
Step 1. File structure
Remember that you Linux a single tree structure for the entire file system (as opposed to Windows) with a root for each drive and device. This means that all drives and devices are part of a single file system tree with a "/" at the very top. Any other drives must be mounted to this tree. We can do this with the command mount.
When we mount a device, we place it in some directory and it becomes part of the tree. We can mount any device to ANY directory, but when we do this, the directory in which the device is mounted will become “closed” and inaccessible to us. This means that we will not be able to access any of the files in this directory. Of course, this is not very good. That's why we have special empty directories for mounting devices. Their names differ from one distribution Linux to another, but usually it is either /mnt or /media.
Step 2: mount command
Let's take a look at the team mount. Enter in the console:
Mount -h
This will display command help as shown below:
The screenshot highlights the most important part of the command syntax. Mainly:
mount -t<тип файловой системы> <расположение>
Team mount in this form it will “mount” a file system of a certain type (-t) in the specified location. So, for example, we could mount a cdrom in the /media directory by typing:
Mount -t /dev/cdrom /media
This command will mount the cdrom to the /media directory in the file system tree.
We also have a variety of options that can be used when mounting devices, including:
rw- mount read/write
ro- mount read-only
user- allow any user to mount devices/disks
auto/noauto– whether the file system will automatically mount the device/disk
exec/noexec- allow or disable the execution of binary (executable) files on the mounted device
You can look at the built-in manual (man) for the command mount to find out all its options:
Man mount
Step 3. Set up automounting using Fstab
Fstab- This " F ile s system tab le" (file system table). In system Linux it's just a configuration file. Team mount reads fstab to determine which options to use when mounting a file system. Thus, it automatically detects the connection parameters when we mount the device. She just reads the entry in the table fstab for a given device and applies the mount parameters specified there.
As you can see in the screenshot above, we simply displayed the contents of the file fstab using the cat command:
Cat fstab
Table fstab consists of six (6) columns. Here they are:
Device(device) - UUID (Universal Unique Identifier)
Mount point(Mount point) - the directory where we want to mount the device
Type(Type) - file system type, for example: ext2, ext3, swap, ISO9660, etc.
Options(Parameters) are: rw (read/write), auto, nouser, async, suid, etc.
Dump(Dump) - specifies how often to back up this drive
Pass- defines the "pass" option when fsck should check the filesystem.
Step 4: Unmount
When we need to unmount (unmount) a disk or device, then the command we should use is umount. Pay attention to its spelling. It is called umount, but not unmount.
To unmount our cdrom device that we mounted above, enter:
Umount /dev/cdrom
You will not be able to disconnect a drive or device that is currently in use by the system.
Come back for more tutorials on hacking and the basics Linux, which you need to know to hack like a real PRO.