Guest User

Dual boot Encrypted Windows and Encrypted Linux

a guest
Feb 14th, 2015
429
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.24 KB | None | 0 0
  1. ### Sources for walkthrough:
  2. ## https://wiki.archlinux.org/index.php/Dm-crypt/Encrypting_an_Entire_System#LVM_on_LUKS
  3. ## https://wiki.archlinux.org/index.php/Dm-crypt/Drive_preparation
  4. ## https://wiki.archlinux.org/index.php/Beginners%27_guide
  5. ## https://www.taricorp.net/2012/chainloading-truecrypt
  6.  
  7. ### Assumptions:
  8.  
  9. ### First, this installation is a LVM on LUKS scenario
  10.  
  11. ### Second, this installation also assumes that there is an encrypted root,
  12. ### encrypted swap and unencrypted boot.
  13.  
  14. ### Third, this installation assumes that Windows is already installed.
  15.  
  16. # For non-US keyboard layout, see Arch wiki on that.
  17.  
  18.  
  19.  
  20. # Test for internet connection:
  21. ping -c 3 www.google.ca
  22. # Should get 3 packets transmitted
  23.  
  24. ##
  25. ## Partitioning:
  26.  
  27. #Note: For later steps, substitute lvmname and vgname if preferred.
  28.  
  29. # Use cfdisk (replace sdX with some drive letter, e.g. sda or sdb: )
  30. cfdisk /dev/sdX
  31.  
  32. # Make the following partitions:
  33. # Note: If using MBR, make sdX1 the boot partition and sdX2 the encrypted lvm
  34. # Also, replace the X in sdX with something like sda or sdb, depending on
  35. # the drive letter
  36.  
  37. # (If using GPT) sdX1 - size 2M - type ?
  38. # sdX2 - Size 200M, type linux
  39. # sdX3 - Remaining space, type lvm
  40.  
  41. # Create the LUKS encrypted container (sdX3)
  42. cryptsetup luksFormat /dev/sdX3
  43.  
  44. # Open container
  45. #Substitute luks if preferred:
  46. cryptsetup open --type luks /dev/sdX3 lvmname
  47.  
  48. # Wipe the encrypted partition beforehand
  49. dd if=/dev/zero of=/dev/mapper/lvmname
  50.  
  51. # Create physical volume and volume group
  52. pvcreate /dev/mapper/lvmname
  53. vgcreate vgname /dev/mapper/lvmname
  54.  
  55. # Create partitions. Replace (size) with any particular size.
  56. lvcreate -C y -L (size) vgname -n swap
  57. lvcreate -l 100%FREE vgname -n root
  58.  
  59. # Also, an extra sample command for creating partitions:
  60. # lvcreate -L (size) vgname -n tmp
  61.  
  62. # Format and activate swap partition
  63. mkwap /dev/mapper/vgname-swap
  64. swapon /dev/mapper/vgname-swap
  65.  
  66. # Format and mount root partition
  67. mkfs.ext4 /dev/mapper/vgname-root
  68. mount /dev/mapper/vgname-root /mnt
  69.  
  70. # Format and mount boot partition
  71. mkfs.ext4 /dev/sdx2
  72. mkdir /mnt/boot
  73. mount /dev/sdx2 /mnt/boot
  74.  
  75. ##
  76. ## Backup current (e.g. Windows) mbr:
  77. dd if=/dev/sda of=/mnt/boot/dc.bs count=1
  78.  
  79. ##
  80. ## The following is almost the same as instructions in the Arch wiki.
  81.  
  82. # Edit /etc/pacman.d/mirrorlist and select your mirror(s) by uncommenting them.
  83. nano /etc/pacman.d/mirrorlist
  84.  
  85. # Install base system and base-devel (for AUR, ABS and other compiling operations)
  86. pacstrap /mnt base base-devel
  87.  
  88. # Generate fstab
  89. genfstab -U -p /mnt >> /mnt/etc/fstab
  90.  
  91. # Check and maybe edit fstab
  92. nano /mnt/etc/fstab
  93.  
  94. # Chroot into the new system
  95. arch-chroot /mnt /bin/bash
  96.  
  97. ##
  98. ## Select a locale:
  99.  
  100. # First, edit /etc/locale.gen
  101. vi /etc/locale.gen
  102.  
  103. # Then, uncomment a locale by removing the #. For example:
  104. en_US.UTF-8 UTF-8
  105.  
  106. # Then, generate the locale:
  107. locale-gen
  108.  
  109. # Create /etc/locale.conf. if necessary, substitute en_US.UTF-8:
  110. echo LANG=en_US.UTF-8 > /etc/locale.conf
  111.  
  112. # Export locale. Substitute en_US.UTF-8 if necessary:
  113. export LANG=en_US.UTF-8
  114.  
  115. ##
  116. ## Timezone:
  117.  
  118. # Create a symbolic link /etc/localtime
  119. # For the following command, substitute Zone and SubZone:
  120. # ln -s /usr/share/zoneinfo/Zone/SubZone /etc/localtime
  121.  
  122. # For example:
  123. ln -s /usr/share/zoneinfo/Europe/Minsk /etc/localtime
  124.  
  125. ##
  126. ## Setup hardware clock:
  127.  
  128. # For example, with UTC (recommended: )
  129. hwclock --systohc --utc
  130.  
  131. ##
  132. ## Set hostname:
  133.  
  134. # Substitute myhostname if preferred:
  135. echo myhostname > /etc/hostname
  136.  
  137. ##
  138. ## Configure network:
  139.  
  140. # For example, with DHCP:
  141. # Substitute interface_name with something else...
  142. systemctl enable dhcpcd@interface_name.service
  143.  
  144. ##
  145. ## Create mkinitcpio (be careful, as this diverges from an Arch
  146. ## install with no encryption.)
  147.  
  148. # Edit /etc/mkinitcpio.conf
  149. nano /etc/mkinitcpio.conf
  150.  
  151. # Add the following hooks:
  152. # encrypt lvm2 fsck
  153.  
  154. # If separate usr partition is created, add the following hook:
  155. # usr
  156.  
  157. # Sample mkinitcpio.conf configuration:
  158. # HOOKS="... encrypt lvm2 filesystems keyboard usr fsck"
  159.  
  160. # Re-generate initramfs image:
  161. mkinitcpio -p linux
  162.  
  163. ##
  164. ## Set root password
  165.  
  166. passwd
  167.  
  168. ##
  169. ## Edit bootloader (also be careful, as this also diverges
  170. ## from an Arch install with no encryption.)
  171.  
  172. # Install the bootloader (in this case, syslinux)
  173. pacman -S syslinux
  174.  
  175. # Manual configuration:
  176. mkdir /boot/syslinux
  177. cp -r /usr/lib/syslinux/bios/*.c32 /boot/syslinux/
  178. extlinux --install /boot/syslinux
  179.  
  180. # Edit /boot/syslinux/syslinux.cfg
  181. nano /boot/syslinux/syslinux.cfg
  182.  
  183. # The entry should look like the following (change it to suit your preferences.)
  184. # Remove the commenting below this:
  185.  
  186. # LABEL arch
  187. # MENU LABEL Arch Linux
  188. # LINUX /vmlinuz-linux
  189. # APPEND root=/dev/mapper/vgname-root cryptdevice=/dev/sdx3:lvmname ro
  190. # INITRD /initramfs-linux.img
  191.  
  192. # Add the following entry for chainloading.
  193. # Again, remove the commenting below this:
  194.  
  195. # LABEL Windows
  196. # MENU LABEL Windows
  197. # COM32 chain.32
  198. # APPEND hd 0 1 file=/dc.bs #This is for /boot in sda2.
  199.  
  200. # If the /boot is in sda1, then replace "hd 0 1" with "hd 0 0"
  201.  
  202.  
  203.  
  204. # Finally, install the MBR:
  205. dd bs=440 count=1 conv=notrunc if=/usr/lib/syslinux/bios/mbr.bin of=/dev/sda
  206.  
  207. # Unmount partitions:
  208. exit
  209.  
  210. # Reboot:
  211. reboot
Advertisement
Add Comment
Please, Sign In to add comment