Ubuntu Forums ubuntu.com - launchpad.net - ubuntu help  

Go Back   Ubuntu Forums > The Ubuntu Forum Community > Main Support Categories > General Help
Register Reset Password Forum Help Forum Council Search Today's Posts Mark Forums Read

General Help
All your general support questions for Ubuntu, Kubuntu, Edubuntu and Xubuntu.

 
Thread Tools Display Modes
Old October 7th, 2008   #1
jerome1232
Iced Blended Vanilla Crème Ubuntu
 
jerome1232's Avatar
 
Join Date: Dec 2007
Location: California
Beans: 2,929
Ubuntu 9.04 Jaunty Jackalope
[SOLVED] How to mount encrypted, LVM volumes?

EDITED to reflect wanchai's comments and additions

Dealing with encryption and LVM from a live cd.

This is more for future refrence, I know I will have to deal with these disks from a live cd sometime. I currently have an encrypted file system that uses lvm. I have no idea how to work with these partitions! Right now I'm booted into a live cd, the file system was encrypted via luks (alternate install cd) I'm using twofish encryption.

Okay this was easier than I thought it was going to be, man pages are great.

/dev/sda1 is my /boot
/dev/sda2 is my crypto partition
Code:
sudo apt-get install cryptsetup            # Installs the tools we need to deal with encrypted partitions
sudo modprobe dm-crypt                      # Inserts a module we need
sudo cryptsetup luksOpen /dev/sda2 cheer   # Unlocks the partition sda2 and names it cheer
Enter LUKS passphrase: 
key slot 0 unlocked.
Command successful.
#
# Now that we have unlocked the encryption, it's just dealing with the lvm
#
#
sudo apt-get install lvm2  # installs the tools we need
sudo modprobe dm-mod       # inserts a module we need
sudo vgscan                # Scans for all volume groups
  Reading all physical volumes.  This may take a while...
  Found volume group "Ubuntu" using metadata type lvm2
sudo vgchange -a y Ubuntu  # this made the VG Ubuntu active, if you don't give it a volume group as an argument it'll make them all active        
sudo lvscan                # This command lists the logical volumes and their /dev path
  ACTIVE            '/dev/Ubuntu/Root' [15.00 GB] inherit
  ACTIVE            '/dev/Ubuntu/swap' [1.00 GB] inherit
  ACTIVE            '/dev/Ubuntu/home' [215.89 GB] inherit
#
# Now I mount them to do whatever it is I need to do, if you wanted to run a fsck on them you obviously wouldn't mount them.
#
sudo mkdir /media/root; sudo mkdir /media/home
sudo mount /dev/Ubuntu/Root /media/root; sudo mount /dev/Ubuntu/home /media/home
#
# Now to reverse the process and unmount everything
#
sudo umount /media/root; sudo umount /media/home
sudo rmdir /media/root; sudo rmdir /media/home
sudo vgchange -a n Ubuntu 
sudo cryptsetup luksClose cheer
__________________
"You can't expect to hold supreme executive power just because some watery tart lobbed a sword at you"

"Don't let your mind wander -- it's too little to be let out alone."

Last edited by jerome1232; January 9th, 2009 at 03:46 PM..
jerome1232 is offline   Reply With Quote
Old October 16th, 2008   #2
wanchai
A Carafe of Ubuntu
 
wanchai's Avatar
 
Join Date: Nov 2006
Location: Hong Kong
Beans: 92
Ubuntu 9.04 Jaunty Jackalope
Re: [SOLVED] How to mount encrypted, LVM volumes?

Thanks for your post, solved my problem.

Why are you saying that you are not sure how to mount them? Your last line in the code box does exactly that.


More stuff for future reference:

