博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
将现有硬盘(分区)无损创建为RAID1
阅读量:4560 次
发布时间:2019-06-08

本文共 2335 字,大约阅读时间需要 7 分钟。

背景

如果现在有一块硬盘(分区)正在使用,如果要设置成RAID1,并不需要将数据拷出,然后创建RAID1。

可以先将此硬盘设置成降级RAID1,然后添加新硬盘再激活RAID1即可,整个过程数据无损。

参考:

正文

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

转载于:https://www.cnblogs.com/felix-zp/p/9742056.html

你可能感兴趣的文章
【实战HTML5与CSS3】用HTML5和CSS3制作页面(上)
查看>>
小公司的一年,一起看看小公司的前端可以怎么做
查看>>
oracle数据批处理
查看>>
Json网络解析
查看>>
[转]Google Chrome/IE/FireFox查看HTTP请求头request header响应头
查看>>
Harris角点检测
查看>>
Struts2的处理流程及为Action的属性注入值
查看>>
设计中最常用的CSS选择器
查看>>
Maven项目打包成可执行Jar文件
查看>>
nginx http proxy 正向代理
查看>>
对BFC的总结
查看>>
第十四周Java学习总结
查看>>
税率等级
查看>>
__alloc_pages
查看>>
web service 使用多态(转载)
查看>>
23醒
查看>>
Google Hack的一些整理
查看>>
[贪心] JZOJ P3757 随机生成器
查看>>
Codeforces Round #370 (Div. 2)(简单逻辑,比较水)
查看>>
ppt转换为html格式 抄的别人的 但是改成了web版 比较简陋
查看>>