LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-02-2007, 02:29 PM   #1
kpachopoulos
Member
 
Registered: Feb 2004
Location: Athens, Greece
Distribution: Gentoo,FreeBSD, Debian
Posts: 705

Rep: Reputation: 30
mount directories of partitions, not partitions possible?


Hi,
is it possible to mount a directory of a local hard disk, not the whole hard disk?
Something like:
/dev/hda1:/shared/xdir /somewhere/here auto defaults 0 0
 
Old 09-02-2007, 02:32 PM   #2
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
No. It is not possible to mount a subdirectory on a partition.
 
Old 09-02-2007, 02:34 PM   #3
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
You don't mount disks, you mount filesystems. The unit of a filesystem is typically a partition, though there are other variants. Directories are structures within a filesystem, and as such don't meet the requirement.
 
Old 09-02-2007, 02:36 PM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Normally, you mount devices to mount points. Devices = partitions, floppies, CD's, etc. It is not possible to mount a whole drive--only partitions.

Then there is the "bind" option to mount a directory to a mount point. See "man mount" for details.
 
Old 09-02-2007, 02:39 PM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by stress_junkie View Post
No. It is not possible to mount a subdirectory on a partition.
That's OK, because that's not what he asked....

You can mount devices and directories---but only TO mountpoints (which are really directories.....confused yet??..)
 
Old 09-02-2007, 02:44 PM   #6
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Quote:
Originally Posted by pixellany View Post
That's OK, because that's not what he asked....

You can mount devices and directories---but only TO mountpoints (which are really directories.....confused yet??..)
I'm not really sure. I thought that the question was to mount a subdirectory on a partition into the mounted file system. I don't know.

I thought that mount --bind would create a second access point to a mounted partition, not mount a subdirectory on a partition.
Code:
mount /dev/hda3 /mnt/hda3
mount --bind /mnt/hda3 /home
I know for a fact that the above two commands work because I just tested them.

It seemed to me that the OP wanted to do something like this.
Code:
mount /dev/hda3/subdir /somewhere
... which AFAIK is not permitted.

Last edited by stress_junkie; 09-02-2007 at 02:53 PM.
 
Old 09-02-2007, 04:19 PM   #7
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Deep breath.....

I **think** it works like this:
  • You can mount a device to a mountpoint. "device" means partition, floppy disk, etc. the device would have to have an entry in /dev.
  • Using bind, you can mount a directory to another directory (aka mountpoint). This assumes that the partition containing said directory is already mounted somewhere.
  • You cannot mount TO anything except a mountpoint (aka directory)
  • You cannot use bind to mount something prefixed with a /dev pathname--ie you can only mount directories to directories
 
Old 09-02-2007, 06:48 PM   #8
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
Quote:
Originally Posted by pixellany View Post
Deep breath.....

I **think** it works like this:
  • You can mount a device to a mountpoint. "device" means partition, floppy disk, etc. the device would have to have an entry in /dev.
  • Using bind, you can mount a directory to another directory (aka mountpoint). This assumes that the partition containing said directory is already mounted somewhere.
  • You cannot mount TO anything except a mountpoint (aka directory)
  • You cannot use bind to mount something prefixed with a /dev pathname--ie you can only mount directories to directories
Well shiver me timbers. I just tried this and it worked.
Code:
mount --bind /etc /var/db
ls /var/db
a2ps.cfg              info-dir                     ppp
a2ps-site.cfg         init.d                       printcap
acpi                  initlog.conf                 printer
activeheartstylerc    inittab                      product.id
adjtime               inputrc                      profile
...
My /etc directory is not a separate partition. This is great. Now I can cross mount any number of directories to other directories.

There's always more to learn.

Last edited by stress_junkie; 09-02-2007 at 06:50 PM.
 
Old 09-02-2007, 07:11 PM   #9
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
The functionality of 'mount --bind' is the equivalent of just performing a symbolic or hard link, with two exceptions that I can think of:

- A 'mount --bind' will work for a chroot jail, while a symbolic link will not.
- A hard link will work for a chroot jail, but not if the link is to another filesystem.

Unless you need that specific functionality, links work just as well.
 
Old 09-02-2007, 07:25 PM   #10
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
This is great. Now I can cross mount any number of directories to other directories.
Sounds like a really great way to confuse yourself...I raise you one:
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Mounting Partitions and Associating Paths/Directories to Them fc6_user Linux - General 8 05-16-2007 12:06 PM
windows killed my partitions! no linux partitions found on this computer. The MJ Linux - Software 10 01-05-2007 08:31 AM
Question on creating more partitions than default ones, i.e. /home,/root partitions casmac SUSE / openSUSE 1 12-20-2006 05:02 PM
Directories on seperate partitions. ToothlessRebel Linux - Newbie 5 11-27-2004 09:34 AM
Moving directories to their own partitions bxb32001 Debian 7 12-08-2003 06:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration