How to read/mount full Ubuntu volume from now external hard drive
Yesterday I decided to upgrade my laptop hard drive to an SSD. I was previously running Ubuntu 14.04 on the HDD that came with it. I have installed Ubuntu 14.10 on the SSD.
I would like to mount the old HDD so that I can copy over all my files. So I purchased an enclosure that lets me treat it like an external USB drive. I put the HDD into the enclosure and plugged it in. It is detected and it sees all of the volumes. But it only mounts the boot volume for read/write.
The HDD is 750GB and the SSD is 120GB. When I inspect it in the "Disks" utility I see both hard drives and can easily tell the difference between the two. When I inspect the HDD I see: Partition 1 Ext2 (boot volume), Extended Partition 2, and Partition 5 LVM2 PV.
So clearly it can see the volumes as well. It reports that the disk is ok but has one bad sector. The drive is not encrypted. I am not sure why it shows two volumes of the same size. Probably has to do with it being an LVM volume.
How do I get it to let me read the files from my old installation of Ubuntu?
$ sudo fdisk -l
Disk /dev/sda: 223.6 GiB, 240057409536 bytes, 468862128 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: 0x7f79a18e
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 499711 497664 243M 83 Linux
/dev/sda2 501758 468860927 468359170 223.3G 5 Extended
/dev/sda5 501760 468860927 468359168 223.3G 8e Linux LVM
Disk /dev/mapper/ubuntu--vg-root: 215.6 GiB, 231479443456 bytes, 452108288 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
Disk /dev/mapper/ubuntu--vg-swap_1: 7.8 GiB, 8317304832 bytes, 16244736 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
Disk /dev/sdb: 596.2 GiB, 640135028736 bytes, 1250263728 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: 0x0004f632
Device Boot Start End Sectors Size Id Type
/dev/sdb1 * 2048 499711 497664 243M 83 Linux
/dev/sdb2 501758 1250263039 1249761282 596G 5 Extended
/dev/sdb5 501760 1250263039 1249761280 596G 8e Linux LVM
I had this issue and found a solution from this Ubuntu Forums Thread. I will give further details in case others have this issue and/or that link goes dead in the future.
System Details
Running Ubuntu 16.04 on primary. I have 2 internal drives (SDA = Ubuntu 16.04 with Grub, SDB = Windows 10). I also had an internal SATA drive with Ubuntu 14.04 from a different machine which I decided to mount using an SATA-to-USB external dock, which subsequently placed this disk at SDC; I will refer to this drive as "delta" (view these with sudo lsblk
or sudo fdisk -l
, or optionally launch GUI "Disks" from Dash)
Issues
Simply looking in Nautilus (Files GUI) I can see a 255 MB Volume when the delta drive is connected, however this is the Partition 1 Master Boot Record (Linux Bootable; EXT2). Looking in Disks GUI it is clear I have an Extended Partition (partition2) of 1,000 GB and Partition5 which is 1,000 GB LVM2 Physical Volume, but no option to mount this partition.
Fix
-
First run
$ sudo vgscan Reading all physical volumes. This may take a while... Found volume group "ubuntu-vg" using metadata type lvm2 Found volume group "ubuntu-vg" using metadata type lvm2
The issue with this output is that both my primary drive and this secondary "delta" drive are showing the same volume group name
ubuntu-vg
which causes some conflicts and makes it difficult to distinguish one from the next. So we need to change one of them. Unplug the secondary (delta) drive. If it is internal you'll need to shutdown to do this, since I'm using a dock I just power it down.
-
After reboot, re-run:
$ sudo vgscan Reading all physical volumes. This may take a while... Found volume group "ubuntu-vg" using metadata type lvm2
-
Run:
sudo vgrename /dev/ubuntu-vg /dev/ubuntu-vg-primary
Choose anything you want as the new name, I opted to append
-primary
here. Now either shutdown and re-attach secondary and reboot, or just attach the drive if using an external dock as I am.
-
Again run:
$ sudo vgscan Reading all physical volumes. This may take a while... Found volume group "ubuntu-vg-primary" using metadata type lvm2 Found volume group "ubuntu-vg" using metadata type lvm2
This is what we want to see; two unique volume group names.
-
To activate our secondary (delta) drive volume group, run:
$ sudo vgchange -ay ubuntu-vg 2 logical volume(s) in volume group "ubuntu-vg" now active 2 logical volume(s) in volume group "ubuntu-vg-primary" now active
-
Make a mount point if you haven't already, such as:
sudo mkdir -p /mnt/delta/
-
Make the mount point owned by your user:
sudo chown $(id -u):$(id -g) /mnt/delta/
Important Note:
At this point your system would either fail to reboot into Ubuntu, or it would attempt to load the version of Ubuntu corresponding to the "secondary" drive; At boot time the default/standard is to load from volume group identified as "ubuntu-vg". In order to handle this situation I went ahead and did the following:
$ sudo vgscan
2 logical volume(s) in volume group "ubuntu-vg" now active
2 logical volume(s) in volume group "ubuntu-vg-primary" now active
$ sudo vgchange -ay ubuntu-vg
$ sudo vgrename /dev/ubuntu-vg /dev/ubuntu-vg-secondary
$ sudo vgscan
2 logical volume(s) in volume group "ubuntu-vg-secondary" now active
2 logical volume(s) in volume group "ubuntu-vg-primary" now active
$ sudo vgchange -ay ubuntu-vg-primary
$ sudo vgrename /dev/ubuntu-vg-primary /dev/ubuntu-vg
$ sudo vgscan
2 logical volume(s) in volume group "ubuntu-vg-secondary" now active
2 logical volume(s) in volume group "ubuntu-vg" now active
Finally we can mount with:
sudo mount /dev/ubuntu-vg-secondary/root /mnt/delta/
At this point you can navigate in Nautilus to "Computer" then /mnt/delta/ and view the root of your external drive. You can quickly add a bookmark to this location so that you can easily access it. You could proceed (cautiously) to backup your existing /etc/fstab (to /etc/fstab.bak) and modify the existing fstab to attempt to auto-mount this device/location to the mount point. Make sure to test your fstab before shutting-down or rebooting.
Using sudo blkid
I was able to find all of the relevant UUIDs, devices, partitions, volume group info, as well as FS Types, and use this information to add a mount entry directive to my fstab. For example:
UUID=d7556cd2-67b3-4fb4-acc8-1e33dd0eb040 /mnt/delta ext4 defaults 0 2
Test using sudo mount -a
(no output means good; any output can mean there are errors which should be dealt with before attempting to reboot else you may not be able to reboot back to your OS properly).
You have to mount the LVM partition. It can be confusing if the physical volumes and/or logical volumes have the same name ...
Scan your system for LVM volumes and identify in the output the volume
sudo vgscan
you will see something like
Found volume group "fedora" using metadata type lvm2
You should see two volume groups
activate the (old) volumegroup
sudo vgchange -ay fedora
change "fedora" to your volume group ;)
Find the logical volume / partition that has your old ubuntu install
sudo lvs
or
sudo lvdisplay
or
ls /dev/fedora
again, change fedora to your volume group name
Mount the logical volumes
sudo mount /dev/fedora/home /mnt
and on ....
There is only one graphical too I know of, system-config-lvm
sudo apt-get install system-config-lvm
sudo system-config-lvm
There are lots of ways to copy over your data, even if your data folders are encrypted. All you have to do is boot the old drive and copy the data you want to copy onto external media and back to the new media. You could also try using the included "backup" utility which works very well in my experience.
Having said all of that, had you asked me before you did the upgrade I've have offered you entirely different advice. I'd have pointed out that 14.04 is an LTS version and that upgrading to 14.10 merely commits you to upgrading every six months, which I find bothersome.
I would have advised you to download clonezilla and merely clone your old hard drive to the new media, directly, and continue using the installation you already have with no need to start over. Of course you can still do that, but by now you might have made up your mind to stick with the new installation.