XOS>> P5>> 返回
项目作者: VfcD

项目描述 :
Arch Linux encrypted 2 HDD installation
高级语言:
项目地址: git://github.com/VfcD/P5.git
创建时间: 2017-10-04T12:31:46Z
项目社区:https://github.com/VfcD/P5

开源协议:MIT License

下载


Arch Linux encrypted 2 HDD installation and UEFI Boot

scenario:

  1. sda = root 100G & swap 8G & (left space) data
  2. sda1 = UEFI boot
  3. sda2 = luks lvm
  4. - main-root
  5. - main-swap
  6. - main-data
  7. sdb = home (whole disk)
  8. sdb1 = luks lvm
  9. - main-home

understanding lvm diagram: https://askubuntu.com/questions/219881/how-can-i-create-one-logical-volume-over-two-disks-using-lvm

in praxis we used to connect to installation pc via ssh. for this just do:

check ip with:

  1. ip addr OR ifconfig
  2. passwd
  3. systemctl start sshd.service

now change to remote pc:

  1. ssh root@IPADDR
  1. prepare partition table as mentioned for sda:

    1. gdisk /dev/sda
  2. prepare partition table as mentioned for sdb:

    1. gdisk /dev/sdb
  3. make file systems for both disks:

    1. mkfs.fat -F 32 -n EFIBOOT /dev/sda1
    2. cryptsetup -c aes-xts-plain64 -y -s 512 luksFormat /dev/sda2
    3. cryptsetup -c aes-xts-plain64 -y -s 512 luksFormat /dev/sdb1
  4. create LVM on both disks:

    1. cryptsetup luksOpen /dev/sda2 lvm
    2. pvcreate /dev/mapper/lvm
    3. vgcreate main /dev/mapper/lvm
    4. lvcreate -L 100GB -n root main
    5. lvcreate -L 8GB -n swap main
    6. lvcreate -l 100%FREE -n data main
    7. cryptsetup luksOpen /dev/sdb1 lvmB
    8. pvcreate /dev/mapper/lvmB
    9. vgextend main /dev/mapper/lvmB
    10. lvcreate -l 100%FREE -n home main

    make filesystems for all partitions:

    1. mkfs.ext4 -L root -O \^64bit /dev/mapper/main-root
    2. mkfs.ext4 -L data -O \^64bit /dev/mapper/main-data
    3. mkswap -L swap /dev/mapper/main-swap
    4. mkfs.ext4 -L home -O \^64bit /dev/mapper/main-home
  5. mount partitions in folders:

    1. mount /dev/mapper/main-root /mnt
    2. mkdir /mnt/home
    3. mount /dev/mapper/main-home /mnt/home
    4. mkdir /mnt/boot
    5. mount /dev/sda1 /mnt/boot
    6. mkdir /mnt/data
    7. mount /dev/mapper/main-data /mnt/data
    8. swapon /dev/mapper/main-swap
  6. install base system

    prepare mirror list:

    1. cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak
    2. grep -E -A 1 ".*Germany.*$" /etc/pacman.d/mirrorlist.bak | sed '/--/d' > /etc/pacman.d/mirrorlist

    base packets:

    1. pacstrap /mnt base base-devel intel-ucode wpa_supplicant grub efibootmgr dosfstools gptfdisk

    create fstab with UUID and labels (ULp)

    1. genfstab -ULp /mnt > /mnt/etc/fstab
  7. modify fstab for SSD drive (not home drive because of no SSD drive)

    1. LABEL=root / ext4 rw,defaults,noatime,discard 0 1
    2. LABEL=data /data ext4 rw,defaults,noatime,discard 0 2
    3. LABEL=swap none swap defaults,noatime,discard 0 0
  8. change root

    1. arch-chroot /mnt
  9. configure system

    1. echo ArchComputer > /etc/hostname
  1. write following lines into **/etc/locale.conf**:
  2. 1-liner:
  3. echo LANG=de_DE.UTF-8 > /etc/locale.conf && echo LC_COLLATE=C >> /etc/locale.conf && echo LANGUAGE=de_DE >> /etc/locale.conf
  4. OR
  5. echo LANG=de_DE.UTF-8 > /etc/locale.conf
  6. echo LC_COLLATE=C >> /etc/locale.conf
  7. echo LANGUAGE=de_DE >> /etc/locale.conf
  8. write following lines into **/etc/vconsole.conf**:
  9. echo KEYMAP=de-latin1 > /etc/vconsole.conf
  10. echo FONT=lat9w-16 >> /etc/vconsole.conf
  11. link to local time zone:
  12. ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime
  13. uncomment following lines in **/etc/locale.gen**:
  14. nano /etc/locale.gen
  15. #de_DE.UTF-8 UTF-8
  16. #de_DE ISO-8859-1
  17. #de_DE@euro ISO-8859-15
  18. generate locals with:
  19. locale-gen
  1. configure GRUB

    1. grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=arch_grub --recheck --debug
    2. mkdir -p /boot/grub/locale
    3. cp /usr/share/locale/en\@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo

    check UUID from encrypted partition sda2:

    1. blkid
    2. open **/etc/default/grub** and comment existing **GRUB_CMDLINE_LINUX=""** and replace with:
    3. nano /etc/default/grub
    4. GRUB_CMDLINE_LINUX="lang=de locale=de_DE.UTF-8 cryptdevice=UUID="de2c8075-fa4d-4e08-821e-bf16051a5623":main root=/dev/mapper/main-root"

    create grub config file (don’t care about warnings)

    1. grub-mkconfig -o /boot/grub/grub.cfg
  2. edit /etc/mkinitcpio.conf:

    1. nano /etc/mkinitcpio.conf
    2. MODULES="ext4"
    3. comment existing HOOKS and paste following line:
    4. HOOKS="base udev autodetect modconf block keyboard keymap encrypt lvm2 filesystems fsck shutdown"
  1. prepare /etc/crypttab for extern home sdb1:

    1. make folder to store keyfile:
    2. mkdir root/crypto

    create keyfile:

    1. dd if=/dev/urandom of=/root/crypto/home.key bs=1k count=2

    add key do channel for open:

    1. cryptsetup luksAddKey /dev/sdb1 /root/crypto/home.key

    nano /etc/crypttab :

    1. home UUID=67dc0b7c-f72b-404d-a177-b9e539f85b43 /root/crypto/home.key
  2. create kernel-image

    1. mkinitcpio -p linux
  3. enable network DHCP:

    1. systemctl enable dhcpcd.service
  1. leave chroot, umount and reboot

    1. passwd
    2. exit
    3. umount -R /mnt
    4. reboot