Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Moving Gentoo to another partition?
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
ih8tgentoo
n00b
n00b


Joined: 01 Jan 2003
Posts: 58

PostPosted: Sun Aug 17, 2003 12:06 am    Post subject: Moving Gentoo to another partition? Reply with quote

I have gentoo installed on a smallish partion (hda6) and would like to move it to another partition (hda8) where I have more space. Is there an easy way to accomplish this? Tried re-installing on hda8 with 1.4final and its been a disaster. Too much has changed from 1.4rc2 so I think I'm better off using what I have. Any suggestions appreciated.
Back to top
View user's profile Send private message
Vanquirius
Retired Dev
Retired Dev


Joined: 14 Jun 2002
Posts: 1297
Location: Ethereal plains

PostPosted: Sun Aug 17, 2003 12:16 am    Post subject: Reply with quote

I think these threads might be of interest:

https://forums.gentoo.org/viewtopic.php?t=58767
https://forums.gentoo.org/viewtopic.php?t=72947
https://forums.gentoo.org/viewtopic.php?t=57471
_________________
Hello.
Back to top
View user's profile Send private message
bmichaelsen
Veteran
Veteran


Joined: 17 Nov 2002
Posts: 1276
Location: Hamburg, Germany

PostPosted: Sun Aug 17, 2003 12:25 am    Post subject: Reply with quote

how about:
1) mkfs hda8
2) mount hda8
3)
Code:
rsync -a --exclude /mnt/hda8 / /mnt/hda8

4)fix fstab grub.conf etc.
5)pray
6)reboot
7)#!?! :evil: :!: 8O :oops:
8)reboot
9)done
_________________
etc-proposals, your friendly config file updater!
Back to top
View user's profile Send private message
ih8tgentoo
n00b
n00b


Joined: 01 Jan 2003
Posts: 58

PostPosted: Mon Aug 18, 2003 11:10 am    Post subject: Another question Reply with quote

There seems to be no definitive way to transfer entire distros from one partition to another. Lots of advice and a few success stories from people moving from one disk to another but not from partition to partition on the same disk.

So....I spent the entire weekend trying to install 1.4 final from a stage3 tarball.
Back to top
View user's profile Send private message
ledjon
n00b
n00b


Joined: 13 Jun 2003
Posts: 16

PostPosted: Mon Aug 18, 2003 2:10 pm    Post subject: Reply with quote

The use of 'dd' (as one of the other threads covered, i believe) is your best chance:

dd if=/dev/hda6 of=/dev/hda8
( these steps vary based on file system type: )
fsck.ext3 -f -y /dev/hda8
resize2fs -p /dev/hda8

That will copy, check and resize (to match the partition) of your file system.

You may also many want to kill un-needed processes and remount /dev/hda6 read-only before you start the dd.
Back to top
View user's profile Send private message
petsun
n00b
n00b


Joined: 11 Jul 2003
Posts: 6
Location: Sweden

PostPosted: Mon Aug 18, 2003 5:55 pm    Post subject: Reply with quote

This method has worked for me!

The point is to avoid copying the files mounted at boot.

