Celebrazio Net



Contact Us

Installing Manjaro on existing LVM partitions

April, 2017

As I began my install of Manjaro, I was surprised to see that LVM partition was not supported by the graphical installer. And the command line installer had been phased out. And there weren't too many details in any forum I found. This page provides details for anyone setting out on this path. LUKS was not included for me, but some of the references talk about it.

Objectives of the Install

  • Get the latest Manjaro (17.0.1 at the time)
  • Use the same machine, dual-boot with an unrelated distro
  • Ensure UUID naming is used for persistence
  • Use existing LVM partitions for home, root, boot
  • Ensure Grub properly discovers other distro boot options

Preparation - temporary install partitions

I was lucky to have extra disk space available. LVM partitions already existed (machine is shared with another distro), and a separate HDD had the space. Created Temp partitions to get the installation before copying to LVM.


Final  :  Temp 
/dev/mapper/lvhome  :  /dev/sda7 
/dev/mapper/lvroot  :  /dev/sda6   

Install manjaro to temporary partitions

follow installation steps for this... omitted.

Double-checking partition and LVM naming, locations:

   sudo fdisk -l /dev/sda
  Device  Boot    ...    Size  ...
   ... 
  /dev/sda6              6.4G
  /dev/sda7             20G 

  sudo  LVdisplay 
  ... 
  LV Path        /dev/ssdvg/lvroot
  ...
  LV Path        /dev/ssdvg/lvhome 

  # scan uuid values: 
  sudo lsblk -o +UUID 

Mount LVM and temp installed partitions

Handy Reference - LVM help from Arch: Arch LVM Wiki Page. I scan, make volume group available, and delete previous junk from partition (by reformatting). Didn't want to reformat the home partition, just the root one. Deleting detritus from failed install of weeks ago. Keeping user in /home from later successful install (on separate partition).

  sudo vgscan 
  sudo vgchange -ay
  sudo mkfs.ext4 /dev/mapper/ssdvg-lvroot
  # not reformatting lvhome however - contains other user dir for other distro

  sudo mkdir /mnt/installed/
  sudo mkdir /mnt/installed/home
  sudo mkdir /mnt/existinglvm/
  sudo mkdir /mnt/existinglvm/home
  sudo mount /dev/sda7        /mnt/installed/ 
  sudo mount /dev/sda6        /mnt/installed/home
  sudo mount /dev/ssdvg/lvroot  /mnt/existinglvm/

su # duh. discovered this along the way. Root makes things easier ...

Copy Files

  cp -a /mnt/installed/*   /mnt/existinglvm
  # (takes a few seconds... )  
  
  # Mount other drive: 
  mount /dev/ssdvg/lvhome  /mnt/existinglvm/home
  mkdir /mnt/existinglvm/home/newuser
  # newuser is the new username I'll run on manjaro
  # don't want to clobber by old / existing username of the other distro. 

  chown manjaro /mnt/existinglvm/home/newuser
  chgrp manjaro /mnt/existinglvm/home/newuser
  # giving permissions to manjaro user here still resulted in 
  # permissions to "newuser" when it's all completed. 

  cp -a /mnt/installed/home/newuser/*  /mnt/existinglvm/home/newuser

That concludes the file copying. Next we'll need to fix fstab to point to LVM partitions instead of temporary installed partitions. Arch wiki on persistent block device names was my reference.

Fix /etc/fstab

   # need to use LVM not installation target 
   # edited /etc/fstab  - changed to UUID of my existinglvm partitions

chroot

I was going to need some fixes from within the chroot environment, as outlined by Manjaro forum threads. Restore Grub thread on Manjaro wiki was helpful. I've already mounted / and /home, just one more partition for me.

  mount /dev/sdc1  /mnt/existinglvm/boot

  cd /mnt/existinglvm
  mount -t proc proc /mnt/existinglvm/proc
  mount -t sysfs  sys /mnt/existinglvm/sys
  mount -o bind  /dev   /mnt/existinglvm/dev
  mount -t devpts  pts  /mnt/existinglvm/dev/pts/
  mount  # review that everything has been mounted

  chroot /mnt/existinglvm

Install Stuff

Curious that vi and vim don't exist in this install yet. using nano temporarily. I had to overcome a problem with my pacman repos too. Maybe my firewall doesn't permit ftp, anyway, got it fixed.

  # problems with pacman repos. 
  pacman -Syy  # fails - what to do? 
  nano /etc/pacman.d/mirrorlist
  pacman -Syy  # sigh of relief. 
  # looks better now with different mirror. 
  pacman -S vim 
  pacman -S mtools
  pacman -S os-prober 

fix LVM2 InitramFS

I blundered through this the first 2 times and had to come back around to fix it. You'll probably do better. Manjaro Forum Classic thread on mkinitcpio was a nice read here. The idea is that LVM2 is needed in the initRamFS of course, and not available by default. You need to configure for LVM2 support there (and LUKS crypto for those in the need), and then recreate initRamFS. On other distros, I believe the command is "mkinitramfs", but here it's called "mkinitcpio".

  #change 'mkinitcpio.conf' at /etc/mkinitcpio.conf
  #insert "lvm2" here before "filesystems"  on line "HOOKS" 

  ls /etc/mkinitcpio.d
  mkinitcpio -p linux49 #in my case - just use the right linux for your kernel... 

If you get this boot error as I did:
ERROR: device '/dev/mapper/ssdvg-lvroot' not found. skipping fsck
it means you may need to do the mkinitcpio steps above. That fixed it for me.

A good reference on fixing errors of LVM inaccessibility: Superuser question on Manjaro LVM device not found. I also had errors while chrooted referring to lvmetad. However, I never fixed them and they didn't appear again after I fully booted. Probably no fix needed. If you want to check, see /etc/lvm/lvm.conf and setting use_lvmetad = 1.

GRUB setup

Almost to the end of the odyssey now. But be careful with GRUB - has many ways of biting you. Critical reading for these steps in Manjaro Wiki Grub Restore Howto. A few other good suggestions came from Arch here: Wiki on Grub Tips and Tricks.

  man grub-install 

  vim /etc/default/grub
  # os-prober finds another manjaro on /dev/sda7 - the one I copied from 
  # vim /boot/grub/grub.cfg - just to look at the menuentries
  # I created /etc/grub.d/15_local_custom as a menuentry I thought would work better. 
  # I felt like installing grub on both drives just to be safe: 
  grub-install /dev/sda 
  update-grub

uname -a:  Linux darkstar 4.9.20-1-MANJARO #1 SMP PREEMPT Fri Mar 31 17:49:34 UTC 2017 
           x86_64 GNU/Linux

Filesystem                Size    Used  Avail  Use%   Mounted on
...
/dev/mapper/ssdvg-lvroot   25G    4.5G    20G   19%   /
...




1998-2017 Celebrazio.net