Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] Moving root partition to new location?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
gthiruva
n00b
n00b


Joined: 03 May 2009
Posts: 24
Location: Vegas, Baby!

PostPosted: Wed May 13, 2009 12:38 am    Post subject: [SOLVED] Moving root partition to new location? Reply with quote

I was wondering if anyone has any best practicies suggestions for this scenario:

I'm working remotely to a Gentoo install on a machine with two disks - an old small one and a new big one. The partitioning scheme is simple - one big root partition and nothing else on the old small one (/dev/sda1). The new big partition (/dev/sdb1) is empty and I want to move everything from sda1 to sdb1 and make sdb1 the new root partition.

Any thoughts on how to best achieve this? Since I'm remote I want to be really careful and not mess up the GRUB configuration and make the system unbootable - then I'll have to waste time getting the local sys folks to scope things out for me and that'll take days.

I'm not averse to leaving anything on sda1. So transforming sda1 into /boot (if that makes things easier) is perfectly fine.

Thanks in advance!


Last edited by gthiruva on Wed May 20, 2009 3:58 pm; edited 1 time in total
Back to top
View user's profile Send private message
bjlockie
Veteran
Veteran


Joined: 18 Oct 2002
Posts: 1182
Location: Canada

PostPosted: Wed May 13, 2009 2:34 am    Post subject: Reply with quote

I did a similar thing but I would get someone local do it.
Copy everything on the old disk to the new one, change grub to point to the kernel on the new disk.

Do all this when the system is NOT running.
Be REALLY careful with grub.
In fact I would leave the old disk in and copy the existing grub entry so you have a failsafe.
Once you're sure it is using the new disk, you can get rid of the old disk. ;-)

It is not hard, just be very, very careful.
_________________
AMD FX6100 CPU, 16 GiB RAM, OCZ Vertex 3 SSD
ASRock 970 Extreme3 motherboard with S/PDIF audio
Galaxy-NVidia GeForce 8800GT video card, Cyber Power CP550HG USB UPS
Back to top
View user's profile Send private message
gthiruva
n00b
n00b


Joined: 03 May 2009
Posts: 24
Location: Vegas, Baby!

PostPosted: Wed May 13, 2009 6:43 am    Post subject: Reply with quote

bjlockie wrote:
Copy everything on the old disk to the new one, change grub to point to the kernel on the new disk.

Do all this when the system is NOT running.
Be REALLY careful with grub.
In fact I would leave the old disk in and copy the existing grub entry so you have a failsafe.
Once you're sure it is using the new disk, you can get rid of the old disk. ;-)


Just change the grub config (/boot/grub/grub.conf)? I would also asume /etc/fstab needs to change too since the disk devices are changing?

Anything else? And is it possible to do this while booting off the original partition (/dev/sda1 in my case)? Or, alternatively, is there a way to boot normally and then create a fresh install (not a copy) on the new partition (sdb1) and copy the data later after rebooting?
Back to top
View user's profile Send private message
tw04l124
Veteran
Veteran


Joined: 03 Oct 2006
Posts: 1308
Location: A t z e l, lower austria

PostPosted: Wed May 13, 2009 8:56 am    Post subject: Reply with quote

hi

realroot=/dev/sdaXX in kernel line of your grub.conf

adjust your fstab in your new partition

copy your partition with e.g. gparted running a livecd or with rdiffbackup or there is a stage4 backup script on this forum.

or do a fresh install, but this is insane!
Back to top
View user's profile Send private message
gthiruva
n00b
n00b


Joined: 03 May 2009
Posts: 24
Location: Vegas, Baby!

PostPosted: Wed May 13, 2009 3:29 pm    Post subject: Reply with quote

tw04l124 wrote:
... or do a fresh install, but this is insane!


Well, that's how I roll! But the local IT guys are always backed up so if I can do it myself remotely, I can get to work this week instead of next week or the week after.

But seriously, is there a way to do a fresh install to a new root partition without having to reboot? Again, since I'm in the US and the server is in the UK, I won't have access to the machine if it has to reboot into a new setup or installer CD.