1. Boot with livecd. (Files mounted at boot are mounded in livecd's own envirement.)

2. Mount the old partition (/dev/hda6 in your case)

3. cd and tar the entire partition.

4. Mount the new partition (/dev/hda8).

5. Copy the tar file to new partition.

6. Untar on the new partition.

7. Edit fstab on the new partition and se to it that lilo or grub starts the new partition.

8. Reboot whitout livecd.

If you don't have diskspace to make a tar I suppose you could try to copy directly from hda6 to hda8, I haven't tried that, but the point is to avoid copying files mounted at boot.


Last edited by petsun on Tue Aug 19, 2003 12:29 pm; edited 1 time in total
Back to top
View user's profile Send private message
schism39401
Tux's lil' helper
Tux's lil' helper


Joined: 13 Mar 2003
Posts: 130

PostPosted: Tue Aug 19, 2003 7:33 am    Post subject: Reply with quote

Just wanted to say that petsun's post is awesome!!!! I followed it and switched my / and /home partitions around. Worked like a charm, had a few problems but i have my working gentoo system back up plus some nice backups of / and /home. Thanks to everyone in this community for all great support!!!!

Now for anyone else who is going to do this. Here are some of the problems i ran into, granted I have only been using gentoo for about 8 months and had very little experience with linux before that. But anyway, I would strongly suggest moving your .tar.gz files to a separate computer. I decided that since i was going to do this i was going to resize my partitions so i moved the .tar.gz files to my server and resized everything and got it the way i wanted. Then i tried to use scp to copy everything back over, granted the errors that i recieved doing this i probably could have worked around but it is almost 3am and i just wanted to get it done..So I made an NFS mount of my home dir on the server where I moved the .tar.gz files and just copied them over and followed petsun's post. And everything is all good. My / partition is enjoying life in its new home. And that was really the only issue that I had. So, sorry if this is a ramble, like i said it is 3am but just wanted to express my thanks!
Back to top
View user's profile Send private message
petsun
n00b
n00b


Joined: 11 Jul 2003
Posts: 6
Location: Sweden

PostPosted: Tue Aug 19, 2003 12:47 pm    Post subject: Reply with quote

Thanks, I have had some great support form this forum too.


I use the method to backup my system too. In a sence you get your own "stage tarball", with all your own configurations ready. With it you can get a new partition up and running in half an hour in stead of hours of compiling.

I have partitioned my disk so I have an "experimental partition". When I want to test a new package I mount it , wget my tarball, untar it and edit startups. Then it does'nt matter if I mess it up and when I'm confident how to configure I install it at its final place.
Back to top
View user's profile Send private message
Pythonhead
Developer
Developer


Joined: 16 Dec 2002
Posts: 1801
Location: Redondo Beach, Republic of Calif.

PostPosted: Tue Aug 19, 2003 6:41 pm    Post subject: Reply with quote

Here's a couple articles on partitioning that might help:

Moving /home: A step-by-step partition moving how-to
http://www-106.ibm.com/developerworks/library/l-partplan.html

Consolidating data: Moving /tmp and /var to their own shared partition
http://www-106.ibm.com/developerworks/library/l-partplan4.html
Back to top
View user's profile Send private message
ruben
Guru
Guru


Joined: 04 Jul 2003
Posts: 462

PostPosted: Tue Aug 19, 2003 7:04 pm    Post subject: Reply with quote

My advice would be:

1) boot from a livecd, or every other bootable linux cd (or even tomsrbt) will do (as long as your filesystem types are supported by it of course)
2) mount your old partition /dev/hda6 on /mnt/old
3) mount your new/empty partition /dev/hda8 on /mnt/new
4) then do: cp -a /mnt/old /mnt/new
5) change /etc/fstab in /mnt/new appropriately (/mnt/new/etc/fstab)
6) change /etc/lilo.conf (or grub.conf) (/mnt/new/etc/lilo.conf) to make sure you will boot the linux system from /mnt/new (/dev/hda8)
7) then do: chroot /mnt/new /sbin/lilo (or corresponding command for grub to write the new boot sector)
8) reboot
9) enjoy the bigger partition :)

Just saying this in response to the post from petsun, because there really is no need to make a tar-file of the original partition...

I personally would not use dd... if you use cp, then all data from the same file will nicely be copied to consecutive blocks on the harddisk. Using 'dd' will nicely recreate the internal/external fragmentation you already had in the original partition.
Back to top
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 17805

PostPosted: Wed Aug 04, 2004 11:25 pm    Post subject: Reply with quote

Another thread: https://forums.gentoo.org/viewtopic.php?t=14755

Searching the Duplicate Threads forum for "move partition" will return many other results.
_________________

