Montar partición en Ubuntu


Identificar la unidad que queremos montar y en particular su UUID
sudo blkid

En mi ordenador cuando tenía un solo disco daba lo siguiente:
/dev/sda1: LABEL="Reservado para el sistema" UUID="705298025297CB6C" TYPE="ntfs"
/dev/sda2: UUID="8A8EAB868EAB6A01" TYPE="ntfs"
/dev/sda5: UUID="c49f4260-9a89-4ee7-a77c-ae1af60950c9" TYPE="swap"
/dev/sda6: UUID="6ad927a7-4e59-45f8-96fa-b5f99733c144" TYPE="ext4"
/dev/sda7: UUID="fc10b054-604c-41ce-b261-33651333f27e" TYPE="ext4"
/dev/sda8: LABEL="Almacen" UUID="4A7A96767A965E8F" TYPE="ntfs"
/dev/sdb1: LABEL="B-PMAILTBOY" UUID="3433-3231" TYPE="vfat"

Ahora con dos discos da esto:
/dev/sda1: LABEL="Reservado para el sistema" UUID="705298025297CB6C" TYPE="ntfs"
/dev/sda2: UUID="D89848C29848A13C" TYPE="ntfs"
/dev/sda3: UUID="A082160B8215E696" TYPE="ntfs"
/dev/sda5: LABEL="Almacen" UUID="3C44B15B61982732" TYPE="ntfs"
/dev/sda6: UUID="900314da-a5b5-4128-b73f-8ffac147b513" TYPE="ext4"
/dev/sda7: UUID="93d376b9-a440-4338-b608-915f2e531efc" TYPE="ext4"
/dev/sda8: UUID="36b2ec92-937d-4072-8d41-c74fd0ac65c5" TYPE="swap"
/dev/sda9: UUID="17acc845-6cd0-408e-b714-bea101cee0db" TYPE="swap"
/dev/sda10: LABEL="boot" UUID="36db0d7f-61c4-4ba6-9574-b0f8fb6ec713" TYPE="ext2"
/dev/sda11: LABEL="ub64" UUID="5644b2b7-472e-4467-b4d9-d7020f21899c" TYPE="ext4"
/dev/sda12: LABEL="home ub64" UUID="338d2a9d-34f1-4be7-8038-3eefbaa478df" TYPE="ext4"
/dev/sdb1: LABEL="Reservado para el sistema" UUID="4C1AAA491AAA2FBE" TYPE="ntfs"
/dev/sdb2: UUID="8632B00B32B001EB" TYPE="ntfs"
/dev/sdb5: UUID="44ea5b1a-cd41-40e4-8a63-1251b22b6ace" TYPE="ext2"
/dev/sdb6: UUID="bf74b150-cd8e-45f0-b8de-1ad3f75052bc" TYPE="ext4"
/dev/sdb7: UUID="365683f2-034d-4aa9-a81d-b8bb6d04eb31" TYPE="ext4"
/dev/sdb8: UUID="3b42a13d-973a-445e-85f2-4d289b8e10e4" TYPE="swap"
/dev/sdb9: LABEL="bkalmacen" UUID="32af0d75-6d30-4b00-9d09-cc19d73054e0" TYPE="ext4"

Crear la carpeta para el punto de montaje:

para la partición que está en sda
sudo mkdir /mnt/almacen

y para la partición que está en sdb
sudo mkdir /mnt/bkalmacen

Hacer backup de fstab y editarlo:
sudo cp /etc/fstab/etc/fstab.old
gksudo gedit /etc/fstab

Añadir al final del archivo fstab un comentario y la linea para montar la unidad
# Almacen was on /dev/sda6 during installation
UUID=4A7A96767A965E8F /mnt/almacen ntfs rw,auto,users,exec,nls=utf8,umask=003,gid=46,uid=1000 0 0

y para montar la unidad que está en ntfs pongo
# bklmacen was installed on /dev/sdb9 after installation
UUID=32af0d75-6d30-4b00-9d09-cc19d73054e0 /mnt/bkalmacen ext4 defaults 0 2



Hay que dejar una linea al final del archivo para que el montaje funcione.
Nota: auto se puede cambiar por noauto si se quiere montaje manual y no automático. El resto de las opciones ver: https://help.ubuntu.com/community/Fstab

