BTRFS on SUSE

Ingo Wichmann iw at linuxhotel.de
Mon Jan 11 13:32:07 CET 2016


Hi!

I've updated Fai to 5.0.1 and rewrote my config space. For most setups,
I use setup-storage now instead of custom scripts.

I use Fai to install the notebooks for our linux and open-source
trainings. My goal is that the resulting installation looks as similar
as possible to what the installer of the distribution (eg. CentOS,
Debian, Fedora, openSuSE, SLES, Ubuntu) would produce.

SuSE has been using btrfs since some time. Unfortunately, the BTRFS
support of setup-storage is not useful for that purpose. So I had to
write my own script.

If you hit a similar challenge, you may have a look at my solution in
the attached script.

Ingo

-- 
Linuxhotel GmbH, Geschäftsführer Dipl.-Ing. Ingo Wichmann
HRB 20463 Amtsgericht Essen, UStID DE 814 943 641
Antonienallee 1, 45279 Essen, Tel.: 0201 8536-600, http://www.linuxhotel.de
-------------- n�chster Teil --------------
#!/bin/bash

skiptask partition

: ${BOOT_DEVICE:=/dev/sda}
: ${LOGDIR:=/tmp/fai}
: ${target:=/target}

# setup-storage fails to wipe sometimes
[ -b ${BOOT_DEVICE}2 ] && wipefs -a -f ${BOOT_DEVICE}2

cat <<-SETUPSTORAGE > $LOGDIR/setup-storage.conf
	disk_config $BOOT_DEVICE fstabkey:uuid
	
	primary swap  1GiB          swap  sw
	primary -     16GiB-        -     -
SETUPSTORAGE

setup-storage -f $LOGDIR/setup-storage.conf -X 2>&1 | tee $LOGDIR/format.log

mkfs.btrfs ${BOOT_DEVICE}2
uuid=$(lsblk -n -o uuid ${BOOT_DEVICE}2)

mkdir $target
mount UUID="$uuid" $target || exit

btrfs subvolume create ${target%/}/@
btrfs subvolume create ${target%/}/@/.snapshots
mkdir -p               ${target%/}/@/.snapshots/1
btrfs subvolume create ${target%/}/@/.snapshots/1/snapshot
mkdir -p               ${target%/}/@/boot/grub2
btrfs subvolume create ${target%/}/@/boot/grub2/i386-pc
btrfs subvolume create ${target%/}/@/boot/grub2/x86_64-efi
btrfs subvolume create ${target%/}/@/opt
btrfs subvolume create ${target%/}/@/srv
btrfs subvolume create ${target%/}/@/tmp
mkdir -p               ${target%/}/@/usr
btrfs subvolume create ${target%/}/@/usr/local
mkdir -p               ${target%/}/@/var
btrfs subvolume create ${target%/}/@/var/crash
mkdir -p               ${target%/}/@/var/lib/libvirt
btrfs subvolume create ${target%/}/@/var/lib/libvirt/images
btrfs subvolume create ${target%/}/@/var/lib/mailman
btrfs subvolume create ${target%/}/@/var/lib/mariadb
btrfs subvolume create ${target%/}/@/var/lib/mysql
btrfs subvolume create ${target%/}/@/var/lib/named
btrfs subvolume create ${target%/}/@/var/lib/pgsql
btrfs subvolume create ${target%/}/@/var/log
btrfs subvolume create ${target%/}/@/var/opt
btrfs subvolume create ${target%/}/@/var/spool
btrfs subvolume create ${target%/}/@/var/tmp

subvolid=$(btrfs subvolume show $target/@/.snapshots/1/snapshot | sed -rn 's/.*Object ID:\s+//p')
btrfs subvolume set-default "$subvolid" "$target"

umount $target

cat <<-DISK_VAR > $LOGDIR/disk_var.sh
	SWAPLIST=\${SWAPLIST:-"${BOOT_DEVICE}1"}
	BOOT_DEVICE=\${BOOT_DEVICE:-${BOOT_DEVICE}}
	ROOT_PARTITION=\${ROOT_PARTITION:-${BOOT_DEVICE}2}
	BOOT_PARTITION=\${BOOT_PARTITION:-${BOOT_DEVICE}2}
DISK_VAR

cat <<-FSTAB >> $LOGDIR/fstab
	# device during installation: ${BOOT_DEVICE}2
	UUID=$uuid  /                        btrfs  defaults                         0  0
	UUID=$uuid  /boot/grub2/i386-pc      btrfs  subvol=@/boot/grub2/i386-pc      0  0
	UUID=$uuid  /boot/grub2/x86_64-efi   btrfs  subvol=@/boot/grub2/x86_64-efi   0  0
	UUID=$uuid  /opt                     btrfs  subvol=@/opt                     0  0
	UUID=$uuid  /srv                     btrfs  subvol=@/srv                     0  0
	UUID=$uuid  /tmp                     btrfs  subvol=@/tmp                     0  0
	UUID=$uuid  /usr/local               btrfs  subvol=@/usr/local               0  0
	UUID=$uuid  /var/crash               btrfs  subvol=@/var/crash               0  0
	UUID=$uuid  /var/lib/libvirt/images  btrfs  subvol=@/var/lib/libvirt/images  0  0
	UUID=$uuid  /var/lib/mailman         btrfs  subvol=@/var/lib/mailman         0  0
	UUID=$uuid  /var/lib/mariadb         btrfs  subvol=@/var/lib/mariadb         0  0
	UUID=$uuid  /var/lib/mysql           btrfs  subvol=@/var/lib/mysql           0  0
	UUID=$uuid  /var/lib/named           btrfs  subvol=@/var/lib/named           0  0
	UUID=$uuid  /var/lib/pgsql           btrfs  subvol=@/var/lib/pgsql           0  0
	UUID=$uuid  /var/log                 btrfs  subvol=@/var/log                 0  0
	UUID=$uuid  /var/opt                 btrfs  subvol=@/var/opt                 0  0
	UUID=$uuid  /var/spool               btrfs  subvol=@/var/spool               0  0
	UUID=$uuid  /var/tmp                 btrfs  subvol=@/var/tmp                 0  0
	UUID=$uuid  /.snapshots              btrfs  subvol=@/.snapshots              0  0
	#UUID=c8b7e681-ee5a-4fcc-9e47-253037c2139c /home                xfs        defaults              1 2
FSTAB



More information about the linux-fai mailing list