Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
booting LVM root fs, while snapshot present
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
fikiz
Apprentice
Apprentice


Joined: 07 Mar 2005
Posts: 258
Location: Italy

PostPosted: Tue Dec 24, 2013 12:50 pm    Post subject: booting LVM root fs, while snapshot present Reply with quote

Hi all.

This is a tricky question... at least to me :-)

I'm setting up my first Gentoo installation with root partition on LVM logical volume; classic configuration with boot partition on sda1 and initramfs. Everything works; this is my init script inside initramfs:

Code:
#!/bin/sh

mount -t proc none /proc
CMDLINE='cat /proc/cmdline'

mount -t sysfs none /sys

#wait a little to avoid trailing kernel output
sleep 3

#rescue function in case something is going wrong
rescue_shell() {
    echo Something went wrong. Dropping you to a shell.
    busybox --install -s
    exec /bin/sh
}

cat /etc/msg

#lvm
/bin/lvm vgscan
/bin/lvm vgchange -ay vg00 || rescue_shell

#root filesystem
mount -r LABEL=ROOTFS /newroot || rescue_shell

#unmount pseudo FS
umount /sys
umount /proc

#root switch
exec /bin/busybox switch_root /newroot /sbin/init

(btw... suggestions about this script happily accepted!)

note that I'm mounting root fs by label reference. I like it!

The question is: if I have a snapshot of my root volume while booting, how can I be sure that my init script will mount the REAL root volume, not its snapshot? both have LABEL=ROOTFS. And it happened it booted using the snapshot, actually.

I tried to mount by lv path (/dev/vg00/root or /dev/mapper/v00-root), but these special files aren't created automagically (I suppose because udev is missing at this very moment).

My initramfs contains /dev/dm-0 ... /dev/dm-7 special files.

Thank you for you help!
Back to top
View user's profile Send private message
frostschutz
Advocate
Advocate


Joined: 22 Feb 2005
Posts: 2424
Location: Germany

PostPosted: Tue Dec 24, 2013 6:08 pm    Post subject: Re: booting LVM root fs, while snapshot present Reply with quote

fikiz wrote:
The question is: if I have a snapshot of my root volume while booting, how can I be sure that my init script will mount the REAL root volume, not its snapshot?


Well, that's the only downside of the UUID/LABEL system. It is only reliable as long as it is unique. With snapshots, you lose the uniqueness.

What you can do though is change the UUID/LABEL of the snapshot at the time you create it.

Alternatively use something that stays unique even with snapshots. I.e. instead of mounting by label, mount by vg/lv name.
_________________
Linux-User @ VServer (Debian), Desktop (Gentoo), Netbook (Ubuntu), Router (OpenWRT), PDA (Cacko), Smartphone (Android)
Back to top
View user's profile Send private message
fikiz
Apprentice
Apprentice


Joined: 07 Mar 2005
Posts: 258
Location: Italy

PostPosted: Thu Dec 26, 2013 12:02 am    Post subject: Reply with quote

UUID of snapshots are different from their origin LV, but it is not possible to mount a filesystem by the UUID of its LV. I even tried to activate only a selected LV (by path or UUID) in order to skip the multiple LABEL problem, but I couldn't figure it out how to do this.
If mounting 'by label' you mean using the lv path (e. g. /dev/vg00/root), I cannot do it because LV special files aren't available. Only device mapper's files /dev/dm-0, /dev/dm-1, ... are present in initramfs.

thank you anyway.
Back to top
View user's profile Send private message
frostschutz
Advocate
Advocate


Joined: 22 Feb 2005
Posts: 2424
Location: Germany

PostPosted: Thu Dec 26, 2013 1:19 am    Post subject: Reply with quote

fikiz wrote:
UUID of snapshots are different from their origin LV


It is? Then it's smarter than I gave it credit for :D

fikiz wrote:
it is not possible to mount a filesystem by the UUID of its LV


Works fine for me. I have root on LVM and mount it by UUID (using busybox findfs in the Initramfs). I also mount all other LV by UUID as the system boots. UUID would be kinda pointless if it did not work for LVM.

fikiz wrote:
If mounting 'by label' you mean using the lv path (e. g. /dev/vg00/root), I cannot do it because LV special files aren't available.


