====== Linux storage ======
This page contains my personal notes on Linux filesystems, partitioning, backups, performance tuning, and related concepts. **Warning:** //these notes are specific to my own non-critical systems and may not be applicable in general use cases.//
> **Update:** Due to a a number of stability issues I've returned to using [[https://neon.kde.org/|KDE neon]] on my work laptop. Nod to the KDE devs for maintaining a stable rolling release distro. The general principles still apply to any modern distro.
===== Partitioning for Ubuntu 19.04 workstations =====
I'm currently the following configuration on my Dell Precision 5520 notebook computer:
* 256GB NVMe drive
* 256MiB EFI partition as a raw FAT partition
* 512MiB /boot partition as a raw ext4 partition
* the rest of the disk is configured as an LVM PV consuming 92% of the drive
* this currently contains one volume group with two logical volumes, 16GiB for swap (to allow hibernate) and the remaining space is used for /
==== Initializing partitions using gparted ====
GNU parted manual: https://www.gnu.org/software/parted/manual/parted.html#Using-Parted-1
parted /dev/nvme0n1
print # check to see what's already on the disk before you do anything else
mklabel gpt
unit MiB # use binary format units when partitioning
mkpart efi fat32 1MiB 257MiB # align the first block
mkpart boot ext4 257MiB 769MiB
mkpart lvm-pv0 ext4 769MiB 92% # finish the LVM pv at 92% capacity
If this worked you will see something like this when you print the partition table
(parted) print
Model: PC401 NVMe SK hynix 256GB (nvme)
Disk /dev/nvme0n1: 256GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 269MB 268MB ext4 efi msftdata
2 269MB 806MB 537MB boot
3 806MB 236GB 235GB lvm-pv0 lvm
As far as I can tell parted can't label volumes as Linux LVM, so I do that using fdisk.
root@kubuntu:~# fdisk /dev/nvme0n1
Welcome to fdisk (util-linux 2.33.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): t
Partition number (1-3, default 3): 3
Partition type (type L to list all types): 31
Changed type of partition 'Linux filesystem' to 'Linux LVM'.
Command (m for help): p
Disk /dev/nvme0n1: 238.5 GiB, 256060514304 bytes, 500118192 sectors
Disk model: PC401 NVMe SK hynix 256GB
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 14779AE7-C2BB-4F6A-9F6E-A927FAF7AAFB
Device Start End Sectors Size Type
/dev/nvme0n1p1 2048 526335 524288 256M Microsoft basic data
/dev/nvme0n1p2 526336 1574911 1048576 512M Linux filesystem
/dev/nvme0n1p3 1574912 460107775 458532864 218.7G Linux LVM
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
=== Create filesystems and LVM structure ===
pvcreate /dev/nvme0n1p3
vgcreate vg0 /dev/nvme0n1p3
lvcreate -n swap0 -L 16GiB vg0
lvcreate -n root -l 100%FREE vg0
If you did this correctly you should see the following
lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root vg0 -wi-a----- 202.64g
swap0 vg0 -wi-a----- 16.00g