The error: "mount: only root can do that" while mounting a partition

I've installed Ubuntu 12.04 along with Windows 8.1. When I tried to open the C: drive in Ubuntu a window is popping out saying to run this command:

mount -t ntfs-3g -o remove_hiberfile /dev/sda2 /media/2A36EE3236EDFEA7

After running the command I'm getting the error mount: only root can do that.

What should I do?


Solution 1:

Use (note sudo in front)

sudo mount -t ntfs-3g -o remove_hiberfile /dev/sda2 /media/2A36EE3236EDFEA7

If in future, a program informs you that "only root can do that", "root access required", "super user required", "Permission denied", or similar permissions based problems, you should try sticking sudo in front of the command you're executing.


Mounting a device like Nautilus

If you just want to mount a device from the command line, like it would be mounted if you clicked its icon in the Nautilus sidebar, you can use this command:

udisksctl mount -b /dev/<device>

replacing <device> with your device. This doesn't requrire root access, however will only allow you to do a safe mount, i.e. without any custom mount options and mounting to /media/$USER/<device> only.

Solution 2:

In case you want to mount a partition as a non-administrative user without the sudo command you could also do so with udisks. This allows mounting of partitions (or files) in the /media/<drive_identifier> directory.

Usage:

udisks --mount /dev/<sdxX>  ## to mount
udisks --unmount /dev/<sdxX> ## to unmount

Replace <sdxX> with your drive's device number. You can only safely mount Windows partitions when they were not hibernated.