{"id":1697,"date":"2013-04-28T13:39:52","date_gmt":"2013-04-28T12:39:52","guid":{"rendered":"http:\/\/kudzia.eu\/b\/?p=1697"},"modified":"2018-04-11T15:10:07","modified_gmt":"2018-04-11T14:10:07","slug":"installation-of-debian-wheezy-on-mdadm-raid1-gpt","status":"publish","type":"post","link":"https:\/\/kudzia.eu\/b\/2013\/04\/installation-of-debian-wheezy-on-mdadm-raid1-gpt\/","title":{"rendered":"installation of debian wheezy on mdadm raid1 + gpt"},"content":{"rendered":"<p><\/a>in branch offices i tend to install two identical pcs running linux and working in active &#8211; hot-spare setup. things evolved over time &#8211; one location has both routers running under vmware esxi on two different hosts, another &#8211; hardware raid, other &#8211; desktop-class pcs with single hard drives. hardware raids are good as long as there&#8217;s plenty of similar devices around and swapping the raid controller in case it dies is an option. mdadm [software] raid1 might be a <a href=\"http:\/\/www.cyberciti.biz\/tips\/raid-hardware-vs-raid-software.html\">reasonable solution<\/a> for me during the next round of hardware upgrades. below some notes from testing it under vmware and on a physical machine.<br \/>\n<!--more--><br \/>\ni&#8217;m running the setup using release candidate of debian wheezy with two separate hard drives. in the installer&#8217;s boot menu i select <i>Advanced options > Expert install<\/i>, after choice of language, keyboard layout, network parameters and login credentials and disk detection phase i reach the interesting part &#8211; <i>Partition disks > Manual<\/i>. <\/p>\n<p>there i repeat all the steps for first and second drive &#8211; sda and sdb.<\/p>\n<ul>\n<li>create gpt partition table\n<p><a href=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-0.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-0.png\" alt=\"mdraid_gpt-di-0\" width=\"795\" height=\"552\" class=\"alignnone size-full wp-image-1758\" srcset=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-0.png 795w, https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-0-300x208.png 300w\" sizes=\"auto, (max-width: 795px) 100vw, 795px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-1.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-1.png\" alt=\"mdraid_gpt-di-1\" width=\"795\" height=\"552\" class=\"alignnone size-full wp-image-1759\" srcset=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-1.png 795w, https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-1-300x208.png 300w\" sizes=\"auto, (max-width: 795px) 100vw, 795px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-2.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-2.png\" alt=\"mdraid_gpt-di-2\" width=\"795\" height=\"552\" class=\"alignnone size-full wp-image-1704\" srcset=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-2.png 795w, https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-2-300x208.png 300w\" sizes=\"auto, (max-width: 795px) 100vw, 795px\" \/><\/a><\/p>\n<\/li>\n<li>create partitions:\n<ul>\n<li>1MB partitioni marked <i>Use as: Reserved BIOS boot area\/do not use<\/i><\/li>\n<li>2018 addition: 100MB EFI System Partition<\/li>\n<li>as many partitions as needed for the OS. all of them marked <i>Use as: physical volume for RAID<\/i><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>final result of the partitioning physical drives:<\/p>\n<p>2018 version:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/partitions.png\" alt=\"\" width=\"366\" height=\"175\" class=\"alignnone size-full wp-image-2863\" srcset=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/partitions.png 366w, https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/partitions-300x143.png 300w\" sizes=\"auto, (max-width: 366px) 100vw, 366px\" \/><\/p>\n<p>earlier version:<\/p>\n<p><a href=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-3.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-3.png\" alt=\"mdraid_gpt-di-3\" width=\"795\" height=\"552\" class=\"alignnone size-full wp-image-1726\" srcset=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-3.png 795w, https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-3-300x208.png 300w\" sizes=\"auto, (max-width: 795px) 100vw, 795px\" \/><\/a><\/p>\n<p>Using <i>Configure software RAID<\/i> i&#8217;m creating raid 1 devices on pairs of partitions earlier marked as <i>physical volume for RAID<\/i>.<\/p>\n<p><a href=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-4.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-4.png\" alt=\"mdraid_gpt-di-4\" width=\"795\" height=\"552\" class=\"alignnone size-full wp-image-1708\" srcset=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-4.png 795w, https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-4-300x208.png 300w\" sizes=\"auto, (max-width: 795px) 100vw, 795px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-5.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-5.png\" alt=\"mdraid_gpt-di-5\" width=\"795\" height=\"552\" class=\"alignnone size-full wp-image-1709\" srcset=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-5.png 795w, https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-5-300x208.png 300w\" sizes=\"auto, (max-width: 795px) 100vw, 795px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-6.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-6.png\" alt=\"mdraid_gpt-di-6\" width=\"795\" height=\"552\" class=\"alignnone size-full wp-image-1710\" srcset=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-6.png 795w, https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-6-300x208.png 300w\" sizes=\"auto, (max-width: 795px) 100vw, 795px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-7.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-7.png\" alt=\"mdraid_gpt-di-7\" width=\"795\" height=\"552\" class=\"alignnone size-full wp-image-1711\" srcset=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-7.png 795w, https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-7-300x208.png 300w\" sizes=\"auto, (max-width: 795px) 100vw, 795px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-8.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-8.png\" alt=\"mdraid_gpt-di-8\" width=\"795\" height=\"552\" class=\"alignnone size-full wp-image-1712\" srcset=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-8.png 795w, https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-8-300x208.png 300w\" sizes=\"auto, (max-width: 795px) 100vw, 795px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-9.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-9.png\" alt=\"mdraid_gpt-di-9\" width=\"795\" height=\"552\" class=\"alignnone size-full wp-image-1728\" srcset=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-9.png 795w, https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-9-300x208.png 300w\" sizes=\"auto, (max-width: 795px) 100vw, 795px\" \/><\/p>\n<p>after repeating that for all raid partitions:<\/p>\n<p><a href=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-b.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-b.png\" alt=\"mdraid_gpt-di-b\" width=\"795\" height=\"552\" class=\"alignnone size-full wp-image-1730\" srcset=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-b.png 795w, https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-b-300x208.png 300w\" sizes=\"auto, (max-width: 795px) 100vw, 795px\" \/><\/a><\/p>\n<p>now file systems and mount points can be defined for newly created mdX devices spanning across both drives. in my case it&#8217;ll be just root and swap:<\/p>\n<p><a href=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-c.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-c.png\" alt=\"mdraid_gpt-di-c\" width=\"795\" height=\"552\" class=\"alignnone size-full wp-image-1732\" srcset=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-c.png 795w, https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-c-300x208.png 300w\" sizes=\"auto, (max-width: 795px) 100vw, 795px\" \/><\/a><\/p>\n<p>after <i>Finish partitioning and write changes to disk<\/i> there&#8217;ll be set of usual questions about packages and mirrors. when asked where to place the GRUB boot-loader i leave the default option &#8211; <i>Install the GRUB boot loader to the master boot record: Yes<\/i>:<\/p>\n<p><a href=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-e.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-e.png\" alt=\"mdraid_gpt-di-e\" width=\"795\" height=\"552\" class=\"alignnone size-full wp-image-1720\" srcset=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-e.png 795w, https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-e-300x208.png 300w\" sizes=\"auto, (max-width: 795px) 100vw, 795px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-f.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-f.png\" alt=\"mdraid_gpt-di-f\" width=\"795\" height=\"552\" class=\"alignnone size-full wp-image-1734\" srcset=\"https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-f.png 795w, https:\/\/kudzia.eu\/b\/wp-content\/uploads\/2013\/04\/mdraid_gpt-di-f-300x208.png 300w\" sizes=\"auto, (max-width: 795px) 100vw, 795px\" \/><\/a><\/p>\n<p>after the reboot \/ and swap [in my case] already is mounted from the RAID1 spanning both physical drives but i have to install manually grub on the 2nd drive so the system can boot even if the first disk is physically removed:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nroot@debian:~# grub-install \/dev\/sdb\r\nInstallation finished. No error reported.\r\n<\/pre>\n<p>and voil\u00e0 &#8211; the system will boot up even if the first drive gets physically removed.<\/p>\n<p>status of all raids can be checked by:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nroot@debian:~# cat \/proc\/mdstat\r\nPersonalities : &#x5B;raid1]\r\nmd1 : active (auto-read-only) raid1 sda3&#x5B;0] sdb3&#x5B;1]\r\n      1260480 blocks super 1.2 &#x5B;2\/2] &#x5B;UU]\r\n\r\nmd0 : active raid1 sdb2&#x5B;1]\r\n      2927552 blocks super 1.2 &#x5B;2\/1] &#x5B;_U]\r\n\r\nunused devices: &lt;none&gt;\r\n<\/pre>\n<p>status of single mdX device:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nroot@debian:~# mdadm --detail \/dev\/md0\r\n\/dev\/md0:\r\n        Version : 1.2\r\n  Creation Time : Sun Apr 28 12:03:26 2013\r\n     Raid Level : raid1\r\n     Array Size : 2927552 (2.79 GiB 3.00 GB)\r\n  Used Dev Size : 2927552 (2.79 GiB 3.00 GB)\r\n   Raid Devices : 2\r\n  Total Devices : 1\r\n    Persistence : Superblock is persistent\r\n\r\n    Update Time : Sun Apr 28 12:34:09 2013\r\n          State : clean, degraded\r\n Active Devices : 1\r\nWorking Devices : 1\r\n Failed Devices : 0\r\n  Spare Devices : 0\r\n\r\n           Name : debian:0  (local to host debian)\r\n           UUID : 9ebb319c:b0463e21:4d852665:f6527d33\r\n         Events : 75\r\n\r\n    Number   Major   Minor   RaidDevice State\r\n       0       0        0        0      removed\r\n       1       8       18        1      active sync   \/dev\/sdb2\r\n<\/pre>\n<p>to re-add disk removed earlier for a while:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nroot@debian:~# mdadm -a \/dev\/md0 \/dev\/sda2\r\nmdadm: added \/dev\/sda2\r\nroot@debian:~# mdadm -a \/dev\/md1 \/dev\/sda3\r\nmdadm: added \/dev\/sda3\r\n<\/pre>\n<p>to force a consistency check on a single mdX device:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\necho check &gt; \/sys\/block\/md0\/md\/sync_action\r\n<\/pre>\n<p>to clone partition setup from one disk to another [for instance when new blank drive was installed replacing failed disk] i use <a href=\"http:\/\/serverfault.com\/questions\/320833\/parted-equivalent-of-sfdisk-d\">gdisk<\/a>:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n#sgdisk is part of debians gdisk package. it's available for squeeze via backports\r\n#partition data from sda will be copied to sdb\r\nsgdisk -R=\/dev\/sdb \/dev\/sda\r\n<\/pre>\n<p>after that repeat for all mdX:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nmdadm -a \/dev\/md0 \/dev\/sdb2\r\n<\/pre>\n<p>and after a while of syncing it&#8217;s done.<\/p>\n<p>side notes:<\/p>\n<ul>\n<li>RAID1 is not a replacement for scheduled and monitored backups &#8211; it&#8217;ll not save any information in case of accidental delete<\/li>\n<li>BIOS of the computer has to be configured with both drives added to the &#8216;boot order&#8217; so the OS can be loaded even if the first disk is gone<\/li>\n<li>disk swapping has to be done with the power off. i&#8217;ve tried to simulate hdd failure by disconnecting a running drive while the system was running &#8211; all my attempts ended with the OS crash.<\/li>\n<li><i>grub-install \/dev\/sdb<\/i> should be repeated whenever there&#8217;s update of grub \/ kernel<\/li>\n<li>to force re-read of the partition table after modifications i used <i>partprobe \/dev\/sdb;\/sbin\/blockdev &#8211;rereadpt \/dev\/sdb<\/i><\/li>\n<\/ul>\n<p>following resources were helpful:<\/p>\n<ul>\n<li>https:\/\/raid.wiki.kernel.org\/index.php\/Linux_Raid<\/li>\n<li>http:\/\/kb.haeringer.org\/configuring-a-raid1-with-mdadm-on-debian-squeeze\/<\/li>\n<li>http:\/\/www.ducea.com\/2009\/03\/08\/mdadm-cheat-sheet\/<\/li>\n<\/ul>\n<p><b>2018 notes \/ debian stretch<\/b><\/p>\n<ul>\n<li>besides the 1MB Reserved BIOS boot area i had to add EFI System Partition on both boot disks, each having 100MB<\/li>\n<li>to make the system bootable from both drives i&#8217;ve cloned content of that partition between the disks: <i>dd if=\/dev\/sdX2 of=\/dev\/sdY2 bs=1M<\/i>, <a href=\"https:\/\/askubuntu.com\/a\/660038\">looks like<\/a> this cloning does not have to be repeated too often<\/li>\n","protected":false},"excerpt":{"rendered":"<p>in branch offices i tend to install two identical pcs running linux and working in active &#8211; hot-spare setup. things evolved over time &#8211; one location has both routers running under vmware esxi on two different hosts, another &#8211; hardware raid, other &#8211; desktop-class pcs with single hard drives. hardware raids are good as long [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[],"class_list":["post-1697","post","type-post","status-publish","format-standard","hentry","category-tech"],"_links":{"self":[{"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/posts\/1697","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/comments?post=1697"}],"version-history":[{"count":45,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/posts\/1697\/revisions"}],"predecessor-version":[{"id":2865,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/posts\/1697\/revisions\/2865"}],"wp:attachment":[{"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/media?parent=1697"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/categories?post=1697"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kudzia.eu\/b\/wp-json\/wp\/v2\/tags?post=1697"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}