External hard drives in linux

Little Girl littlergirl at gmail.com
Sun Feb 6 15:17:00 UTC 2022


Hey there,

M.R.P. zensky via ubuntu-users wrote:

>My external drive shows it’s contents in caja but I can’t do things
>like create a folder. It seems like a permission issue but I don’t
>know how to change it.

It's maddening. I had the same issue with a couple of external drives
that I had bought for backups. Here's why:

https://askubuntu.com/questions/392154/why-are-the-default-permissions-for-media-username-rootroot

Have you partitioned the drive already and would you just like to
access the drive as it is? Or would you like to partition the drive
and then access it?

I've got the steps I took for both if you need them all. Since there
are 44 steps for all of that combined, I'm taking the risk of putting
the cart before the horse by providing only the steps for accessing
the drive below.

Note that I'm not necessarily recommending these steps (since this
will be the first time anyone but me has reviewed them and there may
well be flaws in my process), but just letting you know that they're
the steps I successfully followed to gain access to my external drives
instantly whenever I plug them in. I've used them on multiple drives
and they've worked without needing any intervention on each one.
Hopefully you'll have the same luck.

Last, but not least, when you look below, the steps look more
daunting than they are. This process actually takes just a couple of
minutes to do.

Without further ado, here they are two different ways - one mostly for
the command line and one mostly for the GUI and here's hoping the
mailing list doesn't mess up the formatting:

====================
(MOSTLY) COMMAND LINE:
	1. Get the path to your external drive:
		1. If the drive is plugged in, unplug it.
		2. Type this command into a terminal window:
		fdisk -l
		3. Note the paths that it lists.
		4. Plug the device in.
		5. When it auto-mounts, type this command into a
		terminal window:
		fdisk -l
		6. Note the new path that is listed. This is the path
		to your external drive.
	2. Open a terminal window and type this command to see if
	you're the owner of the device (unlikely) or if root is the
	owner of the device (more likely):
	stat -c "%U %G"
	3. If you’re the owner, skip this step. Otherwise, if root is
	the owner:
		1. Open a terminal window.
		2. Type this command to change ownership of the
		device: sudo chown -R
		$USER:$USER /PATH/TO/YOUR/EXTERNAL/DRIVE
		3. Type this command to specify what owner, group,
		and others can do on the device:
		sudo chmod 775 /PATH/TO/YOUR/EXTERNAL/DRIVE
		4. Close the terminal window.
		5. Unplug the device.
		6. Plug the device back in.
		7. When it auto-mounts, click its icon on the desktop
		to open the drive in the file manager.
		8. Right-click in the right pane of the file manager
		and see if you have the power to create a directory
		or file. If you do, you're done.
	4. Make sure the dot directories have proper ownership:
		1. Open a terminal window.
		2. Change to the directory of the USB device:
		cd /PATH/TO/YOUR/EXTERNAL/DRIVE
		3. Type this command and take a look at the . and ..
		directories to see who the owners are:
		ls -al
		4. The . entry should be owned by you since that
		refers to the current directory. The .. directory
		should be owned by root since that refers to the
		parent of the current directory. If either of them
		aren't properly owned, correct them with either or
		both of these commands:
			* Change the ownership and permissions of
			  the . directory to yourself with these
			  commands:
			 sudo chown -R $USER:$USER .
			 sudo chmod 775 .
			* Change the ownership and
			  permissions of the .. directory to root
			  with these commands:
			 sudo chown -R root:root ..
			 sudo chmod 755 ..
====================
(MOSTLY) GUI:

	1. Get the path to your external drive:
		1. If the drive is plugged in, unplug it.
		2. Plug the drive in.
		3. When it auto-mounts, right-click its icon on your
		desktop.
		4. Choose Properties from the context menu.
		5. Note the path to your external drive.
	2. Open a terminal window and type this command to see if
	you're the owner of the device (unlikely) or if root is the
	owner of the device (more likely):
	stat -c "%U %G"
	3. If you’re the owner, skip this step. Otherwise, if root is
	the owner:
		1. Open a terminal window.
		2. Type this command to give yourself escalated
		privileges, entering your password when prompted:
		sudo -i
		3. Type this command in the same terminal window to
		open the file manager with escalated privileges:
		caja
		4. Right-click the drive in Caja.
		5. Select Properties from the context menu.
		6. Click the Permissions tab.
		7. Choose yourself from the User drop-down menu.
		8. Give yourself the power to Create and delete files
		from the Folder access drop-down menu.
		9. Choose yourself from the Group drop-down menu.
		10. Give yourself the power to Access files from the
		Folder access drop-down menu.
		11. Give Others the power to Access files from the
		Folder access drop-down menu.
		12. Click the Close button.
		13. Close the terminal window.
		14. Unplug the device.
		15. Plug the device back in.
		16. When it auto-mounts, click its icon on the
		desktop to open the drive in the file manager.
		17. Right-click in the right pane of the file manager
		and see if you have the power to create a directory or
		file. If you do, you're done.
	4. Make sure the dot directories have proper ownership:
		1. Open a terminal window.
		2. Change to the directory of the USB device:
		cd /PATH/TO/YOUR/EXTERNAL/DRIVE
		3. Type this command and take a look at the . and ..
		directories to see who the owners are:
		ls -al
		4. The . entry should be owned by you since that
		refers to the current directory. The .. directory
		should be owned by root since that refers to the
		parent of the current directory. If either of them
		aren't properly owned, correct them with either or
		both of these commands:
			* Change the ownership and permissions of
			  the . directory to yourself with these
			  commands:
			 sudo chown -R $USER:$USER .
			 sudo chmod 775 .
			* Change the ownership and
			  permissions of the .. directory to root
			  with these commands:
			 sudo chown -R root:root ..
			 sudo chmod 755 ..
====================

Let me know if you'd like the partitioning instructions I used for
my drives, I can put those in here as well. I used GPT for my drives.

-- 
Little Girl

There is no spoon.




More information about the ubuntu-users mailing list