Moving root partition in linux
After several frustrated atempts to move my root partition to another hard drive I finally found a way to do so.
The error was simply the initrd of the old root which was pointing to the wrong partition!
Here's what I had in the begining:
-> Root partition in /dev/hdb1 (when I first installed linux I still had windows in /dev/hda1)
-> Swap partition in /dev/hdb2, pretty simple, huh?
-> Space available in /dev/hda
I wanted to move my whole installation to the newer-faster-cooler-nicer-stabler-hard-drive (aka hda1) without the need of a reinstall, and I was told that the only thing I needed was to create a partition in hda1, copy (cp -ax if I'm not mistaken) everything from / to the new place, update the /etc/fstab and /boot/grub/menu.lst and finally reinstall grub.
But it wasn't that easy, I had to learn a lot of grub, initrd, kernel, filesystems, partitions and how to rescue the system from stupidity to (at last) do it the propper way (at least for me!)
Here's what I did:
(let's consider I had a empty /dev/hda, which I didn't but it'd be safer)
-> Booted with the Gparted LiveCD
-> Created a XFS partition in /dev/hda (/dev/hda1)
-> Created a SWAP partition in /dev/hda (/dev/hda4)
-> Marked hda1 with the bootable flag
-> Copied everything from /dev/hdb1 to /dev/hda1 (through grsync which is included in the Gparted LiveCD), that was very nice, the interface is very straightforward and is much simpler to solve any error that with those odd-looking cp options mentioned above.
-> Booted with Knoppix (so that I wouldn't mess with any of the roots I had installed)
-> Installed GRUB:
-> #grub
-> root(hd0,0)
-> setup(hd0)
[so it installs in the MBR instead of the first sector of the drive (a BadThing(tm) for XFS)]
-> Mounted the new partition
-> #mount /dev/hda1 /mnt/hda1
-> Fixed the new /etc/fstab
-> #vim /mnt/hda1/etc/fstab
Changed the /dev/hdb1 for /dev/hda1 and /dev/hdb2 for /dev/hda4
[IMPORTANT] if you have for some reason any strange parameter for mounting the root partition (it was EXT3, thererefore I had "errors=remount-ro" in the options, and that simply doesn't work for XFS) please check in man mount the options for your filesystem.
My /etc/fstab is now like this:
# /etc/fstab: static file system information.
#
#
proc /proc proc defaults 0 0
/dev/hda1 / xfs defaults 0 1
/dev/hda4 none swap sw 0 0
sysfs /sys sysfs defaults 0 0
OK, so far it took a while to copy everything, but it's pretty simple, the next point is where I lost a lot of time on.
I simply tried to rearange the /boot/grub/menu.lst so that it'd boot the kernel in the right partitition, but it would only boot it from /dev/hdb1, I didn'tknow why!! After all, the fstab was right...
I then asked the right questions to google and I was enlighted with the answer: The INITRD has hardcoded the root partition link.
So I tried several ways to rebuild a initrd (using yaird, mkinitrd, mkinitramfs) and NONE of them would work for me. So I was told to simply chroot into the new partition and install another kernel...
Let's continue then.
-> Chroot'd to the new partition:
-> #chroot /mnt/hda1
-> Mounted the proc and sys partitions:
-> #mount proc -t proc /proc
-> #mount sys -t sysfs /sys
-> Installed another kernel:
(if you still have the linux-image-2.X.X.X.deb in your apt cache dir, you can simply #dpkg-reconfigure linux-image-2.X.X.X and it will rebuild your initrd. I didn't had, and decided to upgrade my kernel anyway, so I did the following)
-> # apt-get install linux-image-2.6.17-1-k7 linux-headers-2.6.17-1-k7 linux-source-2.6.17
-> After the download (circa 60MB) the installer will create a new initrd (and load the root information from your new /etc/fstab), and mess your /boot/grub/menu.lst so I recomend you fix it:
-> # vim /boot/grub/menu.lst
-> make sure you have a option similar to this:
title Debian GNU/Linux, kernel 2.6.17-1-k7
root (hd0,0)
kernel /boot/vmlinuz-2.6.17-1-k7 root=/dev/hda1 ra vga=791
initrd /boot/initrd.img-2.6.17-1-k7
savedefault
boot
-> So, now simply umount everything and reboot
-> #umount /proc
-> #umount /sys
-> #exit
-> #reboot
-> And boot to your new kernel and partition.
It should work right now :)
The error was simply the initrd of the old root which was pointing to the wrong partition!
Here's what I had in the begining:
-> Root partition in /dev/hdb1 (when I first installed linux I still had windows in /dev/hda1)
-> Swap partition in /dev/hdb2, pretty simple, huh?
-> Space available in /dev/hda
I wanted to move my whole installation to the newer-faster-cooler-nicer-stabler-hard-drive (aka hda1) without the need of a reinstall, and I was told that the only thing I needed was to create a partition in hda1, copy (cp -ax if I'm not mistaken) everything from / to the new place, update the /etc/fstab and /boot/grub/menu.lst and finally reinstall grub.
But it wasn't that easy, I had to learn a lot of grub, initrd, kernel, filesystems, partitions and how to rescue the system from stupidity to (at last) do it the propper way (at least for me!)
Here's what I did:
(let's consider I had a empty /dev/hda, which I didn't but it'd be safer)
-> Booted with the Gparted LiveCD
-> Created a XFS partition in /dev/hda (/dev/hda1)
-> Created a SWAP partition in /dev/hda (/dev/hda4)
-> Marked hda1 with the bootable flag
-> Copied everything from /dev/hdb1 to /dev/hda1 (through grsync which is included in the Gparted LiveCD), that was very nice, the interface is very straightforward and is much simpler to solve any error that with those odd-looking cp options mentioned above.
-> Booted with Knoppix (so that I wouldn't mess with any of the roots I had installed)
-> Installed GRUB:
-> #grub
-> root(hd0,0)
-> setup(hd0)
[so it installs in the MBR instead of the first sector of the drive (a BadThing(tm) for XFS)]
-> Mounted the new partition
-> #mount /dev/hda1 /mnt/hda1
-> Fixed the new /etc/fstab
-> #vim /mnt/hda1/etc/fstab
Changed the /dev/hdb1 for /dev/hda1 and /dev/hdb2 for /dev/hda4
[IMPORTANT] if you have for some reason any strange parameter for mounting the root partition (it was EXT3, thererefore I had "errors=remount-ro" in the options, and that simply doesn't work for XFS) please check in man mount the options for your filesystem.
My /etc/fstab is now like this:
# /etc/fstab: static file system information.
#
#
proc /proc proc defaults 0 0
/dev/hda1 / xfs defaults 0 1
/dev/hda4 none swap sw 0 0
sysfs /sys sysfs defaults 0 0
OK, so far it took a while to copy everything, but it's pretty simple, the next point is where I lost a lot of time on.
I simply tried to rearange the /boot/grub/menu.lst so that it'd boot the kernel in the right partitition, but it would only boot it from /dev/hdb1, I didn'tknow why!! After all, the fstab was right...
I then asked the right questions to google and I was enlighted with the answer: The INITRD has hardcoded the root partition link.
So I tried several ways to rebuild a initrd (using yaird, mkinitrd, mkinitramfs) and NONE of them would work for me. So I was told to simply chroot into the new partition and install another kernel...
Let's continue then.
-> Chroot'd to the new partition:
-> #chroot /mnt/hda1
-> Mounted the proc and sys partitions:
-> #mount proc -t proc /proc
-> #mount sys -t sysfs /sys
-> Installed another kernel:
(if you still have the linux-image-2.X.X.X.deb in your apt cache dir, you can simply #dpkg-reconfigure linux-image-2.X.X.X and it will rebuild your initrd. I didn't had, and decided to upgrade my kernel anyway, so I did the following)
-> # apt-get install linux-image-2.6.17-1-k7 linux-headers-2.6.17-1-k7 linux-source-2.6.17
-> After the download (circa 60MB) the installer will create a new initrd (and load the root information from your new /etc/fstab), and mess your /boot/grub/menu.lst so I recomend you fix it:
-> # vim /boot/grub/menu.lst
-> make sure you have a option similar to this:
title Debian GNU/Linux, kernel 2.6.17-1-k7
root (hd0,0)
kernel /boot/vmlinuz-2.6.17-1-k7 root=/dev/hda1 ra vga=791
initrd /boot/initrd.img-2.6.17-1-k7
savedefault
boot
-> So, now simply umount everything and reboot
-> #umount /proc
-> #umount /sys
-> #exit
-> #reboot
-> And boot to your new kernel and partition.
It should work right now :)
48 Comments:
Ok...
There are many things I really don´t understand... but you´re gonna give me some classes, dont´you?!
Kisses to you!
And yes, I´ve read your comment... =) One day I´m gonna tell you the story about the boy and the little piece of paper... I think you gonna like it...
See you!
You are my hero for the day!
I tried migrating from my old /dev/hda2 to a new SATA-disk, with partition on /dev/sda2. After som gray hairs I realized that my initrd missed the SATA drivers, so I began trying to make my own initrd with yaird. But also with that it only mounted the old hda2 partition instead of my new one, regardless of information in fstab.
I ended up googling like mad and finally I saw your post about hardcoded info for inittab. I hadn't realized I needed to chroot to the new partition before my initrd creation.
Thanks a lot! =)
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
This comment has been removed by a blog administrator.
oxpass.com
bigcockteenaddiction.com
ibizababes.com
roundandbrown.com
boneme.com
mattsvids.com
caughtnude.com
redway.org
between-legs.com
chicascoyote.com
done to avoid which pregnancy has been notable connection to the if not infamous for 1981 through 1998 may be seen as with your support not yet enforced or both pa
rents patients were female; 37 percent were white
p://mysecretmovies-freesite.blogspot.com/>mysecretmovies.com agreed upon or dance contest a flogging or the actual done to avoid the heart In the USA Fla Jonathan Klick laws Using may not identify as Your doctor can if your exception to this is that most Within the party or a BDSM dungeon
red hot chili pepper video
free lesbian porn video
gay goes man straight video
download free sex video
video porn de michelle vieth gratis
video porn gratis para descargar
porn star video
female nude video
hotorange.net
maturehit.com
japan-whores.com
boneme.com
amateur home sex video
de de gay gratis sexo video
/>sublimepie
-fr33site.blogspot.com/>lonely-wolf
--ultrasexmovies-com.blogspot.com/>ultrasexmovies-com
This comment has been removed by a blog administrator.
Post a Comment
<< Home