User Tools

Site Tools


nas:build_a_linux_nas:prepare_the_raid_disks

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
nas:build_a_linux_nas:prepare_the_raid_disks [2021/09/25 15:49] – created peternas:build_a_linux_nas:prepare_the_raid_disks [2021/10/12 20:36] (current) – [Test the Disks] peter
Line 1: Line 1:
 ====== NAS - Build a Linux NAS - Prepare the RAID Disks ====== ====== NAS - Build a Linux NAS - Prepare the RAID Disks ======
 +
 +===== Determine the available disks =====
 +
 +<code bash>
 +lsblk
 +</code>
 +
 +returns:
 +
 +<code bash>
 +NAME                   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
 +sda                      8:0    0 232.9G  0 disk 
 +├─sda1                   8:   0  1007K  0 part 
 +├─sda2                   8:   0   512M  0 part /boot/efi
 +├─sda3                 253:28       8G  0 part [SWAP]
 +├─sda4                 253:29      58G  0 part /
 +sdb                      8:32    14.6T  0 disk 
 +sdc                      8:48    14.6T  0 disk 
 +sdd                      8:64    14.6T  0 disk 
 +</code>
 +
 +<WRAP info>
 +**NOTE:**  This shows:
 +
 +  * **sda**:  The boot disk of the host OS. Leave this alone!
 +  * **sdb**:  A free disk.
 +  * **sdc**:  A free disk.
 +  * **sdd**:  A free disk.
 +
 +The free disks do not have any partitions yet and will be included into a RAID.
 +
 +</WRAP>
 +
 +----
 +
 +===== Obtain the Serial Numbers of the Disks =====
 +
 +<code bash>
 +hdparm -i /dev/sdd | grep SerialNo
 +</code>
 +
 +returns:
 +
 +<code bash>
 +Model=ST16000NM001G-2KK103, FwRev=SB30, SerialNo=WL2091XL
 +</code>
 +
 +<WRAP important>
 +**IMPORTANT:**  Obtain the serial number for every disk; and keep a record of this somewhere safe.
 +</WRAP>
 +
 +
 +<WRAP info>
 +**NOTE:**  Many disks also have the serial number written on the disk.
 +
 +The reason for recording the serial number of each disk is that in the case of a disk failure, there needs to be a way to determine which disk has failed and needs to be replaced.
 +
 +  * The enclosure being used for the disks may not support hot-swapping and there may not be a separate light for each disk, so there may not be a straight-forward way to determine which specific disk has failed.
 +
 +</WRAP>
 +
 +----
 +
 +===== Test the Disks =====
 +
 +All hard drives, both new and old, should be tested before adding them to an array.
 +
 +See S.M.A.R.T. to view smart data and run smart tests.
 +
 +Do a short smart test:
 +
 +<code bash>
 +smartctl -t short /dev/sdb [-d sat]
 +</code>
 +
 +Do a long smart test:
 +
 +<code bash>
 +smartctl -t long /dev/sdb [-d sat]
 +</code>
 +
 +Check all smart attributes:
 +
 +<code bash>
 +smartctl -a /dev/sdb [-d sat]
 +</code>
 +
 +Do a random readwrite test:
 +
 +<code bash>
 +sudo fio --filename="/dev/sdb --name=randwrite --ioengine=sync --iodepth=1 --rw=randrw --rwmixread=50 --rwmixwrite=50 --bs=4k --direct=0 --numjobs=8 --size=300G --runtime=7200 --group_reporting
 +</code>
 +
 +<WRAP info>
 +**NOTE:** The smartmontools package might be needed to be installed:
 +
 +<code bash>
 +sudo apt install smartmontools
 +</code>
 +
 +  * **-d sat**:  Sata disks.
 +
 +See:  https://www.smartmontools.org/
 +
 +</WRAP>
 +
 +----
 +
 +===== Initialize the free disks =====
 +
 +<code bash>
 +sudo fdisk /dev/sdb
 +</code>
 +
 +returns:
 +
 +<code bash>
 +Welcome to fdisk (util-linux 2.36.1).
 +Changes will remain in memory only, until you decide to write them.
 +Be careful before using the write command.
 +
 +Device does not contain a recognized partition table.
 +The size of this disk is 14.6 TiB (16000900661248 bytes). DOS partition table format cannot be used on drives for volumes larger than 2199023255040 bytes for 512-byte sectors. Use GUID partition table format (GPT).
 +
 +Created a new DOS disklabel with disk identifier 0xc778227a.
 +
 +Command (m for help): 
 +</code>
 +
 +----
 +
 +==== Create a GPT Partition ====
 +
 +<code bash>
 +Command (m for help): g
 +</code>
 +
 +returns:
 +
 +<code bash>
 +Created a new GPT disklabel (GUID: 6D811672-A5FE-BA4F-8F79-D17E0285C5E1).
 +</code>
 +
 +<WRAP info>
 +**NOTE:**  GPT (GUID Partition Table) is much better than MBR (Master Boot Record) partitions:
 +
 +  * GPT supports much larger disks.
 +  * GPT allows for a nearly unlimited number of partitions. 
 +  * GPT also stores cyclic redundancy check (CRC) values to check that its data is intact.
 +    * If the data is corrupted, GPT can notice the problem and attempt to recover the damaged data from another location on the disk.
 +
 +</WRAP>
 +
 +----
 +
 +==== Create a Linux RAID Partition ====
 +
 +<code bash>
 +Command (m for help): n
 +Partition number (1-128, default 1):     
 +First sector (2048-31251759070, default 2048): 
 +Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-31251759070, default 31251759070): 
 +</code>
 +
 +returns:
 +
 +<code bash>
 +Created a new partition 1 of type 'Linux filesystem' and of size 14.6 TiB.
 +</code>
 +
 +<WRAP info>
 +**NOTE:** Just taking the default values uses the entire disk.
 +</WRAP>
 +
 +----
 +
 +==== Print the Partition ====
 +
 +<code bash>
 +Command (m for help): p
 +</code>
 +
 +returns:
 +
 +<code bash>
 +Disk /dev/sdb: 14.55 TiB, 16000900661248 bytes, 31251759104 sectors
 +Disk model: ST16000NM001G-2K
 +Units: sectors of 1 * 512 = 512 bytes
 +Sector size (logical/physical): 512 bytes / 4096 bytes
 +I/O size (minimum/optimal): 4096 bytes / 4096 bytes
 +Disklabel type: gpt
 +Disk identifier: 6D811672-A5FE-BA4F-8F79-D17E0285C5E1
 +
 +Device     Start         End     Sectors  Size Type
 +/dev/sdb1   2048 31251759070 31251757023 14.6T Linux filesystem
 +</code>
 +
 +<WRAP info>
 +**NOTE:** This shows that there is a single partition, /dev/sdb1, using the entire disk.
 +</WRAP>
 +
 +----
 +
 +==== Change the Partition Type ====
 +
 +<code bash>
 +Command (m for help): t
 +Selected partition 1
 +Partition type or alias (type L to list all): 29
 +</code>
 +
 +returns:
 +
 +<code bash>
 +Changed type of partition 'Linux filesystem' to 'Linux RAID'.
 +</code>
 +
 +<WRAP info>
 +**NOTE:** The type is changed to Linux RAID, which is type 29.
 +
 +
 +</WRAP>
 +
 +
 +----
 +
 +==== Print the Partition again ====
 +
 +<code bash>
 +Command (m for help): p
 +</code>
 +
 +returns:
 +
 +<code bash>
 +Disk /dev/sdd: 14.55 TiB, 16000900661248 bytes, 31251759104 sectors
 +Disk model: ST16000NM001G-2K
 +Units: sectors of 1 * 512 = 512 bytes
 +Sector size (logical/physical): 512 bytes / 4096 bytes
 +I/O size (minimum/optimal): 4096 bytes / 4096 bytes
 +Disklabel type: gpt
 +Disk identifier: EAA2F832-9810-AA45-9DDB-8ED531C20139
 +
 +Device     Start         End     Sectors  Size Type
 +/dev/sdd1   2048 31251759070 31251757023 14.6T Linux RAID
 +</code>
 +
 +<WRAP info>
 +**NOTE:** This shows the Type has been changed to **Linux RAID**.
 +</WRAP>
 +
 +----
 +
 +==== Write the Partition Table ====
 +
 +<code bash>
 +Command (m for help): w
 +</code>
 +
 +returns:
 +
 +<code bash>
 +The partition table has been altered.
 +Calling ioctl() to re-read partition table.
 +Syncing disks.</code>
 +
 +----
 +
 +===== Partition other Disks =====
 +
 +<WRAP info>
 +**NOTE:** Repeat the above instructions for the other free disks.
 +</WRAP>
 +
 +
 +----
 +===== Check the available disks again =====
 +
 +<code bash>
 +lsblk
 +</code>
 +
 +returns:
 +
 +<code bash>
 +NAME                   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
 +sda                      8:0    0 232.9G  0 disk 
 +├─sda1                   8:   0  1007K  0 part 
 +├─sda2                   8:   0   512M  0 part /boot/efi
 +├─sda3                 253:28       8G  0 part [SWAP]
 +├─sda4                 253:29      58G  0 part /
 +sdb                      8:32    14.6T  0 disk 
 +├─sdb1                   8:33    14.6T  0 part 
 +sdc                      8:48    14.6T  0 disk 
 +├─sdc1                   8:49    14.6T  0 part 
 +sdd                      8:64    14.6T  0 disk 
 +├─sdd1                   8:65    14.6T  0 part 
 +</code>
 +
 +<WRAP info>
 +**NOTE:**  This shows the original free disks all now have partitions.
 +
 +  * At this point, these disks can be tied together as a RAID array.
 +</WRAP>
 +
  
nas/build_a_linux_nas/prepare_the_raid_disks.1632584980.txt.gz · Last modified: 2021/09/25 15:49 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki