how to install manjaro on existing lvm logical volume?
Calamares do not support LVM installations very well - you will have to resort to manual installation when you are using LVM.
When you are using LVM you are expected to know how to mount your volume(s) manually and you should be able to adapt the following to fit your purpose.
I have been working on this problem and have created a couple of scripts. These are very much a work in progress but may help a little. The script is designed to mimic Debian LVM partitioning to create separtate /var /tmp /boot and /home partitions as I use Debian for the servers and Manjaro for the desktops and wanted to unify things a bit.
The first script partitions the disk and installs the base operating system. WARNING: This will wipe your drive
Boot manjaro from an image and then open up a terminal and sudo -i then make a file called install.sh in an accessible location. chmod the file to 770 so that it is executable.
#!/bin/bash
DRIVE=''
VOLGP=''
FORMAT="system"
PART=false
while getopts d:f:v:p option; do
case "${option}" in
f) FORMAT=${OPTARG};;
d) DRIVE=${OPTARG};;
v) VOLGP=${OPTARG};;
p) PART=true;;
esac
done
prompt_confirm() {
while true; do
read -r -n 1 -p "${1:-Continue?} [y/n]: " REPLY
case $REPLY in
[yY]) echo ; return 0 ;;
[nN]) echo ; return 1 ;;
*) printf " \033[31m %s \n\033[0m" "invalid input"
esac
done
}
clean_up() {
if [ -d /mnt/boot/EFI ]; then
umount /mnt/boot/EFI
fi
if [ -d /mnt/boot ]; then
umount /mnt/boot
fi
if [ -d /mnt/tmp ]; then
umount /mnt/tmp
fi
if [ -d /mnt/home ]; then
umount /mnt/home
fi
if [ -d /mnt/var ]; then
umount /mnt/var
fi
if grep -qs "${VOLGP//-/--}-root" /proc/mounts; then
printf "\033[32mUnmounting the file system.\n\033[0m"
umount /dev/$VOLGP/root
fi
swapoff -a
}
if [ $PART = true ]; then
while [ ! $DRIVE ]; do
printf "\033[1;33mPlease enter the drive that you wish to initialise (eg. /dev/sda)\033[0m"
read DRIVE
if [ ! $DRIVE ]; then
printf "\033[31mThe logical volume name cannot be blank\n\033[0m"
else
if [ ! $(lsblk -ln -o NAME | grep -w $(basename "$DRIVE")) ]; then
printf "\033[31mDevice does not exit!\n\033[0m"
DRIVE=""
fi
fi
done
if prompt_confirm "Do you wish to partition the disk $DRIVE (WARNING: This will wipe any existing data from the disk)"; then
#PARTITION THE DISK
sgdisk -og $DRIVE
sgdisk -n 1:2048:+512MiB -c 1:"EFI System Partition" -t 1:ef00 $DRIVE
sgdisk -n 2:0:+256MiB -c 2:"Linux /boot" -t 2:8300 $DRIVE
ENDSECTOR=`sgdisk -E $DRIVE`
sgdisk -n 3:0:$ENDSECTOR -c 3:"Linux LVM" -t 3:8e00 $DRIVE
sgdisk -p $1
fi
partprobe $DRIVE
#CREATE THE LOGICAL VOLUME GROUP
while [ ! $VOLGP ]; do
printf "\033[1;33mPlease enter a name for the new logical volume group\033[0m [manjaro-vg]: "
read VOLGP
VOLGP=${VOLGP:-manjaro-vg}
if [ ! $VOLGP ]; then
printf "\033[1;31mThe logical volume name cannot be blank\n\033[0m"
else
printf "\033[36mCreating logical volume $VOLGP using drive ${DRIVE}3\n\033[0m"
umount -R /mnt
swapoff -a
EXISTINGVOL=$(vgs -o vg_name --noheadings)
if [ $EXISTINGVOL ]; then
vgremove -f $EXISTINGVOL
fi
vgcreate $VOLGP ${DRIVE}3
fi
done
#CREATE THE PARTITIONS
lvcreate -L 20G -n root /dev/$VOLGP
lvcreate -L 20G -n var /dev/$VOLGP
lvcreate -L 2G -n tmp /dev/$VOLGP
#GET MEMORY SIZE (Round to nearest GB)
#NOTE: To round up we and (denominator -1 to the enumerator and then divide by the denominator
MEMSZ=$(( ($(grep MemTotal /proc/meminfo |sed 's/[^0-9]*//g') + 1023999) / 1024000 ))
#CREATE THE SWAP PARTITION
lvcreate -L $MEMSZ -n swap /dev/$VOLGP
lvcreate -l 100%FREE -n home /dev/$VOLGP
fi
############################################################################
# #
# Prior to running this script you need to ensure that you create the #
# correct partitions. #
# #
# The script requires the following ordinary partitions #
# #
# /boot #
# /boot/efi #
# #
# And the following logical volumes: #
# #
# /root #
# /var #
# /tmp #
# /home #
# #
# The script will format the both the basic partitions and the logical #
# volumes. It will prompt to format the /home partition as you may #
# want to leave it intact. #
# #
############################################################################
if [ ! $VOLGP ]; then
printf "\033[1;32mPlease enter the volume group where you wish to install the operating sytsem (eg. my-volume-group)\033[0m [manjaro-vg]: "
read VOLGP
VOLGP=${VOLGP:-manjaro-vg}
fi
#PARTITION THE DISK/s
if prompt_confirm "WARNING: This will erase the contents of the volume group"; then
#CLEAN UP FAILED INSTALLATIONS
umount -R /mnt
swapoff -a
#ROOT PARTITION
printf "\033[32mFormatting the root filesystem.\n\033[0m"
mkfs.ext4 -F /dev/$VOLGP/root
if [ $? -ne 0 ]; then
printf "\033[31mERROR: Could not format the filesystem; exiting!\n\033[0m"
exit 1
fi
printf "\033[32mMounting the root filesystem.\n\033[0m"
mount /dev/$VOLGP/root /mnt
#BOOT PARTITION
if [ ! $DRIVE ]; then
printf "\033[36mLISTING PARTITONS:\n\033[0m"
lsblk
printf "\033[1;33mPlease enter the boot partition (eg. /dev/sdaX):\033[0m "
read BOOTPART
else
BOOTPART=${DRIVE}2
fi
if grep -qs "$BOOTPART" /proc/mounts; then
printf "\033[32mUnmounting $BOOTPART.\n\033[0m"
umount $BOOTPART
fi
printf "\033[32mFormatting the boot partition.\n\033[0m"
mkfs.ext2 -F $BOOTPART
if [ $? -ne 0 ]; then
printf "\033[31mERROR: Could not format the filesystem; exiting!\n\033[0m"
exit 1
fi
mkdir /mnt/boot
mount $BOOTPART /mnt/boot
#EFI PARTITION
if [ ! $DRIVE ]; then
printf "\033[1;33mPlease enter the EFI partition (eg. /dev/sdaX):\033[0m "
read EFIPART
else
EFIPART=${DRIVE}1
fi
if grep -qs "$EFIPART" /proc/mounts; then
printf "\033[32mUnmounting $EFIPART.\n\033[0m"
umount $EFIPART
fi
printf "\033[32mFormatting the EFI partition.\n\033[0m"
mkfs.fat -F32 $EFIPART
if [ $? -ne 0 ]; then
printf "\033[31mERROR: Could not format the filesystem; exiting!\n\033[0m"
exit 1
fi
mkdir /mnt/boot/EFI
mount $EFIPART /mnt/boot/EFI
#/VAR /TMP and /HOME PARTITIONS
printf "\033[32mFromatting the system partitions.\033[0m"
mkfs.ext4 -F /dev/$VOLGP/var
mkfs.ext4 -F /dev/$VOLGP/tmp
if [ "$FORMAT" = "all" ]; then
mkfs.ext4 -F /dev/$VOLGP/home
else
if prompt_confirm "Do you wish to format the /home partition (WARNING - ALL DATA WILL BE LOST)?"; then
mkfs.ext4 -F /dev/$VOLGP/home
fi
fi
mkswap /dev/$VOLGP/swap
mkdir /mnt/var
mkdir /mnt/tmp
mkdir /mnt/home
mount /dev/$VOLGP/var /mnt/var
mount /dev/$VOLGP/tmp /mnt/tmp
mount /dev/$VOLGP/home /mnt/home
swapon /dev/$VOLGP/swap
else
exit 0
fi
printf "\033[36mINSTALLING THE BASE OPERATING SYSTEM\n\033[0m"
printf "\033[1;33mPlease enter a keymap\033[0m [uk]"
read KEYMAP
KEYMAP=${KEYMAP:-uk}
loadkeys $KEYMAP
systemctl enable --now systemd-timesyncd
pacman-mirrors --api --set-branch stable -c United_Kingdom
pacman -Syy pacman archlinux-keyring manjaro-keyring
pacman-key --init
pacman-key --populate archlinux manjaro
pacman-key --refresh-keys
basestrap /mnt base linux510 dhcpcd networkmanager grub mkinitcpio efibootmgr vi nano sudo links
fstabgen /mnt >> /mnt/etc/fstab
# RUN THE SETUP SCRIPT FROM THE CHROOTED ENVIRONMENT
cp setup.sh /mnt
chmod 770 /mnt/setup.sh
manjaro-chroot /mnt /setup.sh
exit 0
next create another file called “setup.sh” in the same location (this does not need to be made executable) and paste the following:
#!/bin/bash
#SET THE KEYBOARD
sed -i '/KEYMAP/ c\KEYMAP=$KEYMAP' /etc/vconsole.conf
#SET THE LOCALE
printf "\033[1;33mPlease enter a locale\033[0m [en_GB.UTF-8]"
read LOCALE
LOCALE=${LOCALE:-en_GB.UTF-8}
#NOTE: grep returns 0 if found
while ! grep -Fq "$LOCALE" /etc/locale.gen; do
printf "\033[1;33mSorry the locale you entered is not valid, Please enter a valid locale\033[0m [en_GB.UTF-8]"
read LOCALE
LOCALE=${LOCALE:-en_GB.UTF-8}
done
sed -i 's/#en_GB.UTF-8/en_GB.UTF-8/g' /etc/locale.gen
locale-gen
#SET THE TIME ZONE
printf "\033[1;33mPlease enter a timezone\033[0m [Europe/London]"
read TIMEZONE
TIMEZONE=${LOCALE:-Europe/London}
ln -sf /usr/share/zoneinfo/$TIMEZONE /etc/localtime
hwclock --systohc --utc
#SET THE HOSTNAME
##########################################################################
# #
# Setting the host name here sets its basic name rather than a fully #
# qualified domain name. #
# #
# It does not map the name to an ip address because if you are using #
# DHCP the IP may not be known at the time of installation. If you #
# are not using a name server you may have to manually map the host #
# to the IP address in /etc/hosts. #
# #
##########################################################################
printf "\033[1;33mPlease enter the hostname:\033[0m "
read HOSTNAME
echo $HOSTNAME > /etc/hostname
echo 127.0.0.1 localhost >> /etc/hosts
echo ::1 localhost >> /etc/hosts
echo 127.0.0.1 $HOSTNAME.local $HOSTNAME >> /etc/hosts
#
sed -i s/#%wheel/%wheel/ /etc/sudoers
systemctl enable NetworkManager
systemctl enable systemd-timesyncd
#NOTHING BELOW WORKS WITH THE WORKAROUND
#this is not working
pacman -S lvm2
#installing the firmware will not do any harm
pacman -S manjaro-firmware
#need to manually edit /etc/mkinitcpio.conf to add lvm2
sudo sed -i '/^#/!s/HOOKS=(base udev autodetect modconf block filesystems keyboard fsck)/HOOKS=(base udev autodetect modconf block lvm2 filesystems keyboard fsck)/g' /etc/mkinitcpio.conf
mkinitcpio -P
grub-install --target=x86_64-efi --efi-directory=/boot/EFI --bootloader-id=Manjaro
grub-mkconfig -o /boot/grub/grub.cfg
#SET THE ROOT PASSWORD
PASSWORD=''
CONFPASSWORD=''
while [ "$PASSWORD" != "$CONFPASSWORD" ] || [ -z "$PASSWORD" ]; do
printf "\033[1;33mPlease enter a password for the root user:\033[0m "
read PASSWORD
printf "\033[1;33mConfirm the password:\033[0m "
read CONFPASSWORD
if [ "$PASSWORD" = "$CONFPASSWORD" ]; then
printf "\033[36mThe root password has been set.\n\033[0m"
echo "root:$PASSWORD" | chpasswd
break
else
printf "\033[31mSorry the passwords do not match\033[0m - "
fi
done
#ADD A REGULAR USER
USR=''
while [ -z "$USR" ]; do
printf "\033[1;33mPlease enter a user name for the new regular user:\033[0m "
read USR
if [ -z "$USR" ]; then
printf "\033[31mSorry the user name cannot be blank match\033[0m - "
else
useradd -mG lp,network,power,sys,wheel $USR
fi
done
USRPASSWORD=''
CONFUSRPASSWORD=''
while [ "$USRPASSWORD" != "$CONFUSRPASSWORD" ] || [ -z "$USRPASSWORD" ]; do
printf "\033[1;33mPlease enter a password for the new user:\033[0m "
read USRPASSWORD
printf "\033[1;33mConfirm the password:\033[0m "
read CONFUSRPASSWORD
if [ "$USRPASSWORD" = "$CONFUSRPASSWORD" ]; then
printf "\033[36mThe user password has been set.\n\033[0m"
echo "$USR:$USRPASSWORD" | chpasswd
break
else
printf "\033[31mSorry the passwords do not match\033[0m - "
fi
done
#INSTALL KDE (This is pretty much all you need to change if you want to install a different desktop manager)
pacman -S plasma kio-extras
pacman -S kde-applications
systemctl enable sddm.service --force
pacman -S manjaro-kde-settings manjaro-settings-manager-knotifier manjaro-settings-manager-kcm
pacman -S breath2-icon-themes breath2-wallpaper plasma5-themes-breath2 sddm-breath2-theme
exit 0
now run your install.sh with a ‘-p’ flag to partition the hard disk and if you follow the instructions you should end up with a kde desktop on the next boot.
./install.sh -p
I have only tried this in a virtual machine so far and to be honest it needs some work, but it will give you a rough idea of want you need to do to install manjaro on lvm partitions.
If you want something other then kde then change the last few lines in setup.sh. It should also be fairly easy to modify the script if you do not want to create separate partitions, but that was the whole point of it for me.
Lastly, be careful at the prompts, Some things are checked and others aren’t (as I said, it is very much a work in progress). Hope this helps.
I’ve done several Manjaro installs to LVM using Manjaro Architect. It works.
Sadly Architect is no more; that is what led me to writing a script.
You can still install it in an iso environment and it still works.
I feel a bit dumb now because I never thought of doing that; Ahh Well; that was two days of my life wasted (won’t be the first time; won’t be the last)!
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.