View previous topic :: View next topic |
Author |
Message |
ih8tgentoo n00b
Joined: 01 Jan 2003 Posts: 58
|
Posted: Sun Aug 17, 2003 12:06 am Post subject: Moving Gentoo to another partition? |
|
|
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 |
|
|
Vanquirius Retired Dev
Joined: 14 Jun 2002 Posts: 1297 Location: Ethereal plains
|
|
Back to top |
|
|
bmichaelsen Veteran
Joined: 17 Nov 2002 Posts: 1277 Location: Hamburg, Germany
|
Posted: Sun Aug 17, 2003 12:25 am Post subject: |
|
|
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)#!?!
8)reboot
9)done |
|
Back to top |
|
|
ih8tgentoo n00b
Joined: 01 Jan 2003 Posts: 58
|
Posted: Mon Aug 18, 2003 11:10 am Post subject: Another question |
|
|
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 |
|
|
ledjon n00b
Joined: 13 Jun 2003 Posts: 16
|
Posted: Mon Aug 18, 2003 2:10 pm Post subject: |
|
|
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 |
|
|
petsun n00b
Joined: 11 Jul 2003 Posts: 6 Location: Sweden
|
Posted: Mon Aug 18, 2003 5:55 pm Post subject: |
|
|
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 |
|
|
schism39401 Tux's lil' helper
Joined: 13 Mar 2003 Posts: 130
|
Posted: Tue Aug 19, 2003 7:33 am Post subject: |
|
|
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 |
|
|
petsun n00b
Joined: 11 Jul 2003 Posts: 6 Location: Sweden
|
Posted: Tue Aug 19, 2003 12:47 pm Post subject: |
|
|
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 |
|
|
Pythonhead Developer
Joined: 16 Dec 2002 Posts: 1801 Location: Redondo Beach, Republic of Calif.
|
|
Back to top |
|
|
ruben Guru
Joined: 04 Jul 2003 Posts: 462
|
Posted: Tue Aug 19, 2003 7:04 pm Post subject: |
|
|
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)
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 |
|
|
pjp Administrator
Joined: 16 Apr 2002 Posts: 20581
|
Posted: Wed Aug 04, 2004 11:25 pm Post subject: |
|
|
Another thread: https://forums.gentoo.org/viewtopic.php?t=14755
Searching the Duplicate Threads forum for "move partition" will return many other results. _________________ Quis separabit? Quo animo? |
|
Back to top |
|
|
masikh n00b
Joined: 27 May 2003 Posts: 17
|
Posted: Tue Sep 28, 2004 8:50 am Post subject: tar is a good one for this. |
|
|
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 |
|
|
torchZ06 Apprentice
Joined: 01 Nov 2003 Posts: 175 Location: the front range
|
Posted: Fri Jan 07, 2005 9:48 pm Post subject: Re: tar is a good one for this. |
|
|
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 |
|
|
masikh n00b
Joined: 27 May 2003 Posts: 17
|
Posted: Sat Jan 08, 2005 2:46 pm Post subject: |
|
|
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 |
|
|
torchZ06 Apprentice
Joined: 01 Nov 2003 Posts: 175 Location: the front range
|
Posted: Mon Jan 10, 2005 9:31 pm Post subject: |
|
|
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 |
|
|
masikh n00b
Joined: 27 May 2003 Posts: 17
|
Posted: Mon Jan 10, 2005 11:06 pm Post subject: |
|
|
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 |
|
|
torchZ06 Apprentice
Joined: 01 Nov 2003 Posts: 175 Location: the front range
|
Posted: Fri Apr 22, 2005 3:22 pm Post subject: |
|
|
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
|
|
Back to top |
|
|
masikh n00b
Joined: 27 May 2003 Posts: 17
|
Posted: Fri Apr 22, 2005 5:12 pm Post subject: |
|
|
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 |
|
|
Darknight Guru
Joined: 26 Jan 2004 Posts: 485 Location: Italy
|
Posted: Wed Nov 09, 2005 10:59 pm Post subject: |
|
|
Should I add -p to your line, masikh, if I want to preserve all attributes?
Very useful anyway. |
|
Back to top |
|
|
masikh n00b
Joined: 27 May 2003 Posts: 17
|
Posted: Sun Jul 23, 2006 8:27 pm Post subject: A reminder to all! |
|
|
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 |
|
|
iarwain Apprentice
Joined: 25 Sep 2003 Posts: 253
|
Posted: Thu Aug 24, 2006 11:16 am Post subject: |
|
|
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 |
|
|
iarwain Apprentice
Joined: 25 Sep 2003 Posts: 253
|
Posted: Thu Aug 24, 2006 12:07 pm Post subject: |
|
|
nevermind, reinstalled grub and solved. |
|
Back to top |
|
|
|