Moving XFS / partition to new EXT3 partition

Hello,

I have an 80 GB XFS / partition wich is dying. Got some errors like this:
ata9: SError: { UnrecovData Dispar BadCRC Handshk }

It’s not a problem to create another partition, I’ve got 2 500GB and 2 1TB disks, all EXT3. I’ve also 2 80 GB disks, 1 for / and 1 for /home.

I will remove the 2 80 GB disks but I have a lot of stuff compiled myself. I use openSUSE 11.1.

Is it possible to create a 80 GB EXT3 partition on each of the 500 GB hdd, 1 for / and 1 for /home and move the data to it? must it be done with the DD command or can I easily copy everything within a live-cd.

The /boot and swap are already on one of the 500GB disks, and there is no bootrecord on the 80 GB disks.

dd copy is generally used to operate on raw byte level data with devices, so is not appropriate to transfer files from one filesystem to the other.

As the filesystem is XFS, I am wondering if you had power failure? Due to limitations in PC hardware design, I/O operations my continue after RAM contents become unreliable, thus leading to corruption, (often meany nulls). If that’s the case, your disk may be healthy, only written data was lost.

The main problem you’ll have copying data, is that you need a program that will not give up on i/o errors, but do the best it can, perhaps skipping unrecoverable files.

I think GNU tar will try to continue, I like the options of rsync, but it looks like it might not tolerate faults, though if “rsync -cax . /some/where/else/” works you have a checksummed data copy.

Best to make a quick install on new disks, with failing hardware powered off, to minimise reliance on the suspect disks.

I think it is hardware failure. And I have to much hdd’s in my case so I will remove some of them.
And I hope and think if I copy now there are not to much i/o errors.

I’ve already moved the /home. That was easy.

Can I copy / from within a running session or must I use a live-cd?

I think when I copy it within a running session and boot it, it is the same as a hw-reset or failure.

I copy / & /boot regularly, but do an update in single user mode on quiescent system, when moving them to a different disk. I do “rsync -cax”, though if you have sparse files (which could bloat badly by copying), there’s an option to detect those. The new /boot partition should not have large inodes in ext3, and any other features that change the on-disk layout. A small ext2 partition is the most reliable.

Then changes to /etc/fstab and /boot/grub/menu.lst are necessary to boot. Then you need GRUB installed on the new disk, so the first stage knows where to find the 2nd, and read the filesystem structure.

If you have particular trouble with I/O error in important files, then in past, folk used small programs to persistently try getting the blocks and recover as much data as possible.

I’ve also made image copies of partitions, to then work on a copy via loopback mount, but that gets more complicated.

I regularly use rsync for mirroring and backups, and have never once had a problem with it. But it is important to understand and use the right arguments - one of these is -a which will preserve permissions, attributes, symlinks, etc. Another is -x which prevents crossing filesystem boundaries and will suppress moving dynamically subdirectory contents like /dev and /proc. A third is the --excludes option; this is particularly important if the job is running from within the OS (vs separately ala LiveCD, etc.) and the target is mounted, it ensures not copying what is being copied. As already mentioned, depending on your layout once done, you may have to modify fstab, and possibly the grub device.map and menu.lst files along with reinstalling grub.

Thanks for your replies, but for safe, I’ve got some questions.

I’ve resized one EXT3 partition and created a new 120GB one. I’ve mounted it now under /mnt/newdisk.
Should the rsync command be:

rsync -cax / /mnt/newdisk ?

Changing fstab from:
/dev/disk/by-id/ata-SAMSUNG_HD080HJ_S08EJ10P607510-part1 / xfs defaults,noatime,nodiratime 1 1

to

/dev/disk/by-id/ata-Hitachi_HDT725050VLA360_VFB400R4CUJAEA-part2 /mnt/diversen ext3 noatime,nodiratime,acl,user_xattr 1 2

Changing /boot/grub/menu.lst from:

title openSUSE 11.1 - 2.6.27.13-3
root (hd0,0)
kernel /vmlinuz-2.6.27.13-3-default root=/dev/disk/by-id/ata-SAMSUNG_HD080HJ_S08EJ10P607510-part1 resume=/dev/disk/by-id/ata-Hitachi_HDT725050VLA360_VFB400R4CUKNSA-part2 splash=silent showopts vga=0x31a
initrd /initrd-2.6.27.13-3-default

to

title openSUSE 11.1 - 2.6.27.13-3
root (hd3,1)
kernel /vmlinuz-2.6.27.13-3-default root=/dev/disk/by-id/ata-Hitachi_HDT725050VLA360_VFB400R4CUJAEA-part2 resume=/dev/disk/by-id/ata-Hitachi_HDT725050VLA360_VFB400R4CUKNSA-part2 splash=silent showopts vga=0x31a
initrd /initrd-2.6.27.13-3-default

