Logical Volume mounting on WD Mybook Live Duo

I recently decided to play around with my old MyBook Live Duo NAS with two 3TB drives. I managed to install OpenWRT, expand the space for it to 16GB as I was running out of space when trying to install different packages. I managed to set up two LVM partitions on both drives, create physical volumes, volume group and logical volume. Currently I am facing two issues:

  1. I am able to mount the logical volume using "mount /dev/vgdata/lvdata /data", but not using block mount or via LuCI, which I understand is a proper way to mount in OpenWRT.
  2. If I mount a share like above, I am able to access and modify it via ssh, but it's readonly via smb. It's not persistent through reboot, but when I tried editing /etc/fstab I got an error in LuCI. I am suspecting the reason might be the same - I am mounting it wrong, but I am unable to figure out the right way to do it :slight_smile:

Some outputs, let me know if something else would help:

root@OpenWrt:~# fdisk -l
Disk /dev/mtdblock0: 120 KiB, 122880 bytes, 240 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mtdblock1: 8 KiB, 8192 bytes, 16 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/mtdblock2: 320 KiB, 327680 bytes, 640 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sda: 2.73 TiB, 3000592982016 bytes, 5860533168 sectors
Disk model: WDC WD30EZRX-00M
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 36B7A300-2CAB-44B8-AE0D-1016C05CD869

Device        Start        End    Sectors  Size Type
/dev/sda1      8192      24575      16384    8M Linux filesystem
/dev/sda2     32768   33554432   33521665   16G Linux filesystem
/dev/sda3  33556480 5860532223 5826975744  2.7T Linux LVM


Disk /dev/sdb: 2.73 TiB, 3000592982016 bytes, 5860533168 sectors
Disk model: WDC WD30EZRX-00M
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 63653BAD-731D-4EF6-A462-17193B29ED3D

Device        Start        End    Sectors  Size Type
/dev/sdb1      8192      24575      16384    8M Linux filesystem
/dev/sdb2     32768   33554432   33521665   16G Linux filesystem
/dev/sdb3  33556480 5860533134 5826976655  2.7T Linux LVM


Disk /dev/mapper/vgdata-lvdata: 5.43 TiB, 5966816870400 bytes, 11653939200 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
root@OpenWrt:~# vgdisplay
  --- Volume group ---
  VG Name               vgdata
  System ID             
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               <5.43 TiB
  PE Size               4.00 MiB
  Total PE              1422600
  Alloc PE / Size       1422600 / <5.43 TiB
  Free  PE / Size       0 / 0   
  VG UUID               8OUiyg-wlsT-dTm6-WIpR-vRHL-r2wN-EFTnoJ

root@OpenWrt:~# lvdisplay
  --- Logical volume ---
  LV Path                /dev/vgdata/lvdata
  LV Name                lvdata
  VG Name                vgdata
  LV UUID                NlK3tL-c6jy-YoHN-94uM-6qFY-QfFP-jm2oW4
  LV Write Access        read/write
  LV Creation host, time OpenWrt, 2024-06-10 18:20:51 +0000
  LV Status              available
  # open                 1
  LV Size                <5.43 TiB
  Current LE             1422600
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

root@OpenWrt:~# block info
/dev/sda1: UUID="023999f3-175d-4701-aed8-d5795d8f0f5f" VERSION="1.0" MOUNT="/boot" TYPE="ext2"
/dev/sda2: UUID="ff313567-e9f1-5a5d-9895-3ba130b4a864" LABEL="rootfs" VERSION="1.0" MOUNT="/" TYPE="ext4"
/dev/sda3: UUID="xe9TYh-z2Sy-IYOT-HzUm-vYT7-lSm2-GLUrJ6" TYPE="LVM2_member"
/dev/sdb1: UUID="97366d9c-8b7b-4424-8d7b-364d74801376" VERSION="1.0" TYPE="ext4"
/dev/sdb2: UUID="e1d050b1-ee5f-4df8-b90c-029dcf209bc3" VERSION="1.0" TYPE="ext4"
/dev/sdb3: UUID="yq0yLC-yg1t-Qjd0-ojcd-DvN0-4HlL-BNTD22" TYPE="LVM2_member"
/dev/dm-0: UUID="26fb3374-c646-46de-8093-5545ad94cf47" VERSION="1.0" TYPE="ext4"


root@OpenWrt:~# block detect
config 'global'
	option	anon_swap	'0'
	option	anon_mount	'0'
	option	auto_swap	'1'
	option	auto_mount	'1'
	option	delay_root	'5'
	option	check_fs	'0'

config 'mount'
	option	target	'/boot'
	option	uuid	'023999f3-175d-4701-aed8-d5795d8f0f5f'
	option	enabled	'0'

config 'mount'
	option	target	'/'
	option	uuid	'ff313567-e9f1-5a5d-9895-3ba130b4a864'
	option	enabled	'0'

