LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-18-2017, 02:20 AM   #1
lse123
Member
 
Registered: Dec 2008
Posts: 125

Rep: Reputation: 15
Every file system mount requirws a new partition


Lets say in partition exist a file system and in a folder is mounted another file system... this means I have one partition, in other words every files system Not requires separate partition for it??? Correct
 
Old 01-18-2017, 02:53 AM   #2
aragorn2101
Member
 
Registered: Dec 2012
Location: Mauritius
Distribution: Slackware
Posts: 553

Rep: Reputation: 277Reputation: 277Reputation: 277
Hi,

Not sure what you are "exactly" expecting. But here's how it works:

Let us say you have a hard disk on a PC with three partitions on it. The layout is

sda (first hard disk drive)
|-- sda1
|-- sda2
|-- sda3

If your OS is found on sda1, then it will be mounted at / by default. Then, inside your Linux filesystem, you can have mount points anywhere. A mount point is simply a directory which you can use to mount drives/filesystems, e.g. mounting sda3 at /mnt/hdisk:
Code:
mkdir -p /mnt/hdisk   (creating the mount point)
mount -t FILESYSTEM_TYPE /dev/sda3 /mnt/hdisk/
Now, let us say you want to mount sda2 at a mount point under /mnt/hdisk/... Yes, you can. You simply make sure the mount point exists and you mount sda2 there.
e.g.
Code:
mkdir -p /mnt/hdisk/mnt2/hdisk   (creating the mount point)
mount -t FILESYSTEM_TYPE /dev/sda2 /mnt/hdisk/mnt2/hdisk/
And now, let's say you plug in a pendrive. You will see that the /dev/sdb drive will be activated and you will probably have a FAT partition sdb1 under it. Basically, the drive/disk is sdb and the filesystem(s) under it, in this case there is only one, is sdb1.

Then you decide to mount sdb1 under the mounted sda2's filesystem:
Code:
mkdir -p /mnt/hdisk/mnt2/hdisk/mnt3/usbdrive   (creating the mount point)
mount -t FILESYSTEM_TYPE /dev/sdb1 /mnt/hdisk/mnt2/hdisk/mnt3/usbdrive/
Finally, you see that you have drives and then partitions on them. Note that each partition is treated like a different filesystem which you can mount at a given mount point. That's all.

Last edited by aragorn2101; 01-18-2017 at 02:56 AM.
 
Old 01-18-2017, 03:17 AM   #3
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 16,513

Rep: Reputation: 5554Reputation: 5554Reputation: 5554Reputation: 5554Reputation: 5554Reputation: 5554Reputation: 5554Reputation: 5554Reputation: 5554Reputation: 5554Reputation: 5554
If I understood your question well: different filesystems (located on different partitions) can be mounted on the same filesystem, using different directories, but these are only the mount points, not the filesystems themselves. Every partition may contain (hold) only one filesystem.
and you can also mount the same filesystem several times into different directories.
 
1 members found this post helpful.
Old 01-18-2017, 09:51 AM   #4
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873
You can have a file that contains a filesystem. I often do that sort of thing for swap space that rarely gets used.

# dd if=/dev/zero of=/SWAPFILE.swap bs=1M count=1000
# mkswap -v1 /SWAPFILE.swap
# swapon /SWAPFILE.swap
# swapon -s

Creates and uses a 1GB file that contains the swap filesystem. Much the same as a mount would be except without mkfs, and mount. If you're concerned about wear you can systematically create new swap files and leave the old one(s) to occupy the worn space, but change the configuration to not use them. Of course a filesystem on a filesystem will be slower than a raw device.
 
Old 02-22-2017, 06:03 AM   #5
lse123
Member
 
Registered: Dec 2008
Posts: 125

Original Poster
Rep: Reputation: 15
So in other words mounting a file system in a dir/dir1/
And dir2/dir3 can accessed same files from two points?
A partition holds ONLY one file system but this file system can have mount points?

THESE are correct?
 
Old 02-22-2017, 06:16 AM   #6
r3sistance
Senior Member
 
Registered: Mar 2004
Location: UK
Distribution: CentOS 6/7
Posts: 1,375

Rep: Reputation: 217Reputation: 217Reputation: 217
I think you are asking is can you do the following....