Now, / is on sde1. Then I’ve got sdf, sda, sdb, sdc, sdd. Because now root (hd0,0), I think sdf = hd1, sda = hd2, sdb = hd3. The new partition is on sdb, sdb2. So it would be hd3,1 is this correct?

And should I replace this one:
gfxmenu (hd0,0)/message with
gfxmenu (hd3,1)/message?

After this all should it boot from the new partition or did I forget something?

Grub is installed on sda, swap on sda2 and /boot on sda1 so I think that’s not a problem.

And can this all be done from a running system?

tune2fs is your friend. Look at the option to create volume labels. Then you can mount via those, and use LABEL=foobar instead of a device in fstab(5).

Your rsync commands looked OK. I do it once in multi-user, then go single user for exclusivity and update fast.

Experiment a little yourself with parts of directory tree. The odd thing about rsync, is that the trailing ‘/’ on a path is meaningful, usually it isn’t. So for instance, to sync up /usr with /mnt/usr, I might “cd /; rsync -cax ./usr /mnt” or “rsync -cax /usr /mnt/usr/”.

But I may be remembering this wrong, it is far better if you get used to playing and experimenting with commands, carefully yourself than being spoon fed, without gaining understanding.

I think you can install GRUB with YaST. There’s many threads with installing GRUB examples on CLI.

The menu.lst file, you can use /dev/disk/by-label/foobar where a device is needed, and LABEL=OS-Root seems to work to, which is really nice :slight_smile:

You have several problems. First, in your rysnc command(s) you need a trailing slash, so that the directory tree is built the same on the target. Without the trailing slash, you would get / under / on the new partition.

Also, if you are moving the data from one partition to two partitions, that is, /home is on a separate partition, then you need to run rysnc twice. Furthermore, you need to suppress copying /boot, because that is already on a separate partition. So you need to use one of rsync’s filter or exclude commands. For example, you create a text file named “excludedirs” and give it two lines:

/home/*
/boot/*

Then your first rsync command would be:

rsync -cax --exclude-from=excludedirs // /mnt/newdisk/

which would create a new root directory under /mnt/newdisk excluding any files mounted to /boot plus the files under /home. Then you would mount your new /home partition to your new root partition and copy /home to it:


mount -t ext3 /dev/xxx /mnt/newdisk/home
rsync -cax /home/ /mnt/newdisk/home/

I don’t understand your new fstab mount point. If the new partition is your new root, why would it not now be mounted at / like the replaced partition? And where is the mount statement for your new /home partition?

Re menu.lst: If you have a separate /boot partition, then you would not change the root statement unless you are changing the boot sequence in the bios. The grub numbering should always be aligned to the bios boot order using the device.map file. But you would change the kernel line root= clause to point to the new partition. You will not need to reinstall grub if the boot setup has not changed. It’s a good idea to leave the old boot stanza in menu.lst and not remove the old partition just yet, until you’ve tested that everything is working correctly.

Thanks.

About the fstab line, it must be:

/dev/disk/by-id/ata-Hitachi_HDT725050VLA360_VFB400R4CUJAEA-part2 / ext3 noatime,nodiratime,acl,user_xattr 1 2

The new partition is created on the disk where now /mnt/diversen is mounted. So I copied that line and forget to change that. :frowning:

/home is already on a new partition and working, had no problem and don’t post that line.

So I need to add --exclude=/boot/ --exclude=/home/ --exclude=/mythtv/ --exclude=/mnt/ to the rsync command?

And about grub, I only need to change the “root=” option? I will try it on monday, tomorrow it’s sunday and then my wife’s will watch a lot of mythtv recordings…

IIRC your exclude statements will work correctly. Re menu.lst - the root statement refers to where the kernel is located, so if you have /boot on a separate partition, then the root is already pointing to that and would not change. It only needs to change if you have changed to bios boot disk order (sequence), in which case device.map needs to be changed and grub re-installed and well as the change to menu.lst.

You don’t need a trailing / so long as the source directory and destination are going to be same name.

So “rsync -cax usr /mnt” will sync up ./usr and /mnt/usr.
To split up file systems, you can simply do something like :

cd /
mount /mnt
mount /mnt/var
mount /mnt/usr
rysnc -cax . /mnt

Assuming you prepared filesystems and mount point in /mnt first.

So, today I did it. I’ve used rsync and changed menu.lst and fstab, rebooted and now it works without any problem. Never thought it was so easy.

Thanks you all!!

You’re quite welcome - glad is worked out for you! :slight_smile:

Yeh! Nice to have some positive feedback, glad you managed :slight_smile:

I have a similar situation. My / partition is filling up and I need to know what my options are. Ideally I would like to shrink my /home partition and resize my /. Otherwise, I may add a new hard disk and move my / and increase my /home on the origional disk. I am new to Linux and want to keep from shooting myself in the foot.

The root partition is ext3, the /home partition is xfs, and I am running 11.4

Any thoughts would be greatly appreciated.

Maybe you should start a new thread rather the resurrect a 2 year old thread.