{"id":1253,"date":"2014-01-12T00:28:56","date_gmt":"2014-01-11T23:28:56","guid":{"rendered":"http:\/\/www.sciencetronics.com\/greenphotons\/?p=1253"},"modified":"2025-06-16T18:38:10","modified_gmt":"2025-06-16T16:38:10","slug":"upgrading-a-raid-1-ubuntu-server","status":"publish","type":"post","link":"https:\/\/www.sciencetronics.com\/greenphotons\/?p=1253","title":{"rendered":"Upgrading a RAID-1 Ubuntu-server"},"content":{"rendered":"<p>It&#8217;s almost 4 years now since I installed my server and I decided it was time for some new (bigger) harddisks. I wrote about my server earlier <a href=\"http:\/\/www.sciencetronics.com\/greenphotons\/?p=294\" title=\"A new server\">in my blog<\/a>, but here is a short summary about its current state before the upgrade:<\/p>\n<table>\n<tr>\n<th>processor<\/th>\n<td>AMD Athlon (Barton) 1.3 GHz(?)<\/td>\n<\/tr>\n<tr>\n<th>mainboard<\/th>\n<td>Zenith &#8230;<\/td>\n<\/tr>\n<tr>\n<th>memory<\/th>\n<td>512 MByte<\/td>\n<\/tr>\n<tr>\n<th>hdd<\/th>\n<td>2x 1TByte SATA<br \/> two different brands<\/td>\n<\/tr>\n<tr>\n<th>OS<\/th>\n<td>Ubuntu Linux 11.04<\/td>\n<\/tr>\n<\/table>\n<p>The two 1TByte hdd were in a RAID-1 configuration, according to the following specs:<\/p>\n<table>\n<tr>\n<th>sda1, sdb1<\/th>\n<td>980GByte 0x83<\/td>\n<\/tr>\n<tr>\n<th>sda2, sdb2<\/th>\n<td>10GByte 0x82 swap<\/td>\n<\/tr>\n<tr>\n<th>md0<\/th>\n<td>raid1 sda1, sdb1<\/td>\n<\/tr>\n<\/table>\n<p>with both data and system in a single, flat volume. Previously I had always kept the system separate from my data, but lately I became lazy&#8230;<\/p>\n<p>Now I wanted to swap the two harddisk for new ones with 2TByte capacity. I googled the internet and found an uncountable number of guides and discussions, indicating that this might not be compeletely simple.<\/p>\n<p>Therefore I now add yet another description of a successful upgrade and swap of the drives.<\/p>\n<ol>\n<li>say goodbye to your server and shut it down\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:435px;\"><div class=\"text codecolorer\">root@phoenix:\/home\/uwezi#sudo shutdown -h now<\/div><\/div>\n<\/li>\n<li>open the computer and unplug one of the harddisks from the RAID1 array, you could first check the drive status in case one of the drives is more reliable than the other: that one should stay in the system for now.<\/li>\n<li>prepare a Linux live-CD. You might be able to use your server&#8217;s operating system for sme of the steps, but at leatest when it comes to resizing the filesystem you need to run another system. I used a Knoppix 7.2 from here<a href=\"http:\/\/www.knoppix.org\/\" target=\"_blank\">www.knoppix.org<\/a><\/li>\n<li>take the first of the new drives out of its bag and connect it to your server.<\/li>\n<li>boot the system off the live-CD. You will not need a graphical system, booting into a console might save you some time. For Knoppix give it the following command at boot:\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:435px;\"><div class=\"text codecolorer\">knoppix 2<\/div><\/div>\n<\/li>\n<li>Analyze the structure of the remaining disk, in order to identify its partitions:\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:435px;\"><div class=\"text codecolorer\">root@Knoppix:\/# fdisk \/dev\/sda<br \/>\nCommand (m for help): p<br \/>\n<br \/>\n&nbsp; &nbsp;Device Boot &nbsp; &nbsp; &nbsp;Start &nbsp; &nbsp; &nbsp; &nbsp; End &nbsp; &nbsp; &nbsp;Blocks &nbsp; Id &nbsp;System<br \/>\n\/dev\/sda1 &nbsp; * &nbsp; &nbsp; &nbsp; &nbsp;1306 &nbsp; &nbsp; &nbsp;121601 &nbsp; 971513900 &nbsp; 83 &nbsp;Linux<br \/>\n\/dev\/sda2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1 &nbsp; &nbsp; &nbsp; &nbsp;1306 &nbsp; &nbsp;10485760 &nbsp; 82 &nbsp;Linux swap \/ Solaris<\/div><\/div>\n<\/li>\n<li>for all but the main partition use <em>fdisk<\/em> now to create the same structre on the new drive. The main partition will receive all the remaining space.\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:435px;\"><div class=\"text codecolorer\">root@Knoppix:\/# fdisk \/dev\/sdb<br \/>\nCommand (m for help): p<br \/>\n<br \/>\nDevice Boot &nbsp; &nbsp; &nbsp;Start &nbsp; &nbsp; &nbsp; &nbsp; End &nbsp; &nbsp; &nbsp;Blocks &nbsp; Id &nbsp;System<br \/>\n\/dev\/sdb1 &nbsp; * &nbsp; &nbsp; &nbsp; &nbsp;1306 &nbsp; &nbsp; &nbsp;243202 &nbsp;1943027800 &nbsp; 83 &nbsp;Linux<br \/>\n\/dev\/sdb2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1 &nbsp; &nbsp; &nbsp; &nbsp;1306 &nbsp; &nbsp;10485760 &nbsp; 82 &nbsp;Linux swap \/ Solaris<\/div><\/div>\n<\/li>\n<li>Knoppix does not by default look for RAID arrays, but now we have come to the point where we will include the new drive into the array. Lets assume that <em>\/dev\/sda<\/em> is your old drive and <em>\/dev\/sdb<\/em> your new, bigger one. The information about the old RAID array is still on <em>\/dev\/sda<\/em>:\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:435px;\"><div class=\"text codecolorer\">root@Knoppix:\/# mdadm --examine --scan \/dev\/sda &gt;&gt; \/etc\/mdadm\/mdadm.conf<br \/>\nroot@Knoppix:\/# mdadm --assemble --scan<\/div><\/div>\n<p>Then you can check the status of your RAID array at this point in time:<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:435px;\"><div class=\"text codecolorer\">root@Knoppix:\/# cat \/proc\/mdstat<br \/>\nmd0 : active raid1 sda1<br \/>\nxxxxxxxxxx blocks [1\/2] [U_]<\/div><\/div>\n<p>indicating that one drive from the array is down or gone.<\/li>\n<li>now you add your newly prepared partition on the new drive to the array:\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:435px;\"><div class=\"text codecolorer\">root@Knoppix:\/# mdadm --add \/dev\/sdb1<\/div><\/div>\n<\/li>\n<li>the system will now take all the data from the remaining drive and copy it onto the new mirror drive. This will take a while, but you can watch the progress using\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:435px;\"><div class=\"text codecolorer\">root@Knoppix:\/# cat \/proc\/mdstatmd0 : active raid1 sda1<br \/>\nxxxxxxxxxx blocks [2\/2] [UU]<br \/>\n[****&gt;.....................] recovery = 15% (xxxxx\/yyyyyy)<\/div><\/div>\n<p>On my system it took about 3 hours to copy everything.<\/li>\n<li>now everything is copied and your new drive is a mirror of the contents of the RAID array. It&#8217;s time to swap the other drive. Shutdown the system again, disconnect the old harddisk and connect the new harddisk.<\/li>\n<li>boot back into the live-CD console and repeat the above steps:<\/li>\n<li>Analyze the structure of the remaining disk, in order to identify its partitions:\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:435px;\"><div class=\"text codecolorer\">root@Knoppix:\/# fdisk \/dev\/sdb<br \/>\nCommand (m for help): p<br \/>\n<br \/>\n&nbsp; &nbsp;Device Boot &nbsp; &nbsp; &nbsp;Start &nbsp; &nbsp; &nbsp; &nbsp; End &nbsp; &nbsp; &nbsp;Blocks &nbsp; Id &nbsp;System<br \/>\n\/dev\/sdb1 &nbsp; * &nbsp; &nbsp; &nbsp; &nbsp;1306 &nbsp; &nbsp; &nbsp;243202 &nbsp;1943027800 &nbsp; 83 &nbsp;Linux<br \/>\n\/dev\/sdb2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1 &nbsp; &nbsp; &nbsp; &nbsp;1306 &nbsp; &nbsp;10485760 &nbsp; 82 &nbsp;Linux swap \/ Solaris<\/div><\/div>\n<\/li>\n<li>use <em>fdisk<\/em> now to create the same structre on the new drive.\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:435px;\"><div class=\"text codecolorer\">root@Knoppix:\/# &nbsp;fdisk \/dev\/sda<br \/>\nCommand (m for help): p<br \/>\n<br \/>\nDevice Boot &nbsp; &nbsp; &nbsp;Start &nbsp; &nbsp; &nbsp; &nbsp; End &nbsp; &nbsp; &nbsp;Blocks &nbsp; Id &nbsp;System<br \/>\n\/dev\/sda1 &nbsp; * &nbsp; &nbsp; &nbsp; &nbsp;1306 &nbsp; &nbsp; &nbsp;243202 &nbsp;1943027800 &nbsp; 83 &nbsp;Linux<br \/>\n\/dev\/sda2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 1 &nbsp; &nbsp; &nbsp; &nbsp;1306 &nbsp; &nbsp;10485760 &nbsp; 82 &nbsp;Linux swap \/ Solaris<\/div><\/div>\n<\/li>\n<li>Now <em>\/dev\/sdb<\/em> is your &#8220;old drive&#8221; and <em>\/dev\/sda<\/em> the second new one. The information about the old RAID array is still on <em>\/dev\/sdb<\/em>:\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:435px;\"><div class=\"text codecolorer\">root@Knoppix:\/# mdadm --examine --scan \/dev\/sdb &gt;&gt; \/etc\/mdadm\/mdadm.conf<br \/>\nroot@Knoppix:\/# mdadm --assemble --scan<\/div><\/div>\n<p>Then you can check the status of your RAID array at this point in time:<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:435px;\"><div class=\"text codecolorer\">root@Knoppix:\/# cat \/proc\/mdstat<br \/>\nmd0 : active raid1 sdb1<br \/>\nxxxxxxxxxx blocks [1\/2] [_U]<\/div><\/div>\n<p>indicating that one drive from the array is down or gone.<\/li>\n<li>now you add your newly prepared partition on the new drive to the array:\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:435px;\"><div class=\"text codecolorer\">root@Knoppix:\/# mdadm --add \/dev\/sda1<\/div><\/div>\n<\/li>\n<li>the system will now take all the data from the remaining drive and copy it onto the new mirror drive. This will take a while, but you can watch the progress using\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:435px;\"><div class=\"text codecolorer\">root@Knoppix:\/# cat \/proc\/mdstatmd0 : active raid1 sda1 sdb1<br \/>\nxxxxxxxxxx blocks [2\/2] [UU]<br \/>\n[****&gt;.....................] recovery = 15% (xxxxx\/yyyyyy)<\/div><\/div>\n<p>On my system it again took about 3 hours to copy everything.<\/li>\n<li>Now I had a 1TByte RAID 1 partition&#8217;s data on a 2TByte partition. The next step is to resize the RAID array:\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:435px;\"><div class=\"text codecolorer\">root@Knoppix:\/# mdadm --grow \/dev\/md0 --size=max<\/div><\/div>\n<p>This again will take some time to finish&#8230;<\/li>\n<li>Now you&#8217;ll have to check\/correct the filesystem on the RAID volume, then resize it and check it again:\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:435px;\"><div class=\"text codecolorer\">root@Knoppix:\/# e2fsck -f \/dev\/md0<br \/>\nroot@Knoppix:\/# resize2fs \/dev\/md0<br \/>\nroot@Knoppix:\/# e2fsck -f \/dev\/md0<\/div><\/div>\n<\/li>\n<li>Hopefully everything went fine so far, but in my case I still did not have a running system: the <em>grub<\/em> boot loader had not been copied in the process. And here the internet was somewhat reluctant to give the ultimate clues. I had to look up information from different sites and discussions to get it working without mysterious errors or warnings.<\/li>\n<li>Still in the live-CD&#8217;s console create a mount-point and mount your RAID array:\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:435px;\"><div class=\"text codecolorer\">root@Knoppix:\/# mkdir \/media\/md0<br \/>\nmount \/dev\/md0 \/media\/md0<\/div><\/div>\n<\/li>\n<li>Now for the first time you can browse the contents of your drives &#8211; it is quite comforting to see all your file again, but in case anything had gone wrong you would still have both old drives with unchanged contents!<\/li>\n<li>Finally you have to also mount the virtual file systems of the life-CD inside the mounted RAID-array:\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:435px;\"><div class=\"text codecolorer\">root@Knoppix:\/# for i in \/dev \/dev\/pts \/proc \/sys \/run; do mount -B $i \/media\/md0$i; done<\/div><\/div>\n<p>There is no <em>\/run<\/em> in a Knoppix live-system, so you will get an error message&#8230;<\/li>\n<li>And finally you can switch context to the mounted RAID system and execute the installer for the bootloader:\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;width:435px;\"><div class=\"text codecolorer\">root@Knoppix:\/# chroot \/media\/md0<br \/>\ngrub-install \/dev\/sda<br \/>\ngrub-install \/dev\/sdb<\/div><\/div>\n<\/li>\n<li>Shutdown the live-CD system, take out the CD and reboot your computer &#8211; and if you are as lucky as I am you have a running system again!<\/li>\n<\/ol>\n<p>Total downtime including some sleep was about 24 hours.<\/p>\n<p>Thanks especially to <\/p>\n<ul>\n<li><a href=\"http:\/\/forums.dlink.com\/index.php?topic=19643.0\" title=\"ypchen\" target=\"_blank\">ypchen: DNS-321 RAID-1 upgrade&#8230;<\/a><\/li>\n<li><a href=\"http:\/\/sourceforge.net\/apps\/mediawiki\/bootinfoscript\/index.php?title=Boot_Problems:Cannot_Find_A_Device_For_boot\/grub\" title=\"MeierFra\" target=\"_blank\">MeierFra: Boot Problems:Cannot Find A Device For boot\/grub<\/a><\/li>\n<li>&#8230;and of course all contributors to Ubuntu, Knoppix and Linux, as well as WordPress<\/li>\n<\/ul>\n<p>The next big project will be an update\/upgrade of the Ubuntu-version my server is running&#8230; If only I dared&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s almost 4 years now since I installed my server and I decided it was time for some new (bigger) harddisks. I wrote about my server earlier in my blog, but here is a short summary about its current state before the upgrade: processor AMD Athlon (Barton) 1.3 GHz(?) mainboard Zenith &#8230; memory 512 MByte [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"enabled":false},"version":2}},"categories":[22],"tags":[],"class_list":["post-1253","post","type-post","status-publish","format-standard","hentry","category-computers_en","entry"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p48grL-kd","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.sciencetronics.com\/greenphotons\/index.php?rest_route=\/wp\/v2\/posts\/1253","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sciencetronics.com\/greenphotons\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sciencetronics.com\/greenphotons\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sciencetronics.com\/greenphotons\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sciencetronics.com\/greenphotons\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1253"}],"version-history":[{"count":7,"href":"https:\/\/www.sciencetronics.com\/greenphotons\/index.php?rest_route=\/wp\/v2\/posts\/1253\/revisions"}],"predecessor-version":[{"id":2445,"href":"https:\/\/www.sciencetronics.com\/greenphotons\/index.php?rest_route=\/wp\/v2\/posts\/1253\/revisions\/2445"}],"wp:attachment":[{"href":"https:\/\/www.sciencetronics.com\/greenphotons\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1253"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sciencetronics.com\/greenphotons\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1253"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sciencetronics.com\/greenphotons\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1253"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}