Believing I had supernatural powers I slammed into a brick wall.
I said hey, is this my problem? Is this my fault?
Back to top
View user's profile Send private message
masikh
n00b
n00b


Joined: 27 May 2003
Posts: 17

PostPosted: Tue Sep 28, 2004 8:50 am    Post subject: tar is a good one for this. Reply with quote

We are not going to use dd, because the remaining file isn't that usefull. e.g. You cannot extract a single file from the archive. tar is you friend. Why do you think gentoo uses tar in the first place during it's installation???

ok How to make a dump of the partition:


Go to the root of the mountpoint (thus the partition you like to backup) and issue a simple

# tar -jcvp --one-file-system . > /target/DUMPFILE.tbz2

--one-file-system stay on the local file system when creating archive
v Verbose
j Decompress bzip2
p Preserve permissions
f Extract to a file, not standard input
c Create archive

note: you can also pipe it through ssh to make a clone from one computer on the other.
note 2: Because we use tar instead of dd the size of the partition is of no issue. As long as the tardump fits you're ok

To extract the tardump use (you allready knows this, because you have done it before while installing gentoo !!!) tar -xvjpf TARDUMP.tbz2

btw you do not need to bring a machine down while changing the / mount point to a other partition There is something like remount. Therefor moving from one partition to a other is even possible on a running server with full load. (not wise, but it's possible ;) )

Have a nice day.
_________________
Remember: While root can do most anything, there are cer-
tain privileges only a wife can grand.
Back to top
View user's profile Send private message
torchZ06
Apprentice
Apprentice


Joined: 01 Nov 2003
Posts: 175
Location: the front range

PostPosted: Fri Jan 07, 2005 9:48 pm    Post subject: Re: tar is a good one for this. Reply with quote

masikh wrote:
you can also pipe it through ssh to make a clone from one computer on the other.


would you have an example of that? i'd like to use cp -ax instead of tar, but i've got to move the contents of my partition to a similar partition on another machine and this looks like it might be the key.

cheers
Back to top
View user's profile Send private message
masikh
n00b
n00b


Joined: 27 May 2003
Posts: 17

PostPosted: Sat Jan 08, 2005 2:46 pm    Post subject: Reply with quote

You can do this using scp. (secure copy)

probably something like

tar [options] /files | scp username@machine:/path/on/machine

But this would transver a tar file You could also do something like:

scp -r /files/you/like/to/transver username@machine:/path/on/machine

But I am not sure what this does with file permissions. I should still use tar with respect to the file permissions.
_________________
Remember: While root can do most anything, there are cer-
tain privileges only a wife can grand.
Back to top
View user's profile Send private message
torchZ06
Apprentice
Apprentice


Joined: 01 Nov 2003
Posts: 175
Location: the front range

PostPosted: Mon Jan 10, 2005 9:31 pm    Post subject: Reply with quote

yea, i kinda figured that was how it worked, but with all the piping n stuff it can get a little confusing. i did find this example line, which is similar even though it's using dd instead of tar:
Code:
dd if=/dev/hda1 bs=1k conv=sync,noerror | gzip -c | ssh -c blowfish user@hostname "dd of=filename.gz bs=1k"


i tried that, but dd is a pain in the ass because the partitions have to be the same size. id like to modifiy it to use tar. here's the url:
Notes on backing up entire hard disks or partitions
Back to top
View user's profile Send private message
masikh
n00b
n00b


Joined: 27 May 2003
Posts: 17

PostPosted: Mon Jan 10, 2005 11:06 pm    Post subject: Reply with quote

I am 're-using' my own answer for about 11 years now, so I thought I should add a remote to/from tape solution too!

Using 'Disk Dump' utils (dd): Inflexible solution, reason: All blocks are copied (empty blocks too!). You'll end up with
(possibly unwanted) new partitions too!

# dd if=/dev/hda1 bs=1k conv=sync,noerror | gzip -c | ssh -c blowfish user@hostname "dd of=filename.gz bs=1k"

This on the other hand is flexible and uses tar and ssh for the job.

This example makes a dump of the /usr partition. If for instance /usr/local is an other mount point, then /usr/local is NOT copied. Just the mount point itselve. Thus, on the target machine /usr/local would be an empty directory!!

I think this is exactly what you wanted!!

# tar cfl - /usr | ssh username@remotemachine "cd /usr; tar xvf - "

You can test is on localhost: e.g.

# tar cfl - /home | ssh root@localhost "cd /new-home; tar xvf - "

It is also possible to dump backup to remote tape device:

# tar cvzf - / | ssh root@backup.host.net "cat > /dev/nst0"

OR you can use mt to rewind tape and then dump it using cat command:

# tar cvzf - / | ssh root@backup.host.net $(mt -f /dev/nst0 rewind; cat > /dev/nst0)$

You can restore tar backup over ssh session:

# cd / ;ssh root@backup.host.net "cat /backup.tar.gz" | tar zxvf -

Have fun with this one-liners.

For completeness I copied an article about dump/restore (Linux filesystem backup/restore tools) here
(source: http://www.tcm.phy.cam.ac.uk/~mr349/backup_restore_linux.html)


[b]Simple HowTo for Backup and Restore of Linux System Disk (/)[/b]

This seems to be a nice simple way to backup the system disk of a linux computer. You can put a second disk into a linux server (e.g. webserver) and backup to that.

[b]BACKUP and RESTORE[/b]
==================
make a bootable copy of a disk onto a second disk and
then copy / from /dev/sda1 to /dev/sdb1

# copy partitioning from sda to sdb
sfdisk -d /dev/sda | sfdisk /dev/sdb

# make file systems on new disk (sdb):
mkswap /dev/sdb2
mkfs -t ext4 /dev/sdb1

# mount backup disk (sdb) at /sdb1
mkdir /sdb1
mount /dev/sdb1 /sdb1

# dump from / (sda1) to sdb1 mounted at /sdb1
cd /sdb1
/sbin/dump -z -0 -f - / | restore -rf -


[b]BACKUP[/b]
======
dump to another disk in the computer (or could be remote if you like):
cd /
/sbin/dump -0 -f /backup/hda2.dump / 2>>/var/log/manual_backup_os

in the above / is /dev/hda2 and swap and /dev/hda1.
/backup is /dev/hdd2.

backup partition info to another disk:
sfdisk -d /dev/hda > /backup/partition_info
sfdisk -l /dev/hda >> /backup/partition_info

Can schedule a regular(ish) dump using cron (maybe once per month?)

You might also want a copy of sfdisk (not always on boot CDs)
cp /sbin/sfdisk /backup

OS used for these examples is Suse9.1 Pro.


[b]RESTORE[/b]
=======
disk dead and need to restore OS, so a new disk is fitted:

boot from cd/floppy (Knoppix/Tom's/Suse install CD)

mkdir /backup
mount -t ext3 /dev/hdd2 /backup
cd /backup

Now to partition new disk:
cat partition_info | sfdisk /dev/hda
or
fdisk /dev/hda
and do it manually.

Make file systems on new disk:
mkswap /dev/hda1
mkfs -t ext3 /dev/hda2
mount /dev/hda2 /hda2
cd /hda2
restore rf /backup/hda2.dump

Note: you may need to edit:
/etc/fstab
/boot/grub/menu.lst
if you are restoring to a different partition setup.

[u]Should have a bootable system disk, now we need to configure grub to boot it[/u]:

boot from grub floppy/cdrom (boot restored / on /dev/hda2 which is hd(0,1) to grub)
(link at bottom of page to example grub iso boot CD image) or a Linux boot CD like knoppix

You might need to install grub:
grub-install /dev/hda
or
grub-install /dev/sda

if initrd and vmlinuz are in /boot, otherwise you will need:
grub-install --root-directory=/mnt /dev/sda

If you are not sure which partition actually holds this directory, use the command
find, like this:
grub
grub> find /boot/grub/stage1

Define the root device (boot partition)
grub> root (hd0,1)

Once you've set the root device correctly, run the command setup (see setup):
grub> setup (hd0)
_________________
Remember: While root can do most anything, there are cer-
tain privileges only a wife can grand.


Last edited by masikh on Wed Dec 28, 2016 2:12 pm; edited 2 times in total
Back to top
View user's profile Send private message
torchZ06
Apprentice
Apprentice


Joined: 01 Nov 2003
Posts: 175
Location: the front range

PostPosted: Fri Apr 22, 2005 3:22 pm    Post subject: Reply with quote

thanks masikh!

i know its been a few months since this post, but i've been using your one liner for some time now and it works great! i thought i'd written you back to say thanks, but today i was looking for this post so i could reference that command and i noticed i'd not repilied. sorry!

along with partimage and g4u i've got all the tools i need to handle most any backup/cloning chore.

cheers
:D
Back to top
View user's profile Send private message
masikh
n00b
n00b


Joined: 27 May 2003
Posts: 17

PostPosted: Fri Apr 22, 2005 5:12 pm    Post subject: Reply with quote

Please don't feel sorry, I am glad it was any use to you.

Bye.
_________________
Remember: While root can do most anything, there are cer-
tain privileges only a wife can grand.
Back to top
View user's profile Send private message
Darknight
Guru
Guru


Joined: 26 Jan 2004
Posts: 469
Location: Italy

PostPosted: Wed Nov 09, 2005 10:59 pm    Post subject: Reply with quote

Should I add -p to your line, masikh, if I want to preserve all attributes?
Very useful anyway.
Back to top
View user's profile Send private message
masikh
n00b
n00b


Joined: 27 May 2003
Posts: 17

PostPosted: Sun Jul 23, 2006 8:27 pm    Post subject: A reminder to all! Reply with quote

Hi, it has been long since we have had a chat!

I thought yes. -p as an argument might preserve all the permissions but please check.

Masikh.
_________________
Remember: While root can do most anything, there are cer-
tain privileges only a wife can grand.


Last edited by masikh on Wed Dec 28, 2016 2:15 pm; edited 1 time in total
Back to top
View user's profile Send private message
iarwain
Apprentice
Apprentice


Joined: 25 Sep 2003
Posts: 253

PostPosted: Thu Aug 24, 2006 11:16 am    Post subject: Reply with quote

Hi all, I have an odd problem. I want to clone my / partition from /dev/hda3 to /dev/hda1 (both ext3). Steps I followed:

1) rsync -avHx --delete / /mnt/newroot
2) edit /mnt/newroot/etc/fstab and replace hda3 with hda1
3) add entry in grub.conf
Code:
default 0
timeout 3
splashimage=(hd0,2)/boot/grub/rhel.xpm.gz

title=Gentoo Linux
root (hd0,2)
kernel /boot/bzImage udev video=vesafb:ywrap,mtrr,1280x800-32@60 splash=silent,theme:livecd-2006.0 quiet CONSOLE=/dev/tty1

title=Cloned Gentoo
root (hd0,0)
kernel /boot/bzImage udev video=vesafb:ywrap,mtrr,1280x800-32@60 splash=silent,theme:livecd-2006.0 quiet CONSOLE=/dev/tty1


The odd thing is: when I boot "Cloned Gentoo", grub says "root (hd0,0)" blabla, but gentoo mounts hda3 as / !!!!
wtf?
Back to top
View user's profile Send private message
iarwain
Apprentice
Apprentice


Joined: 25 Sep 2003
Posts: 253

PostPosted: Thu Aug 24, 2006 12:07 pm    Post subject: Reply with quote

nevermind, reinstalled grub and solved.
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