Red HatThis forum is for the discussion of Red Hat Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have two questions that I think are related to each other. Both questions have to do with copying a SATA drive and making it the boot device. I am copying a disk with "dd" and attempting to boot off the first drive. Detailed questions at bottom. (Redhat v6)
1) backup sda to sdb (Both Western Digital 2.0TB, SATA Drives)
dd if=/dev/sda of=/dev/sdb
2) reboot system, When both drives are in always boots off 2nd drive /dev/sdb
3) Output of df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/vg_mast4-lv_root
51606140 13130136 35854564 27% /
tmpfs 4052108 272 4051836 1% /dev/shm
/dev/sdb1 495844 244471 225773 52% /boot
/dev/mapper/vg_mast4-lv_home
1860635512 16287164 1749833560 1% /home
/dev/sr0 2704778 2704778 0 100% /media/K3b data project
Questions:
#1) When both SATA drives are in, it skips the first drive /dev/sda and boots from /dev/sdb. How can I always force the system to always boot from the first drive? The only way I have found is to pull the second drive and the system will boot from first drive /dev/sda. I have tried setting the hardware boot prom to change the boot order to no success.
#2) The SATA harddrives are the same make/model/size. When I use "dd if=/dev/sda of=/dev/sdb" I thought I was making a sector for sector copy. However, the first drive "sda" will only boot when in the first slot and the second drive will only boot when in the second slot. After making a sector for sector copy why are the drives slot dependant?
When a drive is cloned everything is duplicated i.e. VG names, filesystem UUIDs etc. With duplicate names I would guess it depends on how grubs picks which root LV and / to use. Take a look at the output of the dmesg command. It might provide some clues.
When a drive is cloned everything is duplicated ..., filesystem UUIDs ...
Ah! That makes sense. And if that's the problem, then you can fix it with the tune2fs command. (That is, assuming the file system is ext2, ext3 or ext4. It probably is unless you explicitly chose something else.)
Maybe something like this:
tune2fs -L <new-label-1> -U random /dev/sdb1
tune2fs -L <new-label-2> -U random /dev/sdb2
tune2fs -L <new-label-3> -U random /dev/sdb3
See man tune2fs for more.
Also note that once you've assigned unique UUIDs you can edit /etc/fstab to reference the UUID instead of the device. Then it won't matter which device letter gets assigned.
Just out of curiosity, how is your BIOS set up as far as boot order is concerned? Is it possible that BIOS is choosing sdb as a first boot device when both are there and only chooses sda when sdb is not available? If I connect my phone by USB before I boot, BIOS warns me that boot devices have changed. If I press "F1" to ignore, the system is unable to find grub and I have to reboot.
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,629
Rep:
There might be something like /boot/grub/device.map on your disk (depending from the version of GRUB you are using and whether that deemed a map file necessary). It contains assignments of your disks for GRUB. You might experiment with that.
As michaelk suggested, look at dmesg. The boot code is smart enough to figure out they are not actually the same disks so it assigns them different ID's (like HD0 and HD1). That is why is seems the drives are location dependant but all you have to do is go into the grub command line and redetect the proper disk.
I wouldn't worry too much about this. dd does make a bit-for-bit copy but sometimes the BIOS and grub can do funny things to booting up your system. In fact, i am positive that you would find tiny differences between the two disks as simply booting up changes files.
I have used dd many times and never did it fail on me. If you are not certain you could do a diff on both drives for the important dirs (easiest is to use rsync with the -n switch for that; rsync -av -n /dev/sda1 /dev/sdb1)
How can I always force the system to always boot from the first drive?
It must be set via BIOS, where you have in BOOT section a subsection "boot device priority".
Make sure your SECOND drive is set up as first boot device.
Perhaps, where you insert your second drive is actually the 1st SATA port, while your "first" drive was originally inserted into the 2nd one. That's the only possible explanation, except if by "IT boots off" you mean your GRUB bootloader.
Hi. You should use blkid command to show you new block names (in the new device). Then, choose in /etc/fstab the new blkid for each device (for sda1, sdb1, etc). Second: choose in grub the new id names and run: grub-install /dev/sda (or /dev/sdb). Pull out (or not) the old device, and restart. I wish this explanation will useful.
Have a nice day.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.