You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

981 lines
32 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<!DOCTYPE html>
<html lang="en-us">
<head><meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<script type="application/ld+json">
{
"@context" : "http://schema.org",
"@type" : "BlogPosting",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "https:\/\/h.cowbay.org"
},
"articleSection" : "post",
"name" : "[筆記] 用rsync 移轉 centos 6.2的老機器 Transfer Cent6.2 using rsync",
"headline" : "[筆記] 用rsync 移轉 centos 6.2的老機器 Transfer Cent6.2 using rsync",
"description" : "\x3cp\x3e公司的一台老伺服器空間不足了要執行指令都會中斷所以想要擴充空間。\x3c\/p\x3e\n\n\x3cp\x3e看起來不難搞事實上\x26hellip;..\x3c\/p\x3e",
"inLanguage" : "en",
"author" : "Eric Chang",
"creator" : "Eric Chang",
"publisher": "Eric Chang",
"accountablePerson" : "Eric Chang",
"copyrightHolder" : "Eric Chang",
"copyrightYear" : "2019",
"datePublished": "2019-03-27 17:44:49 \x2b0800 CST",
"dateModified" : "2019-03-27 17:44:49 \x2b0800 CST",
"url" : "https:\/\/h.cowbay.org\/post\/transfer-cent62-using-rsync\/",
"wordCount" : "573",
"image" : "https://h.cowbay.orghttps://h.cowbay.org/images/post-default-9.jpg"",
"keywords" : [ ""centos"",""linux"","Blog" ]
}
</script>
<title>[筆記] 用rsync 移轉 centos 6.2的老機器 Transfer Cent6.2 using rsync </title>
<meta name="description" content="some articles about job,food,passion sisters" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="robots" content="all,follow">
<meta name="googlebot" content="index,follow,snippet,archive">
<link rel="stylesheet" id="ct-tracks-google-fonts-css" href="https://fonts.googleapis.com/css?family=Raleway%3A400%2C700&amp;subset=latin%2Clatin-ext&amp;ver=4.7.2" type="text/css" media="all">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
<link href="https://h.cowbay.org/css/style.css?v=1577170732" rel="stylesheet" id="theme-stylesheet" type='text/css' media='all'>
<link href="https://h.cowbay.org/css/custom.css?v=1577170732" rel="stylesheet" type='text/css' media='all'>
<link rel="shortcut icon" href="https://h.cowbay.org/img/favicon.ico" type="image/x-icon">
<link rel="icon" href="https://h.cowbay.org/img/favicon.ico" type="image/x-icon">
<script type="application/javascript">
var doNotTrack = false;
if (!doNotTrack) {
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', 'UA-138954876-1', 'auto');
ga('send', 'pageview');
}
</script>
<script async src='https://www.google-analytics.com/analytics.js'></script>
</head>
<body class="post-template-default single single-post single-format-standard ct-body singular singular-post not-front standard">
<div id="overflow-container" class="overflow-container">
<a class="skip-content" href="#main">Skip to content</a>
<header id="site-header" class="site-header" role="banner">
<div class='top-navigation'>
<div class='container'>
<div id="menu-secondary" class="menu-container menu-secondary" role="navigation">
<button id="toggle-secondary-navigation" class="toggle-secondary-navigation"><i class="fas fa-plus"></i></button>
<div class="menu">
<ul id="menu-secondary-items" class="menu-secondary-items">
<li class="menu-item menu-item-type-taxonomy menu-item-object-category">
<a href="/categories/"></a>
</li>
<li class="menu-item menu-item-type-taxonomy menu-item-object-category">
<a href="/categories/ansible">ansible</a>
</li>
<li class="menu-item menu-item-type-taxonomy menu-item-object-category">
<a href="/categories/linux">linux</a>
</li>
<li class="menu-item menu-item-type-taxonomy menu-item-object-category">
<a href="/categories/proxmox">proxmox</a>
</li>
<li class="menu-item menu-item-type-taxonomy menu-item-object-category">
<a href="/categories/ps">ps</a>
</li>
<li class="menu-item menu-item-type-taxonomy menu-item-object-category">
<a href="/categories/%E7%A2%8E%E5%BF%B5">碎念</a>
</li>
<li class="menu-item menu-item-type-taxonomy menu-item-object-category">
<a href="/categories/%E7%AD%86%E8%A8%98">筆記</a>
</li>
<li class="menu-item menu-item-type-taxonomy menu-item-object-category">
<a href="/categories/%E7%BE%A4%E6%9A%89">群暉</a>
</li>
</ul>
</div>
</div>
<ul class="social-media-icons">
<li>
<a href="full%20Social%20profile%20url%20in%20facebook" data-animate-hover="pulse" class="facebook" target="_blank">
<i class="fab fa-facebook-square" title="facebook"></i>
<span class="screen-reader-text">facebook</span>
</a>
</li>
<li>
<a href="full%20profile%20url%20in%20googleplus" data-animate-hover="pulse" class="gplus" target="_blank">
<i class="fab fa-google-plus-g" title="googleplus"></i>
<span class="screen-reader-text">googleplus</span>
</a>
</li>
<li>
<a href="chang0206" data-animate-hover="pulse" class="twitter" target="_blank">
<i class="fab fa-twitter-square" title="twitter"></i>
<span class="screen-reader-text">twitter</span>
</a>
</li>
<li>
<a href="chang0206" data-animate-hover="pulse" class="instagram" target="_blank">
<i class="fab fa-instagram" title="instagram"></i>
<span class="screen-reader-text">instagram</span>
</a>
</li>
<li>
<a href="mailto:mc@hotshraingmy.info" data-animate-hover="pulse" class="email">
<i class="fas fa-envelope" title="email"></i>
<span class="screen-reader-text">email</span>
</a>
</li>
<li>
<a href="full%20profile%20url%20in%20linkedin" data-animate-hover="pulse" class="linkedin" target="_blank">
<i class="fab fa-linkedin-in" title="linkedin"></i>
<span class="screen-reader-text">linkedin</span>
</a>
</li>
<li>
<a href="full%20profile%20url%20in%20stackoverflow" data-animate-hover="pulse" class="stackoverflow" target="_blank">
<i class="fab fa-stack-overflow" title="stackoverflow"></i>
<span class="screen-reader-text">stackoverflow</span>
</a>
</li>
<li>
<a href="changchichung" data-animate-hover="pulse" class="github" target="_blank">
<i class="fab fa-github" title="github"></i>
<span class="screen-reader-text">github</span>
</a>
</li>
<li>
<a href="full%20profile%20url%20in%20pinterest" data-animate-hover="pulse" class="pinterest" target="_blank">
<i class="fab fa-pinterest" title="pinterest"></i>
<span class="screen-reader-text">pinterest</span>
</a>
</li>
<li>
<a href="https://h.cowbay.org/index.xml" data-animate-hover="pulse" class="rss" target="_blank">
<i class="fas fa-rss" title="rss"></i>
<span class="screen-reader-text">rss</span>
</a>
</li>
</ul></div>
</div>
<div class="container">
<div id="title-info" class="title-info">
<div id='site-title' class='site-title'>
<a href="/"> MC部落 </a>
</div>
</div>
<button id="toggle-navigation" class="toggle-navigation">
<i class="fas fa-bars"></i>
</button>
<div id="menu-primary-tracks" class="menu-primary-tracks"></div>
<div id="menu-primary" class="menu-container menu-primary" role="navigation">
<p class="site-description">Whats the Worst That Could Happen?</p>
<div class="menu">
<ul id="menu-primary-items" class="menu-primary-items">
<li class='menu-item menu-item-type-custom menu-item-object-custom '>
<a href="https://h.cowbay.org/">Home</a>
</li>
<li class='menu-item menu-item-type-post_type menu-item-object-page '>
<a href="https://h.cowbay.org/about/">About</a>
</li>
<li class='menu-item menu-item-type-post_type menu-item-object-page '>
<a href="https://h.cowbay.org/contact/">Get in touch</a>
</li>
</ul>
</div>
</div>
</div>
</header>
<div id="main" class="main" role="main">
<div id="loop-container" class="loop-container">
<div class="post type-post status-publish format-standard has-post-thumbnail hentry category-design tag-design tag-standard-2 tag-tagalicious tag-travel entry full-without-featured odd excerpt-1">
<div class='featured-image lazy lazy-bg-image' data-background="https://h.cowbay.org/images/post-default-9.jpg">
</div>
<div class="entry-meta">
<span class="date">27 March</span> <span> / </span>
<span class="author">
<a href="https://github.com/changchichung" title="Posts by Eric Chang" rel="author">Eric Chang</a>
</span>
<span class="category">
<span> / </span>
<a href="/categories/%E7%AD%86%E8%A8%98">筆記</a>
</span>
</div>
<div class='entry-header'>
<h1 class='entry-title'> [筆記] 用rsync 移轉 centos 6.2的老機器 Transfer Cent6.2 using rsync</h1>
</div>
<div class="entry-container">
<div class="entry-content">
<article>
<p>公司的一台老伺服器空間不足了,要執行指令都會中斷,所以想要擴充空間。</p>
<p>看起來不難搞,事實上&hellip;..</p>
<p>因為前人的功績,所以這台當初的磁碟分割有點「特別」!</p>
<p>實體硬碟是兩顆500G SATA</p>
<p>然後各切三個 partition (sda1/sda2/sda3 and sdb1/sdb2/sdb3)</p>
<p>sda2/sdb2 用250M 來組 raid1 (/dev/md0) 給 /boot 用</p>
<p>sda1/sdb1 各用40G 組raid1 (/dev/md1) 做成LVM 的VG ,然後再切出四個大小不同的分割</p>
<pre><code>* / (sysvg-root)
* /usr (sysvg-usr)
* /var (sysvg-var)
* /tmp (sysvg-tmp)
</code></pre>
<p>What the Fuck !?!? 然後最好笑的是40G的空間還留了2G可以讓後面的倒楣鬼(對,就是我)</p>
<p>在碰到空間不足的問題時,還可以「擴充」</p>
<p>然後剩下的sda3/sdb3 大概有四百多G空間一樣是組raid1 然後分割給這些目錄用</p>
<pre><code>* /data (datavg-datatest) (對的,沒有錯 真的叫 datavg-datatest媽的你test個鬼啊還在test的東西直接上線使用)
* /web (datavg-web)
* /www (datavg-www)
* /home (datavg-home)
</code></pre>
<p>幹!誰可以告訴我 www/web 的差異在哪裡?為什麼要特別切兩個分割給這兩個目錄用?</p>
<p>快下班了,明天再來寫&hellip;</p>
<p>繼續補坑..</p>
<p>先說結論,最後成功的作法如下</p>
<ul>
<li>加裝一顆512G SSD 到機器上</li>
<li>安裝作業系統(centos 6.2) 到 512G SSD裝完後用SSD開機進入系統後先補完一些套件(lvm2,rsync等等)</li>
<li>在系統內直接偵測原先的raid (mdadm &ndash;assemble &ndash;scan)</li>
<li>執行 vgchange -ay 啟動 lvm原來的lv 會出現在 /dev/mapper/xxxxxx</li>
<li>先備份 /etc , /usr (usr 應該可以不用備份)</li>
<li>mount /dev/mapper/xxxxxx /mnt然後把資料抄到SSD的相對路徑裡面 sysvg-usr&ndash;&gt;usr sysvg-var&ndash;&gt;var datavg-datatest&ndash;&gt;data (幹再罵一次test個什麼鬼)</li>
<li>都抄完之後,把剛剛備份的/etc_backup 裡面的fstab 複製回 /etc ,這樣才能正常開機</li>
<li>重新開機,祈禱可以開起來</li>
<li>進入系統後,測試相關程式</li>
</ul>
<p>這次的過程,踩了很多坑&hellip;</p>
<p>導致中間有一段時間一直在鑽牛角尖,想要把問題解掉,加上沒有適合的硬體,就連新買的 1TB SSD 也是地雷</p>
<p>所以花了三天才算成功</p>
<p>簡單紀錄一下碰到了哪些問題,以及對應的解決方式(如果有得解的話)..</p>
<h3 id="加裝兩顆硬碟後-原系統無法使用">加裝兩顆硬碟後,原系統無法使用</h3>
<p>這個問題非常奇怪,因為空間不足嘛,所以很直接就想說加硬碟進去擴充空間好了。</p>
<p>結果加了兩顆500G SATA硬碟之後原有的系統雖然可以開機但是 SSH 沒有啟動</p>
<p>想說就登入檢查一下看看是什麼問題導致SSH起不來然後呢這邊就碰到第一個地雷了</p>
<h1 id="沒有人有root-密碼">沒有人有root 密碼!!!!</h1>
<p>雖然有兩個帳號可以登入但是都是一般user ,不能做 sudo</p>
<p>可以做sudo的帳號沒有人知道密碼(因為都是用key登入)</p>
<p>那用root 登入吧,結果手邊紀錄的密碼都是錯的</p>
<p>好吧那進rescue mode 改密碼總可以吧?事情如果那麼簡單就好了!</p>
<p>進rescue mode 之後,要執行 passwd ,就會出現</p>
<pre><code> /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory
</code></pre>
<p>很奇怪吧,為什麼加硬碟進去,就會碰到這個問題?</p>
<p>這兩顆新增的硬碟之前是用來測試 zfs 的,所以上面有切了 zfs 的分割</p>
<p>就因為這樣所以會碰到這種詭異的狀況嗎? 不知道,不確定,不想面對&hellip;</p>
<p>好,針對 bad ELF interpreter 的問題,網路上的解法都是重新安裝套件</p>
<p>BUT ..yes , there is always a &ldquo;BUT&rdquo;</p>
<p>yum install glibc.i686 一樣出現上面的錯誤,所以無法安裝&hellip;.</p>
<p>很好,卡關&hellip;換下一招!</p>
<p>P.S 其實在這邊犯了個錯誤,既然新增硬碟進去出了問題</p>
<p>那應該移除這兩顆新增的硬碟就可以先恢復原來的狀態(可開機運作,只是要執行程式會空間不足)</p>
<hr>
<h3 id="clonezilla-來源是raid時-無法調整目標磁區的大小">clonezilla 來源是raid時無法調整目標磁區的大小</h3>
<p>因為上面失敗了,所以現在每次調整時,我都會用 clonezilla 先做一份磁碟的備份</p>
<p>但是因為clonezilla 在處理來源是raid 磁區時是用dd 慢慢寫入</p>
<p>備份時間很久因為原本的raid 已經切了99%的空間出去給LVM</p>
<p>所以clonezilla 看到的使用量就是99% 也因此每次備份幾乎就是要用dd 寫完500G的資料</p>
<p>有興趣可以玩看看,在傳統硬碟上這樣做要花多少時間&hellip;</p>
<p>然後我每次都要複製兩顆出來&hellip;</p>
<p>在使用clonezilla 的過程中突然想到clonezilla 可以動態調整目標磁區大小</p>
<p>前提是目標磁碟空間比來源空間大</p>
<p>這個功能要進入 advanced mode 才會看到</p>
<p>興沖沖的改用這個選項複製&hellip;..結果還是一樣的大小&hellip;</p>
<p>其實這個結果不算意外啦,算是一個小嘗試,如果有支援就算賺到</p>
<p>沒有支援也就算了..</p>
<hr>
<h3 id="raid擴充-成功-但不是預期的容量">raid擴充「成功」但不是預期的容量</h3>
<p>磁碟對拷完,改用對拷的磁碟開機</p>
<p>然後再加入兩顆 500G 的SATA硬碟 (怪的是這次加兩顆硬碟就不會造成系統SSH無法啟動)</p>
<p>經過一番手腳 (簡單說就是 mdadm 搭配 <code>--add</code> , <code>--remove</code> , <code>--grow</code> , <code>--raid-devices</code> 這幾個參數下去跑)</p>
<p>終於成功把新的硬碟給加入原有的RAID了</p>
<p>但是一檢查容量, WTF !! 為什麼還是跟原本一樣?</p>
<p>這邊就要說到 raid 的原理了,直接跳過,說結論</p>
<p>如果是 raid1(mirror) ,至少兩顆硬碟這部份沒有問題</p>
<p>但是不管你再加多少顆硬碟進去這個raid他的容量「不會改變」「不會改變」「不會改變」</p>
<p>依照某個外國人的解釋,就是下面這樣</p>
<pre><code>RAID 1 is pure mirroring. No matter how many drives you add to RAID 1, the size never increases. What you increase is how many drives can fail and how good your read performance is.
</code></pre>
<p>所以在原地擴充現有的mirror 空間不可行!</p>
<p>下一招擴充不可行那我改raid type 可以吧??</p>
<hr>
<h3 id="convert-raid1-to-raid5">convert raid1 to raid5</h3>
<p>既然raid1 直接加硬碟不可行那我能不能加入硬碟之後把raid1 轉成 raid5 呢?</p>
<p>理論上是可以的</p>
<p>BUT &hellip;(沒錯還是這個BUT)</p>
<p>我參考底下這篇,過程其實很順利</p>
<p><a href="https://stevesubuntutweaks.blogspot.com/2015/06/converting-raid1-array-to-raid5-using.html">https://stevesubuntutweaks.blogspot.com/2015/06/converting-raid1-array-to-raid5-using.html</a></p>
<p>但是只要我動到放boot 那組RAID重開機之後就完全沒有畫面&hellip;..</p>
<p>不會載入 grub 來開機所以我完全不知道發生了什麼事也沒辦法進grub 改 root 位置</p>
<p>用rescue mode 進去想修grub ,都出現 unknown file system</p>
<p>那不要動不就好了嗎?那這樣就要掛著一顆原本的舊硬碟來開機啊!什麼蠢方法啊!</p>
<p>所以,失敗!&hellip;.</p>
<p>不過我覺得這個方式應該是比較可行的才對,或許會再找虛擬機來測試看看</p>
<hr>
<h3 id="migrate-system-using-rsync">migrate system using rsync</h3>
<p>正所謂事不過三,前面都失敗三次了(已經花了兩天多的時間)</p>
<p>不能再這樣搞下去了</p>
<p>這次改用之前就用過的「正統」解決方式</p>
<ul>
<li>卸除原本主機上的所有硬碟並新增一顆512G 的SSD</li>
<li><p>在新增的512G SSD上安裝一樣的作業系統(CentOS 6.2)</p>
<pre><code>這邊也有地雷...不知道為什麼CentOS 6.2 的ISO我用easy2boot 作到隨身碟上
安裝過程出現CDROM not FOUND的錯誤。好那我用光碟片開機總可以吧
BUT (又是你啊BUT兄 )
在安裝時一樣出現CDROM not FOUND , WTF !!
最後是透過用網路安裝的方式
指定URL到 http://vault.centos.org/6.2/os/x86_64 來進行安裝
而且一開始因為6.2裝不起來所以我改用centos 6.10 的ISO作到隨身碟進行安裝
這樣子安裝就可以,可是最後從原本硬碟把資料抄回來後,會不能開機
會有 /bin/awk too many links 類似這樣的錯誤訊息
總之,還是要想辦法裝回一樣的作業系統
</code></pre></li>
<li><p>系統安裝完成,關機,接上原本主機的一顆硬碟,準備把資料抄回來</p>
<pre><code>如果會怕可以用ubuntu 18.04 live DVD 開機,然後先安裝 mdadm
接著執行 mdadm --assemble --scan 偵測原本的RAID
這時候雖然會抓到RAID但是因為上面是LVM 所以沒辦法直接掛進來
需要再執行一次 vgchange -ay
原本的lvm 磁區,就會出現在 /dev/mapper 裡面
再執行 mount /dev/mapper/sysvg-usr /mnt 把目錄掛進來
</code></pre></li>
<li><p>分次掛載原本的目錄然後sync 回SSD</p>
<pre><code>我是直接在系統內操作沒有透過liveDVD
先備份 /etc , /usr
然後就看原本LVM切了幾個每一個都mount 進來然後把資料用rsync 抄回對應的路徑底下就好
抄完之後,把備份出來的 /etc.bak/fstab 複製回 /etc
這樣才能正常開機
</code></pre></li>
<li><p>重開機</p>
<pre><code>正常的話,這時候重開機應該是可以進入系統
接著就是請同事確認環境、指令是否可以執行
然後修改一些像是目錄權限, uid,gid 等等的問題
基本上系統這樣就轉完了
</code></pre></li>
</ul>
<hr>
<h3 id="地雷產品">地雷產品</h3>
<p>在這過程中因為本來想直接做線上升級到1TB的空間所以買了兩個 TCELL TT550 960G SSD 來用</p>
<p><img src="https://i.imgur.com/94hPMJG.png" alt="TCELL TT550 960G SSD" /></p>
<p>結果因為線上升級失敗改用rsync來做所以就把這兩顆SSD用 mdadm 組成raid1 來做系統</p>
<p>安裝過程沒什麼問題,但是在從舊硬碟抄資料回來的時候,發現速度很慢,而且會有卡住的情況</p>
<p><a href="https://www.youtube.com/watch?v=NOIyRFit64k">https://www.youtube.com/watch?v=NOIyRFit64k</a></p>
<p>從影片中可以看到,一開始複製檔案時,速度會往下掉,然後又慢慢爬上來,中間還會卡住</p>
<p>另一台用的是創見 S370 512G SSD 一顆 (MLC) ,這台就不會有這種問題</p>
<p>但是用Crystal Disk Mark 去測試這顆SSD ,速度又是正常 (4xx/3xx)</p>
<p>不知道是不是因為做RAID的關係或者是linux 的影響?</p>
<p>總之最後這兩顆SSD 就被我退貨了&hellip;</p>
<p>話說我跟TCELL似乎犯衝啊&hellip;</p>
<p>上次買的4K EVO 64G隨身碟也是速度很慢跑了一次RMA換新的回來才正常</p>
<p>這次的960G SSD ($2999) 又有這種問題</p>
<p>看來下次要好好「評估」了..</p>
<hr>
<h3 id="測試raid1轉raid5擴充空間">測試raid1轉raid5擴充空間</h3>
<p>前面有提到如果沒有LVM的話我應該可以很輕易的加入兩顆硬碟到原有的raid1然後就直接擴充容量</p>
<p>不過操作失敗了,但是我一直覺得這個應該很容易解決才對</p>
<p>所以我開了一台VM來做測試</p>
<p>OS: Ubuntu 18.04 Server x64
HDD: 16G vmdisk x4</p>
<p>一開始安裝時就在安裝程式內設定一組raid1 (/dev/vda, /dev/vdb)然後把系統灌在這個raid device上</p>
<p>安裝完成後,先進入系統確認一下現在的狀態</p>
<p><img src="https://i.imgur.com/KDix5IJ.png" alt="" /></p>
<p>可以看到有一個raid1 的磁區,由 /dev/vda1 , /dev/vdb1 組成raid-devices:2 Array Size: 16765952 (15.99 GiB)</p>
<p>然後還有兩個磁碟沒有用到 (/dev/vdc , /dev/vdd)</p>
<p>接著為了進行模擬測試,先拍個快照,然後改用 ubuntu 18.04 Desktop 的ISO開機</p>
<p>進入系統後,要先開啟 terminal 來安裝 mdadm</p>
<pre><code>apt install mdadm -y
</code></pre>
<p><img src="https://i.imgur.com/0tnEdW5.png" alt="install mdadm in ubuntu 18.04 liveDVD" /></p>
<p>然後把剛剛看到的兩顆還沒用到的磁碟切分割加入RAID內</p>
<p>或者可以直接用sfdisk 從原有的磁碟抄partition table過來</p>
<p>我直接用 sfdisk 抄比較快,底下的指令是抄 vda 的partition table 到 vdc和 vdd</p>
<pre><code>sfdisk -d /dev/vda | sfdisk /dev/vdc
sfdisk -d /dev/vda | sfdisk /dev/vdd
</code></pre>
<p><img src="https://i.imgur.com/mlikld4.png" alt="sfdisk copt partition table" /></p>
<p>然後檢查一下是不是正確</p>
<pre><code>fdisk -l /dev/vdc
fdisk -l /dev/vdd
</code></pre>
<p><img src="https://i.imgur.com/5qQNLbu.png" alt="check result after sfdisk" /></p>
<p>再來就偵測原來的RAID然後加入兩個剛剛做出來的分割到raid群組內</p>
<p>接著就直接把raid1轉成raid5然後把raid-devices:2 改成 4看一下狀態</p>
<p>可以看到在把raid-devices 提升到4顆之後原有的raid 就會開始進行reshape (不是rebuild唷)</p>
<pre><code>mdadm --assemble --scan
mdadm --add /dev/md0 /dev/vdc1 /dev/vdd1
mdadm --grow /dev/md0 --level=5
mdadm --grow /dev/md0 --raid-devices=4
cat /proc/mdstat
</code></pre>
<p><img src="https://i.imgur.com/dxwQC0v.png" alt="convert raid1 to raid5 procedure" /></p>
<p>耐心等待raid reshape 跑完要一點時間我只用16G的磁碟來測試也要跑個七八分鐘左右</p>
<p>不敢想像如果是幾TB的空間要跑多久&hellip;</p>
<p>等上面的程序跑完後再看一下raid狀態就會看到原有的RAID空間變大了磁碟變多了心情變好了考試也都考100分了</p>
<p><img src="https://i.imgur.com/7E2qL8Q.png" alt="check raid status after reshape" /></p>
<p>本來想說已經完成了興沖沖的把raid 掛進來看一下空間卻還是16G ?????</p>
<pre><code>mount /dev/md0p1 /mnt
df -h
</code></pre>
<p><img src="https://i.imgur.com/ILjDN1g.png" alt="raid space still 16G" /></p>
<p>其實這邊我一直沒搞懂,文章都說你就跑 e2fsck 檢查一次,然後跑 resize2fs 放大就結束了</p>
<p>問題是,我這樣做沒用&hellip;</p>
<p><img src="https://i.imgur.com/ij2AGw7.png" alt="raid not expand after e2fsck and resize2fs" /></p>
<p>最後我是直接請出 gparted 來做</p>
<p>叫出 gparted 之後可以直接看到剛剛增加的空間沒有被放到原有的raid</p>
<p>那就直接 resize吧</p>
<p><img src="https://i.imgur.com/qLQMRAe.png" alt="unallocated space in gparted" /></p>
<p>gparted resize 太簡單了&hellip;直接用拉的就好了</p>
<p><img src="https://i.imgur.com/KAs3gwu.png" alt="resize partition in gparted" /></p>
<p>好,都做完了,重開機見真章!看看到底有沒有成功?</p>
<p><img src="https://i.imgur.com/uGzxA9t.png" alt="check result after reboot" /></p>
<p>空間順利放大了,打完收工!</p>
<p>我想以後如果又碰到一樣的狀況,大概就會用最後這個方式處理吧!</p>
</article>
</div>
<div class='entry-meta-bottom'>
<div class="entry-categories"><p><span>Categories</span>
<a href="/categories/%E7%AD%86%E8%A8%98" title="View all posts in 筆記">筆記</a>
</p>
</div>
<div class="entry-tags"><p><span>Tags</span>
<a href="/tags/centos" title="View all posts tagged centos">centos</a>
<a href="/tags/linux" title="View all posts tagged linux">linux</a>
</p></div> </div>
<div class="author-meta">
<div class="author">
<img alt='Eric Chang' src="https://www.gravatar.com/avatar/23f8ed94e007297499ac8df1641b3ff5?s=100&d=identicon" class='avatar avatar-72 photo' height='72' width='72'>
<span>
Written by:<a href="https://github.com/changchichung" title="Posts by Eric Chang" rel="author">Eric Chang</a> </span>
</div>
<div class="bio">
<p>塵世裡一個迷途小書僮</p>
<a class="facebook" target="_blank"
href="full%20Social%20profile%20url%20in%20facebook">
<i class="fab fa-facebook-f"
title="facebook icon"></i>
</a>
<a class="googleplus" target="_blank"
href="full%20profile%20url%20in%20googleplus">
<i class="fab fa-google-plus-g"
title="googleplus icon"></i>
</a>
<a class="twitter" target="_blank"
href="chang0206">
<i class="fab fa-twitter-square"
title="twitter icon"></i>
</a>
<a class="linkedin" target="_blank"
href="full%20profile%20url%20in%20linkedin">
<i class="fab fa-linkedin"
title="linkedin icon"></i>
</a>
<a class="email" target="_blank"
href="mailto:mc@hotshraingmy.info">
<i class="fas fa-envelope"
title="email icon"></i>
</a>
<a class="instagram" target="_blank"
href="chang0206">
<i class="fab fa-instagram"
title="instagram icon"></i>
</a>
<a class="stackoverflow" target="_blank"
href="full%20profile%20url%20in%20stackoverflow">
<i class="fab fa-stack-overflow"
title="stackoverflow icon"></i>
</a>
<a class="github" target="_blank"
href="changchichung">
<i class="fab fa-github"
title="github icon"></i>
</a>
<a class="pinterest" target="_blank"
href="full%20profile%20url%20in%20pinterest">
<i class="fab fa-pinterest"
title="pinterest icon"></i>
</a>
</div>
</div>
</div>
</div>
<section id="comments" class="comments">
<div id="disqus_thread"></div>
<script type="application/javascript">
var disqus_config = function () {
};
(function() {
if (["localhost", "127.0.0.1"].indexOf(window.location.hostname) != -1) {
document.getElementById('disqus_thread').innerHTML = 'Disqus comments not available by default when the website is previewed locally.';
return;
}
var d = document, s = d.createElement('script'); s.async = true;
s.src = '//' + "h-cowbay-org-1" + '.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="https://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
</section>
</div>
</div>
<footer id="site-footer" class="site-footer" role="contentinfo">
<h1>
<a href=""> MC部落 </a>
</h1>
<p class="site-description">Whats the Worst That Could Happen?</p>
<div id="menu-footer" class="menu-container menu-footer" role="navigation">
<div class="menu">
<ul id="menu-footer-items" class="menu-footer-items">
</ul>
</div> </div>
<ul class="social-media-icons">
<li>
<a class="facebook" target="_blank"
href="full%20Social%20profile%20url%20in%20facebook" >
<i class="fab fa-facebook-f" title="facebook"></i>
<span class="screen-reader-text">facebook</span>
</a>
</li>
<li>
<a class="googleplus" target="_blank"
href="full%20profile%20url%20in%20googleplus" >
<i class="fab fa-google-plus-g" title="googleplus"></i>
<span class="screen-reader-text">googleplus</span>
</a>
</li>
<li>
<a href="chang0206" class="twitter" target="_blank">
<i class="fab fa-twitter-square" title="twitter"></i>
<span class="screen-reader-text">twitter</span>
</a>
</li>
<li>
<a href="chang0206" class="instagram" target="_blank">
<i class="fab fa-instagram" title="instagram"></i>
<span class="screen-reader-text">instagram</span>
</a>
</li>
<li>
<a href="mailto:mc@hotshraingmy.info" class="email">
<i class="fas fa-envelope" title="email"></i>
<span class="screen-reader-text">email</span>
</a>
</li>
<li>
<a href="full%20profile%20url%20in%20linkedin" class="linkedin" target="_blank">
<i class="fab fa-linkedin-in" title="linkedin"></i>
<span class="screen-reader-text">linkedin</span>
</a>
</li>
<li>
<a href="full%20profile%20url%20in%20stackoverflow" class="stackoverflow" target="_blank">
<i class="fab fa-stack-overflow" title="stackoverflow"></i>
<span class="screen-reader-text">stackoverflow</span>
</a>
</li>
<li>
<a href="changchichung" class="github" target="_blank">
<i class="fab fa-github" title="github"></i>
<span class="screen-reader-text">github</span>
</a>
</li>
<li>
<a href="full%20profile%20url%20in%20pinterest" class="pinterest" target="_blank">
<i class="fab fa-pinterest" title="pinterest"></i>
<span class="screen-reader-text">pinterest</span>
</a>
</li>
<li>
<a href="https://h.cowbay.org/index.xml" data-animate-hover="pulse" class="rss" target="_blank">
<i class="fas fa-rss" title="rss"></i>
<span class="screen-reader-text">rss</span>
</a>
</li>
</ul> <div class="design-credit">
<p>&copy; 2018 Göran Svensson</p>
<p>Nederburg Hugo Theme by <a href="https://appernetic.io">Appernetic</a>.</p>
<p>A port of Tracks by Compete Themes.</p>
</div>
</footer>
</div>
<script src="https://h.cowbay.org/js/jquery.min.js"></script>
<script src="https://h.cowbay.org/js/jquerymigrate.js"></script>
<script src="https://h.cowbay.org/js/production.min.js?v=1577170732"></script>
</body>
</html>