The steps in @Georg Schölly's answer did not work for me at the time, although they might work now, a few Ubuntu releases after. Back then, after the sudo mount /dev/mapper/my_encrypted_volume /media/my_device
step I got the error:
mount: unknown filesystem type 'LVM2_member'
Unlocking and mounting the disk with udiskctl
Instead, I used udisksctl
, a command-line interface that interacts with the udisksd
service.
Here's what worked (/dev/sdb5
is the partition on my hard disk marked as crypt-luks
):
udisksctl unlock -b /dev/sdb5
udisksctl mount -b /dev/mapper/ubuntu--vg-root
After typing the first command, you'll be prompted for your encryption passphrase. Once the encrypted partition is unlocked, the second command will mount it. If that's successful, you'll end up with a message similar to this:
Mounted /dev/dm-1 at /media/dpm/e8cf82c0-f0a3-41b3-ab28-1f9d23fcfa72
From there I could access the data :)
Locking the disk with udiskctl
Unmount the device:
udisksctl unmount -b /dev/mapper/ubuntu--vg-root
You'll need to deactivate all logical volumes in the ubuntu-vg
volume group first. Otherwise you'll get an error along the lines of 'Device busy' if you try to lock it (more info):
sudo lvchange -an ubuntu-vg
Then you'll be able to lock back the encrypted partition
udisksctl lock -b /dev/sdb5
Notes
- The
udisksctl
commands are executed without sudo
.
Device mapper names: the ubuntu--vg-root
naming might change across Ubuntu releases (e.g. I've seen it called system-root
and ubuntu-root
too). An easy way to find out the name is to run the following command after unlocking the LUKS partition:
ls -la /dev/mapper
Then looking at the output of the ls
command, the name you'll need will be generally the one symlinked to /dev/dm-1
Device mapper names, alternative: an alternative to the previous command is to run:
lsblk -e7
There you'll be able to see the device name mapping as a tree view. The -e 7
option is used to exclude the loop devices (ID 7) created by installed snaps from the output. Simply to have less clutter.
- Logical volume names: you can run the
sudo lvs
command to find out the names of volume groups and logical volumes
- Disks app: the GNOME Disks app does not automatically deactivate the logical volumes before locking the partition. Even if you've successfully unlocked the partition via the GUI, you will need to go to the command line and execute the
sudo lvchange -an ubuntu-vg
command before you can lock it from the GUI.
As you can see except for /dev/sda5
as well as /dev/sda7
there is no entry of other partitions in /etc/fstab
. You can manually mount your partitions by following these steps.
First of all unmount all partitions before creating an entry point to /etc/fstab
. You can use command: sudo umount /dev/sdaX
. Replace X with the partition number you want to unmount. Best way to unmount all is to use this command:
sudo umount -a
Since you want to mount your partition at /media/user/mount-drive
; you have to create the mount-point where you want to mount the partitions. Thus you've to create directories there in order to mount the partitions. Execute following in terminal to make the directories(mount point):
sudo mkdir /media/user/sda1 /media/user/sda2 /media/user/sda3 /media/user/sda6
Replace user
with your ubuntu user's name. i,e bsienn
I think.
Now you have to make changes in /etc/fstab
in order to mount your all partitions. Execute following commands to do so:
sudo cp /etc/fstab /etc/fstab.orginal
sudo nano /etc/fstab
go to the last line and add these lines:
UUID=8230744030743D6B /media/user/sda1 ntfs errors=remount-ro 0 1
UUID=60100EA5100E81F0 /media/user/sda2 ntfs errors=remount-ro 0 1
UUID=882C04092C03F14C /media/user/sda3 ntfs errors=remount-ro 0 1
UUID=13ea474a-fb27-4c91-bae7-c45690f88954 /media/user/sda6 ext4 errors=remount-ro 0 1
again replace user
in /media/user/sdaX
with your ubuntu account name.
A little explanation: UUID="contains the ID of your hard disk partitions, 1st is of /dev/sda1
and 2nd is of /dev/sda2
partitions and so on. sudo blkid
command is very useful to get the partitions information like UUID, File-system type, partition entry etc.. So any one can use it to get their information. /media/user/sda1
is the mount entry of 1st partition and so on. Remember why I created 4 directories above. ntfs
is the file system type of your 1st partition: /dev/sda1
. It may be something else also like: ext3
, ext4
, ntfs
, fat
etc, you can get the info from sudo blkid
command as I mentioned above. others will be same for all types of file-system, it tells that if any error occurs then remount the file system in read-only mode
this link is a great tutorial.
press Ctrl+x to save and exit. Press y when prompt to save.
Now mount all partitions by executing this command:
sudo mount -a
If you want to mount any specific partition you can use: sudo mount /dev/sda1
i,e to mount first partition and so on.
Now all your partitions will be mounted automatically when ever you start your system. You can check it by restart your system. :)
Reply if you need further assistance or if something goes wrong.
Edit
I forgot to saw the picture, actually you can create the folder name under /media/bseinn/
the name you want. For example /media/bseinn/data
can be created instead of /media/bseinn/sda3
; similarly /media/bseinn/ubuntudrive
can be created instead of /media/bseinn/sda6
. You've to give the same name in /etc/fstab
file. Hope you can understand.
Best Answer
Try
udisks --mount <device name>
To mount by partition label, you can do