Root server - step 2 - Logical volumes

Create LVM Physical Volume and Volume Group


bash
pvcreate /dev/md2
vgcreate vg_server /dev/md2
________________________________________
 

Create Logical Volumes


bash
# OS
lvcreate -L  20G  -n lv_root        vg_server
lvcreate -L  20G  -n lv_home        vg_server

# Services & data
lvcreate -L  80G  -n lv_var         vg_server
lvcreate -L  20G  -n lv_var_log     vg_server
lvcreate -L 110G  -n lv_mysql       vg_server

# Apps & workloads
lvcreate -L  40G  -n lv_opt         vg_server
lvcreate -L  20G  -n lv_tmp_ffmpeg  vg_server

# Backup staging
lvcreate -L  50G  -n lv_backup      vg_server

# ~70 GB remains unallocated in vg_server — the dynamic pool
________________________________________
 

Format all Logical Volumes


bash
mkfs.ext4  -L root       /dev/vg_server/lv_root
mkfs.ext4  -L home       /dev/vg_server/lv_home
mkfs.xfs   -L var        /dev/vg_server/lv_var
mkfs.xfs   -L var_log    /dev/vg_server/lv_var_log
mkfs.xfs   -L mysql      /dev/vg_server/lv_mysql
mkfs.xfs   -L opt        /dev/vg_server/lv_opt
mkfs.xfs   -L tmp_ffmpeg /dev/vg_server/lv_tmp_ffmpeg
mkfs.xfs   -L backup     /dev/vg_server/lv_backup
ext4 for / and /home — better tooling for OS-level recovery. XFS for everything else — superior for large files (models, DB, media), high-throughput writes, and online resizing.
________________________________________

Mount and fstab


bash
# Mount root first during install, then the rest
mount /dev/vg_server/lv_root /mnt

mkdir -p /mnt/{boot,home,opt,tmp_ffmpeg,backup}
mkdir -p /mnt/var/{log,lib/mysql}

mount /dev/md0                     /mnt/boot
mount /dev/sda1                    /mnt/boot/efi
mount /dev/vg_server/lv_home       /mnt/home
mount /dev/vg_server/lv_var        /mnt/var
mount /dev/vg_server/lv_var_log    /mnt/var/log
mount /dev/vg_server/lv_mysql      /mnt/var/lib/mysql
mount /dev/vg_server/lv_opt        /mnt/opt
mount /dev/vg_server/lv_tmp_ffmpeg /mnt/tmp_ffmpeg
mount /dev/vg_server/lv_backup     /mnt/backup

Step 1 — Install debootstrap (in rescue env)

bash
apt-get install -y debootstrap

Step 2 — Run debootstrap

Best mirror choice for OVH France: http://debian.mirrors.ovh.net/debian/ — it's OVH's own mirror, on-network, fastest possible.

Fallback: http://ftp.fr.debian.org/debian/ — the official French Debian mirror.

bash
debootstrap --arch=amd64 bullseye /mnt http://debian.mirrors.ovh.net/debian/

This will take a few minutes. You'll see it downloading and extracting packages into /mnt.


Step 3 — Once debootstrap finishes, write fstab

Only after debootstrap completes will /mnt/etc/ exist:

 

cat > /mnt/etc/fstab << 'EOF'
# <file system>                        <mount point>     <type>   <options>                     <dump> <pass>

# Root
/dev/vg_server/lv_root                 /                 ext4     defaults,errors=remount-ro    0      1

# Boot
UUID=<uuid-of-md0>                     /boot             ext4     defaults                      0      2

# EFI
UUID=<uuid-of-sda1>                    /boot/efi         vfat     umask=0077,fmask=0077,dmask=0077  0  2

# Home
/dev/vg_server/lv_home                 /home             ext4     defaults                      0      2

# Var
/dev/vg_server/lv_var                  /var              xfs      defaults                      0      2

# Var log
/dev/vg_server/lv_var_log              /var/log          xfs      defaults                      0      2

