背景

如果现在有一块硬盘(分区)正在使用,如果要设置成RAID1,并不需要将数据拷出,然后创建RAID1。
可以先将此硬盘设置成降级RAID1,然后添加新硬盘再激活RAID1即可,整个过程数据无损。

参考:
https://debian-administration.org/article/238/Migrating_To_RAID1_Mirror_on_Sarge

正文

Migrating To RAID1 Mirror on Sarge
Posted by philcore on Thu 8 Sep 2005 at 21:03

Tags: filesystems, raid, raid1, sarge
A guide to migrating to RAID1 on a working Debian Sarge installation which was installed on a single drive.

I suggest reading the following links: Migrating to a mirrored raid using Grub, GRUB and RAID mini-HOWTO.

My setup:

/dev/sda == original drive with data
/dev/sdb == new 2nd drive.
(It is assumed that you have RAID1 enabled in your kernel.)

First of all install md tools:

apt-get install mdadm
change the system types on partitions you want to mirror on the old drive to fd (raid autodetect) using [s]fdisk. Don't change the swap partition! Your finished drive should resemble this output:

[root@firefoot root]# sfdisk -l /dev/sda

Disk /dev/sda: 8942 cylinders, 255 heads, 63 sectors/track
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0

Device Boot Start End #cyls #blocks Id System
/dev/sda1 * 0+ 242 243- 1951866 fd Linux raid autodetect
/dev/sda2 243 485 243 1951897+ fd Linux raid autodetect
/dev/sda3 486 607 122 979965 82 Linux swap / Solaris
/dev/sda4 608 8923 8316 66798270 5 Extended
/dev/sda5 608+ 1823 1216- 9767488+ fd Linux raid autodetect
/dev/sda6 1824+ 4255 2432- 19535008+ fd Linux raid autodetect
/dev/sda7 4256+ 4377 122- 979933+ fd Linux raid autodetect
/dev/sda8 4378+ 8923 4546- 36515713+ fd Linux raid autodetect
Now use sfdisk to duplicate partitions from old drive to new drive:

sfdisk -d /dev/sda | sfdisk /dev/sdb
Now use mdadm to create the raid arrays. We mark the first drive (sda) as "missing" so it doesn't wipe out our existing data:

mdadm --create /dev/md0 --level 1 --raid-devices=2 missing /dev/sdb1
Repeat for the remaining raid volumes md1,md2, etc....

mdadm --create /dev/md1 --level 1 --raid-devices=2 missing /dev/sdb2
Now that the volumes are ready create filesystems for the raid devices. My example shows using ext3, but pick the filesystem of your choice. Again, make sure you have kernel support for your selected filesystem.

mkfs.ext3 /dev/md0
mkfs.ext3 /dev/md1
etc...
Now mount the new raid volumes. I mount them under the /mnt directory:

mount /dev/md0 /mnt
cp -dpRx / /mnt