Or, is that what rdiffbackup or the stage4 script aim to do?
Back to top
View user's profile Send private message
gthiruva
n00b
n00b


Joined: 03 May 2009
Posts: 24
Location: Vegas, Baby!

PostPosted: Wed May 13, 2009 8:02 pm    Post subject: Tell me it's not this easy! Reply with quote

So I emerged rdiff-backup in and am currently running

Code:

 /usr/bin/python /usr/bin/rdiff-backup --force --exclude-other-filesystems / /mnt/tmp/


where /mnt/tmp is the spot where I mounted the new, larger /dev/sdb1 filesystem.

So after this is done, it's just alterations to /boot/grub/grub.conf and /etc/fstab and reboot?

Something tells me the machine will still boot off of the old /boot on the old /dev/sda1 fs.

Keep in mind that since the machine is remote I can't control GRUB at boot time. Nor can I control BIOS level details to choose the boot drive.

So it sounds like the Master Boot Record on /dev/sda will still be in charge (that's fine) and so I need move the contents of /dev/sda1:/boot into /dev/sda1:/. This makes the main challenge telling GRUB that the boot partition on sda1 is not the same as the root partition - which will be sdb1. And thus /dev/sdb1/boot will be the mountpoint for /dev/sda1.

Sound right?
Back to top
View user's profile Send private message
desultory
Administrator
Administrator


Joined: 04 Nov 2005
Posts: 7820

PostPosted: Thu May 14, 2009 2:32 am    Post subject: Reply with quote

gthiruva wrote:
But seriously, is there a way to do a fresh install to a new root partition without having to reboot?
Consult man 8 pivot_root, test locally first.
Back to top
View user's profile Send private message
EzInKy
Veteran
Veteran


Joined: 11 Oct 2002
Posts: 1734
Location: Kentucky

PostPosted: Thu May 14, 2009 3:00 am    Post subject: Re: Moving root partition to new location? Reply with quote

gthiruva wrote:

I'm not averse to leaving anything on sda1. So transforming sda1 into /boot (if that makes things easier) is perfectly fine.


Why not just create some data partitions and/or directories on the big disk and just mount and/or symlink them. Seems a much safer route in your situation. You could even set it up with the standard Gentoo partitions and mirror sda1 in the first partition as backup.
_________________
Time is what keeps everything from happening all at once.
Back to top
View user's profile Send private message
gthiruva
n00b
n00b


Joined: 03 May 2009
Posts: 24
Location: Vegas, Baby!

PostPosted: Fri May 15, 2009 1:24 am    Post subject: Almost got it! .... but not quite! Reply with quote

Well I did a fewsimple things and am 90% there. Thankfully, I managed to get remote console access so I'm able to view the boot sequnce and mess with Grub. But here's what I did:

1) Used rdiff-backup to backup the small /dev/sda2 (hd0,1) to the new larger /dev/sdb1 (hd1,0) and did this by staging /dev/sdb2 on /mnt/tmp.
2) Copied all of the grub files from (hd0,1)/boot to (hd0,1)/ with the intention of making /dev/sda2 a pure grub partition.
3) Updated /mnt/tmp/etc/fstab with appropriate changes to mount /dev/sdb1 as / and /dev/sda2 as /grub.
4) Updated grub config and modded menu.lst to look for the kernel and initrd on (hd1,0) instead:

Code:

title=Gentoo Linux
root (hd1,0)
kernel /boot/kernel-genkernel-x86_64-2.6.25-gentoo-r7 root=/dev/ram0 init=/linuxrc ramdisk=8192 real_root=/dev/sdb1 apm=off noapic acpi=off
initrd /boot/initramfs-genkernel-x86_64-2.6.25-gentoo-r7


And it almost works. The kernel loads, it mounts the root partition, but then panics trying to find /dev/console. Here's a screenshot: http://www.flickr.com/photos/54318468@N00/3531789659/.

