View previous topic :: View next topic |
Author |
Message |
Kwark Tux's lil' helper

Joined: 21 May 2007 Posts: 121
|
Posted: Thu Apr 14, 2011 12:58 pm Post subject: Properly disassemble raid1 (mdadm) |
|
|
I'm using mdadm for a mirrored (RAID1) setup for several partitions (/, /home etc).
Right now I need to disassemble this array and remount all partitions using their "normal" devices.
Eg. /dev/sdb5 instead of /dev/md1
This particular raid will stay disassembled, no need to keep any traces of it.
Can I just changed the partition types from raid-autodetect (FD) to reiserfs,ext3,.. , edit grub.conf, /etc/fstab and reboot?
I have no physical access to this machine, but have serial access (from bios to console), so that's not really a problem.
(No cdrom though) |
|
Back to top |
|
 |
Veldrin Veteran


Joined: 27 Jul 2004 Posts: 1945 Location: Zurich, Switzerland
|
Posted: Thu Apr 14, 2011 1:41 pm Post subject: |
|
|
Basically you could just use those partitions directly...
but this would probably cause a rebuild every time the system gets booted, and you would loos all the redundant space.
I would do the following:
switch to single user mode
split the raid as usual (stop one disk, then 'remove it). take sda, and leave sdb in the array.
change the partition type to linux native (IIRC 83)
create the new partition/filesystem on the 'lose'disk (sda), mount them, and copy all data over.
adjust fstab to use the sole (sda) disk
adjust grub to use sda as boot resp. root device.
reinstall grub in sda (just to be sure)
reboot the system.
destroy the remaining raid part by stopping mdadm, and creating new partitions/filesystems on sdb.
cleanup of mdadm.conf
these instructions come by heart - please verify every step, and ask if there are any questions.
V. _________________ read the portage output!
If my answer is too concise, ask for an explanation. |
|
Back to top |
|
 |
frostschutz Advocate


Joined: 22 Feb 2005 Posts: 2977 Location: Germany
|
Posted: Thu Apr 14, 2011 3:19 pm Post subject: |
|
|
You can stop the RAID and then remove the RAID metadata using mdadm, this way the devices won't be recognized as RAID anymore. However, whether you can use the underlying partitions directly or not, depends on the RAID metadata version you were using. If the metadata was at the end of the device, there is no problem - if it was at the beginning, you may not be able to use the partitions. |
|
Back to top |
|
 |
Kwark Tux's lil' helper

Joined: 21 May 2007 Posts: 121
|
Posted: Fri Apr 15, 2011 10:45 am Post subject: |
|
|
I'm going to try it with the /tmp partition (reiserfs fs).
This is /dev/md3 with /dev/sda7 and /dev/sdb7. How about these steps:
1. reboot single mode (serial console, no physical access)
2. mdadm --stop /dev/md3
3. mdadm --zero-superblock /dev/sda7
mdadm --zero-superblock /dev/sdb7
4. remove from /etc/mdadm.conf
5. restart mdadm
6. fdisk
- change /dev/sda7, /dev/sdb7 filesystem type to reiserfs
7. edit /etc/fstab
- /dev/md3 -> /dev/sdb7
8 mount /tmp |
|
Back to top |
|
 |
Veldrin Veteran


Joined: 27 Jul 2004 Posts: 1945 Location: Zurich, Switzerland
|
Posted: Fri Apr 15, 2011 2:39 pm Post subject: |
|
|
I might have missed the part, where you do not want/need to keep its contents...
I that case mdadm --zero-superblock is an option. But if you are going to to reacreate the partitions either way (assuming that --zero-superblock does destroy them), then I might be superfluous.
you might want to umount /dev/md3 (resp /tmp) first, before you mess around.
the rest looks fine.
V. _________________ read the portage output!
If my answer is too concise, ask for an explanation. |
|
Back to top |
|
 |
Kwark Tux's lil' helper

Joined: 21 May 2007 Posts: 121
|
Posted: Fri Apr 15, 2011 7:38 pm Post subject: |
|
|
I do need to keep the contents of the partitions.
I just tried it with my /tmp and I didn't need to change the partition type with fdisk, it reverted to reiserfs when I stopped the md and cleared the superblock.
This is how it should work, right? The data is there alright. |
|
Back to top |
|
 |
Veldrin Veteran


Joined: 27 Jul 2004 Posts: 1945 Location: Zurich, Switzerland
|
Posted: Fri Apr 15, 2011 7:49 pm Post subject: |
|
|
Looking good.
yes it should...
V. _________________ read the portage output!
If my answer is too concise, ask for an explanation. |
|
Back to top |
|
 |
Kwark Tux's lil' helper

Joined: 21 May 2007 Posts: 121
|
Posted: Mon Apr 18, 2011 6:58 am Post subject: |
|
|
Ok, I changed reverted all partitions except for for / (md1) and /boot (md0).
Is it possible to unmount and move the root partition (md1) in single mode? |
|
Back to top |
|
 |
Kwark Tux's lil' helper

Joined: 21 May 2007 Posts: 121
|
Posted: Tue Apr 19, 2011 1:23 pm Post subject: |
|
|
I'm in the last steps on my migration. Only the new root/boot to go.
Recap:
/dev/md0 = old /boot (now stopped + removed)
/dev/md1 = old / (still mounted at the moment)
/dev/md0 = new / + /boot (not yet mounted as /)
- The HD with the old partitions will be removed after migration and replaced with another HD.
- The new root partition (including /boot) is /dev/md0.
- All root data is copied there and special dirs like /dev, /sys, /proc etc are made.
- grub has been setup manually in the MBR of the new root raid partition (md0):
root (hd0,0), setup(hd0)
What would be the correct final steps? Am I missing something?
- Reboot
- Change bios to search boot from the new HD first
- In grub console, change the root= to /dev/md0
(I know I can do this in a new entry)
/boot/grub/device.map in both the new and old situation both list (hd0)=/dev/sda and (hd1)=/dev/sdb
And both grub.conf 's contain the same root(hd0,0) line in their config, while they should be referring to different HD's.
(sdb is the old, sda is the new) |
|
Back to top |
|
 |
|