0
$ sudo vgs
  VG         #PV #LV #SN Attr   VSize    VFree
  lubuntu-vg   1   3   0 wz--n- <465.26g    0 

$ sudo lvs
  LV               VG         Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  lubuntu--vg-home lubuntu-vg -wi-a----- <413.26g                                                    
  root             lubuntu-vg -wi-ao----   48.00g                                                    
  swap_1           lubuntu-vg -wi-ao----    4.00g     

$ ls -l /dev/mapper/
total 0
crw------- 1 root root 10, 236 Feb 23 13:35 control
lrwxrwxrwx 1 root root       7 Feb 23 13:59 lubuntu--vg-lubuntu----vg--home -> ../dm-2
lrwxrwxrwx 1 root root       7 Feb 23 13:59 lubuntu--vg-root -> ../dm-0
lrwxrwxrwx 1 root root       7 Feb 23 13:59 lubuntu--vg-swap_1 -> ../dm-1

I might name a LV unnecessarily long when creating it. Now I want to rename it, but has an error. How shall I deal with it? Thanks.

$ sudo lvrename /dev/mapper/lubuntu--vg-lubuntu----vg--home   /dev/mapper/lubuntu--vg-home 
  Existing logical volume "lubuntu--vg-lubuntu----vg--home" not found in volume group "lubuntu-vg"

$ sudo lvrename lubuntu-vg lubuntu--vg--home   home 
  Existing logical volume "lubuntu--vg--home" not found in volume group "lubuntu-vg"
  • you wouldn't have accidentally added a space at the end of /dev/mapper/lubuntu--vg-lubuntu----vg--home? – tink Feb 23 at 19:20
  • I don't think so, but how can I verify that? – Tim Feb 23 at 19:23
  • ls -Q will quote names, should then be quite obvious – tink Feb 23 at 19:24
  • Thanks. Strange that I could remove the LV by sudo lvremove lubuntu-vg/lubuntu--vg-home and create a new LV with name home by sudo lvcreate -l 100%FREE -n home lubuntu-vg, so I couldn't test your command. Still I am hoping if someone knows what happened. – Tim Feb 23 at 19:46
  • As mentioned in the manpage, the escaping rules can change between releases, so users shouldn't use the names of LV under /dev/mapper but symlinks under /dev, which always follow the VG/LV naming convention and doesn't need any escaping character handling – 炸鱼薯条德里克 Feb 24 at 12:50
1

I'd say you're mixing up the "minus-sign-escaped" and unescaped forms of the names.

This would be the closest of being correct:

sudo lvrename lubuntu-vg lubuntu--vg--home   home 

But as the lvs command indicated, the LV name was lubuntu--vg-home. Note: the human-friendly form has 3 minus signs, not 4. So the correct form would have been:

sudo lvrename lubuntu-vg lubuntu--vg-home home 

The LV device names in full form are always /dev/mapper/<VG name>-<LV name>, so any single minus signs in either the VG name or the LV name will get doubled to ensure that the single minus sign between the VG and LV names remains unambiguous. But it seems this "minus-sign-escape" rule breaks down somehow if you specify the device names in long "already-escaped" form on the command line.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.