config 'mount'
	option	target	'/mnt/sda3'
	option	uuid	'xe9TYh-z2Sy-IYOT-HzUm-vYT7-lSm2-GLUrJ6'
	option	enabled	'0'

config 'mount'
	option	target	'/mnt/sdb1'
	option	uuid	'97366d9c-8b7b-4424-8d7b-364d74801376'
	option	enabled	'0'

config 'mount'
	option	target	'/mnt/sdb2'
	option	uuid	'e1d050b1-ee5f-4df8-b90c-029dcf209bc3'
	option	enabled	'0'

config 'mount'
	option	target	'/mnt/sdb3'
	option	uuid	'yq0yLC-yg1t-Qjd0-ojcd-DvN0-4HlL-BNTD22'
	option	enabled	'0'

config 'mount'
	option	target	'/mnt/dm-0'
	option	uuid	'26fb3374-c646-46de-8093-5545ad94cf47'
	option	enabled	'0'

If it is indeed a first line of your /etc/config/fstab file, you should remove it.

Additionally, none of the mounts are enabled.

Also, for spinning rust I would strongly recommend

		option  options 'noatime'

with every mount.

2 Likes

Thanks for the response. That was actually a block detect command execution and lousy copypasting on my end, sorry. I edited the original post.

@takimata Could you give me some background on the "option enabled", or point me to where I could read up on it? Searching for option enabled gives me basically all the info in the world about any option that can be enabled, and a more detailed search (+mount +"option enabled") gives next to no results. In OpenWRT documentation I've found just one line "Enables/disables using UCI section" but I am asking more about the implications of each selection. What behavior shoiuld I expect when device is mounted but enabled=0?

I understood that running "block detect" command gives me a list of what I can mount. Am I wrong?
Why am I only seeing the device mapper entry /mnt/dm-0 in the output, instead of the logical volume (/dev/vgdata/lvdata) I created? Also, running dmsetup info /mnt/dm-0 gives me "Device not found", I can only see this, which is not on the block detect list.

EDIT: After looking at the output of block detect I guess what I am seeing is actually something along the lines of "detect everything that can be mounted and produce an output that can be pasted into fstab", correct? That's why I cannot see dmsetup info /mnt/dm-0, because it's not mounted yet and the output of block detect is target mountpoint if I decide to add it to fstab...

root@OpenWrt:~# dmsetup info /dev/dm-0
Name:              vgdata-lvdata
State:             ACTIVE
Read Ahead:        256
Tables present:    LIVE
Open count:        0
Event number:      0
Major, minor:      253, 0
Number of targets: 2
UUID: LVM-8OUiygwlsTdTm6WIpRvRHLr2wNEFTnoJNlK3tLc6jyYoHN94uM6qFYQfFPjm2oW4

And this is what I actually have in /etc/config/fstab

root@OpenWrt:~# cat /etc/config/fstab 

config global
	option anon_swap '0'
	option anon_mount '0'
	option auto_swap '1'
	option auto_mount '1'
	option delay_root '5'
	option check_fs '0'

config mount
	option target '/boot'
	option uuid '023999f3-175d-4701-aed8-d5795d8f0f5f'
	option enabled '0'

config mount
	option target '/'
	option uuid 'ff313567-e9f1-5a5d-9895-3ba130b4a864'
	option enabled '0'

config mount
	option target '/mnt/sdb1'
	option uuid '97366d9c-8b7b-4424-8d7b-364d74801376'
	option enabled '0'

config mount
	option target '/mnt/sdb2'
	option uuid 'e1d050b1-ee5f-4df8-b90c-029dcf209bc3'
	option enabled '0'

EDIT EDIT: while I was looking for solution I noticed that there is a bit of different output between blkid and block info.
This is the line I get from blkid:

root@OpenWrt:~# blkid
/dev/mapper/vgdata-lvdata: UUID="26fb3374-c646-46de-8093-5545ad94cf47" BLOCK_SIZE="4096" TYPE="ext4"

And this is the line I get from block info:

root@OpenWrt:~# block info
/dev/dm-0: UUID="26fb3374-c646-46de-8093-5545ad94cf47" VERSION="1.0" TYPE="ext4"

Can this discrepancy be the reason I am able to mount manually using mount on device /dev/vgdata/lvdata but not using this device for uci fstab?

A mount section that carries option enabled '0' is not enabled and will be ignored, i.e. it will not be auto-mounted at startup and will not be manually mounted using block mount.

Correct. But it only gives the bare minimum: a best-effort autogenerated mount target and the uuid, and it sets them as disabled by default. That is because you probably do not actually want or need all the possible mounts. For the mounts you actually want, you should check and if necessary adjust/append the target and mounting options, and then set enabled to 1 (or delete the enabled option line, 1 is the default if nothing is stated).

Hi, I'm no expert but have an idea for you to try.

Be sure that you change option enabled '0' to option enabled '1' to have mount actually mount what is in the /etc/config/fstab file.

