how to mount a disk without superuser (root)
Normally in Linux by default the action of mounting a disk, regardless of it is internal or external, requires root or elevated privileges. It is a basic security setting. But that setting can easily be modified to suit your needs... and allow specific users or all users to mount
First you will need to be root, or have enough of a superuser privilege to modify the specific security settings to open up the use of the mount
command to users. To do this, there are various ways, see
How to allow non-superusers to mount any filesystem?
you mentioned how to mount an external disk
Whether the disk is external, or internal, is largely irrelevant. As long as Linux first recognizes the connected disk whether it is by USB connection or SATA or SAS or other, it will show up as some block device such as /dev/sdb
for example. That needs to already be happening, if so then if all else is well you should be able *to mount the disk.
you mentioned a NTFS disk
Once the disk shows up as a block device, such as /dev/sdb
for example, then Linux can begin to work with it. But the disk had to then have a valid partition table (GPT or MSDOS for example) as well as valid partitions and then a valid file system on a specific partition. For example the most common partition table today is GPT, and then you may see more than one partition on your disk that shows up as /dev/sdb
and then you will see something like /dev/sdb1
and /dev/sdb2
and so on. On any of those 1,2,3..N partitions will need to be a file system Linux can work with. Since you mentioned NTFS
you will require the ntfs-3g
driver, which is available from https://www.tuxera.com/company/open-source/. However if you are running a very new linux kernel, I have read it now includes support for NTFS file systems so you do not have to manually go get and install ntfs-3g
I have got some issue with auto mount any external drives or partitions
Realize that there are multiple ways to mount a disk in /etc/fstab
- by name
- by uuid
- by disk label
- by path
What can happen if you mount by name
which will be a line something like this in /etc/fstab
/dev/sdb1 /data ntfs-3g defaults,nofail 0 0
That as you add remove disks in the system that sdb
can refer to some other disk, and cause problems. So it is usually best to mount by uuid
, or by label
if you have set a partition label. Such a line in /etc/fstab
would look like
# the uuid xxxx will be some long unique string
/dev/disk/by-uuid/xxxx /data defaults,nofail 0 0
LABEL=yourlabel /data defaults,nofail 0 0
To identify the uuid or label, you can do
lsblk -o size,fstype,model,name,serial,uuid,label
to see pertinent disk information to then understand what is what.
After all that, if you then get file system errors where NTFS is corrupted and you have to run ntfsfix
then that's a different problem. My recommendation here would be to use Microsoft Windows 10 or later and use its ntfsrepair
tool since NTFS is a proprietary microsoft file system; you take your chances with linux tools working on the ntfs file system.
You want to turn off Fast Startup
in Microsoft windows so upon shutdown in windows it will fully close and unmount the NTFS file system so linux can later use it... if your disk gets mounted by linux and windows. Otherwise you will likely always encounter ntfs errors in linux where linux will prompt you to repair it.