Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Sources for walkthrough:
- ## https://wiki.archlinux.org/index.php/Dm-crypt/Encrypting_an_Entire_System#LVM_on_LUKS
- ## https://wiki.archlinux.org/index.php/Dm-crypt/Drive_preparation
- ## https://wiki.archlinux.org/index.php/Beginners%27_guide
- ## https://www.taricorp.net/2012/chainloading-truecrypt
- ### Assumptions:
- ### First, this installation is a LVM on LUKS scenario
- ### Second, this installation also assumes that there is an encrypted root,
- ### encrypted swap and unencrypted boot.
- ### Third, this installation assumes that Windows is already installed.
- # For non-US keyboard layout, see Arch wiki on that.
- # Test for internet connection:
- ping -c 3 www.google.ca
- # Should get 3 packets transmitted
- ##
- ## Partitioning:
- #Note: For later steps, substitute lvmname and vgname if preferred.
- # Use cfdisk (replace sdX with some drive letter, e.g. sda or sdb: )
- cfdisk /dev/sdX
- # Make the following partitions:
- # Note: If using MBR, make sdX1 the boot partition and sdX2 the encrypted lvm
- # Also, replace the X in sdX with something like sda or sdb, depending on
- # the drive letter
- # (If using GPT) sdX1 - size 2M - type ?
- # sdX2 - Size 200M, type linux
- # sdX3 - Remaining space, type lvm
- # Create the LUKS encrypted container (sdX3)
- cryptsetup luksFormat /dev/sdX3
- # Open container
- #Substitute luks if preferred:
- cryptsetup open --type luks /dev/sdX3 lvmname
- # Wipe the encrypted partition beforehand
- dd if=/dev/zero of=/dev/mapper/lvmname
- # Create physical volume and volume group
- pvcreate /dev/mapper/lvmname
- vgcreate vgname /dev/mapper/lvmname
- # Create partitions. Replace (size) with any particular size.
- lvcreate -C y -L (size) vgname -n swap
- lvcreate -l 100%FREE vgname -n root
- # Also, an extra sample command for creating partitions:
- # lvcreate -L (size) vgname -n tmp
- # Format and activate swap partition
- mkwap /dev/mapper/vgname-swap
- swapon /dev/mapper/vgname-swap
- # Format and mount root partition
- mkfs.ext4 /dev/mapper/vgname-root
- mount /dev/mapper/vgname-root /mnt
- # Format and mount boot partition
- mkfs.ext4 /dev/sdx2
- mkdir /mnt/boot
- mount /dev/sdx2 /mnt/boot
- ##
- ## Backup current (e.g. Windows) mbr:
- dd if=/dev/sda of=/mnt/boot/dc.bs count=1
- ##
- ## The following is almost the same as instructions in the Arch wiki.
- # Edit /etc/pacman.d/mirrorlist and select your mirror(s) by uncommenting them.
- nano /etc/pacman.d/mirrorlist
- # Install base system and base-devel (for AUR, ABS and other compiling operations)
- pacstrap /mnt base base-devel
- # Generate fstab
- genfstab -U -p /mnt >> /mnt/etc/fstab
- # Check and maybe edit fstab
- nano /mnt/etc/fstab
- # Chroot into the new system
- arch-chroot /mnt /bin/bash
- ##
- ## Select a locale:
- # First, edit /etc/locale.gen
- vi /etc/locale.gen
- # Then, uncomment a locale by removing the #. For example:
- en_US.UTF-8 UTF-8
- # Then, generate the locale:
- locale-gen
- # Create /etc/locale.conf. if necessary, substitute en_US.UTF-8:
- echo LANG=en_US.UTF-8 > /etc/locale.conf
- # Export locale. Substitute en_US.UTF-8 if necessary:
- export LANG=en_US.UTF-8
- ##
- ## Timezone:
- # Create a symbolic link /etc/localtime
- # For the following command, substitute Zone and SubZone:
- # ln -s /usr/share/zoneinfo/Zone/SubZone /etc/localtime
- # For example:
- ln -s /usr/share/zoneinfo/Europe/Minsk /etc/localtime
- ##
- ## Setup hardware clock:
- # For example, with UTC (recommended: )
- hwclock --systohc --utc
- ##
- ## Set hostname:
- # Substitute myhostname if preferred:
- echo myhostname > /etc/hostname
- ##
- ## Configure network:
- # For example, with DHCP:
- # Substitute interface_name with something else...
- systemctl enable dhcpcd@interface_name.service
- ##
- ## Create mkinitcpio (be careful, as this diverges from an Arch
- ## install with no encryption.)
- # Edit /etc/mkinitcpio.conf
- nano /etc/mkinitcpio.conf
- # Add the following hooks:
- # encrypt lvm2 fsck
- # If separate usr partition is created, add the following hook:
- # usr
- # Sample mkinitcpio.conf configuration:
- # HOOKS="... encrypt lvm2 filesystems keyboard usr fsck"
- # Re-generate initramfs image:
- mkinitcpio -p linux
- ##
- ## Set root password
- passwd
- ##
- ## Edit bootloader (also be careful, as this also diverges
- ## from an Arch install with no encryption.)
- # Install the bootloader (in this case, syslinux)
- pacman -S syslinux
- # Manual configuration:
- mkdir /boot/syslinux
- cp -r /usr/lib/syslinux/bios/*.c32 /boot/syslinux/
- extlinux --install /boot/syslinux
- # Edit /boot/syslinux/syslinux.cfg
- nano /boot/syslinux/syslinux.cfg
- # The entry should look like the following (change it to suit your preferences.)
- # Remove the commenting below this:
- # LABEL arch
- # MENU LABEL Arch Linux
- # LINUX /vmlinuz-linux
- # APPEND root=/dev/mapper/vgname-root cryptdevice=/dev/sdx3:lvmname ro
- # INITRD /initramfs-linux.img
- # Add the following entry for chainloading.
- # Again, remove the commenting below this:
- # LABEL Windows
- # MENU LABEL Windows
- # COM32 chain.32
- # APPEND hd 0 1 file=/dc.bs #This is for /boot in sda2.
- # If the /boot is in sda1, then replace "hd 0 1" with "hd 0 0"
- # Finally, install the MBR:
- dd bs=440 count=1 conv=notrunc if=/usr/lib/syslinux/bios/mbr.bin of=/dev/sda
- # Unmount partitions:
- exit
- # Reboot:
- reboot
Advertisement
Add Comment
Please, Sign In to add comment