Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I try to install PC-BSD 9 besides Fedora 16 on my Thinkpad. I installed Fedora on the hard disk, using default lvm with encryption. I left 50GB "unused" on the 250Gb HDD. When I boot into the LiveCD of PC-BSD it only sees the whole HDD (obviously), not the 50Gb unused space. I use grub2.

So my questions are:

  1. How can I install PC-BSD on the unused space? It does not have to be under luks.

  2. Will there be problems with grub?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

You can't install BSD to a LVM2 volume, so you'll need to shrink the LVM2 physical volume partition and create a regular partition instead.

Remember kids, lots of things can go wrong when you're messing around with resizing partitions and such. Be sure and have backups, just in case.

All these commands require root access, so run su - first or prefix them with sudo.

You'll need to boot from a Fedora LiveCD or USB so you're not currently using the device you're working with. (Technically, any Linux live media will do, but distributions other than Fedora typically don't provide LVM tools on their live media by default.) Then, fire up a terminal.

To get started, activate LVM:

lvm vgchange -a y

Next, figure out the Unix device file and minimum size. First run:


Look on the PV Name line, which should say something like /dev/sda2. That's the device. Also take note of the size, so you know what to shrink it to. You might also want to take a look at the size of all your logical volumes, so you know what the minimum you can shrink it to is. (Don't worry, pvresize won't let you shrink it too much. ;-) To figure that out, run:


With this information in hand, you can resize the LVM physical volume:

pvresize --setphysicalvolumesize <size> <device>

Where <size> is the desired size you want to shrink the LVM PV to and <device> is the device the LVM PV is located on.

Now the fun part. You have to resize the partition the LVM PV is located on. Unfortunately, this requires deleting the old partition from the partition table and recreating it, so be careful.

First, ask LVM how many sectors are in your PV:

lvm pvs --units s

Note the PSize, which is the size of your newly resized LVM PV in sectors.

Now, fire up parted on your hard drive:

parted <device>

Where <device> is your hard drive, e.g. the device you used earlier minus the partition number, for instance /dev/sda.

This lands you in a special parted shell. First, we want to switch it to display sectors instead of megabytes, so rounding errors won't cause issues:

unit s 

Print your partition layout. You likely have a small boot partition on partition 1, and the LVM PV on partition 2.


Note the partition number and start location.

Once you've figured out the PV partition, remove it from the partition table. (This doesn't actually remove any data.)

rm 2

Where 2 is the appropriate partiton number.

Now, recreate the partition with the new size:

mkpart <partiton #> primary <start> <end>

Where <partition #> and <start> are the partition number and start location you just looked up. To calculate the <end>, and the PSize you found earlier to the start location, plus 131072 sectors (64MB) for good measure.

Switch back to gigabytes and check the layout again. You should have around 50MB free at the end now!

unit GB

Now you can reboot from the LiveCD, verify that Fedora still works, and then go ahead and install BSD in the empty space.

*Hat tip to this FedoraSolved entry which helped me formulate these instructions without missing anything.

share|improve this answer
Thanks for that! But it only works on lvm without LUKS, right? because i) the FedoraSolved entry says so and ii) vgchange does not work. Or do I miss something? Can't mount /dev/sd2 because of 'unknown filesystem'. I use Fedora 16 LiveCD. –  Steffen Feb 24 '12 at 16:55
You can't resize a LUKS encrypted logical volume, which only means you can't resize the existing Fedora LVs. As long as you have 50GB of free space at the end of the physical volume, you can still resize the PV. Not sure why lvchange isn't working. What error does it give? –  Patches Feb 24 '12 at 19:31
It says "No logical volumes found" –  Steffen Feb 25 '12 at 16:33
Ugh, I meant vgchange, sorry. Does vgchange -a y give you an error? What does pvdisplay say? –  Patches Feb 27 '12 at 4:28
Ah, I got it! I first had to mount and decrypt it via the disk utility. Then everything's working BUT one point: pvdisplay prints the luks label, not the device (sda). Now everything is working! Thanks a lot! (bsding right now ;) ) –  Steffen Feb 27 '12 at 16:56
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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