{{tag>[archlinux gpt lvm raid1]}} =====Archlinux - Install using GPT, LVM and RAID1===== ====Boot and remove old partitions, LVM and RAID config==== * Boot from ISO * Remove previous LVM and RAID config. * Unmount used filesystems (and swap). * Deactivate volume group:vgchange -a n rootvg * Remove volume group: vgremove rootvg * Remove previous RAID array: mdadm --zero-superblock /dev/sda mdadm --zero-superblock /dev/sdb ====Configure network==== * Configure static networking. Edit /etc/netctl/ethernet-wired, * Start network:netctl start ethernet-static * Edit mirrorlist /etc/pacman.d/mirrorlist. * Update package manager database: pacman -Syy ====Create partitions==== When replacing a failed disk of a RAID, the new disk has to be exactly the same size as the failed disk or bigger — otherwise the array recreation process will not work. Even hard drives of the same manufacturer and model can have small size differences. By leaving a little space at the end of the disk unallocated one can compensate for the size differences between drives, which makes choosing a replacement drive model easier. Therefore, it is good practice to leave about 100 MB of unallocated space at the end of the disk. On a BIOS/GPT configuration a BIOS boot partition is required. GRUB embeds its core.img into this partition. * Install gptfdisk:pacman -S gptfdisk * Create a mebibyte {+1MiB with gdisk) BIOS boot partition on both disks with no file system and type ef02. gdisk /dev/sda o #create empty new GUID partition table. n #add new partition. 1 #partition number 1. 2048 #default first sector. +1MiB #BIOS boot partition size. ef02 #partition type. w #write changes and exit. * Create a partition for software RAID on both disks, leave approx 100MB at end of disk: gdisk /dev/sda n #add new partition. 2 #partition number 2. 4096 #default next sector. +59GB #Partition size. fd00 #partition type. w #write changes and exit. ====Create RAID1 array==== * Build two device array: mdadm --create --verbose --level=1 --metadata=1.2 --raid-devices=2 /dev/md0 /dev/sda2 /dev/sdb21 * Monitor status: cat /proc/mdstat * Copy array config to config file:mdadm --detail --scan >> /etc/mdadm.conf * Assemble the array: mdadm --assemble --scan ====Partition, create VG, LVs and format the filesystem device==== * Create LVM partition on RAID1 devicegdisk /dev/md0 o #create empty new GUID partition table. n #add new partition. 1 #partition number 1. 2048 #default first sector. #LVM partition size. 8e00 #LVM partition type. w #write changes and exit. * Install lvm2: pacman -S lvm2 * Create LVM physical volume: lvmdiskscan pvcreate /dev/md0p1 pvdisplay * Create volume group:vgcreate vg_raid /dev/md0p1 vgdisplay * Create logical volumes:lvcreate -L 8G vg_raid -n lv_root lvcreate -L 1G vg_raid -n lv_home lvcreate -L 4G vg_raid -n lv_var lvcreate -L 500M vg_raid -n lv_boot lvcreate -L 2G vg_raid -n lv_swap * Enable swap: mkswap /dev/mapper/vg_raid-lv_swap swapon /dev/mapper/vg_raid-lv_swap free * Format filesystems:mkfs.ext4 /dev/mapper/vg_raid-lv_root mkfs.ext4 /dev/mapper/vg_raid-lv_home mkfs.ext4 /dev/mapper/vg_raid-lv_var mkfs.ext4 /dev/mapper/vg_raid-lv_boot ====Mount partitions==== * Mount partitions: mount /dev/mapper/vg_raid-lv_root /mnt mkdir -p /mnt/{home,var,boot} mount /dev/mapper/vg_raid-lv_home /mnt/home mount /dev/mapper/vg_raid-lv_var /mnt/var mount /dev/mapper/vg_raid-lv_boot /mnt/boot ====Start installation==== * Install Archlinux! pacstrap /mnt base ====Configure the system==== * Create fstab: genfstab -p /mnt >> /mnt/etc/fstab * Copy RAID config: mdadm --detail --scan >> /mnt/etc/mdadm.conf * Copy network config: cp /etc/netctl/ethernet-static /mnt/etc/netctl * Chroot: arch-chroot /mnt * Configure network:netctl enable ethernet-static * Set hostname: echo computer_name > /etc/hostname * Link correct time zone: ln -sf /usr/share/zoneinfo/zone/subzone /etc/localtime * Uncomment locales in /etc/locale.gen, then run: locale-gen * Configure locale: echo LANG=your_locale > /etc/locale.conf * Edit /etc/mkinitcpio.conf: HOOKS="base udev autodetect block mdadm_udev lvm2 filesystems usbinput fsck" * Create a new initial RAM disk: mkinitcpio -p linux * Set root password:passwd root * Install additional tools: pacman -S gdisk ====Install boot loader===== Make sure you have chrooted into the installed system before installing grub. * Install grub: pacman -S grub grub-install --target=i386-pc --recheck --debug /dev/sda grub-install --target=i386-pc --recheck --debug /dev/sdb grub-mkconfig -o /boot/grub/grub.cfg ====Reboot==== * Exit chroot, unmount filesystem:exit umount -R /mnt * Reboot. ====Post install==== * Install OpenSSH:pacman -S openssh systemctl enable sshd.service systemctl start sshd.service useradd -m -G wheel -s /bin/bash benst passwd * Disable SSH root login, edit /etc/ssh/sshd_config and restart sshd. * Install additional packages:pacman -S dnsutils hdparm smartmontools htop * Enable TRIM for SSDs * LVM: set issue_discards option from 0 to 1 in /etc/lvm/lvm.conf. * Filesystem: Add 'discard' option in /etc/fstab. * Check SSD firmware voor Crucial M4: smartctl --all /dev/sda * Install and configure mail forwarder: pacman -S ssmtp # vi /etc/ssmtp/ssmtp.conf # chmod 640 /etc/ssmtp/ssmtp.conf # chown root:mail /etc/ssmtp/ssmtp.conf # gpasswd -a mail # # Test # echo test | mail -v -s "testing ssmtp setup" tousername@somedomain.com * RAID monitoring: # vi /etc/mdadm.conf #add email address mdadm --monitor --scan -1 --test # test email systemctl start mdmonitor.service * Install and configure NTP:pacman -S ntp vi /etc/ntp.conf systemctl enable ntpd.service systemctl start ntpd.service ntpq -p * Configure firewall. * Disable IPv6 if not needed.