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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
01-18-2017, 02:20 AM
|
#1
|
Member
Registered: Dec 2008
Posts: 130
Rep:
|
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
|
|
|
01-18-2017, 02:53 AM
|
#2
|
Member
Registered: Dec 2012
Location: Mauritius
Distribution: Slackware
Posts: 567
|
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.
|
|
|
01-18-2017, 03:17 AM
|
#3
|
LQ Addict
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,647
|
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.
|
01-18-2017, 09:51 AM
|
#4
|
Senior Member
Registered: Feb 2003
Distribution: debian
Posts: 4,137
|
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.
|
|
|
02-22-2017, 06:03 AM
|
#5
|
Member
Registered: Dec 2008
Posts: 130
Original Poster
Rep:
|
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?
|
|
|
02-22-2017, 06:16 AM
|
#6
|
Senior Member
Registered: Mar 2004
Location: UK
Distribution: CentOS 6/7
Posts: 1,375
|
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.
|
02-22-2017, 08:57 AM
|
#7
|
LQ Guru
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,820
|
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.
|
|
|
02-22-2017, 09:11 AM
|
#8
|
LQ Guru
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342
|
Quote:
Originally Posted by lse123
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.
|
|
|
All times are GMT -5. The time now is 03:19 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|