If you have multiple disks with LVMs, for example the disk your OS is running on plus the USB disk you're trying to mount, then vgchange should get the volume name as an argument, for example:
Code:
sudo vgchange -a y testDiskVG1
To un-do the whole thing, you need to unmount the logical volumes, then close the volume group and lastly close the encrypted partition. For example (using jerome1232's naming scheme):
Code:
sudo umount /media/root; sudo umount /media/home
sudo vgchange -a n Ubuntu 
sudo cryptsetup luksClose cheer

Another little problem I had: both my built-in disk and the external one used the same name for the volume group. In this case it's impossible to activate the second volume group. Use vgdisplay to see what you have. Important are the fields VG Name and VG UUID. Then you can use
Code:
vgrename oldUUID newName
to make the names unique.


One last thing: when you plug in a USB drive with encrypted LVM partitions, Gnome pops up a dialog "Unlock Encrypted Data". When you use that, Ubuntu will do half the job. Do
Code:
ls -l /dev/mapper
to see how far you got. You'll probably have to manually mount the partitions, and you certainly have to un-do things manually. Instead of something short, like 'cheer', this automagic ersatz cryptsetup gizmo will use a long, ugly name, but you'll see it in /dev/mapper.
wanchai is offline   Reply With Quote
Old October 16th, 2008   #3
jerome1232
Iced Blended Vanilla Crème Ubuntu
 
jerome1232's Avatar
 
Join Date: Dec 2007
Location: California
Beans: 2,929
Ubuntu 9.04 Jaunty Jackalope
Re: [SOLVED] How to mount encrypted, LVM volumes?

Yeah I actually just worked it over before anybody responded with an answer, so I edited my post to reflect how I got it working in case someone stumbled on the thread looking for an answer I see I forgot to edit out a few things. I added some of your additions.
__________________
"You can't expect to hold supreme executive power just because some watery tart lobbed a sword at you"

"Don't let your mind wander -- it's too little to be let out alone."

Last edited by jerome1232; October 16th, 2008 at 10:26 AM..
jerome1232 is offline   Reply With Quote
Old November 23rd, 2008   #4
wanchai
A Carafe of Ubuntu
 
wanchai's Avatar
 
Join Date: Nov 2006
Location: Hong Kong
Beans: 92
Ubuntu 9.04 Jaunty Jackalope
Re: [SOLVED] How to mount encrypted, LVM volumes?

Again, for future reference:

cryptmount after booting from Ubuntu 8.10 Desktop CD

Basically it works in the same way, but first you need to manually install packages cryptsetup and lvm2. Unfortunately, these packages are not on the Desktop CD, so you either need network access or have them on a non-encrypted disk.

Then you need to "modprobe dm-crypt". If you don't do the modprobe, cryptsetup openLuks will give you an error that sounds like "wrong password" (https://bugs.launchpad.net/ubuntu/+s...up/+bug/267192)

Last edited by wanchai; January 12th, 2009 at 12:05 PM..
wanchai is offline   Reply With Quote
Old December 21st, 2008   #5
gauthma
First Cup of Ubuntu
 
Join Date: Dec 2008
Beans: 7
Re: [SOLVED] How to mount encrypted, LVM volumes?

After having installed Kubuntu on my laptop using this tutorial, (which an almost identical setup to the one used in the explanation), I had become concerned about to do if I ever encountered problems and needed to boot from a live CD. This post cleared it out for me (worked in the first attempt, and was so much simpler of what I had imagined!)

Anyway, great work!
Big thanks
gauthma is offline   Reply With Quote
Old December 21st, 2008   #6
jerome1232
Iced Blended Vanilla Crème Ubuntu
 
jerome1232's Avatar
 
Join Date: Dec 2007
Location: California
Beans: 2,929
Ubuntu 9.04 Jaunty Jackalope
Re: [SOLVED] How to mount encrypted, LVM volumes?

Quote:
Originally Posted by gauthma View Post
Anyway, great work!
Big thanks
I'm glad it helped you

Quote:
Originally Posted by wanchai View Post
Unfortunately, these packages are not on the Desktop CD, so you either need network access or have them on a non-encrypted disk.
Good point I had never thought about if I was stranded without access to a repository, I think I'll be downloading these packages and putting them somewhere unencrypted/lvm'd.
__________________
"You can't expect to hold supreme executive power just because some watery tart lobbed a sword at you"

"Don't let your mind wander -- it's too little to be let out alone."
jerome1232 is offline   Reply With Quote
Old December 23rd, 2008   #7
wanchai
A Carafe of Ubuntu
 
wanchai's Avatar
 
Join Date: Nov 2006
Location: Hong Kong
Beans: 92
Ubuntu 9.04 Jaunty Jackalope
Re: [SOLVED] How to mount encrypted, LVM volumes?

I built myself a customised boot CD that includes the missing packages (deleted games to create space) following this guide:
https://help.ubuntu.com/community/LiveCDCustomization
wanchai is offline   Reply With Quote
Old January 9th, 2009   #8
John Wiersba
5 Cups of Ubuntu
 
Join Date: Jan 2007
Location: Ann Arbor, MI, USA
Beans: 35
Ubuntu 9.04 Jaunty Jackalope
Re: [SOLVED] How to mount encrypted, LVM volumes?

Quote:
Originally Posted by wanchai View Post
Again, for future reference:
cryptmount after booting from Ubuntu 8.10 Desktop CD
Wanchai: what did you mean by this? Was this supposed to be a be a link to an article?
John Wiersba is offline   Reply With Quote
Old January 12th, 2009   #9
wanchai
A Carafe of Ubuntu
 
wanchai's Avatar
 
Join Date: Nov 2006
Location: Hong Kong
Beans: 92
Ubuntu 9.04 Jaunty Jackalope
Re: [SOLVED] How to mount encrypted, LVM volumes?

John, it wasn't a link, just underlined text, changed it to bold, hopefully that's less confusing
wanchai is offline   Reply With Quote
Old January 29th, 2009   #10
jerremy-tamlin
Just Give Me the Beans!
 
jerremy-tamlin's Avatar
 
Join Date: Apr 2006
Location: Perth, Australia
Beans: 59
Ubuntu 7.04 Feisty Fawn
Re: [SOLVED] How to mount encrypted, LVM volumes?

Hi, I don't suppose you guys have hade any trouble remounting an LVM filesystem have you?

I posted a tread http://ubuntuforums.org/showthread.php?t=1018525 a month ago but got no responces. Haven't been able to figure out the answer. Basically My LVMs all mount fine at boot with the options I specify in fstab but if I try to remount them any options I specify are ignored.

Since you seem to be active and using LVM I thought I'd ask.

Sorry if I'm breaking into the conversation but you seemed to have solved your problem. If you ignore me I'll go away.
Cheers
Jesse
jerremy-tamlin is offline   Reply With Quote

Bookmarks

Tags
encryption, live cd, lvm, mount

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:06 PM.


vBulletin ©2000 - 2010, Jelsoft Enterprises Ltd. Ubuntu Logo, Ubuntu and Canonical © Canonical Ltd. Tango Icons © Tango Desktop Project. bilberry