<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
      <title>μrsi</title>
      <generator uri="https://hugo.spf13.com">Hugo</generator>
    <link>https://www.averagebear.ca/categories/linux/</link>
    <language>en-us</language>
    <author>Jeff Wilson</author>
    <copyright>2015 Jeff Wilson</copyright>
    <updated>Sun, 21 Jun 2015 12:42:09 EDT</updated>
    
    
    <item>
      <title>Server Surgery</title>
      <link>https://www.averagebear.ca/2015/06/server-surgery/</link>
      <pubDate>Sun, 21 Jun 2015 12:42:09 EDT</pubDate>
      <author>Jeff Wilson</author>
      <guid>https://www.averagebear.ca/2015/06/server-surgery/</guid>
      <description>

&lt;p&gt;So, gremlins. I guess that&amp;rsquo;s what happens with some hard disks. One of them turned a peaceful weekend into a mad scramble for backup space and &lt;a href=&#34;https://raid.wiki.kernel.org/index.php/RAID_setup&#34;&gt;mdadm&lt;/a&gt; tips. Call it a fire drill without the staircases. I guess the server means to say I&amp;rsquo;ve been taking it for granted.&lt;/p&gt;

&lt;h1 id=&#34;some-lessons-learned:ea1f1f0303fede3107da10f106d4b975&#34;&gt;Some lessons learned:&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;You &lt;em&gt;can&lt;/em&gt; use drives with different geometry if you have to.&lt;/li&gt;
&lt;li&gt;An IMPI display would have been &lt;em&gt;very&lt;/em&gt; useful for this first-timer.&lt;/li&gt;
&lt;li&gt;When rebuilding a software RAID-1 pair, don&amp;rsquo;t forget you need to reinstall grub!&lt;/li&gt;
&lt;/ol&gt;

&lt;h1 id=&#34;steps-used:ea1f1f0303fede3107da10f106d4b975&#34;&gt;Steps used&lt;/h1&gt;

&lt;p&gt;Confirm the system still sees the new drive as &lt;em&gt;/dev/sda&lt;/em&gt;; that&amp;rsquo;s the disk that got retired from &lt;em&gt;mdadm&lt;/em&gt; early on Saturday, and &lt;em&gt;/dev/sdb&lt;/em&gt; is the working unit.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;root@rescue:~# parted -l
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The drive /dev/sda should have no partition table. More importantly /dev/sdb should have stuff!&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;[snip]
Disk /dev/sdb: 2000GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start   End     Size    Type     File system  Flags
 1      2097kB  21.5GB  21.5GB  primary  ext3         boot, raid
 2      21.5GB  1000GB  978GB   primary               raid
 3      1000GB  1000GB  538MB   primary
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Confirmed: &lt;em&gt;/dev/sdb&lt;/em&gt; is the good drive. Copy the partition tables from /dev/sdb to /dev/sda:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;root@rescue:~# sfdisk -d /dev/sdb | sfdisk /dev/sda
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Add the new partitions back into the raid array:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;root@rescue:~# mdadm /dev/md1 --manage --add /dev/sda1
root@rescue:~# mdadm /dev/md2 --manage --add /dev/sda2
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Keep tabs on the progress (this is showing the rebuild of /dev/sdb I did after /dev/sda completed successfully):&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;root@rescue:~# cat /proc/mdstat
Personalities : [linear] [raid0] [raid1] [raid10] [raid6] [raid5] [raid4] [multipath] [faulty]
md1 : active raid1 sdb1[1] sda1[0]
      20971456 blocks [2/2] [UU]

md2 : active raid1 sdb2[2] sda2[0]
      955260864 blocks [2/1] [U_]
      [================&amp;gt;....]  recovery = 84.6% (808489856/955260864) finish=17.4min speed=140544K/sec

unused devices: &amp;lt;none&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Redefine the swap areas.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;root@rescue:~# mkswap /dev/sda3
root@rescue:~# mkswap /dev/sdb3
root@rescue:~# swapon -a
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The first time around I rebooted here. That wasn&amp;rsquo;t enough. I had to setup grub, which is described &lt;a href=&#34;https://goo.gl/QkvrVg&#34;&gt;here &amp;hellip; in French&lt;/a&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;root@rescue:~# mount /dev/md1 /mnt
root@rescue:~# chroot /mnt
root@rescue:~# grub-install --recheck /dev/sda
root@rescue:~# exit
root@rescue:~# umount /mnt
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Reboot to the hard drive, and we are done.&lt;/p&gt;

&lt;p&gt;So now we are on a new pair of drives, and for good measure I am also the proud (temporary) owner of a failover server too. Now I just need to decide which systems I want to keep running. Live backups are too good to pass up. And I might want it when I decide to tackle configuring my new terabyte of space.&lt;/p&gt;
</description>
    </item>
    
    
  </channel>
</rss>