Ubuntu LTS 12.04 boot confusion

Asked by Thomas Stone

I have installed Ubuntu 121.04 LTS alternate with full disk encryption enabled on an HP DV7 laptop equipped with two 750GB 7200rpm disk drives. After initially configuring the system, I booted from the CD and without mounting either drive I cloned sda to sdb by issuing the command "sudo dd if=/dev/sda of=/dev/sdb". It took about 7 hours for the command to complete.

Over the course of about two weeks, several reboots, and a few package installations, I copied some data to the computer (always using the default sda drive only. When I rebooted the computer, the data was missing. Thinking that the computer might have booted to the wrong drive, I rebooted with the sda drive unplugged. Ubuntu complained that the boot drive was missing. I plugged it back in and tried another reboot but this time it told me I had a bad boot sector.

I unplugged the computer, removed the battery, and swapped the hard drives. When I booted back up, the "missing" data was there along with one of the packages I had previously installed. Somehow the computer booted using sdb as the boot drive. I am now running with sdb unplugged so that the machine can not boot from sdb.

Is this a known bug in ubuntu? Should I only plug in the sdb drive whenever I want to clone my primary drive. It would be nice if I didn't have to open the box every time I want to perform a backup.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu grub2 Edit question
Assignee:
No assignee Edit question
Solved by:
Manfred Hampl
Solved:
Last query:
Last reply:
Revision history for this message
Sam_ (and-sam) said :
#1

Maybe it helps to adjust boot sequence of hd's in BIOS.

Revision history for this message
Manfred Hampl (m-hampl) said :
#2

I think the problem might be that by duplicating the disk with dd they most probably have both received the same UUID.

As grub usually identifies the disks by UUID, it is not predictable, from which disk it will boot if there are two disks with the same UUID.
To verify the UUIDs, you can issue the command "sudo blkid"

If both disk have the same UUID, you can change one with the command "sudo tune2fc -U random /deb/sdb"

Of course you have to be sure to do that on the right device, and you should verify the grub configuration before doing that!

Revision history for this message
Thomas Stone (stone14z) said :
#3

"sudo blkid" does show that the UUIDs are the same for sda and sdb using "sudo blkid" but the system but when I attempt to correct the problem as described I get "sudo: tune2fc: command not found". Is there a different command that should work with unbuntu 12.04. btw... I changed the /deb/sdb to /dev/sdb when I entered the command. When I try "man" or "which" tune2fc is not found.

Revision history for this message
Thomas Stone (stone14z) said :
#4

I did some searching and think that you intended tune2fs, not tune2fc. I still had problems.

ubuntu@ubuntu:~$ sudo blkid
/dev/loop0: TYPE="squashfs"
/dev/sda1: UUID="d1e45c28-6f17-4550-89ae-b0e7f5b081b7" TYPE="ext2"
/dev/sda5: UUID="c2d17ec9-d7fa-4293-a57f-881c505dd650" TYPE="crypto_LUKS"
/dev/sdb1: UUID="d1e45c28-6f17-4550-89ae-b0e7f5b081b7" TYPE="ext2"
/dev/sdb5: UUID="c2d17ec9-d7fa-4293-a57f-881c505dd650" TYPE="crypto_LUKS"
/dev/sr0: LABEL="Ubuntu 12.04 LTS amd64" TYPE="iso9660"
ubuntu@ubuntu:~$ sudo tune2fs -U random /dev/sdb
tune2fs 1.42 (29-Nov-2011)
tune2fs: Bad magic number in super-block while trying to open /dev/sdb
Couldn't find valid filesystem superblock.

The command without either of the drives being mounted. Do the drives need to be mounted to run the command? If so, how do I determine which drive I booted to if both are plugged in?

Revision history for this message
Best Manfred Hampl (m-hampl) said :
#5

Sorry for the typo errors, your assumptions that its should be /dev/ instead of /deb/ and tune2fs instead of tune2fc were completely correct.

The command "mount" should tell which device is mounted to the / directory.

And another error on my side:The tune2fs command has to be executed on the file systems, not on the device. So the commands must be something like
sudo tune2fs -U random /dev/sdb1
I expect that it is necessary that the file systems are not mounted for the command to succeed.

Caution: I do not have experience with encrypted file systems, so I do not if the command will work on /dev/sdb5 (or /dev/sda5) and if that has effects on the encrypted data! Use at your own risk - I do not accept any liability!
It might be that for the encrypted file system you have to use a command like
sudo cryptsetup luksUUID --uuid={UUID in standard UUID format}

Revision history for this message
Thomas Stone (stone14z) said :
#6

Thnak you very much. Since Iḿ doing bare metal backups, if it fails on the encrypted system I can redo the backup and try with the cryptsetup command. Thank you much for your insights into this. You have increased my understanding considerably.

Revision history for this message
Thomas Stone (stone14z) said :
#7

Since blkid showed sdb1 as type exts and sdb5 as crypto_LUKS, I used tune2fs on sdb1 and cryptsetup on sdb5. It worked like a champ; now both drive can stay plugged in all the time. btw... for the uuid for sdb5, all I needed to do was change the last digit of the existing uuid.

A note for anyone else who encounters this problem, when issuing the cryptsetup command, do not quote the uuid on teh --uid option. The correct format of the command is ¨sudo cryptsetup luksUUID /dev/sdb5 --uuid=d1e45c28-6f17-4550-89ae-b0e7f5b081b8¨. After using the ¨sudo blkid"command, use the tunefs command for all partitions on the clone drive that are marked as type EXT2 and use the cryptsetup on all partitions marked as type crypto_LUKS. When using the cryptoLUKS it is ok to re-use the existing UUIDs as long as you change at least one of the digits. If you are pathological and desire a ¨unique¨ uuid, then just feed the existing uuid into a hash calculator and use the SHA1 result as the new uuid.