From 82c1b5a67b250afbcb96c9460ff006f3d02c76cd Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Thu, 7 May 2015 13:44:44 +0200 Subject: Prefer BTRFS over LVM2. --- include/partition.sh | 66 +++++++++++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 29 deletions(-) (limited to 'include') diff --git a/include/partition.sh b/include/partition.sh index 10c17a0..35f259a 100755 --- a/include/partition.sh +++ b/include/partition.sh @@ -85,16 +85,26 @@ encrypt=$RET db_set grub-installer/bootdev "${device%% *}" db_fset grub-installer/bootdev seen true +part_efi= part_boot= +part_swap= part_system= # Create boot and system partitions for d in $device; do - pb=$( fripost_mkpart $d boot 64M ) - ps=$( fripost_mkpart $d system 100% ) - part_boot="${part_boot:+$part_boot }$pb" - part_system="${part_system:+$part_system }$ps" - /sbin/parted -s $d align-check opt ${ps#$d} \ - || fatal "$ps is not aligned" + p=$( fripost_mkpart $d boot 64M ) + part_boot="${part_boot:+$part_boot }$p" + + p=$( fripost_mkpart $d swap 1G ) # FIXME + part_swap="${part_swap:+$part_swap }$p" + /sbin/parted -s $d align-check opt ${p#$d} \ + || fatal "$p is not aligned" + + p=$( fripost_mkpart $d system 100% ) + part_system="${part_system:+$part_system }$p" + /sbin/parted -s $d align-check opt ${p#$d} \ + || fatal "$p is not aligned" + + log "Done with device $d" done # Create an array on top of that @@ -106,6 +116,11 @@ if [ ${raidLevel:-} ]; then fripost_mdadm_create "$part_boot" -f -R -l $raidLevel \ ${raidNumActiveDevices:+-n $raidNumActiveDevices} $devices + devices="$part_swap" + part_swap=/dev/md/swap + fripost_mdadm_create "$part_swap" -f -R -l raid0 \ + ${raidNumActiveDevices:+-n $raidNumActiveDevices} $devices + devices="$part_system" part_system=/dev/md/system fripost_mdadm_create "$part_system" -f -R -l $raidLevel \ @@ -148,31 +163,24 @@ if [ $encrypt = true ]; then fi -# Ensure LVM2 is installed in the target chroot; create logical volumes -# for /, swap and /home. -apt-install lvm2 || true -vg=$(hostname) -pvcreate -ff -y $part_system -vgcreate $vg $part_system - -lvcreate -L 5G -n root $vg # FIXME -lvcreate -L 1G -n swap $vg # FIXME -lvcreate -l 100%FREE -n home $vg # FIXME -vgchange -ay $vg - - # Format the partitions -fripost_mkfs ext2 $part_boot -E resize=512M -m1 -b 4096 -fripost_mkfs ext4 /dev/$vg/root -b 4096 -fripost_mkfs ext4 /dev/$vg/home -b 4096 -mkswap /dev/$vg/swap +fripost_mkfs ext2 "$part_boot" -F -E resize=512M -m1 -b 4096 +fripost_mkfs btrfs "$part_system" -f +mkswap "$part_swap" + +# Create BTRFS subvolumes +mkdir -p /target +apt-install btrfs-tools || true +mount -t btrfs -o compress=lzo "$part_system" /target +btrfs subvol create /target/@ +btrfs subvol create /target/@home +umount /target # Stuff the fstab and mount the devices in the target -fripost_fstab $part_boot /boot ext2 noatime -[ -d /proc/efi -o -d /sys/firmware/efi ] && \ -fripost_fstab $part_efi /boot/efi vfat defaults -fripost_fstab /dev/$vg/root / ext4 noatime,errors=remount-ro -fripost_fstab /dev/$vg/swap none swap sw -fripost_fstab /dev/$vg/home /home ext4 noatime +fripost_fstab "$part_boot" /boot ext2 defaults +fripost_fstab "$part_efi" /boot/efi vfat defaults +fripost_fstab "$part_system" / btrfs compress=lzo,subvol=@ +fripost_fstab "$part_system" /home btrfs compress=lzo,subvol=@home +fripost_fstab "$part_swap" none swap sw fripost_mount_partitions -- cgit v1.2.3