Code:
#  mount | grep /dev/mapper
/dev/mapper/centos-root on / type xfs (rw,relatime,attr2,inode64,logbsize=64k,sunit=128,swidth=128,noquota)
/dev/mapper/centos-tmp on /tmp type xfs (rw,relatime,attr2,inode64,logbsize=64k,sunit=128,swidth=128,noquota)
/dev/mapper/centos-var on /var type xfs (rw,relatime,attr2,inode64,logbsize=64k,sunit=128,swidth=128,noquota)
# mkdir /mnt/var
# mount /dev/mapper/centos-var /mnt/var
# mount | grep /dev/mapper
/dev/mapper/centos-root on / type xfs (rw,relatime,attr2,inode64,logbsize=64k,sunit=128,swidth=128,noquota)
/dev/mapper/centos-tmp on /tmp type xfs (rw,relatime,attr2,inode64,logbsize=64k,sunit=128,swidth=128,noquota)
/dev/mapper/centos-var on /var type xfs (rw,relatime,attr2,inode64,logbsize=64k,sunit=128,swidth=128,noquota)
/dev/mapper/centos-var on /mnt/var type xfs (rw,relatime,attr2,inode64,logbsize=64k,sunit=128,swidth=128,noquota)
# echo "test" > /var/log/test.log
# cat /mnt/var/log/test.log
test
Correct? If so... then yes you can.

In regards to a partition, a partition generally can only hold one filing system however LVM and logical volumes make this a little bit more complicated tho. As LVM itself can store multiple logical volumes within a single partition (or spanned across multiple partitions). As you'll note above, what I have actually mounted it a logical volume as opposed to a partition. Here we have several volumes stored in one partition as such:

Code:
# pvs
  PV         VG     Fmt  Attr PSize  PFree
  /dev/sda2  centos lvm2 a--  29.41g 4.36g
# vgs
  VG     #PV #LV #SN Attr   VSize  VFree
  centos   1   5   0 wz--n- 29.41g 4.36g
# lvs
  LV     VG     Attr       LSize  Pool   Origin Data%  Meta%  Move Log Cpy%Sync Convert
  pool00 centos twi-aotz-- 22.00g               19.52  9.13
  root   centos Vwi-aotz-- 10.00g pool00        21.38
  swap   centos -wi-ao----  3.00g
  tmp    centos Vwi-aotz--  2.00g pool00        0.56
  var    centos Vwi-aotz-- 10.00g pool00        21.45

Last edited by r3sistance; 02-22-2017 at 06:46 AM. Reason: LVM
 
2 members found this post helpful.
Old 02-22-2017, 08:57 AM   #7
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 9,159
Blog Entries: 4

Rep: Reputation: 3233Reputation: 3233Reputation: 3233Reputation: 3233Reputation: 3233Reputation: 3233Reputation: 3233Reputation: 3233Reputation: 3233Reputation: 3233Reputation: 3233
To clarify: LVM (Logical Volume Management) – which I strongly recommend using – separates the physical storage picture (what disks there are, how big, where, partitions, etc. etc.) from the logical one (what the operating system's users see).

Physical volumes are used to create "storage pools." LVM itself decides how data is distributed among the volumes in the pool, but the data is distributed. This can be used to seamlessly achieve things like load-balancing and RAID. It's also great for those ... "click, click!" ... sounds ... that disk drives sometimes begin to make.

The space created by these "storage pools" is then distributed among "logical volumes." And you can simply paint the picture that you want, without regard to partitions, disks, and so on.

You can make changes on the fly without rebooting the system.
Quote:
LVM: Don't Leave Home Without It.™

Last edited by sundialsvcs; 02-22-2017 at 08:58 AM.
 
Old 02-22-2017, 09:11 AM   #8
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (current), FreeBSD, Win10, It varies
Posts: 9,952

Rep: Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148Reputation: 2148
Quote:
Originally Posted by lse123 View Post
Lets say in partition exist a file system (directory structure) and in a folder (directory) is mounted another file system(a sub-directory )... this means I have one partition.

in other words every files system (directory structure with sub-directories) Not requires separate partition for it??? Correct
Correct, you do not have to split up your directory structure in Linux in order to use it, but it does have the ability to do so if one wants to.

But it will only use the root directories for each partition.
I'll leave it at that for now.
but the key word bind for your fstab is something you can look into when you get frisky for learning about splitting up directory structures and there sub-directories.

Last edited by BW-userx; 02-22-2017 at 09:36 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] The installer can't put a btrfs file system in a partition that already contains a file system. Didier Spaier Slackware 6 03-11-2016 01:13 PM
how tocreate new partition on ubuntu 10.4 to mount new (mine) file system to this janakiramulu Ubuntu 5 01-18-2011 10:05 PM
[SOLVED] how tocreate new partition on ubuntu 10.4 to mount new (mine) file system to this janakiramulu Ubuntu 2 01-18-2011 08:33 AM
Mount NTFS partition deeper in file system with fstab? fhsm Linux - Newbie 2 03-15-2010 10:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:04 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