Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Moving root to another filesystem
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
TheKingOfPain
n00b
n00b


Joined: 13 Aug 2011
Posts: 14

PostPosted: Fri Apr 20, 2012 4:20 pm    Post subject: Moving root to another filesystem Reply with quote

I'd like to format my root partition to another filesystem(probably ext4, but everything else then btrfs should be fine). Is it possible to move the whole partition (for example using cp -R ;) ) to another one, format root partition and move everything back?
Of course I mean if it is not only possible, but also if it is sensible.
Back to top
View user's profile Send private message
ShadowCat8
Apprentice
Apprentice


Joined: 07 Oct 2008
Posts: 173
Location: San Bernardino, CA, USA

PostPosted: Fri Apr 20, 2012 5:36 pm    Post subject: Reply with quote

Well,

Something to keep in mind as you put everything back: As parted loves you remind you - "Remember to update your fstab."

Overall, as long as you are doing the copy out and back from a LiveCD/LiveDVD environment, I don't see any major issues with it. And, to make sure that you cut down possible issues, I would recommend using
Code:
 ~ # cp -a <source> <dest>

That should maintain ownership, permissions, timestamps, symlinks, etc.

HTH. Let us know.
_________________
________________________

"As far as the laws of mathematics refer to reality, they are not
certain, and as far as they are certain, they do not refer to reality."

-- Albert Einstein
Back to top
View user's profile Send private message
denial
n00b
n00b


Joined: 15 Nov 2007
Posts: 5

PostPosted: Fri Apr 20, 2012 6:47 pm    Post subject: Reply with quote

This should not be a problem at all, as long as you have a way of booting the system (Live CD, or from a USB stick) and another partition with enough space.

I would recommend tar rather than cp.

All the information you might need about that (and more) can be found here: http://en.gentoo-wiki.com/wiki/Custom_Stage4
Back to top
View user's profile Send private message
Roman_Gruber
Advocate
Advocate


Joined: 03 Oct 2006
Posts: 3846
Location: Austro Bavaria

PostPosted: Fri Apr 20, 2012 7:44 pm    Post subject: Reply with quote

i moved recently root with cp -a source destination

the only weird thing i had to move the destinatin form a folder one folder below thats it..

Boot with livecd, and cp -a thats it

there are other suggestions with DD and other stuff but i dont suggest to use dd..
Back to top
View user's profile Send private message
aCOSwt
Bodhisattva
Bodhisattva


Joined: 19 Oct 2007
Posts: 2537
Location: Hilbert space

PostPosted: Fri Apr 20, 2012 8:04 pm    Post subject: Reply with quote

I like rsync.
So I would backup root that way
Code:
# rsync -vaHXx8 --del / whatever_backup_location_path

Then... the other way around.
_________________
Back to top
View user's profile Send private message
denial
n00b
n00b


Joined: 15 Nov 2007
Posts: 5

PostPosted: Fri Apr 20, 2012 8:24 pm    Post subject: Reply with quote

I guess I just like tar, but I agree that cp and rsync can do the job. Definitely not dd though as it works below the file-system level and would destroy any reformatting changes.

Whatever too you use, you should take care with /proc and /dev - you don't want to leave your system without /dev/null and /dev/console after restoring.
Back to top
View user's profile Send private message
BillWho
Veteran
Veteran


Joined: 03 Mar 2012
Posts: 1600
Location: US

PostPosted: Sat Apr 21, 2012 12:36 am    Post subject: Reply with quote

TheKingOfPain,

I think cp -a would be better than cp -R if you decide to go that route.

Also, don't forget grub entries rootfstype= real_root = or root=

Good luck :wink:
_________________
Good luck :wink:

Since installing gentoo, my life has become one long emerge :)
Back to top
View user's profile Send private message
Goverp
Advocate
Advocate


Joined: 07 Mar 2007
Posts: 2014

PostPosted: Sat Apr 21, 2012 8:38 am    Post subject: Reply with quote

KingOfPain, Do you have a separate /boot partition? If not, and it's part of your root file system, I think you should rerun grub-install after moving to the new format. Otherwise grub might barf when it tries to find its components that have moved.
_________________
Greybeard
Back to top
View user's profile Send private message
toralf
Developer
Developer


Joined: 01 Feb 2004
Posts: 3925
Location: Hamburg

PostPosted: Sat Apr 21, 2012 8:55 am    Post subject: Reply with quote

denial wrote:
Whatever too you use, you should take care with /proc and /dev - you don't want to leave your system without /dev/null and /dev/console after restoring.
IMHO /dev/console isn't necessary, but /dev/zero should already been created.
Back to top
View user's profile Send private message
toralf
Developer
Developer


Joined: 01 Feb 2004
Posts: 3925
Location: Hamburg

PostPosted: Sat Apr 21, 2012 9:16 am    Post subject: Re: Moving root to another filesystem Reply with quote

TheKingOfPain wrote:
(but everything else then btrfs should be fine).
yes
TheKingOfPain wrote:
(for example using cp -R ;) )
better "cp -ar", or you use something like
Code:
cd /to/old/root/; tar -cpf- ./* | (cd /to/new/root; tar -xpf-)
while you booted from a LiveCD - at least in the (bad) old days "tar" was faster than "cp" in such a szenario
Back to top
View user's profile Send private message
ShadowCat8
Apprentice
Apprentice


Joined: 07 Oct 2008
Posts: 173
Location: San Bernardino, CA, USA

PostPosted: Mon Apr 23, 2012 9:07 pm    Post subject: Reply with quote

Greetings,

@toralf: Just as a note, the "cp -ar" is a bit redundant as '-a' covers '-r'. That being said, excellent call on the "tar stream copy" (as one of my linux mentors used to call it). Using that should also preserve everything and, in my experience, be even faster than "cp" in this case.

HTH.
_________________
________________________

"As far as the laws of mathematics refer to reality, they are not
certain, and as far as they are certain, they do not refer to reality."

-- Albert Einstein
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo 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