Tag Archives: lvm

LVM: reduce partition size

# umount mountpoint with lvm partition
unmount /data

# check for errors and fix them
fsck -f /dev/sys/data

# resize filesystem to 80Gb
resize2fs /dev/sys/data 80G

# deactivate logical volume
lvchange -an /dev/sys/data

# change size of logical volume
lvreduce --size 191G /dev/sys/data

# create new volume «drbdmaster» in logical group «sys» with size 4Gb
lvcreate -n drbdmaster -L4G sys

# activate volumes
lvchange -ay  /dev/sys/data
lvchange -ay /dev/sys/drbdmaster

# mount data
mount /dev/sys/data

# create filesystem on drbdmaster
mkfs.ext4 /dev/sys/drbdmaster

# mount drbdmaster
mkdir -p /drbd/master
mount /dev/sys/drbdmaster /drbd/master

Arch: encrypted partition above lvm

1. Create two partitions:
sda1 — for /boot
sda2 — for lvm

2. Create lvm partitions:

3. Encrypt partitions with «cryptosetup luksFormat»

4. Example of /boot/grub/menu.lst:
title Arch Linux Crypto
root (hd0,0)
kernel /vmlinuz26-lts cryptdevice=/dev/local/root:root root=/dev/mapper/root ro
initrd /kernel26-lts.img

5. Setup crypttab:
home            /dev/local/home         /etc/cryptfs.key
swap            /dev/local/swap         /etc/cryptfs.key

6. Setup fstab:
add there devices names of unencrypted devices like «/dev/mapper/root», example:
tmpfs /tmp tmpfs nodev,nosuid 0 0
LABEL=localboot /boot ext2 defaults 0 1
/dev/mapper/root / ext4 defaults 0 1
/dev/mapper/home /home ext4 defaults 0 0
/dev/mapper/swap swap swap defaults 0 0

7. Edit /etc/mkinitcpio.conf
HOOKS="base udev autodetect pata scsi sata lvm2 encrypt filesystems usbinput"

8. Regenerate initrd:
mkinitcpio -p kernel26-lts