Author Topic: How to install Manjaro on btrfs subvolumes with CLI installer  (Read 10387 times)

0 Members and 2 Guests are viewing this topic.

Offline eugen-b

  • Support Team
  • ****
  • Posts: 3191
  • Branch: testing
  • Desktop: LXDE, Fluxbox, JWM, LXQt, bspwm
  • GPU Card: Intel 82945G/GZ
  • GPU driver: free
  • Kernel: 4.5, 4.6
  • Skill: Intermediate
I'm using btrfs on all of my machines. (Only on a netbook where I have an older kernel I am using ext4.)
Advantages:
1) compression of all data: saves space on your drive and makes reads faster (in terms of useful data)
2) flexible space for root and home instead of rigid partition space
3) ability to make snapshots, for example before installing or updating packages or other experiments
NOTICE: These features can be (partly or fully) achieved with other filesystems (ZFS, NILFS,...) or utilities (LVM,...).
WARNING: The filesystem btrfs itself and its integration into the kernel, systemd and other applications are still being delevoped. This means there will be changes somewhere and these changes might affect negatively the running system in an unintended or unforeseen way despite all the testing being made. Therefore it is advisable to regularly back up your data and have another system in reserve.

Installation process
0.) The following steps describe the installation with the CLI installer with the aim to have a system in subvolumes for system and user files (@ and @home). This can be achived with other installers (which install on the partition directly) by folowing this guide. The guide explains how to conver an exr4 system, but if you install on btrfs partiton you can simply skip the ext4->btrfs conversion step.
1.) Preparatory steps: You need to create a bootable Live medium and a btrfs formatted partition. For the second task I recommend GParted to create one btrfs partition spanning the whole disk.
2.) Boot with Live medium and launch the CLI installer - from the Welcome screen, for example.


3.) The CLI installer runs in a terminal window. Choose option 1 Set date and time and set these up the way you want.
4.) Then select the Option 2 Disks preparation


4.1) And then 4 Set filesystem Mountpoints (because you've already partitioned your disk)


4.2) You'll be asked which partition to mount as swap - select NONE (or the partition which you intend to use as swap)

You'll get a warning, but choose Continue.

4.3) You will be asked which partition to mount as /

To be sure to choose the right partition open a new tab in the terminal window and enter the command blkid

Then switch to the previous terminal tab and select the partition you want to install your system on.
4.4) Select the fiesystem for your partition to be btrfs

4.5) You'll be asked whether you want to create a filesystem on the partition you selected - choose No (choosing Yes will likely give you errors, therefore I recommend to make partitioning beforehand)
4.6) You'll be asked whether you want to create a subvolume on the partition you selected - choose Yes


Enter a subvolume name then - I recommend to name it @ or @<edition_name> like @xfce. Then you can name the home subvolume @home or @xfcehome.


You'll be asked whether you want to compress the data in your subvolume - select Yes and in the next screen select lzo compression.




Choose to optimize the filesystem for SSD usage if installing on an SSD


Enter additional mount options, at least noatime can be recommended, but can be added later


4.7) Now you can mount the @home subvolume. If you don't want a separate home subvolume you can skip this step and select NONE.
If you do want an @home subvolume on the same partition then select the partition which you've just mounted you root subvolume on:


Enter the mountpoint, /boot is in the field, but you need to enter /home


Enter the subvolume name @home


Do the next steps as for the root subvolume: compression, ssd optimization.
Then select DONE.


You'll get a (somewhat cryptic) summary of your mount options


On the next screen select UUID to be used for your fstab and other config files


On successful mounting you'll get a success message


Return to Main menu


5.) INSTALLATION
5.1) You can select 3 Install system, but don't click "OK" if you want to achieve a stronger compression. Open a new tab in the terminal window where you are running th installer or just a new terminal window and read on below 5.2).
If you don't want stronger compression click "OK" and follow point XXXXX


5.2) Compression [optional]: The partition will get mounted with compress=lzo option by the installer (can be checked by cat /proc/mounts), but this option will not compress all files, but only those where it would yield enough. By remounting the partiton with the option compress-force=lzo one can achieve that all files get compressed. To do this prepare the following command in the new terminal tab, but don't hit the "Enter" button, yet:
Code: [Select]
sudo mount -o remount,compress-force=lzo,ssd -t btrfs /dev/sda1 /install
Then enter a third terminal tab and run the command df. You will see that the target partiton where Manjaro is to be installed on is mounted on /install and /install/home. But you don't need to care about the second mount point, because it will be remounted exacly like the first.
Return to the tab with the installer and click "OK" now. You will get the following screen with a progress bar

Switch to the third terminal tab and run the df command several times until you see that some 2-3MB have been written to the target partition, then switch to the second tab with the mount -o remount ... command and hit "Enter".

5.3) Wait for the following screen which would declare a successful installation and click "Continue"


5.4) Select 4 Configure system


You can now change root password (otherwise it will stay "manjaro") and set up a user. These steps will not explained here in detail. Other options are likely not relevant since you will get the settings with which you have booted the live CD on your installed system by default.

After having created a new user you can get back to the main menu.

5.5) In the main menu of the installer select 5 Install bootloader
You will get the screen where you can choose between BIOS and UEFI. I selected BIOS.


Then you can choose between GRUB and SYSLINUX, I chose GRUB.


On successful install of the bootloader you get a confirmation message.


6.) Returning to the main menu you can now select 6 Quit.


« Last Edit: 27. February 2016, 20:51:45 by eugen-b »
MSI Wind Nettop, Intel Atom 230 1.6GHz (64bit), 2GB RAM
DEs: NET-minimal + (LXDE / Fluxbox / JWM); LXQt OpenRC
how to install on btrfs subvolumes
http://manjaro.github.io/donate/

Offline simgin

  • Held Mitglied
  • *****
  • Posts: 774
  • Branch: All.
  • Desktop: XFCE+Alpine Linux, Mate+Fedora, Ubuntu Server + Mate and NoX+LinuxBBQ
  • GPU Card: GeForce 8600M & GT 555M 2GB
  • Skill: Intermediate
Re: How to install Manjaro on btrfs subvolumes with CLI installer
« Reply #1 on: 24. January 2016, 17:10:03 »
^ Thank you Eugen-B  :)

Offline Chrysostomus

  • Maintainer
  • ***
  • Posts: 1634
  • Neckbeards are cool
    • Git
  • Branch: unstable
  • Desktop: Gnome, bspwm
  • GPU Card: Intel HD4000
  • GPU driver: free
  • Kernel: linux44-x64
  • Skill: Intermediate