For your lv,

If /dev/vgdata/lvdata is present on a fresh boot without you needing to type any commands, try changing your /etc/config/fstab file replacing the option uuid with device.

change

config mount
	option target '/mnt/sdb1'
	option uuid '97366d9c-8b7b-4424-8d7b-364d74801376'
	option enabled '1'

to

config mount
	option target '/mnt/sdb1'
	option device 'vgdata/lvdata'
	option enabled '1'

I think you can test the fstab file interactively with mount -a .

Note that on OpenWrt, mount is a built-in command of busybox and may be customized and not work as expected in a full linux distro.

root@OpenWrt:~# ls -l /bin/mount
lrwxrwxrwx    1 root     root             7 Jan  2  2023 /bin/mount -> busybox*

See mount --help
and
https://openwrt.org/docs/guide-user/storage/fstab#the_mount_sections for more info.

I intentionally left off the /dev/ in the device path for the lv. Read more or experiment with that as needed.

If this part works then you can work on r/w access in smb.

I don't know how the lv/dmsetup plays into the uci driven mount in the startup scripts and what uuid you need to reference. I did not find much with a quick search of the forum so I proposed a non uuid way to test.

Good luck!

Sorry for not replying earlier, I was sick.

A mount section that carries `option enabled '0'` is not enabled and will be ignored, i.e. it will not be auto-mounted at startup and will not be manually mounted using `block mount`.

I feel like I'm asking a stupid question but why is option enabled set to '0' for target '/' and I can access root dir? Is it because this is actually mounted during boot earlier? Like described in Wiki here?

Does it mean I can just remove this section from fstab?

@spence Thanks, I tried what you suggested but to no avail, also tried some other combinations but I cannot seem to make it work using the vg and lv names I created. The only thing that makes it at least available as a mounted share is using /dev/dm-0 as device:

root@OpenWrt:/# cat /etc/config/fstab 

config global
	option anon_swap '0'
	option anon_mount '0'
	option auto_swap '1'
	option auto_mount '1'
	option delay_root '5'
	option check_fs '0'

config mount
	option target '/boot'
	option uuid '023999f3-175d-4701-aed8-d5795d8f0f5f'
	option enabled '0'
	option options 'noatime'

config mount
	option target '/'
	option uuid 'ff313567-e9f1-5a5d-9895-3ba130b4a864'
	option enabled '0'
	option options 'noatime'

config mount
	option enabled '1'
	option device '/dev/dm-0'
	option target '/data'
	option options 'noatime'

root@OpenWrt:/#  block mount

Maybe it's a mapping issue?

The thing is, that I can mount using my vg and lv names when using mount instead of block mount.

Using regular mount - this works, I can see my random folders in /data

root@OpenWrt:/# which mount
/bin/mount
root@OpenWrt:/# mount /dev/vgdata/lvdata /data

Using block mount - cannot access logical volume, /data is empty

root@OpenWrt:/# cat /etc/config/fstab 

config global
	option anon_swap '0'
	option anon_mount '0'
	option auto_swap '1'
	option auto_mount '1'
	option delay_root '5'
	option check_fs '0'

config mount
	option target '/boot'
	option uuid '023999f3-175d-4701-aed8-d5795d8f0f5f'
	option enabled '0'
	option options 'noatime'

config mount
	option target '/'
	option uuid 'ff313567-e9f1-5a5d-9895-3ba130b4a864'
	option enabled '0'
	option options 'noatime'

config mount
	option enabled '1'
	option device '/dev/vgdata/lvdata'
	option target '/data'
	option options 'noatime'

root@OpenWrt:/# block mount

That does not really surprise me. Perhaps block mainly/only deals with block devices and may be customized for core OpenWrt usage.

It looks like using lvm is not standard in the core services so you may need to manage the start/stop sequence of lvs and everything using them.

I'm no expert but some more ideas are to create your own init script to mount/unmount your lv and add it to the init system so it is called after the vg/lv are set up on boot and also umount on shutdown or as called manually as needed.

I don't have any recent experience with init to help but hopefully the docs will get you started and you can also search the forum for posts about adding boot scripts and init scripts. I had read several related forum threads so I know there is some good info in the forum. You can do runs of a script and don't need a daemon running that needs monitoring etc.

I think I did something like this ( not using lvm) a few years ago with a basic shell script.

Maybe /etc/init.d/umount would handle graceful umount on graceful shutdown since it uses mount and not block.

You might try adding a call to your shell script in /etc/rc.local or just put your mount command in that file.

You may need to add S and K script links in /etc/rc.d for rc.local or any scripts you add.

You may need a sleep statement to wait for the lv to show up or a loop to detect it and wait as needed.

You may need modify the init sequence for your smb server to be after your mount script is done and the filesystem is verified to be accessible.

Consider not using lvm and put your supported filesystems on a partition and maybe block mount can handle them.