Demystifying /dev/mapper
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:
Code:
[michael@vps ~]$ mkdir /home/michael/devicefilexxx |
You can't (in any sensible sense). :)
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). Have a read of p12 of https://fullcirclemagazine.org/issue-80/ |
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.
|
It wouldn't make sense for Q1. :)
/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 |
Thanks again Jeremy,
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, Code:
mount Code:
df -h |
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...
|
Have to admit that I don't rely on fstab for my backups.
I use a script to mount and unmount LV's as they are needed. But that doesn't mean fstab wouldn't work - especially if you used UUID's to identify the LV's. |
To add a bind mount entry in fstab, just follow manual
man mount Code:
The bind mounts. |
Quote:
The bind driver redirects all access to the primary mount. Quote:
You can run df on any(!) file, it gives you the filesystem (mount point, device, size, usage) Quote:
Quote:
Quote:
The next stage is the volume group, displayed with vgs or vgdisplay The last step is the logical volume, displayed with lvs or lvdisplay |
Redhat has very decent documentation about lvm2.
Quote:
in comparison Quote:
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 -- Quote:
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. -- as for the dm stuff => https://wiki.gentoo.org/wiki/Device-mapper I only use lvm2 + luks. For several reasons -- luckily lvm2 provides rename tools. You may use em. CAreful to fix your boot process. -- Quote:
-- https://unix.stackexchange.com/quest...apper-in-fdisk https://en.wikipedia.org/wiki/Device_mapper Quote:
http://"https://askubuntu.com/questi...-and-etc-mtab" I assume some sort of automounter in your distro screwed up. I did not used mtab for quite a while. Judging from your mount output, it seems you have your "/" mounted two times in your system, once as /, once as subfolder in your home directory |
Quote:
Quote:
Volume Groups are divided into Logical Volumes (LV). Quote:
Quote:
|
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. Code:
[michael@vps ~]$ mkdir /home/michael/devicefile1 |
Quote:
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 -- I found something to add to this topic https://forums.gentoo.org/viewtopic-...ighlight-.html Quote:
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. |
Quote:
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? |
All times are GMT -5. The time now is 04:08 AM. |