Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FS#1215 - /sbin/block is not able to mount logical volumes over the /overlay directory. #7971

Closed
openwrt-bot opened this issue Dec 9, 2017 · 4 comments
Labels

Comments

@openwrt-bot
Copy link

tabad:

Some days ago I wrote the topic //[[https://forum.lede-project.org/t/how-to-use-lvm-for-extend-the-root-filesystem/9166|How to use LVM for extend the root filesystem]]// into //[[https://forum.lede-project.org/c/general|Installing and Using LEDE]]// category of LEDE Forum trying to do exactly that but when the system tryies to mount the logical volume destinated to /overlay on boot time, the command block mount fails.

Everything information about the bug and the way to reproduce it is wrote in //[[https://forum.lede-project.org/t/how-to-use-lvm-for-extend-the-root-filesystem/9166|How to use LVM for extend the root filesystem]]//.

Thanks in advance,

@openwrt-bot
Copy link
Author

mkresin:

Nope, doesn't work this way. Please add all required informations and the steps to reproduce the issue to this ticket.

If you want to get a bug fixed, make it as easy as possible to reproduce the issue.

Forcing someone to extract all the required informations from a forum thread isn't what I would call easy.

@openwrt-bot
Copy link
Author

tabad:

Hello Mathias,

Yes, you are right but as I wrote the topic like it was a bug report I thought it was a valid start point; I apologize.

Well, I'm going to include here all the information and the steps to reproduce the error.

