<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<atom:link href="http://gentoo-zh.org/extern.php?action=feed&amp;tid=597&amp;type=rss" rel="self" type="application/rss+xml" />
		<title><![CDATA[Gentoo中文社区 / Gentoo-on-btrfs]]></title>
		<link>http://www.gentoo-zh.org/viewtopic.php?id=597</link>
		<description><![CDATA[Gentoo-on-btrfs 最近发表的帖子。]]></description>
		<lastBuildDate>Thu, 01 Dec 2022 04:17:18 +0000</lastBuildDate>
		<generator>FluxBB</generator>
		<item>
			<title><![CDATA[Gentoo-on-btrfs]]></title>
			<link>http://www.gentoo-zh.org/viewtopic.php?pid=638#p638</link>
			<description><![CDATA[<p>## Gentoo BTRFS with Optimizations and Musl Libc<br />This is the Gentoo Btrfs with Optimizations and Musl Libc. or GentooBOML (GBOML) :penguin:</p><br /><p>| :warning: Disclaimer&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; |<br />| :---------------------------------------------------------------------------------------------------------------------------------- |<br />| Please keep in mind that this might not work on your machine, this guide is specified for amd64 CPUs and EFI machines.&#160; &#160; &#160; &#160; &#160; &#160; &#160; |</p><p>## Why?<br />This is (going to be) a painful journy to achive maximum performance on gentoo with many unusual choices. This all began when i started having issues with replacing and matching different parts of linux in a virtual machine. I struggled with making proper alterations to common parts like glibc and gcc, so i&#039;m making this guide to document the progress of GentooBOML.</p><p>## What Does This Contain?<br />1. Btrfs! an alternative file system to EXT4 which offers many features such as: Autodefrag, Compression, Subvolumes, Self-Healing and most importantly, Great Snapshotting of data instantaneously. It has got many developments over the years, and now 1 year in, i&#039;ve never had a problem with using Btrfs, although many still consider it unstable, many linux distros have made the bold switch to the future file system BTRFS.<br />2. Musl Libc! although not a common choice, Musl has proven to be a great standard C library with great simplicity and a small code base, it can do as much as glibc. * This comes to the indivisuals&#039; choice, if you want a stable system then prefer not to use musl libc. It can break many packages!<br />3. LTO! lto is very controversial in the gentoo community with many opting to just stick with use flags and masking, but lto can offer a great performace boost on many machines, for me i&#039;ve used lto for many months now and never had a system breaking problem, mostly small breakages that need an hour of fixing for a month use, but be warned, you&#039;ll have to debug a lot on your own!</p><p>## Let&#039;s Start with the BTRFS basics<br />Btrfs can produce snapshots of the system data, and you can rollback anytime you want, to take proper advantage of these features, btrfs subvolumes must be properly setup.<br />For making snapshots, subvolumes are a way to exclude variable files from being snapshotted, this prevents data loss and removes big snapshots.</p><p>Here I follow the standard subvolumes model provided by [OpenSUSE Wiki](<a href="https://aya1.eu.org:443/https/en.opensuse.org/SDB:BTRFS#Default_Subvolumes" rel="nofollow">https://aya1.eu.org:443/https/en.opensu … Subvolumes</a>)<br />The following directories should be excluded from snapshots:</p><p>1. /home/&#160; &#160; &#160; &#160;**Avoided if home is on a different partition.**<br />2. /root/&#160; &#160; &#160; &#160;**Default root user directory.**<br />3. /opt/&#160; &#160; &#160; &#160; **For 3rd party software installations.**<br />4. /srv/&#160; &#160; &#160; &#160; **For data of WEB and FTP servers.**<br />5. /usr/local&#160; &#160;**Containing local temperory files and caches.**<br />6. /var/&#160; &#160; &#160; &#160; **Containing variable files.**<br />7. /.snapshots/ **This is a custom directory made specifically for snapshots. ❗ You don&#039;t want to take a snapshot of a snapshot ❗**<br />8. /tmp/&#160; &#160; &#160; &#160; **For temporary files.**</p><p>Now that you know how btrfs works. Let&#039;s continue to the early setup phase:</p><p>## Phase 1: Disk Preparation<br />First of all. Pepare your partitions. I prefer the following setup:</p><p>|Partition |&#160; Filesystem&#160; |&#160; Partition Type&#160; |&#160; Size&#160; |<br />|----------|--------------|------------------|--------|<br />|/dev/sda1 |&#160; &#160; &#160;vFat&#160; &#160; &#160;|&#160; EFI Partition&#160; &#160;|&#160; 512M&#160; |<br />|/dev/sda2 |&#160; &#160; &#160;Btrfs&#160; &#160; |&#160; Home Partition&#160; |&#160; any%&#160; |<br />|/dev/sda3 |&#160; &#160; &#160;Btrfs&#160; &#160; |&#160; Linux Partition |&#160; 60G&#160; &#160;|</p><p>**Home Partition is optional but preferable.** For more information about this setup see the [FAQ](#faq)</p><p>After making the partitions make sure to format them correctly:<br />```bash<br />mkfs --type vfat /dev/{efipart}&#160; &#160; # Replace {efipart} with your EFI part.<br />mkfs --type btrfs /dev/{homepart}&#160; # You can also have ext4 or vfat // Replace {homepart} with your home partition if you have one.<br />mkfs --type btrfs /dev/{linuxpart} # Replace {linuxpart} with your linux partition.<br />```</p><p>Now that you have setup disks, you&#039;re ready for Phase 2. Please notice that from now on i&#039;ll be using the setup above, you must change it according to your setup...</p><p>## Phase 2: Mouting and Setup<br />Mount the linux partition first<br />```bash<br />mount /dev/sda3 /mnt<br />cd /mnt<br />```</p><p>Let&#039;s make sure that the subvolumes are created properly, this is done bt creating subvolumes using the standard @ format:<br />```bash<br />btrfs subvolume create @<br />btrfs subvolume create @root<br />btrfs subvolume create @opt<br />btrfs subvolume create @srv<br />btrfs subvolume create @local<br />btrfs subvolume create @var<br />btrfs subvolume create @tmp<br />btrfs subvolume create @.snapshots<br />btrfs subvolume create @home # Not needed if you use a seperate partition&#160; //<br />```</p><p>**@ is the main parent subvolume, it&#039;s like the / which is the parent directory.**</p><p>Now unmount the partition and make sure to be outside the /mnt directiry<br />```bash<br />cd /<br />umount -r /mnt<br />```</p><p>Now mount the linux partition firstly to create the specified directories:<br />```bash<br />mount -o defaults,noatime,compress=zstd,commit=120,autodefrag,subvol=@ /dev/sda3 /mnt<br />```<br />Make sure to create the following directories:<br />```bash<br />mkdir -p /mnt/{home,srv,root,tmp,opt,usr/local,var,.snapshots,efi,boot}<br />```<br />Great! Now mount the rest of the subvolumes:<br />```bash<br />mount -o defaults,noatime,compress=zstd,commit=120,autodefrag,subvol=@local /dev/sda3 /mnt/usr/local<br />mount -o defaults,noatime,compress=zstd,commit=120,autodefrag,subvol=@root /dev/sda3 /mnt/root<br />mount -o defaults,noatime,compress=zstd,commit=120,autodefrag,subvol=@opt /dev/sda3 /mnt/opt<br />mount -o defaults,noatime,compress=zstd,commit=120,autodefrag,subvol=@srv /dev/sda3 /mnt/srv<br />mount -o defaults,noatime,compress=zstd,commit=120,autodefrag,subvol=@var /dev/sda3 /mnt/var<br />mount -o defaults,noatime,compress=zstd,commit=120,autodefrag,subvol=@tmp /dev/sda3 /mnt/tmp<br />mount -o defaults,noatime,compress=zstd,commit=120,autodefrag /dev/sda2 /mnt/home<br />mount /dev/sda1 /mnt/efi<br />```<br />**I mounted the EFI Partition on /efi because it&#039;s better to seperate the /boot for kernels and /efi for grub and efi configurations.**</p><p>Download the latest Musl Libc in the /mnt directory. This can change so make sure to &quot;wget&quot; the latest version from [Gentoo Downloads](<a href="https://aya1.eu.org:443/https/www.gentoo.org/downloads/" rel="nofollow">https://aya1.eu.org:443/https/www.gentoo.org/downloads/</a>)<br />```bash<br />cd /mnt<br />wget <a href="https://aya1.eu.org:443/https/gentoo.osuosl.org//releases/amd64/autobuilds/20220220T170542Z/stage3-amd64-musl-hardened-20220220T170542Z.tar.xz" rel="nofollow">https://aya1.eu.org:443/https/gentoo.os … 42Z.tar.xz</a><br />```<br />Now all we need is to untar the tar<br />```bash<br />tar xpvf stage3-*.tar.xz --xattrs-include=&#039;*.*&#039; --numeric-owner<br />```</p><p>Now this is the end of [Phase 2](#phase-2-mouting-and-setup). We can go to Phase 3.</p><p>## Phase 3<br />***TO BE CONTINUED... Phase 3 and 4 are under experimentation. Bulletproof methodes are not possible, although some startigies can be applied for a usable system. soon enough i&#039;ll be able to make a gentoo system that works with musl libc and clang. I hope i can get these phases finished before summer. or if i can&#039;t then next year when Musl Libc gentoo is stable. Please be patient...***</p><p>***Testing for Phase 3 and 4 failed. Project halted until further notice <img src="http://www.gentoo-zh.org/img/smilies/sad.png" width="15" height="15" alt="sad" />***</p><p>## FAQ<br />**1. Why put the EFI partition first?**<br />Because the EFI partition is a common partition between different linux distros, so it doesn&#039;t need to change according to the distro.</p><p>**2. Why put the Home partition second?**<br />Because the Home partition starts at a certain section in the hard disk or SSD, which when increasing or decreasing the partition size from the begining, it needs to move the partition data, increasing/decreasing the size at the ends doesn&#039;t need to move the data. So, by having it between the EFI partition and Linux partition, it fixes the issue.<br />**3. What is the minimum size for the partitions?**<br />EFI can be up to 512 Megabyes, Home partition can be whatever size you want, and the Linux partition needs to be at least 50-60 Gigabytes.</p>]]></description>
			<author><![CDATA[dummy@example.com (batsom)]]></author>
			<pubDate>Thu, 01 Dec 2022 04:17:18 +0000</pubDate>
			<guid>http://www.gentoo-zh.org/viewtopic.php?pid=638#p638</guid>
		</item>
	</channel>
</rss>
