Originally posted by: idea
So I installed a PCI SATA controller in the Linux box and added two 320GB SATA's that I saw over in Hot Deals.. I have a few questions.
Slackware 9.0 linux-2.6.13.2
PCI SATA - Promise SATA150 TX2plus
2x Western Digital 320GB SATA 7200RPM
I built the kernel with the chipset, then installed the card and hdds. I boot up. First problem:
The computer now wants to boot off the SATA drive. How do I have it acknowledge the IDE controller, BEFORE the SATA? I want to boot Linux to make sure the drives are mountable and the SATA card is installed properly.
Sounds like a BIOS issue. That is the computer tries to access the "MBR" on the sata drives instead of the one you want on the pata drive, right? Should be able to go into the bios and select what boot device to try first.
After I get that fixed... we have the issue of ghosting the old hdds to the new ones
I understand Norton Ghost off a DOS boot disk is not the best way to copy a linux partition, so I tried Ghost 4 Unix. It will detect the IDE disks but not the new SATA ones, even though my controller is listed as supported. I emailed the author so we'll see what happens.
In the mean time, what is the best way to ghost a linux partition to another disk?
The easiest way is to boot up with a boot cdrom like knoppix. Knoppix, if you don't already know,
😉 is a live linux cdrom. That means it boots off of the cdrom drive and runs completely from it.
After you boot up then you use the dd command to copy the old drive over to the new one. DD is a command to copy block devices from one file to another for various reasons. It's pretty simple, but it's very capable. I beleive it was originally designed for making backups to tapes and such.
For instance if you want to make a ISO image of a data cdrom you have...
dd if=/dev/cdrom of=/tmp/cdrom.iso
and that would make a iso image thats a bit for bit match of the cdrom, which you can use later to make more cdroms.
Well you can use that to duplicate partitions, drives, or whatever you want. The reason it's easier to boot off of the cdrom is that it's much more difficult to copy from a drive while it's in use.
So if your PATA drive is /dev/hda and your SATA drive is /dev/sda then you can simply go:
dd if=/dev/hda of=/dev/sda
And then it will completely copy over the contents of one drive to the other. Partitions, MBR, empty space, the whole nine yards.
Then if you want to use the entire space of the new and much larger drive then you use the qtparted utility that's on the knoppix drive and resize the partitions to use up the new extra space.. or make new partitions for you to setup mount points later.
Then all that remains is that you need to mount the new 'root' partition and go in and adjust your bootloader configuration file and your /etc/fstab to reflect the changes in partition/drive naming/numbering.
Also you may need to re-run the bootloader installation command. To do this you need to use the chroot command.
Chroot means 'change root'. And what it does is that if your booted up on one root OS, but you have another one mounted somewere, or you have a little Linux distro copied to a directory somewere, you can use chroot to change the context of your shell enviroment from one root enviroment to another. So that even though your booted up with something else, you can effectively run commands and do things as if you were running the OS your chroot'd into.
So it's like this:
mount /dev/sda1 /mnt/myroot
mount -t proc proc /mnt/myroot/proc
(then mount any other file systems you feel like like /boot or /home or anything like that)
cd /mnt/myroot
chroot ./
Then you can easily change the configuration file and run grub-install or lilo or whatever command.
However the downside to DD is that your copying _everything_. This can take a very very long time to copy like 80 gigs of information, especially when 30-40 gigs would be empty space. Plus then you have to resize partitions and such which can be messy.
A alternative way is to partition everything ahead of time and then format the new partitions with whatever file system you like (ext3 or xfs or whatever) and then simply copy over the files from one drive to another.
So if you go (assuming that /dev/hda1 is the source partition and /dev/sda1 is the target for the OS, and after you partitioned and formatted the target drive):
mkdir /mnt/source
mount /dev/hda1 /mnt/source
mkdir /mnt/target
mount /dev/sda1 /mnt/target
cd /mnt/source
tar cf - * | ( cd /mnt/target ; tar xfp - )
and that should copy over the files. Then what you have to do is use the chroot comand to go into the new partition, edit the /etc/fstab file and install the bootloader. If you want to see the progress of the tar you can add 'v' to it. But be aware that in xterms with lots and lots of text scrolling by quickly it can eat up cpu resources and slow the file transfer down a bit. Don't forget about proc.
Then if you want to get fancy and do network installs and stuff like that like you can with ghost then you can use the netcat command (nc) to pipe data over the network and duplicate OSes that way from computer to computer. If you use dd command and there is no change in the order of the target drives and partitions from one computer to another everything should just boot up without having to muck around with chroot and the bootloader and stuff. On a modern distro even when using computers with different hardware it should be all autodetected and setup when they next boot up. Good for making images of drives for backups and stuff like that too.
Google around and you can find numerious examples of people using dd and tar and even just cp to make duplicates of OSes from one drive or system to another. I've done it myself a couple times. So if I confused you you can find better answers elsewere.