I’ve got a machine that’s used as a local file server (Samba & NFS) which I wanted to upgrade the OS (it’s running Kubuntu 10.04) and increase the size of the primary drive 1TB -> 2TB. I also wanted to switch to LVM partitioning because I’ve been using it on another machine since openSUSE 11.3 (it’s now up to openSUSE 12.3) and I like the flexibility. Doing the LVM setup in YAST was so simple that I thought I’d do the disk partitioning and LVM setup in YAST before installing the OS. That way I could copy all of the non-changing files from the old drive to the new one and minimize the down-time of the file sharing system.
So I plugged the drive into my USB 2.0-to-SATA adapter attached to the openSUSE machine, went into the Yast partitioner and created a 500 MB primary partition formatted as ext4 and an unformatted extended partition that occupied the rest of the drive. I created a volume group that encompassed that entire partition and created a number of ext4 formatted logical volumes.
When YAST had completed, all of those new logical volumes showed up in /dev/disk/by-label/, so I mounted one of them at /mnt and proceeded to copy everything from the NFS-mounted volume on the other machine (cpio -p). When the copy was complete, I unmounted the volume at /mnt and tried to do an e2fsck of the just unmounted volume. I was greeted with an error about a zero-length superblock, and got the same error when trying to do an e2fsck on any of the newly-created (but never mounted or used) logical volumes.
So I assumed that I needed to format the extended partition before creating the volume group and proceeded to do the entire process over, but this time formatting the extended partition as ext4 before going back into the YAST partitioner to create the volume group and logical volumes. Unfortunately that didn’t help. Exactly the same error message.
It seems that there’s some issue (udev rules?) with udev and dm for drives that aren’t present at boot time. For example:
# ls -l /dev/disk/by-label/
total 0
lrwxrwxrwx 1 root root 10 Dec 29 16:33 FB_boot -> ../../sdd1
lrwxrwxrwx 1 root root 10 Dec 29 10:19 FreeBSD -> ../../sdb3
lrwxrwxrwx 1 root root 9 Dec 29 10:21 openSUSE\x2013.1\x20KDE\x20Live -> ../../sr0
lrwxrwxrwx 1 root root 10 Dec 29 10:19 oS_boot -> ../../sda1
lrwxrwxrwx 1 root root 10 Dec 29 10:19 oS_home -> ../../dm-0
lrwxrwxrwx 1 root root 10 Dec 29 10:19 oS_opt -> ../../dm-1
lrwxrwxrwx 1 root root 10 Dec 29 10:19 oS_root -> ../../dm-2
lrwxrwxrwx 1 root root 10 Dec 29 10:19 oS_shared -> ../../dm-3
lrwxrwxrwx 1 root root 10 Dec 29 10:19 oS_srv -> ../../dm-4
lrwxrwxrwx 1 root root 10 Dec 29 10:19 oS_swap -> ../../dm-5
lrwxrwxrwx 1 root root 10 Dec 29 10:19 oS_tmp -> ../../dm-6
lrwxrwxrwx 1 root root 10 Dec 29 10:19 oS_usr -> ../../dm-7
lrwxrwxrwx 1 root root 10 Dec 29 10:19 oS_var -> ../../dm-8
lrwxrwxrwx 1 root root 10 Dec 29 10:19 System -> ../../sdb1
lrwxrwxrwx 1 root root 10 Dec 29 10:19 V-WXPpro-32 -> ../../sdb2
notice that a number of nodes have been created at /dev/dm-?
These are the logical volumes that are in use by the running system (openSUSE 12.3 x86_64). Notice also the /dev/disk/by-label/FB_boot is the first (only) primary partition on /dev/sdd. So udev finds the “hotplugged” USB drive, but not the logical volumes on that drive.
see
# pvscan
PV /dev/sdd5 VG freebee lvm2 [1.82 TiB / 0 free]
PV /dev/sda2 VG system lvm2 [465.62 GiB / 301.62 GiB free]
Total: 2 [2.27 TiB] / in use: 2 [2.27 TiB] / in no VG: 0 [0 ]
now see
# vgscan
Reading all physical volumes. This may take a while...
Found volume group "freebee" using metadata type lvm2
Found volume group "system" using metadata type lvm2
and
# lvs
LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
backup freebee -wi------ 966.51g
home freebee -wi------ 250.00g
opt freebee -wi------ 3.00g
root freebee -wi------ 1.00g
shared freebee -wi------ 600.00g
srv freebee -wi------ 3.00g
swap freebee -wi------ 4.00g
tmp freebee -wi------ 10.00g
usr freebee -wi------ 10.00g
var freebee -wi------ 15.00g
home system -wi-ao--- 25.00g
opt system -wi-ao--- 3.00g
root system -wi-ao--- 1.00g
shared system -wi-ao--- 100.00g
srv system -wi-ao--- 2.00g
swap system -wi-ao--- 3.00g
tmp system -wi-ao--- 10.00g
usr system -wi-ao--- 10.00g
var system -wi-ao--- 10.00g
so lvm is seeing all of the logical volumes in both volume groups but nodes are only created for those actually present at boot. If I have the USB adapter and drive powered on at bootup, the necessary nodes ARE created.
# ls -l /dev/mapper/
total 0
crw------- 1 root root 10, 236 Dec 29 10:19 control
lrwxrwxrwx 1 root root 7 Dec 29 10:19 system-home -> ../dm-0
lrwxrwxrwx 1 root root 7 Dec 29 10:19 system-opt -> ../dm-1
lrwxrwxrwx 1 root root 7 Dec 29 10:19 system-root -> ../dm-2
lrwxrwxrwx 1 root root 7 Dec 29 10:19 system-shared -> ../dm-3
lrwxrwxrwx 1 root root 7 Dec 29 10:19 system-srv -> ../dm-4
lrwxrwxrwx 1 root root 7 Dec 29 10:19 system-swap -> ../dm-5
lrwxrwxrwx 1 root root 7 Dec 29 10:19 system-tmp -> ../dm-6
lrwxrwxrwx 1 root root 7 Dec 29 10:19 system-usr -> ../dm-7
lrwxrwxrwx 1 root root 7 Dec 29 10:19 system-var -> ../dm-8
It turns out that there’s no problem with the logical volumes created by YAST. I plugged the USB adapter into the Kubuntu machine and after installing the lvm2 package all of the logical volumes appeared and I was able to successfully run fsck on all of them. I can also power down the USB adapter and when I power it back up all of the logical volumes reappear.
So I suspect that this is an issue with udev rules not requiring udev to invoke the device mapper except at boot. I also supect that those same udev rules are why I’m having an issue with demonstrably working eSATA hardware not working in “hotplug” situations.
Any guidance you can provide will be greatly apreciated.
Regards,
ron