rw: read and write (default)
auto: automount the device (unnecessary is default for mount)
users: dejar a todos los usuarios montar y desmontar salvo que
exec: permitir ejecución de binarios en el sistema montado
nls=utf8 usar UTF-8 para convetir los nombres de los archivos
umask=value (003) permisos para el sistema de archivo (se da en octal (say you want your file mode always 774 (-rwxrwxr–) , your umask will have to be 003. How to get it? 777 – 774 = 003. To check the current umask we are having, just type: umask)
gid=value (46 es el grupo plgdev)
uid=value (1000 es adminnistrador adm)
Guardar el archivo fstab

Verficar si funciona.
sudo mount -a
Si da errores no bootear la máquina.

La partición bkalmacen se monta pero sigue sin permitir escribir
Se dan los siguiente comandos:

sudo chgrp plugdev /mnt/bkalmacen
sudo chmod g+w /mnt/bkalmacen

con el primer comando le damos acceso al grupo plugdev pues el propietario era root y con el segundo le damos permiso de escribir.


Para ver mi id de usuario y los grupos a los que pertenezco en terminal escribir
id

Finalmente hay que añadir a los usuarios al grupo plgdev para que tengan acceso al disco montado

Para dar permisos habrá que instalar usuarios y grupos pues no está por defecto en ubuntu 12.04
sudo apt-get install gnome-system-tools

e incluir a los usuarios en el grupo plugdev
de esa forma pueden acceder al volumen montado



Más sobre umask en
http://linux.byexamples.com/archives/370/umask-create-new-files-with-specified-file-mode/

HECHO A PARTIR DE LAS SIGUIENTES

FUENTES:
1. Tomado de:

http://usuarioraiz.wordpress.com/2010/03/11/montar-particion-ntfs-al-inicio-automaticamente/

Debemos tener instalado el controlador ntfs-3g (Viene por defecto)
Editar fstab:
sudo gedit /etc/fstab
Añadir una linea para montar la partición
dev/<particion> /media/<carpeta_montaje> <sistema_archivos> <opciones> 0 0

Ejemplo:
/dev/sda3/media/docs ntfs-3g defaults 0 0

deberíamos crear la carpeta /media/docs para poder montar la partición por lo que nos dirigimos a la carpeta /media:

cd /media

Donde creamos la carpeta:

sudo mkdir docs

2. Tomado de:
http://askubuntu.com/questions/46588/how-to-prevent-automount-of-ntfs-partitions-on-startup

For each ntfs-partition you will have to add one line to that file called /etc/fstab. For me the line I added looks like this:
#Windows-Partition
UUID=<xxxxx> /media/win ntfs rw,auto,users,exec,nls=utf8,umask=003,gid=46,uid=1000 0 0

The part that says UUID=<xxxxx> tells your system which partition to mount. If you follow this procedure and have duplicate devices showing up, replace UUID=<xxxx> with /dev/disk/by-uuid/<xxxxx>. Each partition has it's own unique UUID. Spaces are important, so best copy&paste the line. Replace auto by noauto to manually mount. Users should be in the group plugdev.
See note ManageGroups for ubuntu 12.04

Note that if this line is at the very end of your file there should be a newline after it. Mount will complain if you don't have it.

Open Disk Utility and identify the proper partitions by their size (e.g. 120 GB), file system (e.g. ntfs) and name. Note their "Device:" file (e.g. /dev/sdb1). Instead you can run the following command in a Terminal such as gome-terminal:
sudo fdisk -l
The correct UUID will have the proper device file in front of it and TYPE="ntfs" after. So for me the UUID is "7258CB9858CB598D".

setting the mount point
Now the mount-point. For each partition this will be different. I chooose /media/win You can choose whatever you like. It just has to be an existing empty folder. You could just as well create the folder /home/yourusername/windows1 and then put it in your fstab.

rw,auto,user,exec,nls=utf8,umask=003,gid=46,uid=1000 0 0 need not concern you. Just use those values as they are. They should be fine. It not or if you're just intrested, you can read an explanation of these parameters in https://help.ubuntu.com/community/Fstab

save the file and run sudo mount -a in shell. If you can access your partitions through their mountpoints and no errors are printed out, then all went well. If not check for typos and obvious errors. Don't reboot if sudo mount -a displays errors! With errors a reboot might fail.
confus@confusion:~$ id
uid=1000(confus) gid=1000(confus) groups=1000(confus),4(adm),7(lp),20(dialout),24(cdrom),46(plugdev),112(lpadmin),120(admin),122(sambashare)

Note: A graphical tool graphical tool Install ntfs-config (ntfs-config) is also available but not necessary (and obviously it's current version doesn't work in natty - suppose that will be fixed soon). Besides you might loose old settings in your fstab with this tool (e.g. mounting the cache in the memory), because it overwrites the /etc/fstab file instead of appending things.


finding your user and group id
You can find out your user and group id with the id command.



3. Tomado de:

http://askubuntu.com/questions/138630/ubuntu-12-04-lts-what-is-the-best-and-most-reliable-method-to-mount-a-ntfs-part

Add the disc to /etc/fstab. Your create a backup and can edit the file with these 2 lines:
sudo cp /etc/fstab/etc/fstab.old
gksudo gedit /etc/fstab

Example:
This assumes sda3 is your ntfs partition and it should be mounted into /media/windows//dev/sda3/media/windows ntfs defaults 0 0

sudo fdisk -l

So change sda3 to your partitionname and the windows directory name to something you like better. You can use fdisk to see what ntfs is named in Ubuntu:
sudo fdisk -l



4. Tomado de:

http://askubuntu.com/questions/259094/how-to-mount-all-partitions-at-system-startup

First create the mountpoints, for example for sda2, sda3, sda5 and sda7:
sudo mkdir /mnt/sda2/mnt/sda3/mnt/sda5/mnt/sda7
(If you you want can put other more creative names other than /mnt. Your choice).

Not a bad idea to learn about fstab before editing it . Have a look at some of the first google hits for understanding fstab, look at:
http://www.linuxplanet.com/linuxplanet/tutorials/7048/1
or here to make the search:
http://bit.ly/YQQXOc

Next edit your /etc/fstab and put in lines for each of them, for example for sda2, sda3, sda5 and sda7:

/dev/sda2/mnt/sda2 auto defaults 0 0
/dev/sda3/mnt/sda3 auto defaults 0 0
/dev/sda5/mnt/sda5 auto defaults 0 0
/dev/sda7/mnt/sda7 auto defaults 0 0

You should be able to test it saying:
sudo mount /mnt/sda2 #
and so on for the other partitions

If that works, on next boot they should all come up. If you wish you can replace /dev/sda2 and so on with their respective UUID