# Locked out of drive on Ubuntu Server



## <<Onafets>> (Nov 18, 2012)

Hey guys,
I was trying to delete some torrents that I had downloaded with transmission-daemon and was unable to from my samba share on windows. I figured the best solution was to 'sudo chmod -R 0777 /media/Storage' (my drive with samba) but apparently not.
This locked both my windows user and my user on my ubuntu server out of the drive completely with a message saying 'ls: cannot access /media/Storage: Permission denied'.
I am able to login as root with 'sudo bash' and make changes however I am uncertain as to how to make my drive accessible again. 
Doing a 'ls -ld' on the directory shows 'drwsrwsrwx 39 root root 4096 Nov 17 21:20 /media/Storage'
Any ideas?


----------



## Aquinus (Nov 18, 2012)

<<Onafets>> said:


> Hey guys,
> I was trying to delete some torrents that I had downloaded with transmission-daemon and was unable to from my samba share on windows. I figured the best solution was to 'sudo chmod -R 0777 /media/Storage' (my drive with samba) but apparently not.
> This locked both my windows user and my user on my ubuntu server out of the drive completely with a message saying 'ls: cannot access /media/Storage: Permission denied'.
> I am able to login as root with 'sudo bash' and make changes however I am uncertain as to how to make my drive accessible again.
> ...



try chowning it first:


```
sudo chown -R [username]:[group] /to/some/path
```

Then try granting user permissions.


```
sudo chmod -R u+rw /to/some/path
```


----------



## <<Onafets>> (Nov 18, 2012)

Aquinus said:


> try chowning it first:
> 
> 
> ```
> ...



Both commands executed without errors however I am still unable to access/ls the directory from either Windows or Ubuntu. Still getting the same 'ls: cannot access /media/Storage: Permission denied' message.


----------



## Aquinus (Nov 18, 2012)

<<Onafets>> said:


> Both commands executed without errors however I am still unable to access/ls the directory from either Windows or Ubuntu. Still getting the same 'ls: cannot access /media/Storage: Permission denied' message.



Stop trying to access it in Windows until you can actually get into it in Linux.

Is the drive even mounted?

How does the output of 
	
	



```
sudo mount
```
 look?


----------



## <<Onafets>> (Nov 18, 2012)

Aquinus said:


> Stop trying to access it in Windows until you can actually get into it in Linux.
> 
> Is the drive even mounted?
> 
> ...



sudo mount dumps

```
/dev/sdb1 on / type ext4 (rw,errors=remount-ro)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
udev on /dev type devtmpfs (rw,mode=0755)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)
none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)
none on /run/shm type tmpfs (rw,nosuid,nodev)
/dev/sda1 on /media/Storage type ext4 (rw)
```

/dev/sda1 on /media/Storage type ext4 (rw) is the drive


----------



## Aquinus (Nov 18, 2012)

So after you chmod and chown the directory, what does "ls -l /media/" show?

Preferably a before and after would be nice.


----------



## <<Onafets>> (Nov 18, 2012)

before

```
sudo ls -la /media/Storage
drwsrwsrwx 39 root root 4096 Nov 17 21:20 /media/Storage
```
after 

```
ls -l /media
ls: cannot access /media/cdrom: Permission denied
ls: cannot access /media/Storage: Permission denied
total 0
d????????? ? ? ? ?            ? cdrom
d????????? ? ? ? ?            ? Storage

sudo ls -l
total 8
drwxr-xr-x  2 root      root      4096 Oct  8 20:30 cdrom
drwsrwsrwx 39 onafets onafets 4096 Nov 17 21:20 Storage
```


----------



## Aquinus (Nov 18, 2012)

<<Onafets>> said:


> before
> 
> ```
> sudo ls -la /media/Storage
> ...



Hmmm, and you can't access it now? I'm assuming "onafets" is your account.

When you restart are the permissions the same? 

These are the permissions that I have on my workstation for /media

maybe


```
sudo chown -R root:root /media
sudo chmod -R 775 /media
```

Restart before you try anything else then tell me how it works. Also are you mounting the drive or is Ubuntu doing it for you?


----------



## <<Onafets>> (Nov 18, 2012)

```
sudo chmod -R 775 /media
```
Allows me to access the drive and its contents however I ended up modifying it to 777 so I was able to delete my files. Thank you!


----------



## Aquinus (Nov 18, 2012)

<<Onafets>> said:


> ```
> sudo chmod -R 775 /media
> ```
> Allows me to access the drive and its contents however I ended up modifying it to 777 so I was able to delete my files. Thank you!



You're welcome but make sure you're setting the right permissions to the right directory.


```
sudo chown root:root /media
sudo chmod 775 /media
sudo chmod -R 777 /media/Storage
```

Just make sure /media itself belongs to root and is chmod'ed to 775, even if Storage is 777.


----------