将现有硬盘(分区)无损创建为RAID1的更多相关文章

  1. 解决Win7系统安装时“安装程序无法定位现有 系统分区,也无法创建新的系统分区”提示

    第一步:U盘启动装系统时,格式化主分区的内容后出现上面的问题 第二步:重启机器,通过U 盘启动.进入win pe系统. 第三步:把windows 7的ISO镜像解压到电脑的非系统盘的其他硬盘上.如D: ...

  2. 用PE安装操作系统时:无法创建新的系统分区 也无法定位现有系统分区 的解决办法

    借助U盘的用PE安装操作系统时系统提示:无法创建新的系统分区 也无法定位现有系统分区 的解决办法... --------------------------------- 具体原因是安装时加载到安装程 ...

  3. Windows7安装程序无法定位现有系统分区,也无法创建新的系统分区

    解决Windows7.Windows8系统安装时“安装程序无法定位现有系统分区,也无法创建新的系统分区”提示. 方法一 把Windows7镜像发在你电脑的非系统盘的其他硬盘上. 重启机器,通过U盘启动 ...

  4. Win7/Win8安装"我们无法创建新的分区,也找不到现有的分区"的解决方法

    如果你用pe启动光盘和pe启动盘.加载iso安装时遇到"我们无法创建新的分区,也找不到现有的分区"的情况.. 把iso里的boot和bootgmr以及sources复制到c盘,pe ...

  5. win8转win7+真正解决 “安装程序无法定位现有系统分区,也无法创建新的系统分区”的方法

    问题情况:win8电脑转win7系统,出现问题:“安装程序无法定位现有系统分区,也无法创建新的系统分区”   第一种:猜测可行的方法: 1.老毛桃U盘启动电脑,进入PE系统后,直接使用Diskgeni ...

  6. 管理员技术(六): 硬盘分区及格式化、 新建一个逻辑卷、调整现有磁盘的分区、扩展逻辑卷的大小、添加一个swap分区

    一.硬盘分区及格式化 问题: 本例要求熟悉硬盘分区结构,使用fdisk分区工具在磁盘 /dev/vdb 上按以下要求建立分区: 1> 采用默认的 msdos 分区模式        2> ...

  7. Win10提示无法创建新的分区也找不到现有的分区解法

    原文链接:https://www.pconline.com.cn/win10/1126/11261093.html 1.格式化整个硬盘,重新分区 如果你的硬盘上没有重要数据的话,到了分区这一步时,将硬 ...

  8. 使用U盘安装win7系统,遇到“无法定位现有系统分区”问题

    朋友的本子貌似因为安装360wifi而导致一进入系统就蓝屏重启,虽然之后就卸载了360wifi,但是问题依旧,上网Google了一下,发觉网上不少网友诉苦,也有人分析原因,说是因为360wifi导致了 ...

  9. VmWare扩展硬盘分区

    扩展硬盘 对硬盘进行分区 () 查看现有的硬盘分区情况 [mysql@china ~]$ df -h Filesystem Size Used Avail Use% Mounted on /dev/m ...

随机推荐

  1. NSRange and NSString对象

    http://www.cnblogs.com/pengyingh/articles/2451292.html 当谈到NSString方法时,你会发现很多都涉及到NSRange.不必操心.它事实上仅仅只 ...

  2. Manacher求最长回文

    #1032 : 最长回文子串 时间限制:1000ms 单点时限:1000ms 内存限制:64MB 描写叙述 小Hi和小Ho是一对好朋友.出生在信息化社会的他们对编程产生了莫大的兴趣,他们约定好互相帮助 ...

  3. ASP原码加密工具介绍

    ASP原码加密工具介绍 总是会有非常多方法暴露ASP的原程序.造成数据库的password 路径都能够轻易被其它人搞到,所以对ASP程序实行加密处理是个不错的解决方法.以下来介绍一个工具假设大家感兴趣 ...

  4. luogu1064 金明的预算方案

    这道题我就想说一点:审题!附件只有2个!钱是10的整数倍,不是100的整数倍! #include <cstdio> #include <cstring> #include &l ...

  5. 97. ExtJS之EditorGridPanel afteredit属性

    转自:https://zccst.iteye.com/blog/1328869 1. 之前大多用Ext.grid.GridPanel,现在需要可编辑功能,发现比以前稍复杂一些. 就是需要对指定列进行可 ...

  6. 希尔shell排序——java实现

    希尔排序是对插入排序的优化,将插入排序的交换步长由1增加到h. 希尔排序的思想是使数组中任意间隔为h的元素有序.步长调幅为h = 3*h + 1, 也就是1,4,13,40,121,364, 1003 ...

  7. codevs1519 过路费(最小生成树+LCA)

    1519 过路费  时间限制: 1 s  空间限制: 256000 KB  题目等级 : 大师 Master     题目描述 Description 在某个遥远的国家里,有 n个城市.编号为 1,2 ...

  8. 【钓起来的tips系列】

    一.求n的阶乘: #include<bits/stdc++.h> using namespace std; int n; int jc(int k) { ); )*k; } /*int j ...

  9. HTML中javascript使用dom获取dom节点范例

    <!-- HTML结构 --> <div id="test-div"> <div class="c-red"> <p ...

  10. ruby --Paperclip::NotIdentifiedByImageMagickError

    首先,如果遇到这个问题,Paperclip::NotIdentifiedByImageMagickError,先检查下环境变量是否配置了ImagicMagick的路径. cmd下path 查看,首先加 ...