Linux - NewbieThis 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.
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.
I mounted /home/michael/devicefilexxx at /home/michael/mountpointxxx as shown below. Then I looked at /etc/mtab to see what it looked like before manually editing /etc/fstab. /dev/mapper/centos-root? What is that? Did a bit of research, and found that I am evidently using Logical Volume Management. Okay, good I guess, but have a couple of questions:
How can I have device /dev/mapper/centos-root mounted both at / and /home/michael/mountpointxxx?
How can I identify specifically what is mounted at /home/michael/mountpointxxx?
How do I permanently mount this device? Surely, I cannot simply add /dev/mapper/centos-root /home/michael/mountpointxxx xfs rw,relatime,attr2,inode64,noquota 0 0 to /etc/fdisk as /dev/mapper/centos-root will not uniquely identify the device.
Should I be using a special tool to permanently mount devices instead of just editing /etc/fstab?
What is with /dev/dm-0, /dev/dm-1, and /dev/mapper/control?
Please explain the output of lsblk and how it pertains to the other outputs.
Based on my above questions (or more likely, lack of some pointed question) and displayed command outputs below, what else should I be asking and what other commands should I be running to view my system configuration?
Thank you
Code:
[michael@vps ~]$ mkdir /home/michael/devicefilexxx
[michael@vps ~]$ mkdir /home/michael/mountpointxxx
[michael@vps ~]$ sudo mount --bind /home/michael/devicefilexxx /home/michael/mountpointxxx
[michael@vps ~]$ cat /etc/mtab | grep xxx
/dev/mapper/centos-root /home/michael/mountpointxxx xfs rw,relatime,attr2,inode64,noquota 0 0
[michael@vps ~]$ mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
devtmpfs on /dev type devtmpfs (rw,nosuid,size=1009596k,nr_inodes=252399,mode=755)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,nodev,mode=755)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_prio,net_cls)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpuacct,cpu)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)
configfs on /sys/kernel/config type configfs (rw,relatime)
/dev/mapper/centos-root on / type xfs (rw,relatime,attr2,inode64,noquota)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=34,pgrp=1,timeout=300,minproto=5,maxproto=5,direct)
mqueue on /dev/mqueue type mqueue (rw,relatime)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
/dev/sda1 on /boot type xfs (rw,relatime,attr2,inode64,noquota)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=204060k,mode=700,uid=1000,gid=1000)
/dev/mapper/centos-root on /home/michael/mountpointxxx type xfs (rw,relatime,attr2,inode64,noquota)
[michael@vps ~]$ cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Fri Apr 8 14:15:42 2016
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root / xfs defaults 1 1
UUID=362355d4-e5da-44de-bf5c-5ce92cf43888 /boot xfs defaults 1 2
/dev/mapper/centos-swap swap swap defaults 0 0
[michael@vps ~]$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 80G 0 disk
├─sda1 8:1 0 500M 0 part /boot
└─sda2 8:2 0 79.5G 0 part
├─centos-swap 253:0 0 2G 0 lvm [SWAP]
└─centos-root 253:1 0 77.5G 0 lvm /
sr0 11:0 1 1024M 0 rom
[michael@vps ~]$ ls -l /dev/mapper
total 0
lrwxrwxrwx 1 root root 7 Dec 11 04:09 centos-root -> ../dm-1
lrwxrwxrwx 1 root root 7 Dec 11 04:09 centos-swap -> ../dm-0
crw------- 1 root root 10, 236 Dec 11 04:09 control
[michael@vps ~]$ ls -l /dev/mapper/../dm-1
brw-rw---- 1 root disk 253, 1 Dec 11 04:09 /dev/mapper/../dm-1
[michael@vps ~]$ ls -l /dev/mapper/control
crw------- 1 root root 10, 236 Dec 11 04:09 /dev/mapper/control
[michael@vps ~]$ sudo lvdisplay
--- Logical volume ---
LV Path /dev/centos/swap
LV Name swap
VG Name centos
LV UUID M1qwjs-A6iN-BSMr-CQeA-2VLQ-IuLd-eM1smR
LV Write Access read/write
LV Creation host, time localhost, 2016-04-08 14:15:41 +0000
LV Status available
# open 2
LV Size 2.00 GiB
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0
--- Logical volume ---
LV Path /dev/centos/root
LV Name root
VG Name centos
LV UUID ejjUQX-f22h-HH82-3Cg8-6Tc5-4qtP-bJt0z3
LV Write Access read/write
LV Creation host, time localhost, 2016-04-08 14:15:42 +0000
LV Status available
# open 1
LV Size 77.51 GiB
Current LE 19842
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:1
[michael@vps ~]$ sudo vgdisplay
--- Volume group ---
VG Name centos
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 6
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 79.51 GiB
PE Size 4.00 MiB
Total PE 20354
Alloc PE / Size 20354 / 79.51 GiB
Free PE / Size 0 / 0
VG UUID zPAZLs-6QQe-Tnvz-ijly-mKQu-MFk0-ie0kho
[michael@vps ~]$ sudo pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name centos
PV Size 79.51 GiB / not usable 2.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 20354
Free PE 0
Allocated PE 20354
PV UUID AVJtne-FSKj-8Guj-kv7U-Jis1-x5Nk-Sp60zp
[michael@vps ~]$
Last edited by NotionCommotion; 12-16-2017 at 01:02 PM.
LVM works by taking a bunch of Physical Volumes (PF).
You separate the bunch of PF's into one or more Volume Groups (VG).
Each VG is divided into several Logical Files (LF).
Each LF is equivalent to a normal hard disk partition, except that it is easily resizeable.
Note that a disk error, anywhere, can effectively destroy your entire disk setup.
But it is a good system if you would otherwise be frequently resizing partitions, or needing to have partitions which are bigger than any existing disk.
(I use it for squeezing backups onto a single large disk).
Thanks Jeremy, I can't what? Hopefully not mount /home/michael/devicefilexxx at /home/michael/mountpointxxx and have it remain mounted after a reboot. Doing so is my immediate goal, and hoping to benefit from a bit of education in the process.
/dev/mapper/centos-root could uniquely identify / (in the same way that /dev/sda1 could uniquely identify /).
There is no reason why you cannot mount /dev/mapper/centos-home to a mountpoint such as /mnt/home since you can now have a giant /home directory which spans multiple disks.
Obviously that's not obligatory though.
BTW I suspect the system doesn't handle hyphens well - I suggest you use underscores.
I don't have access to a LVM set-up at the moment...
If you want to play with LVM, you can do so with a USB key of a reasonable size.
In Debian, I could get all the LVM commands by entering (as root)
Code:
lvm
help
For further help I would enter a command followed by -h
Last edited by JeremyBoden; 12-16-2017 at 02:28 PM.
I am glad Q1 didn't make sense to you because it made no sense to me!
Hopefully, the hyphens are not an issue because the server in question is being hosted by 1&1 and they set it up.
I can (and have mounted the device as shown at the very beginning of my original post), but don't know how to make it permanently remain after a reboot.
The hyphen is not important. When I used it:-
If you look at names outside of lvm all hyphens get repeated,
but when you issue commands inside lvm you only use the single hyphen.
Actually, I think I now sort of understand it???
You actually chose a LV Path of /dev/centos/root
However, your fstab file calls this /dev/mapper/centos-root
In some horrible way, I would guess that the mapper gets removed and the hyphen is transliterated into a /.
This makes lvm happy.
But don't expect too much from non-lvm commands like lsblk - dm-0 etc just correspond to bits of storage.
If you want to see what's mounted,
Thanks again Jeremy, But how can I make the mount remain after the machine is rebooted? Typically, one would edit /etc/fstab, no? And put what as the device? /dev/mapper/centos-root and somehow it knows what I was thinking? While that would be impressive, I don't think Linux is that smart. Somehow I need to specify both the device path and mount path...
To add a bind mount entry in fstab, just follow manual
man mount
Code:
The bind mounts.
Since Linux 2.4.0 it is possible to remount part of the file
hierarchy somewhere else. The call is
mount --bind olddir newdir
or shortoption
mount -B olddir newdir
or fstab entry is:
/olddir /newdir none bind
How can I have device /dev/mapper/centos-root mounted both at / and /home/michael/mountpointxxx?
A bind mount is possible.
The bind driver redirects all access to the primary mount.
Quote:
How can I identify specifically what is mounted at ?
df /home/michael/mountpointxxx shows the device.
You can run df on any(!) file, it gives you the filesystem (mount point, device, size, usage)
Quote:
How do I permanently mount this device? Surely, I cannot simply add /dev/mapper/centos-root /home/michael/mountpointxxx xfs rw,relatime,attr2,inode64,noquota 0 0 to /etc/fdisk as /dev/mapper/centos-root will not uniquely identify the device.
Why not? lvs or lvdisplay show the device. I suggest to do the fstab entry first, then run mount /home/michael/mountpointxxx that looks up the other things from the fstab.
Quote:
Should I be using a special tool to permanently mount devices instead of just editing /etc/fstab?
No. A simple text editor like vi is good.
Quote:
What is with /dev/dm-0, /dev/dm-1, and /dev/mapper/control?
Please explain the output of lsblk and how it pertains to the other outputs.
lsblk and pvs or pvdisplay display the physical devices (disks and disk slices).
The next stage is the volume group, displayed with vgs or vgdisplay
The last step is the logical volume, displayed with lvs or lvdisplay
Last edited by MadeInGermany; 12-17-2017 at 06:57 AM.
It is good practise to name the stuff so a human can easily read it.
Naming stuff like centos, root, swap is just bad working practise. Regardless if an installer did it or a human.
I have quite long names, but I can easily say what it is
lv_root_volume_SanDisk => logical volume = lv; root_volume ... /; SanDisk ... manufacturer of the drive who I can blame
vg_root_volume_SanDisk => volume group = vg; root_volume ... /; SanDisk ... manufacturer of the drive who I can blame
vg_root_volume_SanDisk-lv_root_volume_SanDisk => as you can see they are put together with "-" => vg + "-" + lv
I assume my old initramfs and gentoo eudev + openrc recreates it again => lrwxrwxrwx 1 root root 7 Dez 19 13:12 root_vg_root_volume_SanDisk-lv_root_volume_SanDisk-root -> ../dm-1 => i do see a boot error but I do not care. I do backups regularly and recreate the file system during backup stage. less fragmentation, no need for file system checks. => lazy dirty approach. <= i do not care for the init cry about not beeing able to do a file system check.
Applications (like LVM2 and EVMS) that need to create new mapped devices talk to the device mapper via the libdevmapper.so shared library, which in turn issues ioctls to the /dev/mapper/control device node.[4]
You actually chose a LV Path of /dev/centos/root
However, your fstab file calls this /dev/mapper/centos-root
In some horrible way, I would guess that the mapper gets removed and the hyphen is transliterated into a /.
This makes lvm happy.
What the ? The two forms /dev/vg_name/lv_name and /dev/mapper/vg_name-lv_name both point to the same /dev/dm node. They are alternate forms. There is nothing "horrible" about it.
Quote:
LVM works by taking a bunch of Physical Volumes (PF).
You separate the bunch of PF's into one or more Volume Groups (VG).
Each VG is divided into several Logical Files (LF).
Each LF is equivalent to a normal hard disk partition, except that it is easily resizeable.
Physical Volumes are PV (not PF).
Volume Groups are divided into Logical Volumes (LV).
Quote:
But how can I make the mount remain after the machine is rebooted? Typically, one would edit /etc/fstab, no? And put what as the device? /dev/mapper/centos-root and somehow it knows what I was thinking? While that would be impressive, I don't think Linux is that smart. Somehow I need to specify both the device path and mount path...
Again what the ? You would just use /dev/mapper/centos-root in fstab as that is the link to the /dev/dm-n node. Simple as that. Users use links with the VG and LV names in them. These links with the same names are created at every boot.
Quote:
How do I permanently mount this device? Surely, I cannot simply add /dev/mapper/centos-root /home/michael/mountpointxxx xfs rw,relatime,attr2,inode64,noquota 0 0 to /etc/fdisk as /dev/mapper/centos-root will not uniquely identify the device.
Surely you can. /dev/mapper/centos-root will uniquely identify the device as there is only one LVM VG named centos and it has only one LV named root. Therefore the link named /dev/mapper/centos-root will be unique. This link will point to the correct /dev/dm device at every boot.
Last edited by tofino_surfer; 12-20-2017 at 09:00 PM.
Thanks tofino surfer. Been a while since I've been to Tofino. Surf good?
Surly I am missing something. There are two unique paths /home/michael/mountpoint1 and /home/michael/mountpoint2. Neither of them point to / which I expected /dev/mapper/centos-root to be and both paths are not equal so can't point to the same place. Maybe I am confusing myself with the use of the word "point"? I agree /dev/mapper/centos-root uniquely locates a place where they might be located within, but not specifically where they are located within that space.
Any guide says use something human readable. Which makes things clear.
There are certain working principles in life. Go on and name it as short as possible so no one has a clue.
Sarcasm: Really good working habit naming it centos, swap, ... lol
When you read the first post you can see the poster has no glue about it.
It is more obvious and clear when you do the thing I suggested.
I read the hole redhat docs about lvm2 in the past.
I read other posts, some were smart some were not.
Than I adapted my box so it would boot. even my initramfs.
I prefer human readable names instead of using pen and paper to write down what is what before i act.
I use pen and paper because sda2 sdb4 are something which i could easily mix up. and when you mix up, you may disk destroyer (= dd) your hole data for example. And there is still the risk on next reboot the kernel mix up the device tree, as in the past
well, you can kind of get away not putting the / filesystem in fstab. After all - in order to read the fstab, / must already be mounted.
you are probably passing that info via your bootloader as kernel parameter, and/or through initramfs, which mounts / for you.
of course, you should still put it in fstab in the end, if only to check that the correct thing is mounted and with the options.
This explains my double entry.
This forums.gentoo.org post also explains why the volume group was auto mounted in his home folder. Supposely missing fstab entry or wrong fstab entry. so the automounter mounted it in /home.
Again what the ? You would just use /dev/mapper/centos-root in fstab as that is the link to the /dev/dm-n node. Simple as that. Users use links with the VG and LV names in them. These links with the same names are created at every boot.
False.
First of all you need something to boot your computer:
For example: The usual layout with sda2 as suggested in the gentoo handbook with vfat.
Than you need an initramfs and an adapted kernel as linux can not boot on its own from lvm2, with or without luks.
(there are claims that it can boot from lvm2, luks whatever, grub or the kernel, but i never saw a working example, just claims it can, so it can't until someone shows me, it does itself, without a bootloader, without an initramfs! it has a reason why the gentoo handbook still sticks to that layout!)
Than you need the rootfs, realroot parameter which was former called root parameter.
As https://forums.gentoo.org/viewtopic-...ighlight-.html explained and I also know from experience the / entry in fstab is not needed anymore. At this point of stage root is already mounted and fstab gets parsed later
I recommend bothering in how a box boots. I did adapt, rewrite (call it what you want it,these days it is called code reuse) my initramfs. I built my own kernels. I recommend step away from the newbie distros and dive deeper.
--
Go on criticise me. But criticising me for a decent working habit and proper naming things?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.