pantz.org banner
CentOS 5 PATA to SATA initrd image
Posted on 07-25-2008 15:24:14 UTC | Updated on 07-25-2008 19:21:52 UTC
Section: /software/mkinitrd/ | Permanent Link

In CentOS 5 (and 4 for that matter) when you install to a PATA hard drive your installing to /dev/hda as your first disk. If your using disk imaging software and make an image of your first partition (/dev/hda1) then restore that image on a SATA disk your boot will fail horribly. The failure (switchroot: mount failed) will be when it tries to switch from the initrd image to the real file system. The problem here is PATA block devices are built into the kernel but the SCSI and SATA block device modules are not. They are supposed to be loaded by modules from the initrd image. If you did not do the original install with a SATA disk then the needed subsystems are not put in the initrd image that your booting.

So you want to fix this right? To do that we need take the kernel modules for the SATA and SCSI subsystems and put them in a new initrd image. We can use the old PATA disk to make the new initrd image for the new SATA initrd image. To do this boot the PATA disk with the working /dev/hda. After logging in we can make the new initrd image. Let's do this now.

mkinitrd -v -f --with=scsi_mod --with=sd_mod --with=libata --with=ata_piix /boot/initrd-2.6.18-8.1.15.el5.centos.plusPAE-ata.img 2.6.18-8.1.15.el5.centos.plusPAE

The above command will make an initrd image with the SCSI and ATA modules built in. The --with= arguments show the different modules that will be put into the initrd image. The argument with /boot/ is the name of the initrd image you are going to make. The last argument is running kernel version. The example is done with the 2.6.18-8.1.15.el5.centos.plusPAE kernel. Just substitute your own running kernel version for the kernel versions above. You can get your running kernel name by issuing the command "uname -r".

If you have some other modules you need to load into the initrd image you can put those in also with the --with= lines. For example if you have Nvidia disk controllers then none of the ata modules will work for you above. You would need to put --with=sata_nv at the end of the other --with= lines so your initrd image will include this module when it boots. If not the block device for your hard drive will not be made and you will get the same switchroot error. Check your motherboard manufactures book to see what disk controllers you have on your mobo. You could also just boot a distro like knoppix to see what module it uses.

One last example of adding another module for a block device is if you have a raid card and you want to have it's device made before your real root filesystem is brought up. For example with Areca raid cards you can download the linux driver from their website, compile, and install it. After doing this use the same mkinitrd line above but include another --with= line for the module you just installed. The module name for the Areca cards is arcmsr. So you would put in the line --with=arcmsr.

After you have made your initrd image you now need to modify your grub.conf to point to it. Edit the /boot/grub/grub.conf file. You will see your current boot settings in there. Make a copy of the title, root, kernel, and initrd lines from the current entry and paste them below it. Then edit the initrd line and give it the name of your new initrd file your made. Save the file.

The last file you need to edit is the /etc/fstab. Change any hda's to sda if there are any in there. Then save it.

Reboot your machine. Hit escape when grub starts to load during boot. Then select your entry from the menu to test boot it. It should see your sata hard drive on boot and assign it a block device name like /dev/sda. If you want to make it default to that entry you just tested change number next to the line that starts with the word "default" in the grub.conf file. This number sets the default boot entry. The top entry is 0. You count entries up from there.

Del.icio.us! | Digg Me! | Reddit!

Related stories


RSS Feed RSS feed logo
About


3com
3ware
alsa
alsactl
alsamixer
amd
android
apache
areca
arm
ati
auditd
awk
badblocks
bash
bind
bios
bonnie
cable
carp
cat5
cdrom
cellphone
centos
chart
chrome
cifs
cisco
cloudera
comcast
commands
comodo
compiz-fusion
corsair
cpufreq
cpufrequtils
cpuspeed
cron
crontab
crossover
cu
cups
cvs
database
dbus
dd
dd_rescue
ddclient
debian
decimal
dhclient
dhcp
diagnostic
diskexplorer
disks
dkim
dns
dos
dovecot
drac
dsniff
dvdauthor
e-mail
echo
editor
emerald
ethernet
expect
ext3
ext4
fat32
fedora
fetchmail
fiber
filesystems
firefox
firewall
flac
flexlm
floppy
flowtools
fonts
format
freebsd
ftp
gdm
gmail
gnome
greasemonkey
greylisting
growisofs
grub
hacking
hadoop
harddrive
hba
hex
hfsc
html
html5
http
https
idl
ie
ilo
intel
ios
iperf
ipmi
iptables
ipv6
irix
javascript
kde
kernel
kickstart
kmail
kprinter
krecord
kubuntu
kvm
lame
ldap
linux
logfile
lp
lpq
lpr
maradns
matlab
memory
mencoder
mhdd
mkinitrd
mkisofs
moinmoin
motherboard
mouse
movemail
mplayer
multitail
mutt
myodbc
mysql
mythtv
nagios
nameserver
netflix
netflow
nginx
nic
ntfs
ntp
nvidia
odbc
openbsd
openntpd
openoffice
openssh
openssl
opteron
parted
partimage
patch
perl
pf
pfflowd
pfsync
photorec
php
pop3
pop3s
ports
postfix
power
procmail
proftpd
proxy
pulseaudio
putty
pxe
python
qemu
r-studio
raid
recovery
redhat
router
rpc
rsync
ruby
saltstack
samba
schedule
screen
scsi
seagate
seatools
sed
sendmail
sgi
shell
siw
smtp
snort
solaris
soundcard
sox
spam
spamd
spf
sql
sqlite
squid
srs
ssh
ssh.com
ssl
su
subnet
subversion
sudo
sun
supermicro
switches
symbols
syslinux
syslog
systemrescuecd
t1
tcpip
tcpwrappers
telnet
terminal
testdisk
tftp
thttpd
thunderbird
timezone
ting
tls
tools
tr
trac
tuning
tunnel
ubuntu
vi
wget
wiki
windows
windowsxp
wireless
wpa_supplicant
x
xauth
xfree86
xfs
xinearama
xmms
youtube
zdump
zeromq
zic
zlib