mirror of
https://github.com/tboerger/nixos-config
synced 2024-11-22 18:21:58 +01:00
chore: restructure partitioning
This commit is contained in:
parent
de3c0f004e
commit
2145a25f35
@ -39,54 +39,91 @@ if [[ -d /dev/md ]]; then
|
||||
done
|
||||
fi
|
||||
|
||||
echo "----> Drop existing partitions"
|
||||
wipefs -a /dev/disk/by-path/pci-0000:00:14.1-ata-1 || true
|
||||
sfdisk --delete /dev/disk/by-path/pci-0000:00:14.1-ata-1 || true
|
||||
echo "----> Remove previous MDs"
|
||||
if [[ -d /dev/md ]]; then
|
||||
for MD in /dev/md/*; do
|
||||
mdadm --stop $MD
|
||||
done
|
||||
fi
|
||||
|
||||
sgdisk --zap-all /dev/disk/by-path/pci-0000:00:11.0-ata-1.0
|
||||
sgdisk -og /dev/disk/by-path/pci-0000:00:11.0-ata-1.0
|
||||
sgdisk --zap-all /dev/disk/by-path/pci-0000:00:11.0-ata-2.0
|
||||
sgdisk -og /dev/disk/by-path/pci-0000:00:11.0-ata-2.0
|
||||
sgdisk --zap-all /dev/disk/by-path/pci-0000:00:11.0-ata-3.0
|
||||
sgdisk -og /dev/disk/by-path/pci-0000:00:11.0-ata-3.0
|
||||
sgdisk --zap-all /dev/disk/by-path/pci-0000:00:11.0-ata-4.0
|
||||
sgdisk -og /dev/disk/by-path/pci-0000:00:11.0-ata-4.0
|
||||
echo "----> Drop existing partitions"
|
||||
for DISK in pci-0000:00:14.1-ata-1 pci-0000:00:11.0-ata-1.0 pci-0000:00:11.0-ata-2.0 pci-0000:00:11.0-ata-3.0 pci-0000:00:11.0-ata-4.0; do
|
||||
sgdisk --zap-all /dev/disk/by-path/${DISK}
|
||||
sgdisk -og /dev/disk/by-path/${DISK}
|
||||
done
|
||||
|
||||
echo "-----> Wait for cleanup"
|
||||
sleep 3
|
||||
sync
|
||||
|
||||
echo "-----> Mark MBR disks"
|
||||
echo yes | parted -s /dev/disk/by-path/pci-0000:00:14.1-ata-1 -- mklabel msdos
|
||||
echo "-----> Create sda partitions"
|
||||
parted -a opt --script /dev/disk/by-path/pci-0000:00:14.1-ata-1 \
|
||||
mklabel gpt \
|
||||
mkpart primary 1MB 1GB \
|
||||
set 1 bios_grub on \
|
||||
name 1 boot \
|
||||
mkpart primary 1GB 100% \
|
||||
set 2 lvm on \
|
||||
name 2 system
|
||||
|
||||
echo "-----> Create boot partition"
|
||||
parted /dev/disk/by-path/pci-0000:00:14.1-ata-1 -- mkpart primary ext4 1MB 1GB
|
||||
parted /dev/disk/by-path/pci-0000:00:14.1-ata-1 -- set 1 boot on
|
||||
echo "-----> Create sdb partitions"
|
||||
parted -a opt --script /dev/disk/by-path/pci-0000:00:11.0-ata-1 \
|
||||
mklabel gpt \
|
||||
mkpart primary 1GB 100% \
|
||||
set 1 lvm on \
|
||||
name 1 tank1
|
||||
|
||||
echo "-----> Create root partition"
|
||||
parted /dev/disk/by-path/pci-0000:00:14.1-ata-1 -- mkpart primary ext4 1GB 100%
|
||||
echo "-----> Create sdc partitions"
|
||||
parted -a opt --script /dev/disk/by-path/pci-0000:00:11.0-ata-2 \
|
||||
mklabel gpt \
|
||||
mkpart primary 1GB 100% \
|
||||
set 1 lvm on \
|
||||
name 1 tank2
|
||||
|
||||
echo "-----> Create tank partition"
|
||||
sgdisk -n 0:0:0 -t 0:8300 -c 0:tank /dev/disk/by-path/pci-0000:00:11.0-ata-1
|
||||
sgdisk -n 0:0:0 -t 0:8300 -c 0:tank /dev/disk/by-path/pci-0000:00:11.0-ata-2
|
||||
sgdisk -n 0:0:0 -t 0:8300 -c 0:tank /dev/disk/by-path/pci-0000:00:11.0-ata-3
|
||||
sgdisk -n 0:0:0 -t 0:8300 -c 0:tank /dev/disk/by-path/pci-0000:00:11.0-ata-4
|
||||
echo "-----> Create sdd partitions"
|
||||
parted -a opt --script /dev/disk/by-path/pci-0000:00:11.0-ata-3 \
|
||||
mklabel gpt \
|
||||
mkpart primary 1GB 100% \
|
||||
set 1 lvm on \
|
||||
name 1 tank3
|
||||
|
||||
echo "-----> Wait for data"
|
||||
echo "-----> Create sde partitions"
|
||||
parted -a opt --script /dev/disk/by-path/pci-0000:00:11.0-ata-4 \
|
||||
mklabel gpt \
|
||||
mkpart primary 1GB 100% \
|
||||
set 1 lvm on \
|
||||
name 1 tank4
|
||||
|
||||
echo "-----> Reload partition table"
|
||||
partprobe
|
||||
|
||||
echo "-----> Create raid0 volume"
|
||||
echo yes | mdadm --create /dev/md0 --level=10 --raid-devices=4 /dev/disk/by-partlabel/tank1 /dev/disk/by-partlabel/tank2 /dev/disk/by-partlabel/tank3 /dev/disk/by-partlabel/tank4
|
||||
|
||||
echo "-----> Wait for raids"
|
||||
sleep 3
|
||||
sync
|
||||
|
||||
echo "-----> Create data pv"
|
||||
pvcreate /dev/disk/by-path/pci-0000:00:14.1-ata-1-part2
|
||||
pvcreate /dev/disk/by-partlabel/system
|
||||
|
||||
echo "-----> Create data vg"
|
||||
vgcreate system /dev/disk/by-path/pci-0000:00:14.1-ata-1-part2
|
||||
vgcreate system /dev/disk/by-partlabel/system
|
||||
|
||||
echo "-----> Create tank pv"
|
||||
pvcreate /dev/md0
|
||||
|
||||
echo "-----> Create tank vg"
|
||||
vgcreate tank /dev/md0
|
||||
|
||||
echo "-----> Create swap volume"
|
||||
lvcreate -y --size 24G --name swap system
|
||||
lvcreate -y --size $(cat /proc/meminfo | grep MemTotal | cut -d':' -f2 | sed 's/ //g') --name swap system
|
||||
|
||||
echo "-----> Create root volume"
|
||||
lvcreate -y --size 50G --name root system
|
||||
lvcreate -y --size 20G --name root system
|
||||
|
||||
echo "-----> Create nix volume"
|
||||
lvcreate -y --size 50G --name nix system
|
||||
|
||||
echo "-----> Create home volume"
|
||||
lvcreate -y --size 50G --name home system
|
||||
@ -99,42 +136,45 @@ echo "-----> Create root filesystem"
|
||||
mkfs.ext4 -L root /dev/system/root
|
||||
|
||||
echo "-----> Mount root filesystem"
|
||||
mkdir -p /mnt
|
||||
mount -t ext4 /dev/system/root /mnt
|
||||
|
||||
echo "-----> Create nix filesystem"
|
||||
mkfs.ext4 -L nix /dev/system/nix
|
||||
|
||||
echo "-----> Mount nix filesystem"
|
||||
mkdir -p /mnt/nix
|
||||
mount -t ext4 /dev/system/nix /mnt/nix
|
||||
|
||||
echo "-----> Create home filesystem"
|
||||
mkfs.ext4 -L home /dev/system/home
|
||||
|
||||
echo "-----> Mount home filesystem"
|
||||
mkdir /mnt/home
|
||||
mkdir -p /mnt/home
|
||||
mount -t ext4 /dev/system/home /mnt/home
|
||||
|
||||
echo "-----> Create boot filesystem"
|
||||
mkfs.ext4 -L boot /dev/disk/by-path/pci-0000:00:14.1-ata-1-part1
|
||||
mkfs.ext4 -L boot /dev/disk/by-partlabel/boot1
|
||||
|
||||
echo "-----> Mount boot filesystem"
|
||||
mkdir /mnt/boot
|
||||
mount /dev/disk/by-path/pci-0000:00:14.1-ata-1-part1 /mnt/boot
|
||||
mkdir -p /mnt/boot
|
||||
mount /dev/disk/by-partlabel/boot1 /mnt/boot
|
||||
|
||||
echo "-----> Wait for filesystems"
|
||||
sleep 3
|
||||
sync
|
||||
#
|
||||
# STORAGE
|
||||
#
|
||||
|
||||
echo "----> Remove previous MDs"
|
||||
if [[ -d /dev/md ]]; then
|
||||
for MD in /dev/md/*; do
|
||||
mdadm --stop $MD
|
||||
for PARTITION in ; do
|
||||
echo "-----> Create ${PARTITION} volume"
|
||||
lvcreate -y --size 5G --name ${PARTITION} system
|
||||
|
||||
echo "-----> Create ${PARTITION} filesystem"
|
||||
mkfs.ext4 -L ${PARTITION} /dev/system/${PARTITION}
|
||||
|
||||
echo "-----> Mount ${PARTITION} filesystem"
|
||||
mkdir /mnt/var/lib/${PARTITION}
|
||||
mount -t ext4 /dev/system/${PARTITION} /mnt/var/lib/${PARTITION}
|
||||
done
|
||||
fi
|
||||
|
||||
echo "-----> Create raid volume"
|
||||
echo yes | mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/disk/by-path/pci-0000:00:11.0-ata-1.0-part1 /dev/disk/by-path/pci-0000:00:11.0-ata-2.0-part1
|
||||
echo yes | mdadm --create /dev/md1 --level=1 --raid-devices=2 /dev/disk/by-path/pci-0000:00:11.0-ata-3.0-part1 /dev/disk/by-path/pci-0000:00:11.0-ata-4.0-part1
|
||||
|
||||
echo "-----> Create tank pv"
|
||||
pvcreate /dev/md0 /dev/md1
|
||||
|
||||
echo "-----> Create tank vg"
|
||||
vgcreate tank /dev/md0 /dev/md1
|
||||
|
||||
echo "-----> Create shares volume"
|
||||
lvcreate -y --size 10G --name shares tank
|
||||
@ -143,9 +183,8 @@ echo "-----> Create shares filesystem"
|
||||
mkfs.ext4 -L shares /dev/tank/shares
|
||||
|
||||
echo "-----> Mount shares filesystem"
|
||||
mkdir -p /mnt/var/lib/media/shares
|
||||
mount -t ext4 /dev/tank/shares /mnt/var/lib/media/shares
|
||||
chown 20000:20000 /mnt/var/lib/media/shares
|
||||
mkdir -p /mnt/var/lib/shares
|
||||
mount -t ext4 /dev/tank/shares /mnt/var/lib/shares
|
||||
|
||||
echo "-----> Create photos volume"
|
||||
lvcreate -y --size 100G --name photos tank
|
||||
@ -154,9 +193,8 @@ echo "-----> Create photos filesystem"
|
||||
mkfs.ext4 -L photos /dev/tank/photos
|
||||
|
||||
echo "-----> Mount photos filesystem"
|
||||
mkdir -p /mnt/var/lib/media/photos
|
||||
mount -t ext4 /dev/tank/photos /mnt/var/lib/media/photos
|
||||
chown 20000:20000 /mnt/var/lib/media/photos
|
||||
mkdir -p /mnt/var/lib/photos
|
||||
mount -t ext4 /dev/tank/photos /mnt/var/lib/photos
|
||||
|
||||
echo "-----> Create videos volume"
|
||||
lvcreate -y --size 100G --name videos tank
|
||||
@ -165,56 +203,11 @@ echo "-----> Create videos filesystem"
|
||||
mkfs.ext4 -L videos /dev/tank/videos
|
||||
|
||||
echo "-----> Mount videos filesystem"
|
||||
mkdir -p /mnt/var/lib/media/videos
|
||||
mount -t ext4 /dev/tank/videos /mnt/var/lib/media/videos
|
||||
chown 20000:20000 /mnt/var/lib/media/videos
|
||||
|
||||
echo "-----> Create movies volume"
|
||||
lvcreate -y --size 500G --name movies tank
|
||||
|
||||
echo "-----> Create movies filesystem"
|
||||
mkfs.ext4 -L movies /dev/tank/movies
|
||||
|
||||
echo "-----> Mount movies filesystem"
|
||||
mkdir -p /mnt/var/lib/media/movies
|
||||
mount -t ext4 /dev/tank/movies /mnt/var/lib/media/movies
|
||||
chown 20000:20000 /mnt/var/lib/media/movies
|
||||
|
||||
echo "-----> Create shows volume"
|
||||
lvcreate -y --size 500G --name shows tank
|
||||
|
||||
echo "-----> Create shows filesystem"
|
||||
mkfs.ext4 -L shows /dev/tank/shows
|
||||
|
||||
echo "-----> Mount shows filesystem"
|
||||
mkdir -p /mnt/var/lib/media/shows
|
||||
mount -t ext4 /dev/tank/shows /mnt/var/lib/media/shows
|
||||
chown 20000:20000 /mnt/var/lib/media/shows
|
||||
|
||||
echo "-----> Create books volume"
|
||||
lvcreate -y --size 50G --name books tank
|
||||
|
||||
echo "-----> Create books filesystem"
|
||||
mkfs.ext4 -L books /dev/tank/books
|
||||
|
||||
echo "-----> Mount books filesystem"
|
||||
mkdir -p /mnt/var/lib/media/books
|
||||
mount -t ext4 /dev/tank/books /mnt/var/lib/media/books
|
||||
chown 20000:20000 /mnt/var/lib/media/books
|
||||
|
||||
echo "-----> Create music volume"
|
||||
lvcreate -y --size 50G --name music tank
|
||||
|
||||
echo "-----> Create music filesystem"
|
||||
mkfs.ext4 -L music /dev/tank/music
|
||||
|
||||
echo "-----> Mount music filesystem"
|
||||
mkdir -p /mnt/var/lib/media/music
|
||||
mount -t ext4 /dev/tank/music /mnt/var/lib/media/music
|
||||
chown 20000:20000 /mnt/var/lib/media/music
|
||||
mkdir -p /mnt/var/lib/videos
|
||||
mount -t ext4 /dev/tank/videos /mnt/var/lib/videos
|
||||
|
||||
echo "-----> Create printer volume"
|
||||
lvcreate -y --size 5G --name printer tank
|
||||
lvcreate -y --size 10G --name printer tank
|
||||
|
||||
echo "-----> Create printer filesystem"
|
||||
mkfs.ext4 -L printer /dev/tank/printer
|
||||
@ -222,10 +215,9 @@ mkfs.ext4 -L printer /dev/tank/printer
|
||||
echo "-----> Mount printer filesystem"
|
||||
mkdir -p /mnt/var/lib/printer
|
||||
mount -t ext4 /dev/tank/printer /mnt/var/lib/printer
|
||||
chown 20001:20001 /mnt/var/lib/printer
|
||||
|
||||
echo "-----> Create backup volume"
|
||||
lvcreate -y --size 50G --name backup tank
|
||||
lvcreate -y --size 1000G --name backup tank
|
||||
|
||||
echo "-----> Create backup filesystem"
|
||||
mkfs.ext4 -L backup /dev/tank/backup
|
||||
|
@ -32,33 +32,48 @@ for PV in $(pvs --noheadings 2>/dev/null | sed -e 's/^[[:space:]]*//' | cut -d"
|
||||
pvremove -y ${PV} 2>/dev/null
|
||||
done
|
||||
|
||||
echo "----> Remove previous MDs"
|
||||
if [[ -d /dev/md ]]; then
|
||||
for MD in /dev/md/*; do
|
||||
mdadm --stop $MD
|
||||
done
|
||||
fi
|
||||
|
||||
echo "----> Remove previous MDs"
|
||||
if [[ -d /dev/md ]]; then
|
||||
for MD in /dev/md/*; do
|
||||
mdadm --stop $MD
|
||||
done
|
||||
fi
|
||||
|
||||
echo "----> Drop existing partitions"
|
||||
sgdisk --zap-all /dev/disk/by-path/pci-0000:00:1f.2-ata-1.0
|
||||
sgdisk -og /dev/disk/by-path/pci-0000:00:1f.2-ata-1.0
|
||||
for DISK in pci-0000:00:1f.2-ata-1.0; do
|
||||
sgdisk --zap-all /dev/disk/by-path/${DISK}
|
||||
sgdisk -og /dev/disk/by-path/${DISK}
|
||||
done
|
||||
|
||||
echo "-----> Wait for cleanup"
|
||||
sleep 3
|
||||
sync
|
||||
|
||||
echo "-----> Create sda partitions"
|
||||
parted -a opt --script /dev/disk/by-path/pci-0000:00:1f.2-ata-1.0 \
|
||||
parted -a opt --script /dev/disk/by-path/pci-0000:00:14.1-ata-1 \
|
||||
mklabel gpt \
|
||||
mkpart primary fat32 0% 1GiB \
|
||||
mkpart primary 1GiB 100% \
|
||||
mkpart primary fat32 0% 1GB \
|
||||
set 1 esp on \
|
||||
name 1 boot \
|
||||
mkpart primary 1GB 100% \
|
||||
set 2 lvm on \
|
||||
name 2 data
|
||||
name 2 system
|
||||
|
||||
echo "-----> Wait for partitions"
|
||||
sleep 3
|
||||
sync
|
||||
echo "-----> Reload partition table"
|
||||
partprobe
|
||||
|
||||
echo "-----> Create data pv"
|
||||
pvcreate /dev/disk/by-partlabel/data
|
||||
pvcreate /dev/disk/by-partlabel/system
|
||||
|
||||
echo "-----> Create data vg"
|
||||
vgcreate system /dev/disk/by-partlabel/data
|
||||
vgcreate system /dev/disk/by-partlabel/system
|
||||
|
||||
echo "-----> Create swap volume"
|
||||
lvcreate -y --size $(cat /proc/meminfo | grep MemTotal | cut -d':' -f2 | sed 's/ //g') --name swap system
|
||||
@ -80,25 +95,42 @@ echo "-----> Create root filesystem"
|
||||
mkfs.ext4 -L root /dev/system/root
|
||||
|
||||
echo "-----> Mount root filesystem"
|
||||
mkdir -p /mnt
|
||||
mount -t ext4 /dev/system/root /mnt
|
||||
|
||||
echo "-----> Create nix filesystem"
|
||||
mkfs.ext4 -L nix /dev/system/nix
|
||||
|
||||
echo "-----> Mount nix filesystem"
|
||||
mkdir /mnt/nix
|
||||
mkdir -p /mnt/nix
|
||||
mount -t ext4 /dev/system/nix /mnt/nix
|
||||
|
||||
echo "-----> Create home filesystem"
|
||||
mkfs.ext4 -L home /dev/system/home
|
||||
|
||||
echo "-----> Mount home filesystem"
|
||||
mkdir /mnt/home
|
||||
mkdir -p /mnt/home
|
||||
mount -t ext4 /dev/system/home /mnt/home
|
||||
|
||||
echo "-----> Create boot filesystem"
|
||||
mkfs.vfat -F32 -n boot /dev/disk/by-partlabel/boot
|
||||
|
||||
echo "-----> Mount boot filesystem"
|
||||
mkdir /mnt/boot
|
||||
mkdir -p /mnt/boot
|
||||
mount /dev/disk/by-label/boot /mnt/boot
|
||||
|
||||
#
|
||||
# STORAGE
|
||||
#
|
||||
|
||||
for PARTITION in ; do
|
||||
echo "-----> Create ${PARTITION} volume"
|
||||
lvcreate -y --size 5G --name ${PARTITION} system
|
||||
|
||||
echo "-----> Create ${PARTITION} filesystem"
|
||||
mkfs.ext4 -L ${PARTITION} /dev/system/${PARTITION}
|
||||
|
||||
echo "-----> Mount ${PARTITION} filesystem"
|
||||
mkdir /mnt/var/lib/${PARTITION}
|
||||
mount -t ext4 /dev/system/${PARTITION} /mnt/var/lib/${PARTITION}
|
||||
done
|
||||
|
@ -32,15 +32,18 @@ for PV in $(pvs --noheadings 2>/dev/null | sed -e 's/^[[:space:]]*//' | cut -d"
|
||||
pvremove -y ${PV} 2>/dev/null
|
||||
done
|
||||
|
||||
echo "----> Remove previous MDs"
|
||||
if [[ -d /dev/md ]]; then
|
||||
for MD in /dev/md/*; do
|
||||
mdadm --stop $MD
|
||||
done
|
||||
fi
|
||||
|
||||
echo "----> Drop existing partitions"
|
||||
sgdisk --zap-all /dev/disk/by-path/pci-0000:00:1f.2-ata-3.0
|
||||
sgdisk -og /dev/disk/by-path/pci-0000:00:1f.2-ata-3.0
|
||||
sgdisk --zap-all /dev/disk/by-path/pci-0000:00:1f.2-ata-4.0
|
||||
sgdisk -og /dev/disk/by-path/pci-0000:00:1f.2-ata-4.0
|
||||
sgdisk --zap-all /dev/disk/by-path/pci-0000:00:1f.2-ata-5.0
|
||||
sgdisk -og /dev/disk/by-path/pci-0000:00:1f.2-ata-5.0
|
||||
sgdisk --zap-all /dev/disk/by-path/pci-0000:00:1f.2-ata-6.0
|
||||
sgdisk -og /dev/disk/by-path/pci-0000:00:1f.2-ata-6.0
|
||||
for DISK in pci-0000:00:1f.2-ata-3.0 pci-0000:00:1f.2-ata-4.0 pci-0000:00:1f.2-ata-5.0 pci-0000:00:1f.2-ata-6.0; do
|
||||
sgdisk --zap-all /dev/disk/by-path/${DISK}
|
||||
sgdisk -og /dev/disk/by-path/${DISK}
|
||||
done
|
||||
|
||||
echo "-----> Wait for cleanup"
|
||||
sleep 3
|
||||
@ -49,47 +52,50 @@ sync
|
||||
echo "-----> Create sda partitions"
|
||||
parted -a opt --script /dev/disk/by-path/pci-0000:00:1f.2-ata-3.0 \
|
||||
mklabel gpt \
|
||||
mkpart primary fat32 0% 1GiB \
|
||||
mkpart primary 1GiB 100% \
|
||||
set 1 esp on \
|
||||
mkpart primary 1MB 1GB \
|
||||
set 1 bios_grub on \
|
||||
name 1 boot1 \
|
||||
mkpart primary 1GB 100% \
|
||||
set 2 lvm on \
|
||||
name 2 tank1
|
||||
|
||||
echo "-----> Create sdb partitions"
|
||||
parted -a opt --script /dev/disk/by-path/pci-0000:00:1f.2-ata-4.0 \
|
||||
mklabel gpt \
|
||||
mkpart primary fat32 0% 1GiB \
|
||||
mkpart primary 1GiB 100% \
|
||||
set 1 esp on \
|
||||
mkpart primary 1MB 1GB \
|
||||
set 1 bios_grub on \
|
||||
name 1 boot2 \
|
||||
mkpart primary 1GB 100% \
|
||||
set 2 lvm on \
|
||||
name 2 tank2
|
||||
|
||||
echo "-----> Create sdc partitions"
|
||||
parted -a opt --script /dev/disk/by-path/pci-0000:00:1f.2-ata-5.0 \
|
||||
mklabel gpt \
|
||||
mkpart primary fat32 0% 1GiB \
|
||||
mkpart primary 1GiB 100% \
|
||||
set 1 esp on \
|
||||
mkpart primary 1MB 1GB \
|
||||
set 1 bios_grub on \
|
||||
name 1 boot3 \
|
||||
mkpart primary 1GB 100% \
|
||||
set 2 lvm on \
|
||||
name 2 tank3
|
||||
|
||||
echo "-----> Create sdd partitions"
|
||||
parted -a opt --script /dev/disk/by-path/pci-0000:00:1f.2-ata-6.0 \
|
||||
mklabel gpt \
|
||||
mkpart primary fat32 0% 1GiB \
|
||||
mkpart primary 1GiB 100% \
|
||||
set 1 esp on \
|
||||
mkpart primary 1MB 1GB \
|
||||
set 1 bios_grub on \
|
||||
name 1 boot4 \
|
||||
mkpart primary 1GB 100% \
|
||||
set 2 lvm on \
|
||||
name 2 tank4
|
||||
|
||||
echo "-----> Create raid10 volume"
|
||||
echo "-----> Reload partition table"
|
||||
partprobe
|
||||
|
||||
echo "-----> Create raid0 volume"
|
||||
echo yes | mdadm --create /dev/md0 --level=10 --raid-devices=4 /dev/disk/by-partlabel/tank1 /dev/disk/by-partlabel/tank2 /dev/disk/by-partlabel/tank3 /dev/disk/by-partlabel/tank4
|
||||
|
||||
echo "-----> Wait for partitions"
|
||||
echo "-----> Wait for raids"
|
||||
sleep 3
|
||||
sync
|
||||
|
||||
@ -103,13 +109,13 @@ echo "-----> Create swap volume"
|
||||
lvcreate -y --size $(cat /proc/meminfo | grep MemTotal | cut -d':' -f2 | sed 's/ //g') --name swap system
|
||||
|
||||
echo "-----> Create root volume"
|
||||
lvcreate -y --size 10G --name root system
|
||||
lvcreate -y --size 20G --name root system
|
||||
|
||||
echo "-----> Create nix volume"
|
||||
lvcreate -y --size 45G --name nix system
|
||||
lvcreate -y --size 50G --name nix system
|
||||
|
||||
echo "-----> Create home volume"
|
||||
lvcreate -y --size 1G --name home system
|
||||
lvcreate -y --size 50G --name home system
|
||||
|
||||
echo "-----> Enable swap partition"
|
||||
mkswap -L swap /dev/system/swap
|
||||
@ -137,11 +143,27 @@ mkdir -p /mnt/home
|
||||
mount -t ext4 /dev/system/home /mnt/home
|
||||
|
||||
echo "-----> Create boot filesystem"
|
||||
mkfs.vfat -F32 -n boot1 /dev/disk/by-partlabel/boot1
|
||||
mkfs.ext4 -L boot /dev/disk/by-partlabel/boot1
|
||||
|
||||
echo "-----> Mount boot filesystem"
|
||||
mkdir -p /mnt/boot
|
||||
mount /dev/disk/by-label/boot1 /mnt/boot
|
||||
mount /dev/disk/by-partlabel/boot1 /mnt/boot
|
||||
|
||||
#
|
||||
# STORAGE
|
||||
#
|
||||
|
||||
for PARTITION in ; do
|
||||
echo "-----> Create ${PARTITION} volume"
|
||||
lvcreate -y --size 5G --name ${PARTITION} system
|
||||
|
||||
echo "-----> Create ${PARTITION} filesystem"
|
||||
mkfs.ext4 -L ${PARTITION} /dev/system/${PARTITION}
|
||||
|
||||
echo "-----> Mount ${PARTITION} filesystem"
|
||||
mkdir /mnt/var/lib/${PARTITION}
|
||||
mount -t ext4 /dev/system/${PARTITION} /mnt/var/lib/${PARTITION}
|
||||
done
|
||||
|
||||
echo "-----> Create movies volume"
|
||||
lvcreate -y --size 2000G --name movies system
|
||||
|
@ -32,11 +32,25 @@ for PV in $(pvs --noheadings 2>/dev/null | sed -e 's/^[[:space:]]*//' | cut -d"
|
||||
pvremove -y ${PV} 2>/dev/null
|
||||
done
|
||||
|
||||
echo "----> Remove previous MDs"
|
||||
if [[ -d /dev/md ]]; then
|
||||
for MD in /dev/md/*; do
|
||||
mdadm --stop $MD
|
||||
done
|
||||
fi
|
||||
|
||||
echo "----> Remove previous MDs"
|
||||
if [[ -d /dev/md ]]; then
|
||||
for MD in /dev/md/*; do
|
||||
mdadm --stop $MD
|
||||
done
|
||||
fi
|
||||
|
||||
echo "----> Drop existing partitions"
|
||||
sgdisk --zap-all /dev/disk/by-path/pci-0000:00:1f.2-ata-1.0
|
||||
sgdisk -og /dev/disk/by-path/pci-0000:00:1f.2-ata-1.0
|
||||
sgdisk --zap-all /dev/disk/by-path/pci-0000:00:1f.2-ata-2.0
|
||||
sgdisk -og /dev/disk/by-path/pci-0000:00:1f.2-ata-2.0
|
||||
for DISK in pci-0000:00:1f.2-ata-1.0 pci-0000:00:1f.2-ata-2.0; do
|
||||
sgdisk --zap-all /dev/disk/by-path/${DISK}
|
||||
sgdisk -og /dev/disk/by-path/${DISK}
|
||||
done
|
||||
|
||||
echo "-----> Wait for cleanup"
|
||||
sleep 3
|
||||
@ -45,29 +59,34 @@ sync
|
||||
echo "-----> Create sda partitions"
|
||||
parted -a opt --script /dev/disk/by-path/pci-0000:00:1f.2-ata-1.0 \
|
||||
mklabel gpt \
|
||||
mkpart primary fat32 0% 1GiB \
|
||||
mkpart primary 1GiB 100% \
|
||||
mkpart primary fat32 0% 1GB \
|
||||
set 1 esp on \
|
||||
name 1 boot \
|
||||
mkpart primary 1GB 100% \
|
||||
set 2 lvm on \
|
||||
name 2 data
|
||||
name 2 system
|
||||
|
||||
echo "-----> Create sdb partitions"
|
||||
parted -a opt --script /dev/disk/by-path/pci-0000:00:1f.2-ata-2.0 \
|
||||
mklabel gpt \
|
||||
mkpart primary 0% 100% \
|
||||
set 1 lvm on \
|
||||
name 1 tank1
|
||||
name 1 tank
|
||||
|
||||
echo "-----> Wait for partitions"
|
||||
sleep 3
|
||||
sync
|
||||
echo "-----> Reload partition table"
|
||||
partprobe
|
||||
|
||||
echo "-----> Create data pv"
|
||||
pvcreate /dev/disk/by-partlabel/data
|
||||
pvcreate /dev/disk/by-partlabel/system
|
||||
|
||||
echo "-----> Create data vg"
|
||||
vgcreate system /dev/disk/by-partlabel/data
|
||||
vgcreate system /dev/disk/by-partlabel/system
|
||||
|
||||
echo "-----> Create tank pv"
|
||||
pvcreate /dev/disk/by-partlabel/tank
|
||||
|
||||
echo "-----> Create tank vg"
|
||||
vgcreate tank /dev/disk/by-partlabel/tank
|
||||
|
||||
echo "-----> Create swap volume"
|
||||
lvcreate -y --size $(cat /proc/meminfo | grep MemTotal | cut -d':' -f2 | sed 's/ //g') --name swap system
|
||||
@ -89,54 +108,42 @@ echo "-----> Create root filesystem"
|
||||
mkfs.ext4 -L root /dev/system/root
|
||||
|
||||
echo "-----> Mount root filesystem"
|
||||
mkdir -p /mnt
|
||||
mount -t ext4 /dev/system/root /mnt
|
||||
|
||||
echo "-----> Create nix filesystem"
|
||||
mkfs.ext4 -L nix /dev/system/nix
|
||||
|
||||
echo "-----> Mount nix filesystem"
|
||||
mkdir /mnt/nix
|
||||
mkdir -p /mnt/nix
|
||||
mount -t ext4 /dev/system/nix /mnt/nix
|
||||
|
||||
echo "-----> Create home filesystem"
|
||||
mkfs.ext4 -L home /dev/system/home
|
||||
|
||||
echo "-----> Mount home filesystem"
|
||||
mkdir /mnt/home
|
||||
mkdir -p /mnt/home
|
||||
mount -t ext4 /dev/system/home /mnt/home
|
||||
|
||||
echo "-----> Create boot filesystem"
|
||||
mkfs.vfat -F32 -n boot /dev/disk/by-partlabel/boot
|
||||
|
||||
echo "-----> Mount boot filesystem"
|
||||
mkdir /mnt/boot
|
||||
mkdir -p /mnt/boot
|
||||
mount /dev/disk/by-label/boot /mnt/boot
|
||||
|
||||
echo "-----> Create tank pv"
|
||||
pvcreate /dev/disk/by-partlabel/tank1
|
||||
#
|
||||
# STORAGE
|
||||
#
|
||||
|
||||
echo "-----> Create tank vg"
|
||||
vgcreate tank /dev/disk/by-partlabel/tank1
|
||||
|
||||
echo "-----> Create downloads volume"
|
||||
lvcreate -y --size 200G --name downloads tank
|
||||
|
||||
echo "-----> Create downloads filesystem"
|
||||
mkfs.ext4 -L downloads /dev/tank/downloads
|
||||
|
||||
echo "-----> Mount downloads filesystem"
|
||||
mkdir -p /mnt/var/lib/downloads
|
||||
mount -t ext4 /dev/tank/downloads /mnt/var/lib/downloads
|
||||
chown 20000:20000 /mnt/var/lib/downloads
|
||||
|
||||
for PARTITION in acme nzbget jellyfin bazarr lidarr prowlarr radarr readarr sonarr hass; do
|
||||
for PARTITION in acme hass; do
|
||||
echo "-----> Create ${PARTITION} volume"
|
||||
lvcreate -y --size 5G --name ${PARTITION} tank
|
||||
lvcreate -y --size 5G --name ${PARTITION} system
|
||||
|
||||
echo "-----> Create ${PARTITION} filesystem"
|
||||
mkfs.ext4 -L ${PARTITION} /dev/tank/${PARTITION}
|
||||
mkfs.ext4 -L ${PARTITION} /dev/system/${PARTITION}
|
||||
|
||||
echo "-----> Mount ${PARTITION} filesystem"
|
||||
mkdir /mnt/var/lib/${PARTITION}
|
||||
mount -t ext4 /dev/tank/${PARTITION} /mnt/var/lib/${PARTITION}
|
||||
mount -t ext4 /dev/system/${PARTITION} /mnt/var/lib/${PARTITION}
|
||||
done
|
||||
|
@ -15,8 +15,12 @@
|
||||
grub = {
|
||||
enable = true;
|
||||
version = 2;
|
||||
device = "/dev/disk/by-path/pci-0000:00:14.1-ata-1";
|
||||
efiSupport = false;
|
||||
copyKernels = true;
|
||||
|
||||
devices = [
|
||||
"/dev/disk/by-path/pci-0000:00:14.1-ata-1"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -13,13 +13,13 @@
|
||||
];
|
||||
};
|
||||
|
||||
# fileSystems."/nix" = {
|
||||
# device = "/dev/disk/by-label/nix";
|
||||
# fsType = "ext4";
|
||||
# options = [
|
||||
# "noatime"
|
||||
# ];
|
||||
# };
|
||||
fileSystems."/nix" = {
|
||||
device = "/dev/disk/by-label/nix";
|
||||
fsType = "ext4";
|
||||
options = [
|
||||
"noatime"
|
||||
];
|
||||
};
|
||||
|
||||
fileSystems."/home" = {
|
||||
device = "/dev/disk/by-label/home";
|
||||
@ -30,7 +30,7 @@
|
||||
};
|
||||
|
||||
fileSystems."/boot" = {
|
||||
device = "/dev/disk/by-label/boot";
|
||||
device = "/dev/disk/by-label/boot1";
|
||||
fsType = "ext4";
|
||||
options = [
|
||||
"noatime"
|
||||
@ -82,66 +82,6 @@
|
||||
];
|
||||
};
|
||||
|
||||
fileSystems."/var/lib/movies" = {
|
||||
device = "/dev/disk/by-label/movies";
|
||||
fsType = "ext4";
|
||||
options = [
|
||||
"noatime"
|
||||
];
|
||||
};
|
||||
|
||||
fileSystems."/exports/movies" = {
|
||||
device = "/var/lib/movies";
|
||||
options = [
|
||||
"bind"
|
||||
];
|
||||
};
|
||||
|
||||
fileSystems."/var/lib/shows" = {
|
||||
device = "/dev/disk/by-label/shows";
|
||||
fsType = "ext4";
|
||||
options = [
|
||||
"noatime"
|
||||
];
|
||||
};
|
||||
|
||||
fileSystems."/exports/shows" = {
|
||||
device = "/var/lib/shows";
|
||||
options = [
|
||||
"bind"
|
||||
];
|
||||
};
|
||||
|
||||
fileSystems."/var/lib/books" = {
|
||||
device = "/dev/disk/by-label/books";
|
||||
fsType = "ext4";
|
||||
options = [
|
||||
"noatime"
|
||||
];
|
||||
};
|
||||
|
||||
fileSystems."/exports/books" = {
|
||||
device = "/var/lib/books";
|
||||
options = [
|
||||
"bind"
|
||||
];
|
||||
};
|
||||
|
||||
fileSystems."/var/lib/music" = {
|
||||
device = "/dev/disk/by-label/music";
|
||||
fsType = "ext4";
|
||||
options = [
|
||||
"noatime"
|
||||
];
|
||||
};
|
||||
|
||||
fileSystems."/exports/music" = {
|
||||
device = "/var/lib/music";
|
||||
options = [
|
||||
"bind"
|
||||
];
|
||||
};
|
||||
|
||||
fileSystems."/var/lib/printer" = {
|
||||
device = "/dev/disk/by-label/printer";
|
||||
fsType = "ext4";
|
||||
@ -164,4 +104,11 @@
|
||||
"noatime"
|
||||
];
|
||||
};
|
||||
|
||||
fileSystems."/exports/backup" = {
|
||||
device = "/var/lib/backup";
|
||||
options = [
|
||||
"bind"
|
||||
];
|
||||
};
|
||||
}
|
||||
|
@ -12,23 +12,26 @@
|
||||
cleanTmpDir = true;
|
||||
|
||||
loader = {
|
||||
efi = {
|
||||
canTouchEfiVariables = true;
|
||||
};
|
||||
|
||||
systemd-boot = {
|
||||
grub = {
|
||||
enable = true;
|
||||
consoleMode = "2";
|
||||
configurationLimit = 5;
|
||||
editor = false;
|
||||
version = 2;
|
||||
efiSupport = false;
|
||||
copyKernels = true;
|
||||
|
||||
devices = [
|
||||
"/dev/disk/by-path/pci-0000:00:1f.2-ata-3.0"
|
||||
"/dev/disk/by-path/pci-0000:00:1f.2-ata-4.0"
|
||||
"/dev/disk/by-path/pci-0000:00:1f.2-ata-5.0"
|
||||
"/dev/disk/by-path/pci-0000:00:1f.2-ata-6.0"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
kernelModules = [ ];
|
||||
kernelModules = [ "kvm-intel" ];
|
||||
extraModulePackages = [ ];
|
||||
|
||||
initrd = {
|
||||
availableKernelModules = [ "xhci_pci" "uhci_hcd" "ehci_pci" "ahci" "usbhid" "sd_mod" "sr_mod" ];
|
||||
availableKernelModules = [ "ehci_pci" "ahci" "sd_mod" ];
|
||||
kernelModules = [ "dm-snapshot" ];
|
||||
};
|
||||
};
|
||||
|
@ -31,6 +31,41 @@
|
||||
|
||||
fileSystems."/boot" = {
|
||||
device = "/dev/disk/by-label/boot1";
|
||||
fsType = "vfat";
|
||||
fsType = "ext4";
|
||||
options = [
|
||||
"noatime"
|
||||
];
|
||||
};
|
||||
|
||||
fileSystems."/var/lib/movies" = {
|
||||
device = "/dev/disk/by-label/movies";
|
||||
fsType = "ext4";
|
||||
options = [
|
||||
"noatime"
|
||||
];
|
||||
};
|
||||
|
||||
fileSystems."/var/lib/shows" = {
|
||||
device = "/dev/disk/by-label/shows";
|
||||
fsType = "ext4";
|
||||
options = [
|
||||
"noatime"
|
||||
];
|
||||
};
|
||||
|
||||
fileSystems."/var/lib/books" = {
|
||||
device = "/dev/disk/by-label/books";
|
||||
fsType = "ext4";
|
||||
options = [
|
||||
"noatime"
|
||||
];
|
||||
};
|
||||
|
||||
fileSystems."/var/lib/music" = {
|
||||
device = "/dev/disk/by-label/music";
|
||||
fsType = "ext4";
|
||||
options = [
|
||||
"noatime"
|
||||
];
|
||||
};
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
{
|
||||
imports = [
|
||||
(modulesPath + "/profiles/qemu-guest.nix")
|
||||
(modulesPath + "/installer/scan/not-detected.nix")
|
||||
];
|
||||
|
||||
hardware = {
|
||||
|
@ -3,19 +3,29 @@
|
||||
{
|
||||
networking = {
|
||||
hostName = "niflheim";
|
||||
defaultGateway = "192.168.64.1";
|
||||
defaultGateway = "176.9.93.193";
|
||||
defaultGateway6 = "fe80::1";
|
||||
|
||||
nameservers = [
|
||||
"1.1.1.1"
|
||||
"8.8.8.8"
|
||||
"2a01:4ff:ff00::add:1"
|
||||
"2a01:4ff:ff00::add:2"
|
||||
];
|
||||
|
||||
interfaces = {
|
||||
enp0s1 = {
|
||||
enp3s0 = {
|
||||
ipv4 = {
|
||||
addresses = [{
|
||||
address = "192.168.64.4";
|
||||
prefixLength = 24;
|
||||
address = "176.9.93.214";
|
||||
prefixLength = 27;
|
||||
}];
|
||||
};
|
||||
|
||||
ipv6 = {
|
||||
addresses = [{
|
||||
address = "2a01:4f8:151:34ba::2";
|
||||
prefixLength = 64;
|
||||
}];
|
||||
};
|
||||
};
|
||||
|
@ -1,22 +1,6 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
let
|
||||
nfsOptions = [
|
||||
"x-systemd.automount"
|
||||
"noauto"
|
||||
"x-systemd.idle-timeout=60"
|
||||
"x-systemd.device-timeout=5s"
|
||||
"x-systemd.mount-timeout=5s"
|
||||
"nfsvers=4.2"
|
||||
];
|
||||
|
||||
in
|
||||
{
|
||||
environment = {
|
||||
systemPackages = with pkgs; [
|
||||
nfs-utils
|
||||
];
|
||||
};
|
||||
|
||||
swapDevices = [{
|
||||
device = "/dev/disk/by-label/swap";
|
||||
}];
|
||||
@ -62,78 +46,6 @@ in
|
||||
];
|
||||
};
|
||||
|
||||
fileSystems."/var/lib/nzbget" = {
|
||||
device = "/dev/disk/by-label/nzbget";
|
||||
fsType = "ext4";
|
||||
options = [
|
||||
"noatime"
|
||||
"discard"
|
||||
];
|
||||
};
|
||||
|
||||
fileSystems."/var/lib/jellyfin" = {
|
||||
device = "/dev/disk/by-label/jellyfin";
|
||||
fsType = "ext4";
|
||||
options = [
|
||||
"noatime"
|
||||
"discard"
|
||||
];
|
||||
};
|
||||
|
||||
fileSystems."/var/lib/bazarr" = {
|
||||
device = "/dev/disk/by-label/bazarr";
|
||||
fsType = "ext4";
|
||||
options = [
|
||||
"noatime"
|
||||
"discard"
|
||||
];
|
||||
};
|
||||
|
||||
fileSystems."/var/lib/lidarr" = {
|
||||
device = "/dev/disk/by-label/lidarr";
|
||||
fsType = "ext4";
|
||||
options = [
|
||||
"noatime"
|
||||
"discard"
|
||||
];
|
||||
};
|
||||
|
||||
fileSystems."/var/lib/prowlarr" = {
|
||||
device = "/dev/disk/by-label/prowlarr";
|
||||
fsType = "ext4";
|
||||
options = [
|
||||
"noatime"
|
||||
"discard"
|
||||
];
|
||||
};
|
||||
|
||||
fileSystems."/var/lib/radarr" = {
|
||||
device = "/dev/disk/by-label/radarr";
|
||||
fsType = "ext4";
|
||||
options = [
|
||||
"noatime"
|
||||
"discard"
|
||||
];
|
||||
};
|
||||
|
||||
fileSystems."/var/lib/readarr" = {
|
||||
device = "/dev/disk/by-label/readarr";
|
||||
fsType = "ext4";
|
||||
options = [
|
||||
"noatime"
|
||||
"discard"
|
||||
];
|
||||
};
|
||||
|
||||
fileSystems."/var/lib/sonarr" = {
|
||||
device = "/dev/disk/by-label/sonarr";
|
||||
fsType = "ext4";
|
||||
options = [
|
||||
"noatime"
|
||||
"discard"
|
||||
];
|
||||
};
|
||||
|
||||
fileSystems."/var/lib/hass" = {
|
||||
device = "/dev/disk/by-label/hass";
|
||||
fsType = "ext4";
|
||||
@ -142,37 +54,4 @@ in
|
||||
"discard"
|
||||
];
|
||||
};
|
||||
|
||||
fileSystems."/var/lib/downloads" = {
|
||||
device = "/dev/disk/by-label/downloads";
|
||||
fsType = "ext4";
|
||||
options = [
|
||||
"noatime"
|
||||
"discard"
|
||||
];
|
||||
};
|
||||
|
||||
fileSystems."/var/lib/movies" = {
|
||||
device = "192.168.1.10:/movies";
|
||||
fsType = "nfs";
|
||||
options = nfsOptions;
|
||||
};
|
||||
|
||||
fileSystems."/var/lib/shows" = {
|
||||
device = "192.168.1.10:/shows";
|
||||
fsType = "nfs";
|
||||
options = nfsOptions;
|
||||
};
|
||||
|
||||
fileSystems."/var/lib/books" = {
|
||||
device = "192.168.1.10:/books";
|
||||
fsType = "nfs";
|
||||
options = nfsOptions;
|
||||
};
|
||||
|
||||
fileSystems."/var/lib/music" = {
|
||||
device = "192.168.1.10:/music";
|
||||
fsType = "nfs";
|
||||
options = nfsOptions;
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user