Apparently I need to configure /dev/sdb1 so that it can mount /dev. Not too sure how this udev stuff works. Any thoughts?
Back to top
View user's profile Send private message
desultory
Administrator
Administrator


Joined: 04 Nov 2005
Posts: 7820

PostPosted: Fri May 15, 2009 6:06 am    Post subject: Reply with quote

Among others, /dev/console needs to be present before /dev gets mounted.
Back to top
View user's profile Send private message
gthiruva
n00b
n00b


Joined: 03 May 2009
Posts: 24
Location: Vegas, Baby!

PostPosted: Fri May 15, 2009 7:25 am    Post subject: Slick! Almost there! Reply with quote

desultory wrote:
Among others, /dev/console needs to be present before /dev gets mounted.


Ah. Thanks! Did this and now we're going places:

Code:

cd /mnt/tmp/dev
mknod -m 660 console c 5 1
mknod -m 660 null c 1 3


Now I get to where it mounts the root fs and tries to check it and get stuck on an fsck.ext3 that won't proceed. See this screenshot: http://www.flickr.com/photos/54318468@N00/3532371533/.

The fs type is ext3. But for some reason it mentions it's doubts about if being ext2.

Any more thoughts, folks? Thanks for everyone's help so far...
Back to top
View user's profile Send private message
desultory
Administrator
Administrator


Joined: 04 Nov 2005
Posts: 7820

PostPosted: Fri May 15, 2009 7:35 am    Post subject: Reply with quote

The message "fsck.ext3: No such file or directory while trying to open /dev/sdb1" does not mean that the device was found but the filesystem was somehow not recognized, the device itself was not recognized. First stop is normally to verify that any necessary modules are built in to the kernel or are at least available as part of an initrd image. In this case though, it seems that more of the basic device nodes need to be created, /dev/zero being one of them.
Back to top
View user's profile Send private message
gthiruva
n00b
n00b


Joined: 03 May 2009
Posts: 24
Location: Vegas, Baby!

PostPosted: Fri May 15, 2009 3:16 pm    Post subject: Reply with quote

desultory wrote:
The message "fsck.ext3: No such file or directory while trying to open /dev/sdb1" does not mean that the device was found but the filesystem was somehow not recognized, the device itself was not recognized. First stop is normally to verify that any necessary modules are built in to the kernel or are at least available as part of an initrd image. In this case though, it seems that more of the basic device nodes need to be created, /dev/zero being one of them.


Thanks for the tip. Any other devices I need to create other than /dev/null, /dev/console, and /dev/zero?
Back to top
View user's profile Send private message
gthiruva
n00b
n00b


Joined: 03 May 2009
Posts: 24
Location: Vegas, Baby!

PostPosted: Fri May 15, 2009 6:06 pm    Post subject: Reply with quote

gthiruva wrote:
desultory wrote:
The message "fsck.ext3: No such file or directory while trying to open /dev/sdb1" does not mean that the device was found but the filesystem was somehow not recognized, the device itself was not recognized. First stop is normally to verify that any necessary modules are built in to the kernel or are at least available as part of an initrd image. In this case though, it seems that more of the basic device nodes need to be created, /dev/zero being one of them.


Thanks for the tip. Any other devices I need to create other than /dev/null, /dev/console, and /dev/zero?


And the answer is 'yes I do'! I also needed to make the block devices for fsck to work:

Code:

cd /mnt/tmp
mknod dev/sda b 8 0
mknod dev/sda1 b 8 1
mknod dev/sdb b 8 16
mknod dev/sdb1 b 8 17


Finally, there was an error about a missing /sys directory do I also did this:

Code:

cd /mnt/tmp
mkdir sys


And voila! Success! The system now boots:

Code:

gtdb ~ # df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sdb1             493G  6.5G  461G   2% /
udev                   10M  148K  9.9M   2% /dev
/dev/sda2             7.0G  5.5G  1.6G  78% /grub
none                  3.8G     0  3.8G   0% /dev/shm


Notice the /grub partition above which is my old root filesystem.

Insane? A little. But now that I know all of the steps, it is - in hindsight - somewhat easy.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum