MandrivaUsers.org : Move Linux / to another partition, another disk? - MandrivaUsers.org

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Move Linux / to another partition, another disk? [solved]

#1 User is offline   theYinYeti 

  • Mandriva Guru
  • Group: Members
  • Posts: 2,147
  • Joined: 23-September 02

Posted 08 August 2005 - 09:50 PM

Here's the story, in short:
My main PC has Linux installed on a 8GB hard drive, using hda1 (swap), hda2 (/), and hda3 (/local).
I was offered a 180GB hard drive to replace the old one, where I created hdb1, hdb2, and hdb3.
Now, I want to move hda* to hdb*. When all is done, I swith the disks, and hopefully all will run fine...

So, how do I move hda2 and hda3 contents to hdb2 and hdb3?
Of course, hdb2 is bigger than hda2, and hdb3 is bigger than hda3, so dd can't be used. Besides, I'd prefer not to use an "image based" utility, but rather a "file based" one, so that the files get defragmented in the operation (having been above 90% usage for almost a year, the disk is bount to be fragmented).
To make things even less easy, the filesystem will change: hda uses reiserfs, and hdb will use ext3 (because I'm fed up with resolv.conf being reset on reboot, and with ext3, I'll be able to hard-lock the file)

To my knowledge, the most obvious methods to transfer files are cp and tar, the latter being IMO more reliable. So in short, here's what I already tried using a DSL liveCD:
mount -t reiserfs /dev/hda2 /mnt/hda2
mount -t ext3 /dev/hdb2 /mnt/hdb2
(cd /mnt/hda2 && tar cf - --atimepreserve --ignore-failed-read .) ! (cd /mnt/hdb2 && tar xpf - --atimepreserve --same-owner)
mount -t reiserfs /dev/hda3 /mnt/hda2/local
mount -t ext3 /dev/hdb3 /mnt/hdb2/local
(cd /mnt/hda2 && tar cf - --atimepreserve --ignore-failed-read local) ! (cd /mnt/hdb2 && tar xpf - --atimepreserve --same-owner)
(the ! stands for a pipe, because I can't get the pipe character right now...)

Unfortunately:
- The tar commands give errors like that:

Quote

tar: ./dev/log: socket ignored
tar: ./var/spool/postfix/public/flush: socket ignored
tar: ./var/spool/postfix/public/showq: socket ignored
tar: ./var/spool/postfix/public/cleanup: socket ignored
tar: ./var/spool/postfix/private/lmtp: socket ignored
tar: ./var/spool/postfix/private/smtp: socket ignored
tar: ./var/spool/postfix/private/uucp: socket ignored
tar: ./var/spool/postfix/private/old-cyrus: socket ignored
tar: ./var/spool/postfix/private/rewrite: socket ignored
tar: ./var/spool/postfix/private/anvil: socket ignored
tar: ./var/spool/postfix/private/bsmtp: socket ignored
tar: ./var/spool/postfix/private/defer: socket ignored
tar: ./var/spool/postfix/private/cyrus: socket ignored
tar: ./var/spool/postfix/private/error: socket ignored
tar: ./var/spool/postfix/private/local: socket ignored
tar: ./var/spool/postfix/private/relay: socket ignored
tar: ./var/spool/postfix/private/trace: socket ignored
tar: ./var/spool/postfix/private/maildrop: socket ignored
tar: ./var/spool/postfix/private/bounce: socket ignored
tar: ./var/spool/postfix/private/ifmail: socket ignored
tar: ./var/spool/postfix/private/cyrus-chroot: socket ignored
tar: ./var/spool/postfix/private/lmtp-filter: socket ignored
tar: ./var/spool/postfix/private/smtp-filter: socket ignored
tar: ./var/spool/postfix/private/verify: socket ignored
tar: ./var/spool/postfix/private/virtual: socket ignored
tar: ./var/spool/postfix/private/cyrus-deliver: socket ignored
tar: ./var/spool/postfix/private/proxymap: socket ignored
tar: ./var/spool/postfix/private/cyrus-inet: socket ignored
tar: ./root/tmp/orbit-root/linc-eab-0-c77d2cd942ce: socket ignored
tar: ./root/tmp/orbit-root/linc-1205-0-745d2ac67ea9e: socket ignored
tar: ./root/tmp/orbit-root/linc-eab-0-23c74f7986c9: socket ignored
tar: ./root/tmp/orbit-root/linc-e03-0-37ed0bc61c605: socket ignored
tar: ./local/home/iris/tmp/orbit-iris/linc-48fd-0-235b35bd4dafe: socket ignored
tar: ./local/home/iris/tmp/orbit-iris/linc-87e-0-2225f7e4b2863: socket ignored
and so on...
- and on rebooting on hdb (without swaping the drives), I had a kernel panic... so I had to reboot on good old hda instead.

Here is the hdb2:/etc/fstab
/dev/hdb2 / ext3 noatime 1 1
none /dev/pts devpts mode=0620 0 0
/dev/hdb3 /local ext3 noatime 1 2
/dev/hdc /mnt/cdrom auto ro,users,iocharset=iso8859-15,sync,noatime,codepage=850,noauto,nosuid,nodev,noexec 0 0
/dev/hdd /mnt/dvd udf,iso9660 ro,users,iocharset=iso8859-15,sync,noatime,codepage=850,noauto,nosuid,nodev,noexec 0 0
/dev/fd0 /mnt/floppy vfat,msdos,ext2 sync,unhide,noatime,noauto,nosuid,users,nodev,umask=0 0 0
/dev/hda2 /new reiserfs notail,noauto 1 2
/dev/hda3 /new/local reiserfs notail,noauto 1 2
none /proc proc defaults 0 0
none /tmp tmpfs defaults 0 0
/dev/hdb1 swap swap defaults 0 0
This is actually the same as hda2:/etc/fstab, with a swap between hda,reiserfs,notail <-> hdb,ext3,noatime, hence the "/new" directory which actually means "old"... well, it was just a test run.

Here is the hdb2:/etc/lilo.conf (which I used for /sbin/lilo -v after chrooting to /mnt/hdb2)
boot=/dev/hda
map=/boot/map
vga=normal
default="linux"
keytable=/boot/fr-latin1.klt
prompt
nowarn
timeout=50
message=/boot/message
menu-scheme=wb:bw:wb:bw
# splash=silent removed!
image=/boot/vmlinuz
        label="old"
        root=/dev/hda2
        initrd=/boot/initrd.img
        append="devfs=nomount quiet acpi=ht pmdisk=/dev/hda1"
        vga=788
        read-only
image=/boot/vmlinuz
        label="linux"
        root=/dev/hdb2
        initrd=/boot/initrd.img
        append="devfs=nomount quiet acpi=ht pmdisk=/dev/hdb1"
        vga=788
        read-only
image=/boot/vmlinuz
        label="linux-nonfb"
        root=/dev/hdb2
        initrd=/boot/initrd.img
        append="devfs=nomount quiet acpi=ht pmdisk=/dev/hdb1"
        read-only
other=/dev/fd0
        label="floppy"
        unsafe
image=/boot/vmlinuz
        label="failsafe"
        root=/dev/hdb2
        initrd=/boot/initrd.img
        append="devfs=nomount quiet failsafe acpi=ht noresume"
        read-only
Again, I just changed all hda's to hdb's, except the boot=/dev/hda (first line) as the MBR is still on hda. Then I added a "Old" entry for my current hda2 linux installation (which I'm still using because of the kernel panic with the new "Linux" entry).

I was not able to find anything definitive in lilo's man page, on what filesystem exactly is referenced by all those /dev/... and /boot/... everywhere. I wouldn't be surprised if my error was somehow related to that.

SO... Is there something wrong in my config? Or is my whole method simply the wrong one?

Yves.
sedentaire: C2DuoE4300, 3GB, 1TB+NFS, Arch Linux, k3.x, Compiz
joli: Dell Inspiron1501, Arch Linux, k3.x, Gnome 3
sphinx2: eSata SheevaPlug, 512MB, 2GB SDcard, Debian Wheezy, k3.2
nomade: P166MMX, 32MB, 2GB, Deb3.1, k2.4.x, IceWM|XDMCP
work: Samsung(ath wifi), Mdv2009.0, k2.6.x, Gnome(rox)
sphinx: VIA1GHz, 256MB, 512MB USBstick, Debian Lenny, k2.6.x
salon: VIA1GHz, 256MB, 512MB USBstick, saa7134 PCTV Stereo, GeeXboX
0

#2 User is offline   Ixthusdan 

  • Platinum
  • Group: Platinum
  • Posts: 9,042
  • Joined: 17-September 02

Posted 08 August 2005 - 10:07 PM

AFAIK, the boot= in the config must reference he actual boot partition. My lilo.conf only references a device rather than a device in the tree. So,
boot=hda1, or
boot=hdd9

I don't know if there is any practical difference here.
The people never give up their liberties but under some delusion. Edmund Burke, 1784
0

#3 User is offline   theYinYeti 

  • Mandriva Guru
  • Group: Members
  • Posts: 2,147
  • Joined: 23-September 02

Posted 09 August 2005 - 01:50 PM

According to those:
http://reactor-core....-migration.html
http://lists.debian....6/msg00334.html
I'm on the right track, though it seems "cp" would be usable too.

I'll first try and rewrite my lilo.conf as suggested by Ixthusdan, or maybe I'll try grub... Or I'll simply swap the drives once and for all!

Yves.

[edit:]It appears that sockets are the only kind of files that tar is unable to handle! So I may get rid of "socket ignored" errors by switching to cp. On the other hand, it is said that such files are usually automatically re-created when needed, so it wouldn't really matter...[/edit]
sedentaire: C2DuoE4300, 3GB, 1TB+NFS, Arch Linux, k3.x, Compiz
joli: Dell Inspiron1501, Arch Linux, k3.x, Gnome 3
sphinx2: eSata SheevaPlug, 512MB, 2GB SDcard, Debian Wheezy, k3.2
nomade: P166MMX, 32MB, 2GB, Deb3.1, k2.4.x, IceWM|XDMCP
work: Samsung(ath wifi), Mdv2009.0, k2.6.x, Gnome(rox)
sphinx: VIA1GHz, 256MB, 512MB USBstick, Debian Lenny, k2.6.x
salon: VIA1GHz, 256MB, 512MB USBstick, saa7134 PCTV Stereo, GeeXboX
0

#4 User is offline   scarecrow 

  • Platinum
  • Group: Platinum
  • Posts: 5,157
  • Joined: 16-February 05

Posted 09 August 2005 - 08:15 PM

Easy thing:
1. Replace LILO with grub, and put the loader at / or /boot
2. Use a liveCD, and cp everything anywhere you want. You can also use partimage, or if you also use Windows a generic commercial imager/cloner (I like Acronis TrueImage, which I always run from the bootableCD).
3. use your liveCD again to edit /etc/fstab and /boot/grub/menu.lst
4. Install a third party primary loader at HD MBR (I like GaG), and boot your moved Linux.
That simple (although it didn't work once, but it was my fault when imaging).
0

#5 User is offline   theYinYeti 

  • Mandriva Guru
  • Group: Members
  • Posts: 2,147
  • Joined: 23-September 02

Posted 10 August 2005 - 08:26 PM

Solved. I went the easiest route. I did not even bother with grub or lilo. My simple solution was:
- Under DSL (Damn Small Linux), I did the copy:
# mount -t reiserfs /dev/hda2 /mnt/hda2
# mount -t ext3 /dev/hdb2 /mnt/hdb2
# cd /mnt/hda2
# cp --recursive --no-dereference --preserve=all . /mnt/hdb2/
# mount -t reiserfs /dev/hda3 /mnt/hda2/local
# mount -t ext3 /dev/hdb3 /mnt/hdb2/local
# cd ./local
# cp --recursive --no-dereference --preserve=all . /mnt/hdb2/local/
: not a single error.
- I halted the PC.
- I "swaped" the drives (hda <-> hdb): simple matter of changing the drives' jumpers.
- I booted the PC and went into BIOS, because my former hda geometry was "hard-coded" there (manual setting). I put everything on "AUTO" for hda, hdb, hdc, and hdd, which proved to work as expected.
- I saved the BIOS changes and booted the Mandriva rescue mode.
- I mounted the partitions under /mnt, and went to the console, where I changed /mnt/etc/fstab to reflect the fact that hda is now ext3 and noatime, and hdb is now reiserfs and notail,noauto. Back to the rescue menu, I instructed to reinstall the boot-loader.
- REBOOT. ALL OK.

Yves.
sedentaire: C2DuoE4300, 3GB, 1TB+NFS, Arch Linux, k3.x, Compiz
joli: Dell Inspiron1501, Arch Linux, k3.x, Gnome 3
sphinx2: eSata SheevaPlug, 512MB, 2GB SDcard, Debian Wheezy, k3.2
nomade: P166MMX, 32MB, 2GB, Deb3.1, k2.4.x, IceWM|XDMCP
work: Samsung(ath wifi), Mdv2009.0, k2.6.x, Gnome(rox)
sphinx: VIA1GHz, 256MB, 512MB USBstick, Debian Lenny, k2.6.x
salon: VIA1GHz, 256MB, 512MB USBstick, saa7134 PCTV Stereo, GeeXboX
0

#6 User is offline   pmpatrick 

  • Mandriva Guru
  • Group: Members
  • Posts: 1,862
  • Joined: 23-September 02

Posted 11 August 2005 - 12:47 PM

For anyone else doing this, here's my method which I've used several times w/o problems. First I don't like to copy linux partitions when the system is in use as there are too many dynamic files changing which can cause problems and then there are pseudo filesytems like /proc or /sys which are generated at each boot. I always use a live cd like knoppix when doing this to avoid these problems. So boot up with knoppix, mount the partition yoou want to transfer and the partition you want to transfer to with write access. Then cd to the mount point of the partition to be transferred and run as root:

# tar -cf - . | (cd <mount point of partition to recieve transfer>; tar -xvf -)

If you like the copy command, I've also used this:

# cp -pidRv /old_drive/* /new_drive/

a break down of the flags is here:

-p Preserve the original files' owner, group, permissions ...
-R Copy directories recursively and do the right thing when objects
other than ordinary files or directories are encountered.
-i Prompt whether to overwrite existing regular destination files. (I do
this JUST IN CASE! you should start with a new blank partition and
then you'll never get prompted -- you could leave this out or use -f if
you're sure you want to overwrite stuff.)
-d, --no-dereference
Copy symbolic links as symbolic links rather than
copying the files that they point to, and preserve
hard links between source files in the copies.
-v, --verbose
Print the name of each file before copying it. (slows it
down a bit but I like to see it doing stuff rather than
wait blindly.)

That's it. Then you just have to edit fstab and lilo.conf and run lilo in a chroot to get the boot loader rewritten to the mbr for the new location.
0

#7 User is offline   theYinYeti 

  • Mandriva Guru
  • Group: Members
  • Posts: 2,147
  • Joined: 23-September 02

Posted 11 August 2005 - 03:58 PM

I completely agree. Unless there's really no choice, it is much better IMO to use a live CD (that how I did too).

What we both say roughly go along the same lines. However I have some questions: When I tried and used tar (instead of cp), I got those "socket" errors I mention in my first post. Did you get those? If so, was it harmless?

I'd be interested in knowing, and using tar instead of cp next time, because I noticed that cp is much slower than tar!

Yves.
sedentaire: C2DuoE4300, 3GB, 1TB+NFS, Arch Linux, k3.x, Compiz
joli: Dell Inspiron1501, Arch Linux, k3.x, Gnome 3
sphinx2: eSata SheevaPlug, 512MB, 2GB SDcard, Debian Wheezy, k3.2
nomade: P166MMX, 32MB, 2GB, Deb3.1, k2.4.x, IceWM|XDMCP
work: Samsung(ath wifi), Mdv2009.0, k2.6.x, Gnome(rox)
sphinx: VIA1GHz, 256MB, 512MB USBstick, Debian Lenny, k2.6.x
salon: VIA1GHz, 256MB, 512MB USBstick, saa7134 PCTV Stereo, GeeXboX
0

#8 User is offline   pmpatrick 

  • Mandriva Guru
  • Group: Members
  • Posts: 1,862
  • Joined: 23-September 02

Posted 11 August 2005 - 05:11 PM

No, I've never gotten those kind of errors with tar. Did you run the tar command as root ? Some files and directories are only readable/accessible by root. In particular, almost everything on my system in /var/spool/postfix is locked and only accessible by root. The same goes for /root. To me, that's the most likely explanation.
It could also be an artifact of the livecd you used. For example, IIRC with knoppix if you mount the partition as a regular user you have some weird permission problems even in a root console when you try and access the previously mounted partition. I usually wind up unmounting the partition in the console and remounting as root.
Those are my best guesses. It's obviously a permission problem. As to exactly why it occurred, I can't be certain.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users