Showing posts with label mount. Show all posts
Showing posts with label mount. Show all posts

Wednesday, August 29, 2007

Mounting

I have a large drive containing both MP3s and my photographs. I have previously mounted the whole disk into the arbitrarily named /HDD-directory in /home. You need root privileges to mount:

sudo mount /dev/sda1 /home/adder1972/HDD

I decided I wanted to replace my HDD-directory with a /MP3 and a /Pictures directory.

I discovered the "mount --bind"-command, which according to the man-pages enables you to "Remount a subtree somewhere else (so that its contents are available in both places)."

So, I made my two new directories, and now I mount my large harddrive like this:

sudo mount --bind /media/sda1/Pictures /home/adder1972/Pictures
sudo mount --bind /media/sda1/MP3 /home/adder1972/MP3

Modifying /etc/fstab (*see note) would allow for automounting these directories. The way to do this is by adding:

/media/sda1/Pictures /home/
adder1972/Pictures none bind 0 0
/media/sda1/MP3 /home/adder1972/MP3 none bind 0 0

at the end of fstab. Since the "bind" command only re-mounts part of your drive, you cannot remove the original command to mount your drive, which is already in your fstab, i.e.:

/dev/sda1 /media/sda1 none 0 0

Run mount -a to have it take effect immediately.


* Note: Always remember to backup/copy the file you want to modify.
In order to edit fstab, type

sudo gedit /etc/fstab

at the command line (if you are using the "gedit" text editor).

Saturday, April 14, 2007

Monting a second disk

Well, I have heard many great things about the Unix-file system and its flexibility. In order to learn more about the file system, and eventually transforming my home network to be Linux-based, I thought I would try to mount a second disk as a folder in my Home-folder.

I was also thinking that I could use this to mount e.g my external USB-harddrive with all my pictures directly in my Home-folder.

I ran in to some problems along the way. I will try to explain them and their solution.

Problem 1 was to mount the disk. In fact the disk was already mounted by the system and showed up in the "places" bar in the file browser. However, I wanted to mount it myself, so I unmounted it (right click, unmount).

Finally, a chance to test the much feared command line... Opening a terminal-window, I used the command:

sudo mount /dev/hdb1 /home/adder1972/xdisk

This mounted the second disk (with one partition; hdb1) to a folder called "xdisk" in my Home-folder. I had cheated and made the target folder in the file browser (I know I can make it command line as well, of course).

Problem 2 was related to user rights. I couldn't write to my drive/folder now called "xdisk". Command line:

ls -l

showed me the user rights, owner, group, etc. I found that the folder was owned by "root", so I needed to change the rights of the folder.

I used command line:

sudo chmod 775 xdisk

BTW, all command line commands are explained thoroughly in the terminal. You can just write:

man chmod

for instance, to check how to use the "chmod" command. However, I find it difficult to use. The "man"-pages are also available on the Interweb.

Anyway, the new user rights did the trick for me, and my extra disk was now mounted as as a folder under "Home".