==== Hardware & LEDE Firmware ====

  • Hardware
    • [[https://goo.gl/91Mh4X| Linksys WRT160NL]]
    • [[https://goo.gl/wKJqGS|Sandisk Cruzer Fit 16GB]]
  • LEDE Firmware
    • [[https://goo.gl/91Mh4X|LEDE Reboot 17.01.4 r3560-79f57e422d]]

Note: LEDE Reboot 17.01.4 start with its default configuration.

==== How to reproduce the bug ====

  • Installation of packages
root@LEDE:~# opkg -V0 update root@LEDE:~# opkg -V0 install kmod-usb-storage usbutils root@LEDE:~# opkg -V0 install block-mount root@LEDE:~# opkg -V0 install gdisk root@LEDE:~# opkg -V0 install lvm2 root@LEDE:~# opkg -V0 install f2fs-tools kmod-fs-f2fs root@LEDE:~# opkg -V0 install swap-utils
  • Preparation of USB storage device
root@LEDE:~# gdisk /dev/sda Command (? for help): x Expert command (? for help): z Blank out MBR? (Y/N): Y

root@LEDE:~# gdisk /dev/sda
Command (? for help): o
Proceed? (Y/N): Y
Command (? for help): n
Partition number (1-128, default 1): 1
First sector (34-31266782, default = 2048) or {+-}size{KMGTP}: 2048
Last sector (2048-31266782, default = 31266782) or {+-}size{KMGTP}: 31266782
Hex code or GUID (L to show codes, Enter = 8300): 8e00
Command (? for help): w
Do you want to proceed? (Y/N): Y

root@LEDE:# lvm pvcreate -y -ff /dev/sda1
root@LEDE:
# lvm vgcreate -y -s 16M sandisk /dev/sda1
root@LEDE:# lvm lvcreate -L 64M -n swap -y sandisk
root@LEDE:
# lvm lvcreate -L 128M -n overlay -y sandisk
root@LEDE:~# lvm lvcreate -L 2048M -n cifs -y sandisk

  • Preparation of file systems
root@LEDE:~# mkswap -L swap /dev/sandisk/swap root@LEDE:~# mkfs.f2fs -q -l cifs /dev/sandisk/cifs root@LEDE:~# mkfs.f2fs -q -l overlay /dev/sandisk/overlay

root@LEDE:~# block info
/dev/mtdblock2: UUID="b9987b6c-6483eae0-ddc9a928-146c8265" VERSION="4.0" MOUNT="/rom" TYPE="squashfs"
/dev/mtdblock3: MOUNT="/overlay" TYPE="jffs2"
/dev/sda1: UUID="yqu58H-4vkv-9diC-scUc-skXn-UbDp-S1x8zf" TYPE="LVM2_member"
/dev/mapper/sandisk-cifs: UUID="d3121a1b-0afb-4519-aab3-6f524fc143d7" VERSION="1.8" TYPE="f2fs"
/dev/mapper/sandisk-overlay: UUID="5a5c2088-d3ef-4a1b-9f31-2dc814b1097c" VERSION="1.8" TYPE="f2fs"
/dev/mapper/sandisk-swap: UUID="54b4f904-3f8d-42df-bf0e-714e807c2320" LABEL="swap" VERSION="1" TYPE="swap"

  • Preparation of //fstab// section of configuration
root@LEDE:~# block detect > /etc/config/fstab root@LEDE:~# uci show fstab fstab.@global[0]=global fstab.@global[0].anon_swap='0' fstab.@global[0].anon_mount='0' fstab.@global[0].auto_swap='1' fstab.@global[0].auto_mount='1' fstab.@global[0].delay_root='5' fstab.@global[0].check_fs='0' fstab.@mount[0]=mount fstab.@mount[0].target='/mnt/sda1' fstab.@mount[0].uuid='yqu58H-4vkv-9diC-scUc-skXn-UbDp-S1x8zf' fstab.@mount[0].enabled='0' fstab.@mount[1]=mount fstab.@mount[1].target='/mnt/sandisk-cifs' fstab.@mount[1].uuid='d3121a1b-0afb-4519-aab3-6f524fc143d7' fstab.@mount[1].enabled='0' fstab.@mount[2]=mount fstab.@mount[2].target='/mnt/sandisk-overlay' fstab.@mount[2].uuid='5a5c2088-d3ef-4a1b-9f31-2dc814b1097c' fstab.@mount[2].enabled='0' fstab.@swap[0]=swap fstab.@swap[0].uuid='54b4f904-3f8d-42df-bf0e-714e807c2320' fstab.@swap[0].enabled='0'

root@LEDE:# mkdir /mnt/sandisk-cifs
root@LEDE:
# mkdir /mnt/sandisk-overlay

root@LEDE:# uci delete fstab.@mount[0]
root@LEDE:
# uci set fstab.@mount[0].enabled='1'
root@LEDE:# uci set fstab.@mount[1].enabled='1'
root@LEDE:
# uci set fstab.@swap[0].enabled='1'
root@LEDE:# uci set fstab.@mount[1].target='/overlay'
root@LEDE:
# uci commit fstab

  • Preparation of ///dev/mapper/sandisk-overlay//
root@LEDE:~# mount /dev/mapper/sandisk-overlay /mnt/sandisk-overlay/ root@LEDE:~# tar -C /overlay -cf - . | tar -C /mnt/sandisk-overlay -xf - root@LEDE:~# umount /dev/mapper/sandisk-overlay
  • Reboot
root@LEDE:~# reboot

==== The proof ====

Once the router has rebooted:

  • ///dev/mapper/sandisk-cifs// is mounted successfully.
  • ///dev/mapper/sandisk-swap// is activated successfully.
  • ///dev/mapper/sandisk-overlay// is mounted unsuccessfully.
root@LEDE:~# df -hP | grep '/dev/mapper' /dev/mapper/sandisk-cifs 2.0G 188.0M 1.8G 9% /mnt/sandisk-cifs

root@LEDE:~# swapon -s
Filename Type Size Used Priority
/dev/mapper/sandisk-swap partition 65532 0 -1

Note: ///sbin/block mount// doesn't work even after the system has waked up.

root@LEDE:~# block mount block: /dev/mtdblock2 is already mounted on /rom block: /dev/mtdblock3 is already mounted on /overlay block: /dev/mapper/sandisk-cifs is already mounted on /mnt/sandisk-cifs

root@LEDE:~# df -hP | grep '/dev/mapper'
/dev/mapper/sandisk-cifs 2.0G 188.0M 1.8G 9% /mnt/sandisk-cifs

It seems like ///dev/mapper/sandisk-overlay// doesn't exsist. But whether ///dev/mapper/sandisk-overlay// is mounted over whatever other directory, it works perfectly.

root@LEDE:~# uci set fstab.@mount[1].target='/mnt/sandisk-overlay' root@LEDE:~# uci commit fstab

root@LEDE:~# block mount
block: /dev/mtdblock2 is already mounted on /rom
block: /dev/mtdblock3 is already mounted on /overlay
block: /dev/mapper/sandisk-cifs is already mounted on /mnt/sandisk-cifs

root@LEDE:~# df -hP | grep '/dev/mapper'
/dev/mapper/sandisk-cifs 2.0G 188.0M 1.8G 9% /mnt/sandisk-cifs
/dev/mapper/sandisk-overlay 126.0M 56.9M 55.1M 51% /mnt/sandisk-overlay

And this last configuration works even when the system is rebooted.

Best regards,

@openwrt-bot
Copy link
Author

hroo:

If I understood correctly, the problem is that an lvm partition cannot be mounted as /overlay at boot time. I had the same problem and googling for a solution I stumbled over Tomas forum entry.
As there didn't seem to be a solid solution I decided to do some debugging by putting some output commands in the boot scripts. The dmesg output then showed that the root partition and therefore also /overlay, is mounted during preinit when lvm is not yet started. So maybe starting lvm before mounting the root partition would solve the problem, lets just try.

In /lib/preinit I created a file 80_lvm2 with content:
#!/bin/sh

2019-10-20 Harrie Rooijackers

do_lvm() {
echo "Starting lvm2-1" > /dev/kmsg
mkdir -p /tmp/lvm/cache
/sbin/lvm vgscan --ignorelockingfailure --mknodes || :
/sbin/lvm vgchange -aly --ignorelockingfailure || return 2

}

where the statements between {} are copied from /etc/init.d/lvm2

Since 80_lvm2 alphabetically goes before 80_mount_root it should be executed before the root partition is mounted if I interpreted the preinit scripts correctly.

After setting the overlay parameters I rebooted and had the desired overlay mount.

For me this solved my problem quite simple and easy.

Maybe a good solution is to have the lvm package create this script in the /lib/preinit directory so that it is automatically activated.
When trying the script make sure it is in the actual root tree and not in the overlay tree, else it cannot be found.

Hope this helps someone.

@openwrt-bot
Copy link
Author

yousong:

@hroo , thanks for the efforts. Better just open a pull request at https://github.com/openwrt/packages/pulls and ping Daniel Golle the maintainer there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant