|
|
|
@ -96,11 +96,11 @@ auto_partition() {
|
|
|
|
|
check_for_error "${DEVICE} is $part_table"
|
|
|
|
|
|
|
|
|
|
# Create partition table if one does not already exist
|
|
|
|
|
if [[ $SYSTEM == "BIOS" ]] && [[ $part_table != "msdos" ]] ; then
|
|
|
|
|
if [[ $SYSTEM == "BIOS" ]] && [[ $part_table != "msdos" ]] ; then
|
|
|
|
|
parted -s ${DEVICE} mklabel msdos 2>$ERR
|
|
|
|
|
check_for_error "${DEVICE} mklabel msdos" $?
|
|
|
|
|
fi
|
|
|
|
|
if [[ $SYSTEM == "UEFI" ]] && [[ $part_table != "gpt" ]] ; then
|
|
|
|
|
if [[ $SYSTEM == "UEFI" ]] && [[ $part_table != "gpt" ]] ; then
|
|
|
|
|
parted -s ${DEVICE} mklabel gpt 2>$ERR
|
|
|
|
|
check_for_error "${DEVICE} mklabel gpt" $?
|
|
|
|
|
fi
|
|
|
|
@ -124,7 +124,7 @@ auto_partition() {
|
|
|
|
|
DIALOG "" --textbox /tmp/.devlist 0 0
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Finds all available partitions according to type(s) specified and generates a list
|
|
|
|
|
# of them. This also includes partitions on different devices.
|
|
|
|
|
find_partitions() {
|
|
|
|
@ -145,7 +145,7 @@ find_partitions() {
|
|
|
|
|
do
|
|
|
|
|
partition_list="${partition_list} /dev/md/${i}"
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for i in ${partition_list}; do
|
|
|
|
|
PARTITIONS="${PARTITIONS} ${i}"
|
|
|
|
|
NUMBER_PARTITIONS=$(( NUMBER_PARTITIONS + 1 ))
|
|
|
|
@ -160,7 +160,7 @@ find_partitions() {
|
|
|
|
|
(( $i % 2 == 0 )) || continue
|
|
|
|
|
local j=$((i+1))
|
|
|
|
|
check_for_error "${parts[i]} ${parts[j]}"
|
|
|
|
|
done
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
#for test delete /dev:sda8
|
|
|
|
|
#delete_partition_in_list "/dev/sda8"
|
|
|
|
@ -187,7 +187,7 @@ find_partitions() {
|
|
|
|
|
create_partitions
|
|
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
esac
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
## List partitions to be hidden from the mounting menu
|
|
|
|
@ -254,15 +254,17 @@ select_filesystem() {
|
|
|
|
|
DIALOG " $_FSTitle " --menu "\n$_FSBody\n " 0 0 10 \
|
|
|
|
|
"$_FSSkip" "-" \
|
|
|
|
|
"btrfs" "mkfs.btrfs -f" \
|
|
|
|
|
"ext2" "mkfs.ext2 -q" \
|
|
|
|
|
"ext3" "mkfs.ext3 -q" \
|
|
|
|
|
"ext4" "mkfs.ext4 -q" \
|
|
|
|
|
"f2fs" "mkfs.f2fs -q" \
|
|
|
|
|
"jfs" "mkfs.jfs -q" \
|
|
|
|
|
"nilfs2" "mkfs.nilfs2 -fq" \
|
|
|
|
|
"ntfs" "mkfs.ntfs -q" \
|
|
|
|
|
"reiserfs" "mkfs.reiserfs -q" \
|
|
|
|
|
"vfat" "mkfs.vfat -F32" \
|
|
|
|
|
"xfs" "mkfs.xfs -f" 2>${ANSWER} || return 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case $(cat ${ANSWER}) in
|
|
|
|
|
"$_FSSkip") FILESYSTEM="$_FSSkip"
|
|
|
|
|
;;
|
|
|
|
@ -332,21 +334,21 @@ mount_opts() {
|
|
|
|
|
echo ${FS_OPTS} > /tmp/.fs_options
|
|
|
|
|
|
|
|
|
|
format_name=$(echo ${PARTITION} | rev | cut -d/ -f1 | rev)
|
|
|
|
|
format_device=$(lsblk -i | tac | sed -r 's/^[^[:alnum:]]+//' | sed -n -e "/$format_name/,/disk/p" | awk '/disk/ {print $1}')
|
|
|
|
|
|
|
|
|
|
format_device=$(lsblk -i | tac | sed -r 's/^[^[:alnum:]]+//' | sed -n -e "/$format_name/,/disk/p" | awk '/disk/ {print $1}')
|
|
|
|
|
|
|
|
|
|
if [[ "$(cat /sys/block/${format_device}/queue/rotational)" == 1 ]]; then
|
|
|
|
|
sed -i 's/autodefrag - off/autodefrag - on/' /tmp/.fs_options
|
|
|
|
|
sed -i 's/compress=zlip - off/compress=zlip - on/' /tmp/.fs_options
|
|
|
|
|
sed -i 's/nossd - off/nossd - on/' /tmp/.fs_options
|
|
|
|
|
sed -i 's/nossd - off/nossd - on/' /tmp/.fs_options
|
|
|
|
|
else
|
|
|
|
|
sed -i 's/compress=lzo - off/compress=lzo - on/' /tmp/.fs_options
|
|
|
|
|
sed -i 's/ space_cache - off/ space_cache - on/' /tmp/.fs_options
|
|
|
|
|
sed -i 's/commit=120 - off/commit=120 - on/' /tmp/.fs_options
|
|
|
|
|
sed -i 's/ ssd - off/ ssd - on/' /tmp/.fs_options
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
sed -i 's/noatime - off/noatime - on/' /tmp/.fs_options
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FS_OPTS=$(cat /tmp/.fs_options)
|
|
|
|
|
|
|
|
|
|
DIALOG " $(echo $FILESYSTEM | sed "s/.*\.//g;s/-.*//g") " --checklist "\n$_btrfsMntBody\n " 0 0 \
|
|
|
|
@ -521,10 +523,10 @@ raid_level_menu() {
|
|
|
|
|
case $(cat ${ANSWER}) in
|
|
|
|
|
"0") raid_array_menu 0
|
|
|
|
|
;;
|
|
|
|
|
"1") raid_array_menu 1
|
|
|
|
|
"1") raid_array_menu 1
|
|
|
|
|
;;
|
|
|
|
|
"5") raid_array_menu 5
|
|
|
|
|
;;
|
|
|
|
|
;;
|
|
|
|
|
"6") raid_array_menu 6
|
|
|
|
|
;;
|
|
|
|
|
"10") raid_array_menu 10
|
|
|
|
@ -544,8 +546,8 @@ raid_create() {
|
|
|
|
|
RAID_DEVICE_NAME=${3}
|
|
|
|
|
|
|
|
|
|
# creates the array
|
|
|
|
|
mdadm --create --level=${RAID_LEVEL} --metadata=1.2 --raid-devices=${RAID_DEVICE_NUMBER} /dev/md/${RAID_DEVICE_NAME} ${RAID_DEVICES}
|
|
|
|
|
|
|
|
|
|
mdadm --create --level=${RAID_LEVEL} --metadata=1.2 --raid-devices=${RAID_DEVICE_NUMBER} /dev/md/${RAID_DEVICE_NAME} ${RAID_DEVICES}
|
|
|
|
|
|
|
|
|
|
# array is disassembled and reassembled to prevent the array from being named /dev/md/md127
|
|
|
|
|
# the check of /etc/mdadm.conf is preformed to prevent the user from adding duplicate entries
|
|
|
|
|
if [[ $(cat /etc/mdadm.conf | grep "/dev/md/${RAID_DEVICE_NAME}" | wc -l) == 0 ]]; then
|
|
|
|
@ -553,7 +555,7 @@ raid_create() {
|
|
|
|
|
mdadm --stop /dev/md/${RAID_DEVICE_NAME}
|
|
|
|
|
mdadm --assemble --scan
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DIALOG "$__ArrayCreatedTitle" --msgbox "\n$_ArrayCreatedDescription\n\nmdadm --create --level=${RAID_LEVEL} --metadata=1.2 --raid-devices=${RAID_DEVICE_NUMBER} /dev/md/${RAID_DEVICE_NAME} ${RAID_DEVICES}\n" 0 0
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -563,11 +565,11 @@ raid_get_array_name() {
|
|
|
|
|
DIALOG "$_DeviceNameTitle" --inputbox "\n$_DeviceNameDescription\n\n$_DeviceNamePrefixWarning\n" 0 0 2>${ANSWER}
|
|
|
|
|
|
|
|
|
|
raid_device_name=$(cat ${ANSWER})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [[ ${raid_device_name} != "" ]]; then
|
|
|
|
|
raid_create "${1}" ${2} ${raid_device_name}
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
raid_array_menu() {
|
|
|
|
@ -576,21 +578,21 @@ raid_array_menu() {
|
|
|
|
|
INCLUDE_PART='part\|crypt'
|
|
|
|
|
umount_partitions
|
|
|
|
|
find_partitions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Amend partition(s) found for use in check list
|
|
|
|
|
PARTITIONS=$(echo $PARTITIONS | sed 's/M\|G\|T/& off/g')
|
|
|
|
|
RAID_LEVEL=${1}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# select partitions for the array
|
|
|
|
|
echo "" > $ANSWER
|
|
|
|
|
while [[ $(cat ${ANSWER}) == "" ]]; do
|
|
|
|
|
DIALOG "$_PartitionSelectTitle" --checklist "\n$__PartitionSelectDescription\n\n$_UseSpaceBar\n " 0 0 12 ${PARTITIONS} 2> ${ANSWER}
|
|
|
|
|
DIALOG "$_PartitionSelectTitle" --checklist "\n$__PartitionSelectDescription\n\n$_UseSpaceBar\n " 0 0 12 ${PARTITIONS} 2> ${ANSWER}
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ANSWERS=$(cat ${ANSWER})
|
|
|
|
|
|
|
|
|
|
raid_get_array_name "${ANSWERS[@]}" ${RAID_LEVEL}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
luks_menu() {
|
|
|
|
@ -627,7 +629,7 @@ luks_open() {
|
|
|
|
|
find_partitions
|
|
|
|
|
# Filter out partitions that don't contain crypt device
|
|
|
|
|
list_non_crypt > /tmp/.ignore_part
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for part in $(cat /tmp/.ignore_part); do
|
|
|
|
|
delete_partition_in_list $part
|
|
|
|
|
done
|
|
|
|
@ -874,7 +876,7 @@ lvm_create() {
|
|
|
|
|
# Now the final LV. Size is automatic.
|
|
|
|
|
DIALOG " $_LvmCreateVG (LV:$NUMBER_LOGICAL_VOLUMES) " --inputbox "\n$_LvmLvNameBody1 $_LvmLvNameBody2 (${LVM_VG_MB}MB).\n " 0 0 "lvol" 2>${ANSWER} || return 0
|
|
|
|
|
LVM_LV_NAME=$(cat ${ANSWER})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Loop if preceeded with a "/", if nothing is entered, if there is a space, or if that name already exists.
|
|
|
|
|
while [[ ${LVM_LV_NAME:0:1} == "/" ]] || [[ ${#LVM_LV_NAME} -eq 0 ]] || [[ ${LVM_LV_NAME} =~ \ |\' ]] || [[ $(lsblk | grep ${LVM_LV_NAME}) != "" ]]; do
|
|
|
|
|
DIALOG " $_ErrTitle " --msgbox "\n$_LvmLvNameErrBody\n " 0 0
|
|
|
|
@ -1109,8 +1111,8 @@ zfs_auto() {
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# next create the datasets including their parents
|
|
|
|
|
zfs_create_dataset "${ZFS_ZPOOL_NAME}/data" "none"
|
|
|
|
|
zfs_create_dataset "${ZFS_ZPOOL_NAME}/ROOT" "none"
|
|
|
|
|
zfs_create_dataset "${ZFS_ZPOOL_NAME}/data" "none"
|
|
|
|
|
zfs_create_dataset "${ZFS_ZPOOL_NAME}/ROOT" "none"
|
|
|
|
|
zfs_create_dataset "${ZFS_ZPOOL_NAME}/ROOT/manjaro" "none"
|
|
|
|
|
zfs_create_dataset "${ZFS_ZPOOL_NAME}/ROOT/manjaro/root" "/"
|
|
|
|
|
zfs_create_dataset "${ZFS_ZPOOL_NAME}/data/home" "/home"
|
|
|
|
@ -1119,7 +1121,7 @@ zfs_auto() {
|
|
|
|
|
# set the rootfs
|
|
|
|
|
zpool set bootfs=${ZFS_ZPOOL_NAME}/ROOT/manjaro/root ${ZFS_ZPOOL_NAME} 2>$ERR
|
|
|
|
|
check_for_error "Setting zfs bootfs"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# provide confirmation to the user
|
|
|
|
|
DIALOG " $_zfsZpoolCTitle " --infobox "\n$_zfsAutoComplete\n " 0 0
|
|
|
|
|
sleep 3
|
|
|
|
@ -1146,7 +1148,7 @@ zfs_import_pool() {
|
|
|
|
|
|
|
|
|
|
# return a list of imported zpools
|
|
|
|
|
zfs_list_pools() {
|
|
|
|
|
zpool list -H 2>/dev/null | awk '{print $1}'
|
|
|
|
|
zpool list -H 2>/dev/null | awk '{print $1}'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
zfs_new_ds() {
|
|
|
|
@ -1239,7 +1241,7 @@ zfs_destroy_dataset() {
|
|
|
|
|
sleep 3
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# better confirm this one
|
|
|
|
|
DIALOG --defaultno --yesno "$_zfsDestroyMenuConfirm1 ${zdataset} $_zfsDestroyMenuConfirm2" 0 0
|
|
|
|
|
if [ $? ]; then
|
|
|
|
@ -1267,7 +1269,7 @@ zfs_set_property () {
|
|
|
|
|
sleep 3
|
|
|
|
|
return 0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# get property/value input
|
|
|
|
|
local -i loopmenu=1
|
|
|
|
|
zfsmenubody=$_zfsSetMenuBody
|
|
|
|
@ -1436,7 +1438,7 @@ mount_partitions() {
|
|
|
|
|
ROOT_PART=${PARTITION}
|
|
|
|
|
echo ${ROOT_PART} > /tmp/.root_partitioni
|
|
|
|
|
echo ${ROOT_PART} > /tmp/.root_partition
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Reset the mountpoint variable, in case this is the second time through this menu and old state is still around
|
|
|
|
|
MOUNT=""
|
|
|
|
|
|
|
|
|
@ -1459,7 +1461,7 @@ mount_partitions() {
|
|
|
|
|
# No subvolumes present. Make some new ones
|
|
|
|
|
DIALOG " Your root volume is formatted in btrfs " --yesno "\nWould you like to create subvolumes in it? \n " 0 0 && btrfs_subvolumes
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# We need to remove legacy zfs partitions before make_swap since they can't hold swap
|
|
|
|
@ -1538,8 +1540,8 @@ get_cryptroot() {
|
|
|
|
|
# Mountpoint is not directly on LUKS device, so we need to get the crypt device above the mountpoint
|
|
|
|
|
LUKS_ROOT_NAME="$(lsblk -i | tac | sed -r 's/^[^[:alnum:]]+//' | sed -n -e "/\/mnt$/,/crypt/p" | awk '/crypt/ {print $1}')"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Check if LUKS on LVM
|
|
|
|
|
|
|
|
|
|
# Check if LUKS on LVM
|
|
|
|
|
if [[ $(lsblk -lno NAME,FSTYPE,TYPE,MOUNTPOINT | grep "lvm" | grep "/mnt$" | grep -i "crypto_luks" | uniq | awk '{print "/dev/mapper/"$1}') != "" ]]; then
|
|
|
|
|
cryptparts=$(lsblk -lno NAME,FSTYPE,TYPE,MOUNTPOINT | grep "lvm" | grep "/mnt$" | grep -i "crypto_luks" | uniq | awk '{print "/dev/mapper/"$1}')
|
|
|
|
|
for i in ${cryptparts}; do
|
|
|
|
@ -1571,14 +1573,14 @@ get_cryptroot() {
|
|
|
|
|
done
|
|
|
|
|
fi
|
|
|
|
|
echo "$LUKS_DEV" > /tmp/.luks_dev
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get_cryptboot(){
|
|
|
|
|
# If /boot is encrypted
|
|
|
|
|
if $(lsblk | sed -r 's/^[^[:alnum:]]+//' | awk '/\/mnt\/boot$/ {print $6}' | grep -q crypt) || $(lsblk -i | tac | sed -r 's/^[^[:alnum:]]+//' | sed -n -e "/\/mnt\/boot$/,/part/p" | awk '{print $6}' | grep -q crypt); then
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LUKS=1
|
|
|
|
|
boot_name=$(mount | awk '/\/mnt\/boot / {print $1}' | sed s~/dev/mapper/~~g | sed s~/dev/~~g)
|
|
|
|
|
#Get the name of the Luks device
|
|
|
|
@ -1608,7 +1610,7 @@ get_cryptboot(){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
btrfs_subvolumes() {
|
|
|
|
|
#1) save mount options and name of the root partition
|
|
|
|
|
#1) save mount options and name of the root partition
|
|
|
|
|
mount | grep "on /mnt " | grep -Po '(?<=\().*(?=\))' > /tmp/.root_mount_options
|
|
|
|
|
#lsblk -lno MOUNTPOINT,NAME | awk '/^\/mnt / {print $2}' > /tmp/.root_partition
|
|
|
|
|
#2) choose automatic or manual mode
|
|
|
|
@ -1627,7 +1629,7 @@ btrfs_subvolumes() {
|
|
|
|
|
cd
|
|
|
|
|
# Mount subvolumes
|
|
|
|
|
umount /mnt
|
|
|
|
|
# Mount the first subvolume as /
|
|
|
|
|
# Mount the first subvolume as /
|
|
|
|
|
mount -o $(cat ${MOUNT_OPTS}),subvol="$(awk '{print $1}' /tmp/.subvols)" "$(cat /tmp/.root_partition)" /mnt
|
|
|
|
|
# Remove the first subvolume from the subvolume list
|
|
|
|
|
sed -i -r 's/(\s+)?\S+//1' /tmp/.subvols
|
|
|
|
@ -1662,7 +1664,7 @@ btrfs_subvolumes() {
|
|
|
|
|
mount_existing_subvols() {
|
|
|
|
|
# Set mount options
|
|
|
|
|
format_name=$(echo ${PARTITION} | rev | cut -d/ -f1 | rev)
|
|
|
|
|
format_device=$(lsblk -i | tac | sed -r 's/^[^[:alnum:]]+//' | sed -n -e "/$format_name/,/disk/p" | awk '/disk/ {print $1}')
|
|
|
|
|
format_device=$(lsblk -i | tac | sed -r 's/^[^[:alnum:]]+//' | sed -n -e "/$format_name/,/disk/p" | awk '/disk/ {print $1}')
|
|
|
|
|
if [[ "$(cat /sys/block/${format_device}/queue/rotational)" == 1 ]]; then
|
|
|
|
|
fs_opts="autodefrag,compress=zlib,noatime,nossd,commit=120"
|
|
|
|
|
else
|
|
|
|
|