# MySQL
/dev/vg_server/lv_mysql                /var/lib/mysql    xfs      defaults,noatime              0      2

# Opt
/dev/vg_server/lv_opt                  /opt              xfs      defaults                      0      2

# FFmpeg tmp
/dev/vg_server/lv_tmp_ffmpeg           /tmp_ffmpeg       xfs      defaults,noatime,nodiratime   0      2

# Backup
/dev/vg_server/lv_backup               /backup           xfs      defaults,noatime              0      2

# Swap
UUID=<uuid-of-md1>                     none              swap     sw                            0      0
EOF

Replace the three <uuid-of-*> placeholders with the actual values from blkid. Everything else (LVM paths) can stay as device paths — they're stable because LVM resolves them by VG/LV name.

Notes on options used

VolumeNotable optionReason
lv_rooterrors=remount-roProtects against corruption on root errors
lv_mysqlnoatimeAvoids unnecessary inode updates on DB files
lv_tmp_ffmpegnoatime,nodiratimeHigh-throughput scratch space, reduce I/O overhead
lv_backupnoatimeLarge sequential writes, no need for access time
EFIumask=0077Restricts EFI partition to root-only access

 


Verify the result

bash
cat /mnt/etc/fstab

Step 4 — Bind-mount the virtual filesystems for chroot

bash
mount --bind /dev     /mnt/dev
mount --bind /dev/pts /mnt/dev/pts
mount --bind /proc    /mnt/proc
mount --bind /sys     /mnt/sys

Then chroot in:

bash
chroot /mnt /bin/bash

 

Inside the chroot, do these steps in order:


1 — Basic environment

bash
export DEBIAN_FRONTEND=noninteractive

# Set hostname
echo "your-hostname" > /etc/hostname

# Set hosts file
cat > /etc/hosts << 'EOF'
127.0.0.1   localhost
127.0.1.1   your-hostname
::1         localhost ip6-localhost ip6-loopback
EOF

2 — Locale & timezone

bash
apt-get install -y locales tzdata

# Locale
echo "en_US.UTF-8 UTF-8" > /etc/locale.gen
locale-gen
update-locale LANG=en_US.UTF-8

# Timezone
ln -sf /usr/share/zoneinfo/Europe/Paris /etc/localtime
dpkg-reconfigure -f noninteractive tzdata

3 — apt sources

bash
cat > /etc/apt/sources.list << 'EOF'
deb http://debian.mirrors.ovh.net/debian/ bullseye main contrib non-free
deb http://debian.mirrors.ovh.net/debian/ bullseye-updates main contrib non-free
deb http://security.debian.org/debian-security bullseye-security main contrib non-free
EOF

apt-get update

4 — Install essential packages

bash
apt-get install -y \
  linux-image-amd64 \
  linux-headers-amd64 \
  grub-efi-amd64 \
  efibootmgr \
  lvm2 \
  mdadm \
  xfsprogs \
  e2fsprogs \
  openssh-server \
  sudo \
  curl \
  wget \
  vim \
  net-tools \
  iproute2 \
  ifupdown \
  bash-completion

5 — Configure mdadm

bash
mdadm --detail --scan >> /etc/mdadm/mdadm.conf

# Update initramfs to include mdadm config
update-initramfs -u

6 — Set root password

bash
passwd root

7 — Network config

bash
# Check your interface name first
ip link show

Then replace enp3s0 with your actual interface name:

bash
cat > /etc/network/interfaces << 'EOF'
auto lo
iface lo inet loopback

auto enp3s0
iface enp3s0 inet dhcp
EOF

8 — Install GRUB

bash
# Install to EFI
grub-install --target=x86_64-efi \
             --efi-directory=/boot/efi \
             --bootloader-id=debian \
             --recheck

# Generate config
update-grub

9 — Verify GRUB sees everything

bash
grep -i "menuentry\|linux\|initrd" /boot/grub/grub.cfg | head -20