Re: How to install Manjaro on btrfs subvolumes with CLI installer
« Reply #2 on: 29. January 2016, 06:09:18 »
Good data, matches my experience. I had to try this many times, because I chose to create filesystem on partition (even though I had formatted the partition beforehand). This gave me errors every time.
I read tvat creating a subvolume for /var or var/cache is also good policy, since that avoids a alot of unnecessary writes if you take snapshots from / (because /var/cache gets changes all the time, and if it is on separate subvolume, it won't be included in the snapshot of /).

You might wan't to add, that if you are doing uefi install, you need to have esp.

It might also be worth mentioning how to deal with sparse files error that grub gives with btrfs (disable saving the boot choice).

Offline eugen-b

  • Support Team
  • ****
  • Posts: 3191
  • Branch: testing
  • Desktop: LXDE, Fluxbox, JWM, LXQt, bspwm
  • GPU Card: Intel 82945G/GZ
  • GPU driver: free
  • Kernel: 4.5, 4.6
  • Skill: Intermediate
Re: How to install Manjaro on btrfs subvolumes with CLI installer
« Reply #3 on: 27. February 2016, 20:53:25 »
The btrfs install tutorial was updated.
I still have to add some fstab tips and how to use snapshots.
MSI Wind Nettop, Intel Atom 230 1.6GHz (64bit), 2GB RAM
DEs: NET-minimal + (LXDE / Fluxbox / JWM); LXQt OpenRC
how to install on btrfs subvolumes
http://manjaro.github.io/donate/

Offline c00ter

  • Held Mitglied
  • *****
  • Posts: 1534
  • Towelie's cupcake
  • Branch: ☮Olive☮
  • Desktop: Depends©
  • GPU Card: Intel HD4400M CPU: Core i7-4510U
  • GPU driver: Intel/Free
  • Kernel: 4.4-lts & 4.5
  • Skill: Novice
Re: How to install Manjaro on btrfs subvolumes with CLI installer
« Reply #4 on: 27. February 2016, 23:14:35 »
The btrfs install tutorial was updated.
I still have to add some fstab tips and how to use snapshots.

Bless your heart, Eugene. I was just this morning considering btrfs and wondering how, and you've just done an update! :D

Regards
“What, me worry?” ― Alfred E. Newman

Manjaro Wiki: https://wiki.manjaro.org/
Arch Wiki: https://wiki.archlinux.org/
Pacman Rosetta: https://wiki.archlinux.org/index.php/Pacman/Rosetta

Offline eugen-b

  • Support Team
  • ****
  • Posts: 3191
  • Branch: testing
  • Desktop: LXDE, Fluxbox, JWM, LXQt, bspwm
  • GPU Card: Intel 82945G/GZ
  • GPU driver: free
  • Kernel: 4.5, 4.6
  • Skill: Intermediate
Re: How to install Manjaro on btrfs subvolumes with CLI installer
« Reply #5 on: 27. February 2016, 23:58:08 »
An example of an /etc/fstab
Code: [Select]
UUID=3b21f273-239c-45ef-81da-29e12bbe1fc9  /  btrfs  noatime,subvol=@jwm,compress=lzo,ssd,space_cache,commit=180 0 1
UUID=3b21f273-239c-45ef-81da-29e12bbe1fc9  /home  btrfs  noatime,subvol=@jwmhome,compress=lzo,ssd,space_cache,commit=180 0 2
tmpfs /tmp tmpfs defaults,noexec,nosuid,size=1G 0 0
A good explanation of the mount options can be found here https://btrfs.wiki.kernel.org/index.php/Mount_options
Just want to say here that for a HDD replace the option ssd with autodefrag.
The UUID is the same for each line, because the subvolumes are on the same partition.
My root subvolume in this example is @jwm, the home subvolume respectively @jwmhome.

I have several Manjaro spins installed in different subvolumes on the same partition.
This is easily possible with the CLI installer:
- Simply mount the same partition as / in step 4.6) of the tutorial above
- and in step 4.6) give the subvolume a new name. Then the installer will do his job without damaging your other subvolumes.
- But select not to install a bootloader, simply skip the step 5.5)
- Then on the system you installed first edit the file /etc/grub.d/40_custom and add there an entry with values matching the kernel of the newly installed system
Code: [Select]
menuentry 'manjaro JWM (4.1)' --class manjaro --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-3b21f273-239c-45ef-81da-29e12bbe1fc9' {
# savedefault
load_video
set gfxpayload=keep
insmod gzio
insmod part_msdos
insmod btrfs
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  3b21f273-239c-45ef-81da-29e12bbe1fc9
else
  search --no-floppy --fs-uuid --set=root 3b21f273-239c-45ef-81da-29e12bbe1fc9
fi
linux /@jwm/boot/vmlinuz-4.1-x86_64 root=UUID=3b21f273-239c-45ef-81da-29e12bbe1fc9 rw rootflags=subvol=@jwm  quiet
initrd /@jwm/boot/intel-ucode.img /@jwm/boot/initramfs-4.1-x86_64.img
}
Save and run
Code: [Select]
sudo update-gruband you will have JWM now as a Grub menu entry. Caveat: if you want to install a different kernel sieries, 4.4 for example, you will need to add a new entry in /etc/grub.d/40_custom in order to be able to boot with 4.4 kernel. If you just upgrade the 4.1 kernel no changes are needed.
« Last Edit: 28. February 2016, 00:38:10 by eugen-b »
MSI Wind Nettop, Intel Atom 230 1.6GHz (64bit), 2GB RAM
DEs: NET-minimal + (LXDE / Fluxbox / JWM); LXQt OpenRC
how to install on btrfs subvolumes
http://manjaro.github.io/donate/

Offline eugen-b

  • Support Team
  • ****
  • Posts: 3191
  • Branch: testing
  • Desktop: LXDE, Fluxbox, JWM, LXQt, bspwm
  • GPU Card: Intel 82945G/GZ
  • GPU driver: free
  • Kernel: 4.5, 4.6
  • Skill: Intermediate
Re: How to install Manjaro on btrfs subvolumes with CLI installer
« Reply #6 on: 28. February 2016, 00:24:00 »
Snapshots

There are programs with a GUI for managing btrfs (and other) snapshots, but I prefer command line.
To create a snapshot first mount the whole partition (with compress and ssd options)
Code: [Select]
sudo mount -o compress-force=lzo,ssd,noatime -t btrfs /dev/sda1 /mntThen create a snapshot with any name you will be able to recognize. I prefer the name of the subvolume, here @, with appending a date
Code: [Select]
sudo btrfs subvolume snapshot /mnt/@ /mnt/@280216
Later, if you want to make you system go back to the snapshot state:
Code: [Select]
sudo mount -o compress-force=lzo,ssd,noatime -t btrfs /dev/sda1 /mnt
sudo mv /mnt/@ /mnt/@_badroot
sudo mv /mnt/@280216 /mnt/@
Reboot. Verify that your are back to the state when the snapshot was created.
To delete a snapshot or your subvolume @_badroot:
Code: [Select]
sudo mount /dev/sda1 /mnt
sudo btrfs subvol delete /mnt/@_badroot

(There are some things to know about nested subvolumes. That's the term for subvolumes which sit within a subvolume. A snapshot doesn't contain the nested subvolumes. This can be useful and openSUSE sets up its btrfs install with nested subvolume for /var/cache and other. But I prefer to create a subvolume for my pacman cache and mount it on /var/cache/pacman
Code: [Select]
UUID=3b21f273-239c-45ef-81da-29e12bbe1fc9  /var/cache/pacman  btrfs  noatime,subvol=@pacman,compress=lzo,ssd,space_cache,commit=180 0 2Another point to mention about nested subvolumes is that you need to delete it first before you can delete the root subvolume. And you cannot delete a subvolume from the file manager. The rm command will also give errors.)

Snapshots use extra space on the drive. Initially on creation they use almost none, but the more changes happen to the original subvolume @, the more grows the space use of the snapshot @280216. Actually the snapshot saves only the difference in data. This is based on copy-on-write feature of btrfs.

Snapshots are good for "risky" operations with your system. They do not substitute backups!! You cannot do anything with nice snapshots if your drive is broke! ;)
MSI Wind Nettop, Intel Atom 230 1.6GHz (64bit), 2GB RAM
DEs: NET-minimal + (LXDE / Fluxbox / JWM); LXQt OpenRC
how to install on btrfs subvolumes
http://manjaro.github.io/donate/

Offline eugen-b

  • Support Team
  • ****
  • Posts: 3191
  • Branch: testing
  • Desktop: LXDE, Fluxbox, JWM, LXQt, bspwm
  • GPU Card: Intel 82945G/GZ
  • GPU driver: free
  • Kernel: 4.5, 4.6
  • Skill: Intermediate
Re: How to install Manjaro on btrfs subvolumes with CLI installer
« Reply #7 on: 28. February 2016, 00:29:21 »
Thanks everybody for your appreciation!
I would have loved to have such a guide when I first decided to install on btrfs. But there were very few and most of them too difficult to understand for a new Linux user.
I would like to add, that my way of handling btrfs is by far not the only possible. I try to treat subvolumes as a metaphor for partitions, but you can do it in a more technical and abstract way like openSUSE installer does.
MSI Wind Nettop, Intel Atom 230 1.6GHz (64bit), 2GB RAM
DEs: NET-minimal + (LXDE / Fluxbox / JWM); LXQt OpenRC
how to install on btrfs subvolumes
http://manjaro.github.io/donate/

Offline muncharo

  • Vollwertiges Mitglied
  • ***
  • Posts: 110
  • I'm new. Be nice!
  • Branch: stable
  • Desktop: i3
  • GPU Card: VGA compatible controller: Intel Corporation Haswell-ULT Integrated Graphics Controller (rev 09)
  • GPU driver: free
  • Kernel: 4.1.19-1-MANJARO
  • Skill: Advanced
Re: How to install Manjaro on btrfs subvolumes with CLI installer
« Reply #8 on: 28. February 2016, 04:17:05 »
Super awesome guide, thank you!
« Last Edit: 28. February 2016, 10:59:14 by muncharo »

Offline muncharo

  • Vollwertiges Mitglied
  • ***
  • Posts: 110
  • I'm new. Be nice!
  • Branch: stable
  • Desktop: i3
  • GPU Card: VGA compatible controller: Intel Corporation Haswell-ULT Integrated Graphics Controller (rev 09)
  • GPU driver: free
  • Kernel: 4.1.19-1-MANJARO
  • Skill: Advanced
Re: How to install Manjaro on btrfs subvolumes with CLI installer
« Reply #9 on: 28. February 2016, 10:59:34 »
Following your guide (entire disk btrfs) I'm greeted with: Operation System not found after the final reboot. I'm not using UEFI, booting normal legacy mode.

I tried it repeatedly, grub is installed on sda but the menu doesn't give me the choice to install on MBR?

Offline eugen-b

  • Support Team
  • ****
  • Posts: 3191
  • Branch: testing
  • Desktop: LXDE, Fluxbox, JWM, LXQt, bspwm
  • GPU Card: Intel 82945G/GZ
  • GPU driver: free
  • Kernel: 4.5, 4.6
  • Skill: Intermediate
Re: How to install Manjaro on btrfs subvolumes with CLI installer
« Reply #10 on: 28. February 2016, 11:13:59 »
Cannot use different file systems for different mount points.
Cannot use different mount options for subvolumes from the same partition (or RAID volume).
It was perfectly possible for me to mount a different partition in ext4 side by side my btrfs subvolumes.
Cannot use swap area as Btrfs does not support swap files and there is no place to create swap partition. This also limits the use of hibernation/resume, which needs a swap area to store the hibernation image.
...
Does that mean I cannot swap a swap subvolume and I cannot have a swap partition outside of the btrfs partition since it needs the whole disk?
You need a separate swap partition. A btrfs partiton doesn't require to span over the the whole drive. There is some controversy that one could format a whole drive as btrfs without creating a partition and this would boost performance, but this has yet to be proved.

Cannot use UEFI to boot.
You would need a separate fat32 /efi/boot partition.

If I want to encrypt the entire disk I need to have an unencrypted boot partition, multiple ones if I want a second backup linux install, so I need additional partitions next to the btrfs partition? Is encryption pausible with this manjaro installer or do I have to go vanilla arch?
You cold put all the additional partitions on separate devices. At least for the /efi/boot partition it would make sense from security POV.
If you want to encrypt a btrfs setup on partition level you need to do further research. Maybe the approach of openSUSE is better for this and would even work automatically. With Manjaro CLI installer you will need to set up encryption manually after installing. All infos will be in the Arch Wiki. But I see no reason why a btrfs partiton couldn't be encrypted as any other partition. Cryptsetup would decrypt the partition on boot, then the subvolumes become visible to Grub and it will do its job.
MSI Wind Nettop, Intel Atom 230 1.6GHz (64bit), 2GB RAM
DEs: NET-minimal + (LXDE / Fluxbox / JWM); LXQt OpenRC
how to install on btrfs subvolumes
http://manjaro.github.io/donate/

Offline eugen-b

  • Support Team
  • ****
  • Posts: 3191
  • Branch: testing
  • Desktop: LXDE, Fluxbox, JWM, LXQt, bspwm
  • GPU Card: Intel 82945G/GZ
  • GPU driver: free
  • Kernel: 4.5, 4.6
  • Skill: Intermediate
Re: How to install Manjaro on btrfs subvolumes with CLI installer
« Reply #11 on: 28. February 2016, 11:20:13 »
Following your guide (entire disk btrfs) I'm greeted with: Operation System not found after the final reboot. I'm not using UEFI, booting normal legacy mode.

