背景

如果现在有一块硬盘(分区)正在使用,如果要设置成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. Android实战之 万能的接口回调

    转载请标明原地址:http://blog.csdn.net/gaolei1201/article/details/47084111 前言:本人也算是自学"成才",呵呵,大学时尽管学 ...

  2. mysql20170404代码实现

    CREATE DATABASE IF NOT EXISTS school; USE school; CREATE TABLE tblStudent( StuId ) NOT NULL PRIMARY ...

  3. ubuntu下C程序的编辑、编译、运行

    均以hello world程序为例 一.vim hello.c/hello.cpp 创建hello.c/hello.cpp文件,并进入vim界面 二.此时按键盘上的很多键均不会有任何反应,键入i,进入 ...

  4. CodeForces - 749C Voting

    C. Voting time limit per test 1 second memory limit per test 256 megabytes input standard input outp ...

  5. bzoj 2005 & 洛谷 P1447 [ Noi 2010 ] 能量采集 —— 容斥 / 莫比乌斯反演

    题目:bzoj 2005 https://www.lydsy.com/JudgeOnline/problem.php?id=2005   洛谷 P1447 https://www.luogu.org/ ...

  6. bzoj2763: [JLOI2011]飞行路线(分层图spfa)

    2763: [JLOI2011]飞行路线 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 3234  Solved: 1235[Submit][Stat ...

  7. Gym - 101981I The 2018 ICPC Asia Nanjing Regional Contest I.Magic Potion 最大流

    题面 题意:n个英雄,m个怪兽,第i个英雄可以打第i个集合里的一个怪兽,一个怪兽可以在多个集合里,有k瓶药水,每个英雄最多喝一次,可以多打一只怪兽,求最多打多少只 n,m,k<=500 题解:显 ...

  8. HDU1560 DNA sequence

    题目: The twenty-first century is a biology-technology developing century. We know that a gene is made ...

  9. 模拟Queue(wait/notify)

    BlockingQueue:顾名思义,首先它是一个队列,并且支持阻塞的机制,阻塞的放入和得到数据.我们要实现LinkedBlockingQueue下面的两个方法put和take. put(anObje ...

  10. jq中append()、prepend()、after()、before()的区别

    jq中append().prepend().after().before()的区别详解 .append() - 在被选元素的结尾插入内容(内容的结尾,比如说有个a标签,则是在</a>这个标 ...