gentoo squashfs portage under overlay(fs) 記

注意:-
呢嗰 squashfs 响 btrfs 唔 work,
因為 emerge --sync , emerge-webrsync 嘅 rsync 嗰時有問題
overlay files/dir 而家用緊 ext4, / 係 btrfs


2006 年嘅 post, 好多嘢唔同曬
https://forums.gentoo.org/viewtopic-t-465367.html
原本係用 aufs, 太多嘢, 冇搞佢
自從新啲嘅 kernel 有 overlay(fs) 就諗住玩吓
gentoo user "mv" 接手 main 個 project 叫 squashmount,
又唔想响部機 install portage overlay
咁就响部 vm fetch mv overlay, dl & test
將啲 procedures & ebuild, 由 vm 機抄返出嚟 /usr/local/portage/...

要嘅係 mv overlay 嘅
  1. /var/lib/layman/mv/sys-fs/squashmount/squashmount-12.1.1.ebuild
  2. /var/lib/layman/mv/sys-fs/squashfs-tools/squashfs-tools-4.3.ebuild
  3. /var/lib/layman/mv/app-shells/runtitle/runtitle-2.7.ebuild
複製代碼
  1. kernel config
  2. Device Drivers --->
  3.   Block Devices --->
  4.     <M> Loopback device support
  5. File systems  --->
  6.    [M] Overlay filesystem support
  7.    
  8. https://wiki.gentoo.org/wiki/SquashFS#Kernel
  9.        
複製代碼
  1. edit /etc/portage/package.use
  2. sys-fs/squashfs-tools xz lz4 lzma lzo xattr
  3. time emerge -av Term-ANSIColor File-Which squashmount squashfs-tools
複製代碼
用 gentoo/mv 個 squashfs-tools, 自己決定, 問題不大
有問題, 玩得嘅, 應該自己識點 fix.

如果 /usr/portage 有啲特別嘢, 搞過 /etc/fstab 還原返,
backup /usr/portage ( 可以唔做, 做咗冇壞 )
重要嘅係 /usr/portage 只係有啲 ebuild 同 dir structures,
edit /etc/portage/make.conf
嗰啲 DISTFILES PKGDIR 全部要搬曬出去

mv /etc/squashmount.pl /etc/squashmount.pl.org
個 org 有好多 example, 慢慢睇, 用呢個 min conf.
  1. cat /etc/squashmount.pl

  2. #!/usr/bin/perl (this is only for editors)

  3. # The tools which we have installed; if possible only the first in this list
  4. # is used, but the others are a fallback if that fails.

  5. @order = ( overlay ); # 舊啲嘅 kernel 係 overlayfs, chk 清楚

  6. # Even if we define following is empty it is convenient to use
  7. # this local variable throughout, so that we can simply change it:

  8. DIFF => 1;
  9. RESQUASH_ON_START => 1;

  10. push(@mounts, {
  11.    TAG => 'portage',
  12.    DIR => '/usr/portage', # 係响 btrfs partition
  13.    FILE => '/no-XXX/portage.sqfs', # /no-XXX/ 係响 ext4 partition
  14.    CHANGES => '/no-XXX/portage.changes',
  15.    WORKDIR => '/no-XXX/portage.squashfs.workdir',
  16.    READONLY => '/no-XXX/portage.readonly',
  17.    THRESHOLD => '40m', # resquash on umount if 40 megabytes changed
  18.    COMPRESSION => 'lz4'   
  19. });
  20. @umount;
  21. 1;
複製代碼
@order = ( overlay ); 舊啲嘅 kernel 係 overlayfs
可以係第貳啲, 睇 /etc/squashmount.pl.org
no-XXX 要改去, 自己要指去嘅地方
注意最後嗰行係 1;

第一次 run
/etc/init.d/squashmount -d start
-d for debug info
佢會 build squash file /no-XXX/portage.sqfs  ~= 110MB
之後會剷曬 /usr/portage/*
同埋 create /no-XXX/portage.* directories
用 overlay(fs) 嚟 mount /usr/portage
所以如果玩第貳啲 dir, 記得 backup 先,
或者响 vm 試清楚先好去 production
/etc/fstab 唔洗有特別 /usr/portage ... 個 entry

#df -hT 會有 2 個 new mount, loop 同 overlay
  1. /dev/loop0     squashfs  104M  104M     0 100% /home/PORTAGE_FILES/portage.readonly
  2. overlay        overlay   2.6T  435G  2.0T  18% /usr/portage
複製代碼
# mount
  1. /home/PORTAGE_FILES/portage.sqfs on /home/PORTAGE_FILES/portage.readonly type squashfs (ro,noatime)
  2. overlay on /usr/portage type overlay (rw,noatime,lowerdir=/home/PORTAGE_FILES/portage.readonly,upperdir=/home/PORTAGE_FILES/portage.changes,workdir=/home/PORTAGE_FILES/portage.squashfs.workdir)
複製代碼
rc-update add squashmount default
如果 > 40MB changes, shutdown 嗰陣會 recompress,
我部垃圾機都只係用多 ~ 1 分鐘
reboot && good luck

希望冇打漏/錯嘢, 知道先改返