At least one of them should be availabe (not sure if /dev/vg/lv or /dev/mapper/vg-lv).

What you are saying sounds to me more like something is off in your Initramfs.
_________________
Linux-User @ VServer (Debian), Desktop (Gentoo), Netbook (Ubuntu), Router (OpenWRT), PDA (Cacko), Smartphone (Android)
Back to top
View user's profile Send private message
fikiz
Apprentice
Apprentice


Joined: 07 Mar 2005
Posts: 258
Location: Italy

PostPosted: Thu Dec 26, 2013 12:17 pm    Post subject: Reply with quote

I'm talking about UUID of logical volumes, not the UUID of the filesystems they contain. But till now I haven't found how to mount using LV's UUID .

this is the content of /dev inside my initramfs:
Code:
# ll
total 8
crw------- 1 root root   5,  1 Dec 18 18:30 console
brw-rw---- 1 root root 252,  0 Dec 19 22:13 dm-0
brw-rw---- 1 root root 252,  1 Dec 19 22:13 dm-1
brw-rw---- 1 root root 252,  2 Dec 19 22:14 dm-2
brw-rw---- 1 root root 252,  3 Dec 19 22:14 dm-3
brw-rw---- 1 root root 252,  4 Dec 19 22:14 dm-4
brw-rw---- 1 root root 252,  5 Dec 19 22:14 dm-5
brw-rw---- 1 root root 252,  6 Dec 19 22:14 dm-6
brw-rw---- 1 root root 252,  7 Dec 19 22:14 dm-7
drwxr-xr-x 2 root root    4096 Dec 18 11:45 mapper
crw-rw-rw- 1 root root   1,  3 Dec 18 18:30 null
crw-rw-rw- 1 root root   1,  8 Dec 18 18:30 random
brw-rw---- 1 root disk   8,  0 Dec 24 14:48 sda
brw-rw---- 1 root disk   8,  1 Dec 18 10:35 sda1
brw-r--r-- 1 root root   8, 10 Dec 24 14:50 sda10
brw-r--r-- 1 root root   8, 11 Dec 24 14:50 sda11
brw-r--r-- 1 root root   8, 12 Dec 24 14:50 sda12
brw-r--r-- 1 root root   8, 13 Dec 24 14:50 sda13
brw-r--r-- 1 root root   8, 14 Dec 24 14:50 sda14
brw-r--r-- 1 root root   8, 15 Dec 24 14:50 sda15
brw-rw---- 1 root disk   8,  2 Dec 18 10:38 sda2
brw-rw---- 1 root disk   8,  3 Dec 18 10:38 sda3
brw-r--r-- 1 root root   8,  4 Dec 24 14:49 sda4
brw-r--r-- 1 root root   8,  5 Dec 24 14:49 sda5
brw-r--r-- 1 root root   8,  6 Dec 24 14:49 sda6
brw-r--r-- 1 root root   8,  7 Dec 24 14:49 sda7
brw-r--r-- 1 root root   8,  8 Dec 24 14:50 sda8
brw-r--r-- 1 root root   8,  9 Dec 24 14:50 sda9
brw-rw---- 1 root disk   8, 16 Dec 24 14:48 sdb
brw-rw---- 1 root disk   8, 17 Dec 24 14:48 sdb1
brw-rw---- 1 root disk   8, 26 Dec 24 14:48 sdb10
brw-rw---- 1 root disk   8, 27 Dec 24 14:48 sdb11
brw-rw---- 1 root disk   8, 28 Dec 24 14:48 sdb12
brw-rw---- 1 root disk   8, 29 Dec 24 14:48 sdb13
brw-rw---- 1 root disk   8, 30 Dec 24 14:48 sdb14
brw-r--r-- 1 root root   8, 31 Dec 24 14:52 sdb15
brw-rw---- 1 root disk   8, 18 Dec 24 14:48 sdb2
brw-rw---- 1 root disk   8, 19 Dec 24 14:48 sdb3
brw-rw---- 1 root disk   8, 21 Dec 24 14:48 sdb5
brw-rw---- 1 root disk   8, 22 Dec 24 14:48 sdb6
brw-rw---- 1 root disk   8, 23 Dec 24 14:48 sdb7
brw-rw---- 1 root disk   8, 24 Dec 24 14:48 sdb8
brw-rw---- 1 root disk   8, 25 Dec 24 14:48 sdb9
brw-r--r-- 1 root root   8, 32 Dec 24 14:53 sdc
brw-r--r-- 1 root root   8, 33 Dec 24 14:53 sdc1
brw-r--r-- 1 root root   8, 42 Dec 24 14:53 sdc10
brw-r--r-- 1 root root   8, 43 Dec 24 14:53 sdc11
brw-r--r-- 1 root root   8, 44 Dec 24 14:53 sdc12
brw-r--r-- 1 root root   8, 45 Dec 24 14:53 sdc13
brw-r--r-- 1 root root   8, 46 Dec 24 14:53 sdc14
brw-r--r-- 1 root root   8, 47 Dec 24 14:53 sdc15
brw-r--r-- 1 root root   8, 34 Dec 24 14:53 sdc2
brw-r--r-- 1 root root   8, 35 Dec 24 14:53 sdc3
brw-r--r-- 1 root root   8, 36 Dec 24 14:53 sdc4
brw-r--r-- 1 root root   8, 37 Dec 24 14:53 sdc5
brw-r--r-- 1 root root   8, 38 Dec 24 14:53 sdc6
brw-r--r-- 1 root root   8, 39 Dec 24 14:53 sdc7
brw-r--r-- 1 root root   8, 40 Dec 24 14:53 sdc8
brw-r--r-- 1 root root   8, 41 Dec 24 14:53 sdc9
brw-r--r-- 1 root root   8, 48 Dec 24 14:54 sdd
brw-r--r-- 1 root root   8, 49 Dec 24 14:54 sdd1
brw-r--r-- 1 root root   8, 58 Dec 24 14:54 sdd10
brw-r--r-- 1 root root   8, 59 Dec 24 14:54 sdd11
brw-r--r-- 1 root root   8, 60 Dec 24 14:54 sdd12
brw-r--r-- 1 root root   8, 61 Dec 24 14:54 sdd13
brw-r--r-- 1 root root   8, 62 Dec 24 14:54 sdd14
brw-r--r-- 1 root root   8, 53 Dec 24 14:54 sdd15
brw-r--r-- 1 root root   8, 50 Dec 24 14:54 sdd2
brw-r--r-- 1 root root   8, 51 Dec 24 14:54 sdd3
brw-r--r-- 1 root root   8, 52 Dec 24 14:54 sdd4
brw-r--r-- 1 root root   8, 53 Dec 24 14:54 sdd5
brw-r--r-- 1 root root   8, 54 Dec 24 14:54 sdd6
brw-r--r-- 1 root root   8, 55 Dec 24 14:54 sdd7
brw-r--r-- 1 root root   8, 56 Dec 24 14:54 sdd8
brw-r--r-- 1 root root   8, 57 Dec 24 14:54 sdd9
crw-rw-rw- 1 root root   1,  9 Dec 18 18:30 urandom
drwxr-xr-x 2 root root    4096 Dec 18 11:47 vc


the mapper/ directory is empty. the dm-* entries let the kernel to scan trough logical volumes of vg00 (once activated) and find filesystems by LABEL.
What do you thing I'm missing?
Back to top
View user's profile Send private message
frostschutz
Advocate
Advocate


Joined: 22 Feb 2005
Posts: 2424
Location: Germany

PostPosted: Thu Dec 26, 2013 6:05 pm    Post subject: Reply with quote

devtmpfs? but even so, lvm binary should generate the missing nodes...
_________________
Linux-User @ VServer (Debian), Desktop (Gentoo), Netbook (Ubuntu), Router (OpenWRT), PDA (Cacko), Smartphone (Android)
Back to top
View user's profile Send private message
fikiz
Apprentice
Apprentice


Joined: 07 Mar 2005
Posts: 258
Location: Italy

PostPosted: Thu Dec 26, 2013 8:39 pm    Post subject: Reply with quote

Sounds promising!

Do you mind give me details about that? I'm no so expert about /dev/* stuff!

Thank you a lot!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum