Advertisement
plirof2

initrd1.xz finit squashfs overlay limit order

Aug 5th, 2023 (edited)
2,021
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. https://forum.puppylinux.com/viewtopic.php?f=46&t=1857&start=230
  2.  
  3. Fix initrd1 finit to avoid overlay limits
  4. https://forum.puppylinux.com/search.php?keywords=newinitrd&t=1857&sf=msgonly&sid=644d7e18713b4db52ac6333155826141
  5.  
  6.  
  7. =====================
  8. If you want you can change that by modifying initrd1.xz:
  9.  
  10. Extract initrd1.xz from standing in the 'live' dir:
  11.  
  12. mkdir newinitrd        # make dir where the extracted files go
  13. cd newinitrd         # go inside newinitrd directory
  14. xz -dc ../initrd1.xz | cpio -i        # extract  ../initrd1.xz
  15.  
  16. Open inside newinitrd "linuxrc" with texteditor, find the line "NAME=`basename $x`;" (line 213) and change to
  17.     ############### truncate mountpoint names ##############
  18.     #   NAME=`basename $x`; //ORIGINAL line
  19.         NAME=`basename ${x%.*}`; # remove extension .squashfs
  20.         NAME="${NAME:0:14}""-$a"
  21.  
  22.     # skip if (truncated) /memory/images/$NAME exists already
  23.     [ -d /memory/images/$NAME ] && continue
  24.     let a=a+1
  25.     #########################################################
  26.  
  27. Create new initrd1.xz (note: will overwrite existing in live dir):
  28.  
  29. cd newinitrd   # or open terminal in newinitrd dir.
  30. find . -print | cpio -o -H newc 2>/dev/null | xz -f --extreme --check=crc32 > ../initrd1_jon06finit.xz
  31.  
  32. ==================
  33.  
  34.  
  35. 1) Truncates names of the module mountpoints (to 10 chars, change the 10 at NAME="${NAME:0:10}" near the bottom of finit if you like less or more.
  36. One disadvantage may be problem if 2 or more modules begin with the same 10 chars, it might happen, in that case any duplicate will be skipped,
  37. advantage compared to 2) is that you can see a little which module is which, but that is of course the first 10 chars only though)
  38. finit-truncate.gz (rename to finit)
  39.  
  40. 2) Changes the names of the module mountpoints to sequenced number (similar as in above posts, but no symlinks needed)
  41. finit-numbered.gz (rename to finit)
  42.  
  43. With both ways the modules can be in "live" just as it normally used to be before, and the advantage compared to the symlink method is that it should work on FAT32 too.
  44.  
  45. Other option may be a combination of the two, truncated names numbered in sequence, didn't try that (yet?)
  46.  
  47. Fred
  48.  
  49. ============================
  50. finit k ..-23
  51.  
  52.  
  53. ## Functions for porteus init
  54. ## Author brokenman, modified for Debiandog by fredx181
  55.  
  56. # Export some color functions
  57. RED='\033[0;31m'
  58. GREEN='\033[0;32m'
  59. CYAN='\033[0;36m'
  60. YELLOW='\033[1;33m'
  61. BOLD='\033[1;37m'
  62. RST='\033[0m' # Reset Color
  63.  
  64. # Run fstab for setup
  65. fstab() { rm -f /tmp/devices
  66. param nocd || for x in /dev/sr*; do blkid $x >>/tmp/devices; done
  67. param nohd || blkid | egrep -v '/dev/sr|/dev/loop|/dev/mapper' >>/tmp/devices
  68. dev=`egrep -v 'TYPE="sw|TYPE="LVM|TYPE=".*_raid_member"' /tmp/devices 2>/dev/null | cut -d: -f1 | cut -d/ -f3 | sort | uniq`
  69. cat > /etc/fstab << EOF
  70. # Do not edit this file as fstab is recreated automatically during every boot.
  71. # Please use /etc/rc.d/rc.local or sysvinit scripts if you want to mount/unmount
  72. # drive, filesystem or network share.
  73.  
  74. # System mounts:
  75. #aufs / aufs defaults 0 0
  76. overlay / overlay 0 0
  77.  
  78. proc /proc proc defaults 0 0
  79. sysfs /sys sysfs defaults 0 0
  80. devtmpfs /dev devtmpfs defaults 0 0
  81. devpts /dev/pts devpts rw,mode=0620,gid=5 0 0
  82.  
  83. # Device partitions:
  84. EOF
  85. for x in $dev; do
  86.    fs=`grep -w /dev/$x /tmp/devices | egrep -o ' TYPE=[^ ]+' | cut -d'"' -f2`
  87.    [ $fs = vfat ] && echo "/dev/$x /mnt/$x vfat $MOPT,umask=0,check=s,utf8 0 0" >>/etc/fstab || echo "/dev/$x /mnt/$x $fs $MOPT 0 0" >>/etc/fstab
  88.    if [ ! -d /mnt/$x ]; then
  89.     mkdir /mnt/$x
  90.     if [ $fs = ntfs ]; then
  91.         ntfs-3g /dev/$x /mnt/$x -o $MOPT 2>/dev/null || { sed -i "/$x /d" /etc/fstab; rmdir /mnt/$x; }
  92.     else
  93.         mount -n /mnt/$x 2>/dev/null || { modprobe $fs 2>/dev/null && mount -n /mnt/$x 2>/dev/null || { sed -i "/$x /d" /etc/fstab; rmdir /mnt/$x; }; }
  94.     fi
  95.    fi
  96. done
  97.  
  98. if [ -z "`egrep -o " noswap( |\$)" /proc/cmdline`" -a -e /tmp/devices ]; then
  99.     #echo -e "\n# Swap partitions:" >>/etc/fstab
  100.     for x in `grep 'TYPE="swap"' /tmp/devices | cut -d: -f1`; do echo "$x none swap sw,pri=1 0 0" >>/etc/fstab; done
  101. fi }
  102.  
  103. # Mount things
  104. mount_device() {
  105. fs=`blkid /dev/$1 | egrep -o ' TYPE=[^ ]+' | cut -d'"' -f2`
  106. if [ "$fs" ]; then
  107.    mkdir /mnt/$1
  108.    if [ $fs = vfat ]; then
  109.     mount -n /dev/$1 /mnt/$1 -o $MOPT,umask=0,check=s,utf8 2>/dev/null || rmdir /mnt/$1
  110.    elif [ $fs = ntfs ]; then
  111.     ntfs-3g /dev/$1 /mnt/$1 -o $MOPT 2>/dev/null || rmdir /mnt/$1
  112.    else
  113.     mount -n /dev/$1 /mnt/$1 -o $MOPT 2>/dev/null || { modprobe $fs 2>/dev/null && mount -n /dev/$1 /mnt/$1 -o $MOPT || rmdir /mnt/$1; }
  114.    fi
  115. fi }
  116.  
  117. # Search for boot location
  118. search() { FND=none; for x in `ls /mnt | tac`; do
  119. [ $1 /mnt/$x/$2 ] && { DEV=$x; FND=y; break; }; done
  120. [ $FND = y ]; }
  121.  
  122. # Delay booting a little until devices have settled
  123. nap() { echo -en $i"device not ready yet? delaying $SLEEP seconds \r"; sleep 1; }
  124. lazy() { SLEEP=6; while [ $SLEEP -gt 0 -a $FND = none ]; do nap; let SLEEP=SLEEP-1; fstab; search $*; done }
  125.  
  126. # Find location of Porteus files
  127. locate() { LPATH=`echo $2 | cut -b-5 | sed s@/dev@/mnt@`
  128. if [ $LPATH = /mnt/ ]; then
  129.    DEV=`echo $2 | cut -d/ -f3`; LPTH=`echo $2 | cut -d/ -f4-`; SLEEP=6
  130.    while [ $SLEEP -gt 0 -a ! -b /dev/$DEV ]; do nap; let SLEEP=SLEEP-1; fstab; done
  131.    [ -d /mnt/$DEV ] || mount_device $DEV
  132.    [ $1 /mnt/$DEV/$LPTH ]
  133. elif [ $LPATH = UUID: -o $LPATH = LABEL ]; then
  134.    ID=`echo $2 | cut -d: -f2 | cut -d/ -f1`; LPTH=`echo $2 | cut -d/ -f2-`; DEV=`blkid | grep $ID | cut -d: -f1 | cut -d/ -f3`; SLEEP=6
  135.    while [ $SLEEP -gt 0 -a "$DEV" = "" ]; do nap; let SLEEP=SLEEP-1; fstab; DEV=`blkid | grep $ID | cut -d: -f1 | cut -d/ -f3`; done
  136.    [ -d /mnt/$DEV ] || mount_device $DEV
  137.    [ $1 /mnt/$DEV/$LPTH ]
  138. else
  139.    LPTH=$2; search $* || lazy $*
  140. fi }
  141.  
  142. # Check if a location is writable
  143. is_writable(){ touch $1/.test 2>/dev/null; [ -e $1/.test ] && rm $1/.test; }
  144.  
  145. # Booting failed. Failed to find porteus files.
  146. fail() { echo -e $i"couldn't find $1. Correct your from= cheatcode.\n Documentation in /usr/doc/porteus. Press 'enter' to continue booting."; read -s; }
  147.  
  148. # Failed to initiate changes. Creating temporary changes on tmpfs for this session.
  149. fail_chn() { mount -nt tmpfs -o size=$RAMSIZE tmpfs /memory/changes; CHANGES=memory; CHNDEV=memory; touch /etc/nochanges; }
  150.  
  151. # Just draw a line
  152. draw() { echo """---------------------------------------------------------"""; }
  153.  
  154. # Error checking a save file.
  155. fsck_dat() { echo $i"checking $1 for errors"
  156. fs=`blkid $1 | egrep -o ' TYPE=[^ ]+' | cut -b8-10`
  157. if [ $fs = xfs ]; then
  158.    echo $i"detected xfs - performing fsck at mount time"
  159. elif [ $fs = ext ]; then
  160.    draw; e2fsck -C 0 -p $1; wait; draw
  161. elif [ $fs = rei ]; then
  162.    draw; reiserfsck -p $1; wait; draw
  163. else
  164.    echo $i"detected unsupported fs - skipping fsck"
  165. fi }
  166.  
  167. # Copy modules
  168. cpmod() { NUM=`grep -c '.' $1`
  169. modfile=$1
  170. while read x; do
  171.    echo -en """  ($NUM modules left)  \r"""; let NUM=NUM-1; NAME=`basename "$x"`
  172.    cp "$x" /memory/copy2ram 2>/dev/null
  173.    if [ $? -eq 0 ]; then
  174.     sed -i s@^.*/$NAME@/memory/copy2ram/$NAME@ /tmp/modules
  175.    else
  176.     rm /memory/copy2ram/"$NAME"; echo -e $i"""Not enough memory to copy $NAME"""; echo -e $i"""Other modules will be skipped."""
  177.     find /memory/copy2ram -name "*.squashfs" | sort >/tmp/modules
  178.     break
  179.    fi
  180. done < $modfile
  181. echo -en "                       \r"
  182. }
  183.  
  184. # If bootlog cheatcode is present then make log entry
  185. blog(){
  186.         param log && echo "$1" >> $LOGFILE
  187. }
  188.  
  189. # Check for a boot param
  190. #chk_bootcfg(){ grep "^$1" /union/etc/bootcmd.cfg; }
  191.  
  192. #======================================
  193. # setClean
  194. #--------------------------------------
  195. setClean()
  196. {
  197. #=== 変分反映層
  198.     mkdir -p /memory/changes/upperdir
  199. #=== 変分管理データ層
  200.     mkdir -p /memory/changes/workdir
  201.  
  202. #--<継承エリア初期化>--#
  203. local PLACE=/memory/changes/upperdir
  204. #   rm -rf $PLACE/boot 2>/dev/null
  205.     rm -rf $PLACE/dev 2>/dev/null
  206.     rm -rf $PLACE/mnt 2>/dev/null
  207.     rm -rf $PLACE/proc 2>/dev/null
  208.     rm -rf $PLACE/run 2>/dev/null
  209.     rm -rf $PLACE/sys 2>/dev/null
  210.     rm -rf $PLACE/tmp 2>/dev/null
  211.     rm -rf $PLACE/var/lock/* 2>/dev/null
  212.     rm -rf $PLACE/var/run 2>/dev/null
  213.     rm -rf $PLACE/var/tmp 2>/dev/null
  214.     rm -rf $PLACE/var/spool/cron/cron.?????? 2>/dev/null
  215.  
  216. #   chown -R guest:users $PLACE/home/guest 2>/dev/null
  217.  
  218. #--< activate 後 deactivate 無しで終了した残骸を削除する >--#
  219. #--- delete symbolic link setting "entity & tag" ---#
  220. local x
  221. local DIR
  222. local PKG
  223.     for x in `find $PLACE -name '.act.new.*' `
  224.     do
  225.         DIR=${x%/*}
  226.         PKG=${x##*/}
  227.         PKG=${PKG#.act.new.}
  228. #echo "x=$x DIR=$DIR PKG=$PKG"
  229.         if [ -h $DIR/$PKG ]
  230.         then
  231.             rm $DIR/$PKG
  232.         fi
  233.         rm $x
  234.     done
  235.  
  236. #--- recover original entity ---#
  237.     for x in `find $PLACE -name '.act.org.*' `
  238.     do
  239. #       DIR=${x%/*}
  240. #       PKG=${x##*/}
  241. #       PKG=${PKG#.act.org.}
  242. #       mv $x $DIR/$PKG
  243.         rm $x
  244.     done
  245. }
  246. #======================================
  247. # IncludeModules
  248. #--------------------------------------
  249. IncludeModules()
  250. {
  251. #=== 変分反映層
  252. mkdir -p /memory/changes/upperdir
  253. UPPERDIR=/memory/changes/upperdir
  254. #=== 変分管理データ層
  255. mkdir -p /memory/changes/workdir
  256. WORKDIR=/memory/changes/workdir
  257.  
  258. #--<継承エリア初期化>--#
  259. setClean
  260.  
  261. #=== 固定不変層
  262. LOWLIST=""
  263. for x in `cat /tmp/modules`;
  264. do
  265.     ############### truncate mountpoint names ##############
  266.     #   NAME=`basename $x`;
  267.         NAME=`basename ${x%.*}`; # remove extension .squashfs
  268.         NAME="${NAME:0:14}""-$a"
  269.  
  270.     # skip if (truncated) /memory/images/$NAME exists already
  271.     [ -d /memory/images/$NAME ] && continue
  272.     let a=a+1
  273.     #########################################################
  274.  
  275.     mkdir /memory/images/$NAME;
  276.     mount -o loop $x /memory/images/$NAME 2>/dev/null
  277.     if [ $? -eq 0 ];
  278.     then
  279.         echo "  $m  $NAME";
  280.         LOWLIST=/memory/images/${NAME}:${LOWLIST}
  281.     else
  282.         echo $i"""Cannot read $NAME - corrupted module?""";
  283.         rmdir /memory/images/$NAME
  284.     fi
  285. done
  286. if [ -d /memory/images/changes-exit ]
  287. then
  288.     LOWLIST=/memory/images/changes-exit/upperdir:${LOWLIST}
  289.     cp -a /memory/images/changes-exit/workdir/* $WORKDIR/. 2> /dev/null
  290. fi
  291. LOWLIST=`echo $LOWLIST | sed 's/:$//'`
  292.  
  293. #echo "mount -t overlay -o upperdir=$UPPERDIR,lowerdir=$LOWLIST,workdir=$WORKDIR overlay /union"
  294. mount -t overlay -o upperdir=$UPPERDIR,lowerdir=$LOWLIST,workdir=$WORKDIR overlay /union
  295. if [ $? -ne 0 ]
  296. then
  297.     sh
  298. fi
  299. }
  300.  
  301.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement