June 24, 2012
The Odd Couple of Disks
Today we go diving into an old disk for treasures left on the old disks.
Until a couple of years ago, my main computer was a custom built rig made from parts either bought at the local electronics store or eBay. I should warn you that unless you plan to buy peripherals or an entire system, don't buy motherboards and chipsets off of eBay. The performance was more sluggish than advertised and in the end, the "magic smoke" put my machine out of order.
So you could probably see how important it is for me to find a job that provides an income to re-establish the more important parts of the machine. The most expensive parts on the computer will always be the monitor, the graphics card (GPU), the motherboard (MoBo), and the Central Processing Unit (CPU). Since the first two of these items I still have and work perfectly, the last two are still in limbo in terms of financial planning is concerned.
So for now, I roll in this netbook. But there are some upsides to the netbook (when it's not being used as the primary computer, obviously). The nimble capabilities allow for today's hack to work.
I have my old hard disk, a USB 2.0 to IDE/SATA Adapter Kit, and my netbook.
The netbook is a 32-bit Ubuntu Linux system that uses an Intel processor. The old hard disk was used on a X86_64 Fedora Linux system that used an AMD64 processor. Let's call this set up The Odd Couple. We'll call my netbook's user
oscar and my old harddrive's user
Suppose Felix asked Oscar to fetch some old photos from the harddrive of a computer Oscar accidently broke one morning. Both gentlemen use Linux but like their personalities, their computers are asimilar like I mentioned earlier.
Oscar starts out by hooking up the old harddrive to his Bytecc USB 2.0 Drive Mate (you might use a different device). He plugs the power supply into the power strip. He connects the hard disk to the device. And he plugs in the devices USB plug into his computer.
Everything is working like Oscar intended. Or so he thought. While his Ubuntu system scanned the disk and found a partition with the disk he wanted, it was the other disk's boot partition. This would be completely useless to his friend Felix. So Oscar looks to see if there are any other partitions on the harddrive.
oscar@madison:~$ sudo fdisk -l [sudo] password for oscar: Disk /dev/sda: 500.1 GB, 500107862016 bytes 255 heads, 63 sectors/track, 60801 cylinders, total 976773168 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 identifier: 0x000b3030 Device Boot Start End Blocks Id System /dev/sda1 * 2048 970631167 485314560 83 Linux /dev/sda2 970633214 976771071 3068929 5 Extended /dev/sda5 970633216 976771071 3068928 82 Linux swap / Solaris Disk /dev/sdb: 200.0 GB, 200049647616 bytes 255 heads, 63 sectors/track, 24321 cylinders, total 390721968 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 identifier: 0xba44ba44 Device Boot Start End Blocks Id System /dev/sdb1 * 63 208844 104391 83 Linux /dev/sdb2 208845 390716864 195254010 8e Linux LVM oscar@madison:~$
From this we can see the mounted partitions on Oscar's harddrive (all the
/dev/sda* devices) and on Felix's disk (all the
Oscar think's he has this in the bag. So he mounts the other partition on Felix's harddrive to a new directory.
oscar@madison:~$ sudo mkdir /media/felixdisk oscar@madison:~$ sudo mount /dev/sdb2 /media/felixdisk mount: unknown filesystem type 'LVM2_memember'
Again, what could have happened? Oscar did everything right, but he still hasn't recovered his neat friend's photos for the newspaper.
It then dawns on him, that is friend Felix uses Fedora. And Redhat-based Linux distributions use LVM2 (Linux Volume Manager 2) to mount logical volumes. Fortunately, for Oscar all he has to do is type in the following command to install LVM2 on his computer.
$ sudo apt-get install lvm2
Once that is installed, as well as any other software LVM2 needs to work, Felix is ready to roll again. He uses the following commands.
oscar@madison:~$ sudo vgscan Reading all physical volumes. This may take a while... Found volume group "VolGroup00" using metadata type lvm2 oscar@madison:~$ sudo lvs LV VG Attr LSize Origin Snap% Move Log Copy% Convert LogVol00 VolGroup00 -wi--- 184.22g LogVol01 VolGroup00 -wi--- 1.94g oscar@madison:~$ sudo modprobe dm-mod oscar@madison:~$ sudo vgscan Reading all physical volumes. This may take a while... Found volume group "VolGroup00" using metadata type lvm2 oscar@madison:~$ sudo vgchange -ay VolGroup00 2 logical volume(s) in volume group "VolGroup00" are now active
Oscar thinks that he's ready now. So he tries his mount command again.
oscar@madison:~$ sudo mount /dev/sdb2 /media/felixdisk mount: unknown filesystem type 'LVM2_memember'
After all that, Oscar wonders what he did wrong. When mounting a LVM2, you need to mount according to the Logical Volume path.
sudo mount /dev/VolGroup00/LogVol00 /media/felixdisk
Eureka! Felix's disk is now mounted on Oscar's computer. In fact, there is a disk icon on Oscar's computer that has an "LV" icon on it. Oscar clicks on the icon and the window explorer program show Felix's root directory. He clicks on the
home folder, then he clicks on Felix's home directory
felix. And just when Oscar thinks he's got things taken care of, he gets an error message stating he cannot access the folder.
A trip through the harddrive using some
ls -l commands confirms Oscar cannot access the folder because he doesn't have access to it.
oscar@madison:~$ cd /media/felixdisk/home oscar@madison:/media/felixdisk/home$ ls -la total 40 drwxr-xr-x. 3 root root 4096 Apr 19 2010 . dr-xr-xr-x. 27 root root 4096 Nov 19 2010 .. drwx------. 143 500 500 20480 Nov 10 2010 felix
Just about everywhere there is a
500, there would be a
felix if Felix was using a Debian-based Linux distribution instead of a Redhat-based distribution. The best way for Oscar to fix this is to change the permission of each folder or file he needed to inspect.
oscar@madison:/media/felixdisk/home$ sudo chown oscar felix oscar@madison:/media/felixdisk/home$ sudo chgrp oscar felix oscar@madison:/media/felixdisk/home$ ls -la total 40 drwxr-xr-x. 3 root root 4096 Apr 19 2010 . dr-xr-xr-x. 27 root root 4096 Nov 19 2010 .. drwx------. 143 oscar oscar 20480 Nov 10 2010 felix
Of course, everytime Oscar dives deeper into Felix's harddrive, he'll need to use those
chgrp commands. He might also need to use
chmod for command, but for now let's continue our story.
Oscar has saved Felix's skin by recovering Felix's work. It's now time to dismount the harddrive.
When you use a
mount command, you will almost certainly need to use an
umount (Note: no "n" after the first "u"). The changes made to Felix's harddrive should still be there, but Oscar is too lazy to change them back.
oscar@madison:/media/felixdisk/home$ cd ~ oscar@madison:~$ sudo umount /media/felixdisk
Of course, you will still need to "Safely remove" any disk that are still mounted on you device by right clicking on their icons and selecting "Safely Remove".