23

I m using Ubuntu 12.04 and i have to partitions part1 and part2, both are ext4. I want to transfer media files to and from them freely through programs.

6 Answers 6

28

What I would do is the following:

Assuming you have both partitions mounted with the names part1 and part2, you will be the only one using them and you want total free control over them, I would do this:

sudo chmod 777 /media/part1 - This would give all permissions (Read, Write, Execute) to you within the part1 partition.

sudo chmod 777 /media/part2 - This would give all permissions (Read, Write, Execute) to you within the part2 partition.

The permissions (in this case 777) are as follow:

7 - Full (Read, Write & Execute)
6 - read and write
5 - read and execute
4 - read only
3 - write and execute
2 - write only
1 - execute only
0 - none

The first 7 (Starting from the Left) is for the owner, the 2nd is for the group where the owner resides. The last 7 is for other groups. Basically like this you can copy anything you want in the partitions and if you ever need to take the HDD out and connect it to another computer with Ubuntu you will not have any problems with permissions. At least in my case it saves me time because I tend to have 1 or 2 hard drives that hold movies, music and similar stuff and I move them around from PC to PC.

Just to add, if you do not know where the partitions are mounted, you can always open Disk Utility and in the information about the hard drive it will tell you where it is mounted. Remember that you need to apply this to the partition AFTER it has been mounted.

8
  • 1
    I always avoid a mode like 777, mainly because it is often hard to read due to the terminal colors that alert you to it being world writable. If he's the only user, then using 755 accomplish the same thing and be easier to read with normal colors Jul 3, 2012 at 0:19
  • I agree with you on that. Specially folders. Jul 3, 2012 at 2:28
  • 1
    Why even change the permissions when you can just chown it to the current user?
    – n.st
    Oct 12, 2013 at 13:12
  • Hi n.st the reason is that in all cases I have tried, doing a chown did not actually give the needed permissions. It did change the owner to the current one but the files and folders still had wrong permissions and so the user could not write to the unit. Oct 14, 2013 at 15:06
  • Alternatively chmod +rwx could replace the chmod 777.
    – Quidam
    Apr 27, 2020 at 10:12
11

Instead of changing all file permissions, like Luis Alvarado suggested, it would be better to change the file owner - thus keeping the executable bit on any binary and script files that previously had it.

So, assuming your partition is mounted as /media/something and your username is johndoe, you can run

sudo chown -R johndoe:johndoe /media/something

to change the owner and owning group of /media/something (and all files and directories it contains, hence the -R for 'recursive') to johndoe.

This way, all files will retain their permissions, but since you will be the owner of /media/something, you will be able to write to it and change any file permissions, in case you ever need to.

2

Change permission

 sudo chmod -R a+rwx /path/of/folder
1
  • That is exactly the same as what the accepted answer does too, just using different syntax than you. 777 is the same as rwx.
    – Fabby
    Jul 4, 2019 at 11:18
1

You can normally do this already, but my advice would be to add the partitions to /etc/fstab so they will be stable and have a location of your choosing. You can mount them at any existing directory, but conventions seem to be to mount it at /mnt. To do this, follow these steps:

Create the directories under /mnt; the directories can be whatever name you choose. I will simply use "MyMount1" and "MyMount2" for an example. Also, I will use "mylogin" to represent your login name and group; change this to your login account name.

sudo mkdir /mnt/MyMount1
sudo mkdir /mnt/MyMount2
sudo chown mylogin:mylogin /mnt/MyMount1
sudo chown mylogin:mylogin /mnt/MyMount1

You now have the two directories created, with you as the owner.

You need the UUID (Universal Unique Identifier) of the two drives to identify them in the fstab file. To get these, run sudo blkid from a terminal commandline and find the partitions you want to use. The easiest way to use them will be to copy and paste from the terminal to the file.

Open /etc/fstab using a text editor such as gedit. To use gedit, enter

gksu gedit /etc/fstab

Then, enter these two lines at the end of the file (but substitute the UUID for the xxx.... part, and the directory name for MyMounts):

UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx /mnt/MyMount1 ext4 defaults 0 2
UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx /mnt/MyMount2 ext4 defaults 0 2

To test, save the file and enter this at a terminal commandline: sudo mount -a; if there are any errors that you can't understand, ask here. If there are errors and you need to reboot, it may be safest to disable the added lines first by prefixing the line with a pound sign (#) which makes it a comment.

2
  • So what should be the output from the command "sudo mount /a"? My output was "mount: can't find /a in /etc/fstab or /etc/mtab".
    – user73466
    Jul 2, 2012 at 20:09
  • I'm sorry, I don't know how I did that, but I meant "-a", not "/a". It just means to mount everything in fstab, and is a good way to test for errors. I'll correct my post. Jul 3, 2012 at 0:11
1

I had the same problem and solved it by running nautilus as root, right click on the partition, properties, and changed the permissions (or owner if necessary).

If nautilus is not installed:

sudo apt-get nautilus
0

You should be able to mount the partition from nautilus (Ubuntu's default file manager). If you look at the top left hand side of the window, you should be able to see all of the partitions you have on your drive. Just click on one to mount it.

However, if you want a given directory to always be mounted on startup, you need to add it to /etc/fstab. The line that you would add should be something like:

/dev/sda2 /media/part1 ext4 defaults 0 0

The format is

device (tab) mount point (tab) type (in your case ext4) (tab) options (probably "defaults") (tab) dump (tab) pass (probably both 0 in your case)

So basically just replace /dev/sda2 with your device and /media/part1 with your mount point from the example.

If you need more info for editing your /etc/fstab, you could check out this article I found: http://www.tuxfiles.org/linuxhelp/fstab.html.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .