Will Fraser
Posts: 1
Joined: Tue Sep 25, 2012 10:54 am

Problem setting up ext3 on LVM partition on 2 USB sticks

Tue Sep 25, 2012 11:44 am

Hello.

I'm trying to set up a photo album server on my Raspberry Pi. I've currently got about 30 gig of photos & videos.

I had been toying with the idea of using an external hard drive to store these on as although I can just about squeeze these onto the SD card, it doesn't leave any room for more photos in the future. I wasn't sure about leaving the hard-drive switched on all the time, and looked into energy saving devices controllable by the Pi to control the hard-drive. I couldn't find any with a UK plug socket for much under £50 though which seemed a bit excessive. There are USB controlled switches but I'd have to wire them up to mains plugs and I was a bit dubious about doing this safely. I found an eco-plug that would switch off plug sockets based on the power in a USB socket, but unfortunetley (and please correct me if I'm wrong), you can't turn off the 5V power to the USB sockets on the Pi as you can on some machines and so this wouldn't work.

Finally I saw PNY 32Gig USB sticks being sold for £9. I bought 2 of them with the plan to make a single volume out of them using LVM. However I've hit a problem trying to set up a single drive using LVM.

Here's what I did:
I first installed LVM:

Code: Select all

sudo apt-get install lvm2
My 2 32gb usb sticks when inserted are at sda, and sdb.

First I prepare the sticks to have lvm partitions on them. Not sure if nescesary, but doing it to be on safe side.

Code: Select all

sudo fdisk /dev/sda
and use the following options:
d: remove existing partition
n p 1 (followed by few enters): create new primary partition
t 8e: set partition to be linux LVM
p: list new partition setup to ensure it's right
w: write changes & exit

Then repeat this for the 2nd usb stick at sdb

I now create LVM physical volumes on both usb sticks

Code: Select all

sudo pvcreate /dev/sda1
sudo pvcreate /dev/sdb1
I now create the LVM volume group to add the LVG physical volumes to:

Code: Select all

sudo vgcreate vg0 /dev/sda1
I now add the second physical volume:

Code: Select all

sudo vgextend vg0 /dev/sdb1
I check all's going well:

Code: Select all

sudo vgdisplay
and get the following output:

Code: Select all

  --- Volume group ---
  VG Name               vg0
  System ID             
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  2
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               60.94 GiB
  PE Size               4.00 MiB
  Total PE              15600
  Alloc PE / Size       0 / 0   
  Free  PE / Size       15600 / 60.94 GiB
  VG UUID               ytfNNg-xdAK-AA7P-3mxq-9V2g-0rQ0-GaEUul
I now create the logical volume. The lvcreate command requires a size to be specified or it won't run. As I want to have one big partition, I calculate the number of physical extents available and multiply them by the size of the physical extent. From the data above I have 4*15600.

Code: Select all

sudo lvcreate -L 62400 -nlv0 vg0
Again I check all is well with the following command:

Code: Select all

sudo lvdisplay
and get the following output:

Code: Select all

  --- Logical volume ---
  LV Name                /dev/vg0/lv0
  VG Name                vg0
  LV UUID                5vlRRf-kuQ1-aE1W-Sfe0-jlKf-3BSi-dB3bdn
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                60.94 GiB
  Current LE             15600
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:0
And finaly I try and create a file system to sit in the logical volume:

Code: Select all

sudo mkfs -t ext3 -m 1 -v /dev/vg0/lv0
this is where I hit problems. invariably I get the following error just after it's finished writing the inode table:
ext3fs_mkdir: Attempt to read block from filesystem resulted in short read while creating root dir
It hangs at this point. Can't close it with Ctrl-C. If I ssh into a second shell, and try killing off the processes it has no effect. The only way I can close it down is by rebooting.
After rebooting vg0 is missing from /dev as are sda, sda1, sdb, and sdb1. lsusb often only lists one or occasionally neither of the usb sticks. I have to delete the logical volume, and the volume group, and then remove the usb sticks, reboot the pi, and re-insert them before it recognises the usb sticks again.

I haven't a clue why. The usb sticks are fine: they work on my linux netbook, and windows PC without any problems.

The only odd thing I've noticed is that when plugged directly into the Pi, the usb sticks feel quite warm. I've not know sticks to feel hot when inserted into a usb slot before. I have tried plugging them in through two different unpowered hubs. They are not recognised when plugged in either although they are recognised when plugged into my netbook via the unpowered hubs. I'm not sure if there is some sort of power issue here. My power supply provides 1A. I've had issues before with a faulty power supply causing random glitches, but I've tried setting up LVM several times now, always failing in the same way. Also since changing my power supply I've not had any other problems with my Pi.

I have tried setting up LVM on these 2 usb sticks on my linux netbook which runs ubuntu. It works. Oddly enough it's much slower when setting up the inode tables than the Pi, but I can create my file system on top of the logical volume, and can populate the resultant 60gb volume with files.

I've looked up the mkfs error. Some put it down to hardware problems. As far as I can tell my Pi, the power supply, and USB sticks are working (although the failure of the Pi to recognise the USB sticks when plugged in through a USB hub might indicate different). Sometimes they say it's due to having a single too big partition. I would be suprised if format would fail because there wasn't a partition before it, and besides it worked just fine on ubuntu (which is based on debian as is the rasbian os I am running my my Pi). The third problem can stem from partitions over 250gb, but mine is only 60gb and so should not be the problem.

I'd be most grateful for any suggestions people might have as to how to fix this problem, as I'm a little stumped.

jimwrightbe
Posts: 3
Joined: Mon Oct 08, 2012 9:27 pm

Re: Problem setting up ext3 on LVM partition on 2 USB sticks

Sun Mar 03, 2013 6:57 pm

HI Will,

No reply after more than 5 months? Terrible!

I read your post with interest because I was even wondering if lvm is supported. I guess so. Thanks for the info :-) My question was if it requires significant resources.

Did you solve your problem?

I would expect a single larger USB would make more sense if only because at some point you will need more space again and the advantage of LVM is that you can get a second device 4 times the size and migrate everything you have onto it, removing the smaller device to leave a free slot ready for the next upgrade :-)

I assume in your case 2x32G was cheaper than 1x64.

Anyway, not much point in me talking about a 5 month old problem but I am interested to know how you moved on in the end.

Jim

BarbaryPiRate
Posts: 2
Joined: Sat Dec 14, 2013 5:04 am

Re: Problem setting up ext3 on LVM partition on 2 USB sticks

Sat Dec 14, 2013 5:16 am

Thanks Will for a very helpful step-by-step.

If I might suggest (for other latecomers to this thread) to try:
* making the physical volumes noticeably smaller than the full size of the sticks (just to be certain you're not hitting some end-of-stick limit)

Along those same lines try:
* making a couple of small-ish partitions on a single USB stick and then making a logical volume composed of those (to see if the problem is related to trying to wed two sticks or if it's already a problem trying to wed two partitions on a single stick)

Return to “Networking and servers”