Can't initialize LVM volume.

1,012 views
Skip to first unread message

evilsocket

unread,
Apr 5, 2016, 2:49:04 PM4/5/16
to USB armory
I have a LVM partition on my sdcard, here's the config:

  # ls -l /dev/mmcblk0*

  brw-rw---- 1 root disk 179, 0 Apr  6 01:53 /dev/mmcblk0
  brw-rw---- 1 root disk 179, 1 Apr  6 01:53 /dev/mmcblk0p1
  brw-rw---- 1 root disk 179, 2 Apr  6 01:53 /dev/mmcblk0p2

  # fdisk /dev/mmcblk0

  Welcome to fdisk (util-linux 2.25.2).
  Changes will remain in memory only, until you decide to write them.
  Be careful before using the write command.


  Command (m for help): p
  Disk /dev/mmcblk0: 29 GiB, 31104958464 bytes, 60751872 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
  Disklabel type: dos
  Disk identifier: 0x0007a96b

  Device         Boot   Start      End  Sectors  Size Id Type
  /dev/mmcblk0p1        10240  7167999  7157760  3.4G 83 Linux
  /dev/mmcblk0p2      7168000 27959295 20791296  9.9G 8e Linux LVM

Which is not mounted:

  # mount | grep mmc

  /dev/mmcblk0p1 on / type ext4 (rw,relatime,data=ordered)

Still, when I try to inizialize it in order to use it with INTERLOCK:

  # pvcreate /dev/mmcblk0p2    
  Can't initialize physical volume "/dev/mmcblk0p2" of volume group "lvmvolume" without -ff

  # pvcreate /dev/mmcblk0p2 -ff
  Really INITIALIZE physical volume "/dev/mmcblk0p2" of volume group "lvmvolume" [y/n]? y
  Can't open /dev/mmcblk0p2 exclusively.  Mounted filesystem?

What am I missing here? :)

( The usd card is the stock one with debian preinstalled, I just created an additional partition. )

Andrea Barisani

unread,
Apr 6, 2016, 6:52:08 AM4/6/16
to USB armory
I am not sure what is going on here, I tried with a vanilla microSD card and I was able to create the logical volumes, here's the fdisk:

root@usbarmory:~# fdisk -l /dev/mmcblk0

Disk /dev/mmcblk0: 29 GiB, 31104958464 bytes, 60751872 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
Disklabel type: dos
Disk identifier: 0x0007a96b

Device         Boot   Start      End  Sectors  Size Id Type
/dev/mmcblk0p1        10240  7167999  7157760  3.4G 83 Linux
/dev/mmcblk0p2      7168000 60751871 53583872 25.6G 8e Linux LVM

My process was:

1. fdisk and add the new partition (applying the right start sector otherwise it will be created before the existing one and be very small)

2. reboot

3. Create the LVM:

root@usbarmory:~# pvcreate /dev/mmcblk0p2                         # initialize physical volume
  Physical volume "/dev/mmcblk0p2" successfully created
root@usbarmory:~# vgcreate lvmvolume /dev/mmcblk0p2         # create volume group
  Volume group "lvmvolume" successfully created
root@usbarmory:~# lvcreate -L 20G -n encryptedfs lvmvolume  # create logical volume of 20 GB
  Logical volume "encryptedfs" created

So I'm really not sure why it's failing in your case. I suggest re-flashing the microSD card just to be sure.

Thanks!
Reply all
Reply to author
Forward
0 new messages