Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- SCRIPT="2part.sh"
- case "$1" in
- installer)
- # Substitute partman with this script
- sed -i "s|partman|/tmp/$SCRIPT partman|" /var/lib/dpkg/info/partman-base.postinst
- logger "Modified partman-base.postinst. Partitioning will be handled by /tmp/$SCRIPT instead of partman."
- ;;
- partman)
- logger "$SCRIPT partition configuration progress started"
- # Ensure that the device mapper module is loaded
- modprobe dm_mod
- # Wipe the MBR and initialise a new partition table
- dd if=/dev/zero of=/dev/sda bs=512 count=1
- parted -s /dev/sda -- mklabel msdos
- # Create a 2G partition for the root filesystem. Use the rest for LVM.
- parted -s /dev/sda -- mkpart primary 2048s 4196351s
- parted -s /dev/sda -- mkpart primary 4196352s -1s
- parted -s /dev/sda -- toggle 2 lvm
- # Create a single physical volume then create a volume group with it
- pvcreate -ff -y /dev/sda2
- vgcreate vg0 /dev/sda2
- # Allocate 10G for /usr
- lvcreate -L10G -nusr vg0
- # Allocate as much space as possible for /var but leave 100G free. It
- # gives us room to maneuver and also allows for snapshotting.
- LVM2_VG_FREE=`vgs --noheadings --units m -o vg_free vg0 | cut -d. -f1`
- VAR_SIZE=`expr $VG_FREE - 1000000`
- lvcreate -nvar -L${VAR_SIZE}M vg0
- # Create and mount the root filesystem
- mkfs.ext4 -q -FF /dev/sda1
- mkdir /target
- mount /dev/sda1 /target
- # Create and mount the other filesystems
- for fs in usr var; do
- mkfs.xfs -q -f /dev/vg0/$fs
- mkdir -p /target/$fs
- mount /dev/vg0/$fs /target/$fs
- done
- # Create fstab ... TODO
- ;;
- *)
- echo "$0: This script is destructive and should only be run as part of the debian-installer process!"
- ;;
- esac
Add Comment
Please, Sign In to add comment