mercredi 23 juillet 2014

Auto-mount the second hard drive in Ubuntu

1: create a mount point:

  mkdir /media/datadrive 
    create a mount point "datadrive" in /media

2: Change the rights of this directory:


  sudo chmod g+w /media/datadrive
  sudo chmod +t /media/datadrive
 
    The last "chmod +t" adds the sticky bit, so that people can only delete their own files and sub-directories in a directory, even if they have write permissions to it (see man chmod).
3: Edit the /etc/fstab file:

  sudo gedit /etc/fstab

The first column,Ubuntu recommend the UUID instead of logical name. To check the UUID of hard drive and partition, use the following command:

  sudo blkid

wcg1sgh@/mnt$sudo blkid
[sudo] password for wcg1sgh:
/dev/sda1: UUID="8b7a0996-d499-4722-b691-87dde9c0dd37" TYPE="ext4"
/dev/sda5: UUID="2aee8aab-8543-4476-9f43-bde31ab5ee49" TYPE="swap"
/dev/sdb2: LABEL="DATADRIVE" UUID="17b2b066-a817-4f9c-9330-cdd94b7a4191" TYPE="ext4"


    Then, add the following line into /etc/fstab:

    # the second hard drive /dev/sdb
    UUID=17b2b066-a817-4f9c-9330-cdd94b7a4191 /media/datadrive    ext4    defaults    0    2


The detailed explanation of /etc/fstab can be found in [2].

3: run the following command or reboot the computer to have the changes take effect.

  sudo mount -a

4: Then, you can use the second hard drive.

wcg1sgh@/media/datadrive$cd /media/
wcg1sgh@/media$ls
datadrive
wcg1sgh@/media$cd datadrive/
wcg1sgh@/media/datadrive$ls
lost+found  svn


Now, we have to directories in the second hard drive:
1: lost+found
2: svn

references:  
[1] https://help.ubuntu.com/community/InstallingANewHardDrive
[2] http://web.archive.org/web/20130413052717/http://www.tuxfiles.org/linuxhelp/fstab.html 

Aucun commentaire:

Enregistrer un commentaire