I tried it repeatedly, grub is installed on sda but the menu doesn't give me the choice to install on MBR?
I'm not an UEFI expert at all, never installed on UEFI. I can give you the wiki link https://wiki.manjaro.org/index.php?title=BIOS_and_UEFI
And recommend to use the forum search. Maybe the easiest solution would be to use the UEFI mode and have a separate /efi/boot partition.
MSI Wind Nettop, Intel Atom 230 1.6GHz (64bit), 2GB RAM
DEs: NET-minimal + (LXDE / Fluxbox / JWM); LXQt OpenRC
how to install on btrfs subvolumes
http://manjaro.github.io/donate/

Offline Nergal

  • Neuling
  • *
  • Posts: 44
  • Branch: Stable
  • Desktop: KDE Plasma 5
  • GPU Card: Intel / nVidia GTX 970M
  • GPU driver: non-free
  • Kernel: 4.4.3-1
  • Skill: Novice
Re: How to install Manjaro on btrfs subvolumes with CLI installer
« Reply #12 on: 28. February 2016, 11:30:57 »
Nice guide about setting up BTRFS.

In the fstab, I think the pass value should be 0 for BTRFS, at least according to Arch wiki

https://wiki.archlinux.org/index.php/fstab
« Last Edit: 28. February 2016, 11:39:11 by Nergal »
___________________________________
MSI GS60 Ghost Pro 3K- i7-4710HQ - 16GB

Offline Nergal

  • Neuling
  • *
  • Posts: 44
  • Branch: Stable
  • Desktop: KDE Plasma 5
  • GPU Card: Intel / nVidia GTX 970M
  • GPU driver: non-free
  • Kernel: 4.4.3-1
  • Skill: Novice
Re: How to install Manjaro on btrfs subvolumes with CLI installer
« Reply #13 on: 28. February 2016, 11:38:05 »
I have a BTRFS on my laptop and desktop. Both are UEFI.

For UEFI, you need a separate vfat partitition for  /boot/efi.
So the installation is no different from a normal UEFI.

I have an NVME in my desktop and it is a bloody nightmare to get it to work with Manjaro because the current version of GRUB does not support booting from NVME

I managed to get a bootable system by having a separate /boot and /boot/efi partitions.

Currently, the CLI installer does not recognize NVME.
« Last Edit: 28. February 2016, 11:41:32 by Nergal »
___________________________________
MSI GS60 Ghost Pro 3K- i7-4710HQ - 16GB

Offline eugen-b

  • Support Team
  • ****
  • Posts: 3191
  • Branch: testing
  • Desktop: LXDE, Fluxbox, JWM, LXQt, bspwm
  • GPU Card: Intel 82945G/GZ
  • GPU driver: free
  • Kernel: 4.5, 4.6
  • Skill: Intermediate
Re: How to install Manjaro on btrfs subvolumes with CLI installer
« Reply #14 on: 28. February 2016, 12:27:30 »
I was wrong about CLI installer not supporting encryption.
It is in the main menu 2 Disc(s) preparation -> 3 Create Raid, Lvm2 and Luks encryption.
But I haven't tested it.

@Nergal, can you post a Gparted screenshot, your fstab or some kind of visualization of your UEFI setup? :)
About pass 0 for root mount point with btrfs, I think this info is outdated. I had some issues on older Debian ISOs where it wouldn't boot of it wasn't 0, but an update of the kernel and btrfs-progs made pass 1 possible.
Other source, which supports your view
Quote
Be sure to change the /etc/fstab to reflect the change (type to btrfs and fs_passno [the last field] to 0 as Btrfs does not do a file system check on boot).
https://wiki.archlinux.org/index.php/Btrfs
But I think it does perform a filesystem check, I will try to verify it somehow.
« Last Edit: 28. February 2016, 12:53:37 by eugen-b »
MSI Wind Nettop, Intel Atom 230 1.6GHz (64bit), 2GB RAM
DEs: NET-minimal + (LXDE / Fluxbox / JWM); LXQt OpenRC
how to install on btrfs subvolumes
http://manjaro.github.io/donate/