This is a walkthrough for creating btrfs subvolumes. It was originally a larger document detailing the installation of Arch Labs from formatting the hdd all the way up to verification, mounting and swapon. I'm only concerned about using Step 5's info for creating subvolumes via chrooting from another Arch or Manjaro liveUSB.
Install ArchLabs <www.archlabslinux.com> 2018.03 with Btrfs filesystem.
- boot (512M) with ext4 filesystem,
- home (5G) with xfs filesystem,
- root (5G) with btrfs (@, @btrfs, @pkg, @log, @snapshots),
- swap (2.5G) with swap space.
For demonstration purposes only. Do not use this scheme for any live or productive system.
- Create a full backup of your current system (!).
- Download ArchLabs Linux from here and save it.
- Copy ISO image to USB stick with dd:
dd if=archlabs-2018-03.iso of=/dev/sdX bs=5M && sync
- Boot ArchLabs (x86_64) with your fresh USB stick.
- Right-Click on Desktop and select "Install Archlabs".
-
Select Language.
-
Go to Prepare System.
- Set Keyboard Layout.
- Partition Device: /dev/sda 13G
- Chose cfdisk and select gpt for label type.
- [NEW] -> Partition size: 512M # Boot
- [NEW] -> Partition size: 5G # Root with @, @pkg, @log, @snapshots
- [NEW] -> Partition size: 5G # Home
- [NEW] -> Partition size: 2.5G # Swap
- Click on Write, confirm and exit.
root@ArchLabs / # fdisk -l
Disk /dev/sda: 13 GiB, 13958643712 bytes, 27262976 sectors
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: D696C02E-4788-2346-AA7A-C8E23E1FCDE7
Device Start End Sectors Size Type
/dev/sda1 2048 1050623 1048576 512M Linux filesystem
/dev/sda2 1050624 11536383 10485760 5G Linux filesystem
/dev/sda3 11536384 22022143 10485760 5G Linux filesystem
/dev/sda4 22022144 27262942 5240799 2.5G Linux filesystem
...
- Click CTRL+F2 and login as root with password archlabs.
- Format partitions:
mkfs.ext4 -L boot.ext4 /dev/sda1
# Bootmkfs.btrfs -L root.btrfs /dev/sda2
# Root with @, @pkg, @log, @snapshotsmkfs.xfs -L home.xfs /dev/sda3
# Homemkswap -L swap.swap /dev/sda4
# Swap
root@ArchLabs / # mkfs.ext4 -L boot.ext4 /dev/sda1
mke2fs 1.43.9 (8-Feb-2018)
Creating filesystem with 131072 4k blocks and 32768 inodes
Filesystem UUID: 2de35468-684c-4804-a29c-51aa708bf5e0
Superblock backups stored on blocks:
32768, 98304
Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
root@ArchLabs / # mkfs.btrfs -L root.btrfs /dev/sda2
btrfs-progs v4.15.1
See http://btrfs.wiki.kernel.org for more information.
Label: root.btrfs
UUID: 0fdbc292-a9b2-4862-a4be-61b019db243a
Node size: 16384
Sector size: 4096
Filesystem size: 5.00GiB
Block group profiles:
Data: single 8.00MiB
Metadata: DUP 256.00MiB
System: DUP 8.00MiB
SSD detected: no
Incompat features: extref, skinny-metadata
Number of devices: 1
Devices:
ID SIZE PATH
1 5.00GiB /dev/sda2
root@ArchLabs / # mkfs.xfs -L home.xfs /dev/sda3
meta-data=/dev/sda3 isize=512 agcount=4, agsize=327680 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=0, rmapbt=0, reflink=0
data = bsize=4096 blocks=1310720, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
root@ArchLabs / # mkswap -L swap.swap /dev/sda4
Setting up swapspace version 1, size = 2.5 GiB (2683281408 bytes)
LABEL=swap.swap, UUID=caffb094-e15e-4803-875f-b5a2b7152abc
- Create btrfs subvolumes:
mount /dev/sda2 /mnt
btrfs subvolume create /mnt/@
btrfs subvolume create /mnt/@pkg
btrfs subvolume create /mnt/@log
btrfs subvolume create /mnt/@snapshots
umount /mnt
root@ArchLabs / # mount /dev/sda2 /mnt
root@ArchLabs / # btrfs subvolume create /mnt/@
Create subvolume '/mnt/@'
root@ArchLabs / # btrfs subvolume create /mnt/@pkg
Create subvolume '/mnt/@pkg'
root@ArchLabs / # btrfs subvolume create /mnt/@log
Create subvolume '/mnt/@log'
root@ArchLabs / # btrfs subvolume create /mnt/@snapshots
Create subvolume '/mnt/@snapshots'
root@ArchLabs / # ls /mnt
@ @log @pkg @snapshots
root@ArchLabs / # umount /mnt
- Create folders and mount btrfs subvolumes:
mount -o noatime,compress=lzo,space_cache,ssd,subvol=@ /dev/sda2 /mnt
mkdir -p /mnt/{btrfs,boot,home,var/log,var/cache/pacman/pkg,.snapshots}
mount -o noatime,compress=lzo,space_cache=v2,ssd,subvolid=5 /dev/sda2 /mnt/btrfs
mount -o noatime,compress=lzo,space_cache=v2,ssd,subvol=@snapshots /dev/sda2 /mnt/.snapshots
mount -o noatime,compress=lzo,space_cache=v2,ssd,subvol=@pkg /dev/sda2 /mnt/var/cache/pacman/pkg/
mount -o noatime,compress=lzo,space_cache=v2,ssd,subvol=@log /dev/sda2 /mnt/var/log/
root@ArchLabs / # mount -o noatime,compress=lzo,space_cache,ssd,subvol=@ /dev/sda2 /mnt
root@ArchLabs / # mkdir -p /mnt/{btrfs,boot,home,var/log,var/cache/pacman/pkg,.snapshots}
root@ArchLabs / # ls /mnt
boot btrfs home var
root@ArchLabs / # mount -o noatime,compress=lzo,space_cache=v2,ssd,subvolid=5 /dev/sda2 /mnt/btrfs
root@ArchLabs / # mount -o noatime,compress=lzo,space_cache=v2,ssd,subvol=@snapshots /dev/sda2 /mnt/.snapshots
root@ArchLabs / # mount -o noatime,compress=lzo,space_cache=v2,ssd,subvol=@pkg /dev/sda2 /mnt/var/cache/pacman/pkg/
root@ArchLabs / # mount -o noatime,compress=lzo,space_cache=v2,ssd,subvol=@log /dev/sda2 /mnt/var/log/
- Mount boot, home and enable swap partition:
mount /dev/sda1 /mnt/boot
mount /dev/sda3 /mnt/home
swapoff -a && swapon /dev/sda4
root@ArchLabs / # mount /dev/sda1 /mnt/boot
root@ArchLabs / # mount /dev/sda3 /mnt/home
root@ArchLabs / # swapoff -a && swapon /dev/sda4
- Verify setup with:
mount
swapon -s
root@ArchLabs / # mount
...
/dev/sda2 on /mnt type btrfs (rw,noatime,compress=lzo,ssd,space_cache,subvolid=257,subvol=/@)
/dev/sda2 on /mnt/btrfs type btrfs (rw,noatime,compress=lzo,ssd,space_cache,subvolid=5,subvol=/)
/dev/sda2 on /mnt/.snapshots type btrfs (rw,noatime,compress=lzo,ssd,space_cache,subvolid=260,subvol=/@snapshots)
/dev/sda2 on /mnt/var/cache/pacman/pkg type btrfs (rw,noatime,compress=lzo,ssd,space_cache,subvolid=258,subvol=/@pkg)
/dev/sda2 on /mnt/var/log type btrfs (rw,noatime,compress=lzo,ssd,space_cache,subvolid=259,subvol=/@log)
/dev/sda1 on /mnt/boot type ext4 (rw,relatime,data=ordered)
/dev/sda3 on /mnt/home type xfs (rw,relatime,attr2,inode64,noquota)
root@ArchLabs / # swapon -s
Filename Type Size Used Priority
/dev/sda4 partition 2620392 0 -2
- Leave terminal by pressing ALT+[KEY-LEFT] two times.
- Go Back and Install ArchLabs.
- Wait a few minutes.
- Select as Bootloader Device your partition /dev/sda.
- Set System Hostname, Locale + Timezone and Root Password.
- Create a New User and apply System Tweaks (if required).
- Go Back, click on Done and restart into your (new) ArchLabs system.
florian@myarchlabs ~ % df -Th
Filesystem Type Size Used Avail Use% Mounted on
dev devtmpfs 2.0G 0 2.0G 0% /dev
run tmpfs 2.0G 476K 2.0G 1% /run
/dev/sda2 btrfs 5.0G 2.9G 1.8G 62% /
tmpfs tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
tmpfs tmpfs 2.0G 6.3M 2.0G 1% /tmp
/dev/sda2 btrfs 5.0G 2.9G 1.8G 62% /btrfs
/dev/sda2 btrfs 5.0G 2.9G 1.8G 62% /var/cache/pacman/pkg
/dev/sda2 btrfs 5.0G 2.9G 1.8G 62% /var/log
/dev/sda2 btrfs 5.0G 2.9G 1.8G 62% /.snapshots
/dev/sda1 ext4 488M 54M 400M 12% /boot
/dev/sda3 xfs 5.0G 50M 5.0G 1% /home
tmpfs tmpfs 395M 8.0K 395M 1% /run/user/1000
florian@myarchlabs ~ % ls /btrfs
@ @log @pkg @snapshots
florian@myarchlabs ~ % cat /etc/fstab
# /dev/sda2 LABEL=root.btrfs
UUID=0fdbc292-a9b2-4862-a4be-61b019db243a / btrfs rw,noatime,compress=lzo,ssd,space_cache,subvolid=257,subvol=/@,subvol=@ 0 0
# /dev/sda2 LABEL=root.btrfs
UUID=0fdbc292-a9b2-4862-a4be-61b019db243a /btrfs btrfs rw,noatime,compress=lzo,ssd,space_cache,subvolid=5,subvol=/ 0 0
# /dev/sda2 LABEL=root.btrfs
UUID=0fdbc292-a9b2-4862-a4be-61b019db243a /.snapshots btrfs rw,noatime,compress=lzo,ssd,space_cache,subvolid=260,subvol=/@snapshots,subvol=@snapshots 0 0
# /dev/sda2 LABEL=root.btrfs
UUID=0fdbc292-a9b2-4862-a4be-61b019db243a /var/cache/pacman/pkg btrfs rw,noatime,compress=lzo,ssd,space_cache,subvolid=258,subvol=/@pkg,subvol=@pkg 0 0
# /dev/sda2 LABEL=root.btrfs
UUID=0fdbc292-a9b2-4862-a4be-61b019db243a /var/log btrfs rw,noatime,compress=lzo,ssd,space_cache,subvolid=259,subvol=/@log,subvol=@log 0 0
# /dev/sda1 LABEL=boot.ext4
UUID=2de35468-684c-4804-a29c-51aa708bf5e0 /boot ext4 rw,relatime,data=ordered 0 2
# /dev/sda3 LABEL=home.xfs
UUID=dae18c6c-4361-4e73-a775-102662f08ff5 /home xfs rw,relatime,attr2,inode64,noquota 0 2
# /dev/sda4 LABEL=swap.swap
UUID=caffb094-e15e-4803-875f-b5a2b7152abc none swap defaults,pri=-2 0 0
- Btrfs for this great and powerful filesystem,
- unicks.eu aka Nick for all the great videos about GNU/Linux!
- Fix Markdown Syntax.