Results 1 to 1 of 1

Thread: Minimal patch of init for 64-bits and squashfs+cloop

  1. #1
    Senior Member registered user
    Join Date
    Sep 2006
    Posts
    802

    Minimal patch of init for 64-bits and squashfs+cloop

    I have tried to find the minimal set of modifications to minirt init to achieve

    1. Full 64-bits handling
    2. Use of cloop and squashfs transparently for end users

    There are quite a few potential and actual problems with full 64-bits systems, as many details have clearly not been fully handled yet. And the main init tool, busybox, behaves like a somewhat erratically moving target in this respect: I can successfully use vs 1.17 from the Debian package, but neither 1.18 precompiled nor custom compiled seems to work for init.

    The major modifications to minirt are

    • Use 64-bits busybox - 1.17 from deb package (installed in /bin/busybox)
    • Copy over 64-bits dev from running system
    • Patch init script as needed

    The main problem with 64 vs 32 bits init, is that no busybox version has been able to run programs adequately off /UNIONFS, and standard 6.4.4 init simply chains into /sbin/init. This hasn't been possible with the available busyboxes, but chroot works relatively fine.

    Handling squashfs, while keeping the multi-mount option for KNOPPIX[0-7] and the same numbering scheme as the cloops, necessitates that the KNOPPIX-DATA mount be moved from /dev/loop0 to somewhere else. It seems that we may have problems with loops above 9, so I moved it to /dev/loop8 and reduced the multi-mount options for KNOPPIX from 0-7 accordingly. (It's still possible to create an odd crash in a corner case, but anyone getting there should know the way out..)

    By adding the cheatcode "squashfs", squashfs will be mounted, and it is possible to have cloop (KNOPPIX) and squashfs (KNOPPIX.sq) images in the same KNOPPIX directory, if one wants to. But any booting will use only one of the types.

    I have tried out a "uni-minirt" common for 32- and 64-bits, but so far, it seems like the best thing to do is keep them separate. From past confusion, I have learnt to name each minirt.gz version separately, the attached init. for example belongs to a version called minirt_sq_2.gz, compressed from a directory called 64patch_1.

    Here is the diff of original and patched init. mountknoppix() is thoroughly changed, and findknoppix() is modified to look for KNOPPIX.sq.

    Code:
    diff init init644.org > patch_64_squash.txt
    156c156
    <   if [ -r /mnt-system/"$knoppix_dir"/KNOPPIX$knoppix_ext ]; then
    ---
    >   if [ -r /mnt-system/"$knoppix_dir"/KNOPPIX ]; then
    316,324d315
    < 
    < # Setup extension for squashfs
    < if checkbootparam "squashfs" ; then 
    <   knoppix_ext=".sq" ; usecloop=0 ;
    < else
    <   usecloop=1   
    < fi     
    < 
    < 
    586c577
    <  [ -b /dev/loop8 ]    || mknod -m 755 /dev/loop8 b 7 8
    ---
    >  [ -b /dev/loop0 ]    || mknod -m 755 /dev/loop0 b 7 0
    606,608c597,599
    <   losetup -d /dev/loop8 2>/dev/null
    <   runknoppixlib /sbin/losetup -p 0 -e aes -k 256 /dev/loop8 /mnt-system/"$knoppix_dir"/knoppix-data.aes </tmp/knoppix.pw; rc="$?"; rm -f /tmp/knoppix.pw
    <   runknoppixlib /sbin/mke2fs -F -m 0 /dev/loop8
    ---
    >   losetup -d /dev/loop0 2>/dev/null
    >   runknoppixlib /sbin/losetup -p 0 -e aes -k 256 /dev/loop0 /mnt-system/"$knoppix_dir"/knoppix-data.aes </tmp/knoppix.pw; rc="$?"; rm -f /tmp/knoppix.pw
    >   runknoppixlib /sbin/mke2fs -F -m 0 /dev/loop0
    610c601
    <   mount -t ext2 -o rw /dev/loop8 /KNOPPIX-DATA && return 0
    ---
    >   mount -t ext2 -o rw /dev/loop0 /KNOPPIX-DATA && return 0
    627c618
    <    [ -b /dev/loop8 ]    || mknod -m 755 /dev/loop8 b 7 8
    ---
    >    [ -b /dev/loop0 ]    || mknod -m 755 /dev/loop0 b 7 0
    642c633
    <       if runknoppixlib /sbin/losetup -e aes -k 256 /dev/loop8 "$img"; then
    ---
    >       if runknoppixlib /sbin/losetup -e aes -k 256 /dev/loop0 "$img"; then
    644,645c635,636
    <        runknoppixlib /sbin/e2fsck -y /dev/loop8 >/dev/null 2>&1
    <        mount -t ext2 -o rw /dev/loop8 /KNOPPIX-DATA && return 0
    ---
    >        runknoppixlib /sbin/e2fsck -y /dev/loop0 >/dev/null 2>&1
    >        mount -t ext2 -o rw /dev/loop0 /KNOPPIX-DATA && return 0
    648c639
    <       losetup -d /dev/loop8 >/dev/null 2>&1
    ---
    >       losetup -d /dev/loop0 >/dev/null 2>&1
    655c646
    <      losetup -d /dev/loop8 >/dev/null 2>&1
    ---
    >      losetup -d /dev/loop0 >/dev/null 2>&1
    665d655
    < 
    668,670c658,659
    <  if [[ $usecloop = 1 ]]; then
    <    grep -q cloop /proc/devices || insmod /mnt-system/"$knoppix_dir"/modules/cloop.ko preload=32 || return 2
    <  fi
    ---
    >  [ -b /dev/cloop ] || mknod -m 644 /dev/cloop b 240 0
    >  grep -q cloop /proc/devices     || insmod /mnt-system/"$knoppix_dir"/modules/cloop.ko preload=32 || return 2
    672,674c661,663
    <  for k in /mnt-system/"$knoppix_dir"/[Kk][Nn][Oo][Pp][Pp][Ii][Xx]$knoppix_ext \
    <           /mnt-system/"$knoppix_dir"/[Kk][Nn][Oo][Pp][Pp][Ii][Xx][0-7]$knoppix_ext; do
    <   [[ -r "$k" ]] || continue
    ---
    >  for k in /mnt-system/"$knoppix_dir"/[Kk][Nn][Oo][Pp][Pp][Ii][Xx] \
    >           /mnt-system/"$knoppix_dir"/[Kk][Nn][Oo][Pp][Pp][Ii][Xx][0-9]; do
    >   [ -r "$k" ] || continue
    676,682c665,666
    <   if [[ $count = 0 ]]; then
    <     dir=/KNOPPIX
    <     if [[ $usecloop = 1 ]]; then
    <       dev=/dev/cloop ; 
    <     else
    <       dev=/dev/loop0 ; 
    <     fi
    ---
    >   if [ $count = 0 ]; then
    >    dev=/dev/cloop ; dir=/KNOPPIX
    684,689c668,670
    <     dir=/KNOPPIX$count
    <     if [[ $usecloop = 1 ]]; then
    <       dev=/dev/cloop$count ;  
    <     else
    <       dev=/dev/loop$count ; 
    <     fi
    ---
    >    dev=/dev/cloop$count ; dir=/KNOPPIX$count
    >    [ -b $dev ] || mknod -m 644 $dev b 240 $count
    >    [ -d $dir ] || mkdir -m 755 $dir
    691,703c672
    < #  Set up and mount
    <   [[ -d $dir ]] || mkdir -m 755 $dir ; mntsuccess=1;
    <   if [[ $usecloop = 1 ]]; then
    <     [[ -b $dev ]] || mknod -m 644 $dev b 240 $count 
    <     (losetup  $dev $k >/dev/null 2>&1 && mount -r -t iso9660 $dev $dir >/dev/null 2>&1)||mntsuccess=0
    <     echo "mntsuccess cloop: $mntsuccess"
    <   else
    <     [[ -b $dev ]] || mknod -m 755 $dev b 7 $count    
    <     (losetup  $dev $k >/dev/null 2>&1 && mount -r -t squashfs $dev $dir >/dev/null 2>&1)||mntsuccess=0
    <     echo "mntsuccess squashfs: $mntsuccess"
    <   fi
    < # Something went wrong, we unmount all loop-mounts
    <   if [[ $mntsuccess = 0 ]]; then
    ---
    >   if ! losetup $dev $k >/dev/null 2>&1 || ! mount -r -t iso9660 $dev $dir >/dev/null 2>&1; then
    705c674
    <    echo -n -e "\n\r${RED}${BROKENIMAGE}: $k ${ON} "; mount | grep /mnt-system; dmesg | tail | grep 'c*loop'; echo -n "${NORMAL}"
    ---
    >    echo -n -e "\n\r${RED}${BROKENIMAGE}: $k ${ON} "; mount | grep /mnt-system; dmesg | tail | grep cloop; echo -n "${NORMAL}"
    707c676
    <    for dev in /dev/cloop* /dev/loop*; do
    ---
    >    for dev in /dev/cloop*; do
    718,719d686
    < 
    < 
    764c731
    < mount --bind /UNIONFS/home /home
    ---
    > /bin/mount --bind /UNIONFS/home /home
    813,818c780
    < 
    < for d in mnt-system KNOPPIX-DATA ramdisk; do
    <         [ -d /UNIONFS/"$d" ] ||  mkdir /UNIONFS/"$d"
    <         mount --bind /"$d" /UNIONFS/"$d"
    < done
    < exec chroot /UNIONFS /sbin/init "$@" </dev/console >/dev/console 2>&1
    ---
    > exec /sbin/init "$@" </dev/console >/dev/console 2>&1
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


HP Workstation Z640 2x Xeon E5-2623V4 32GB Ram Dual 256GB SSD K420 Linux GA picture

HP Workstation Z640 2x Xeon E5-2623V4 32GB Ram Dual 256GB SSD K420 Linux GA

$234.98



Intel - Core i9-13900K 13th Gen 24 cores 8 P-cores + 16 E-cores 36M Cache, 3 ... picture

Intel - Core i9-13900K 13th Gen 24 cores 8 P-cores + 16 E-cores 36M Cache, 3 ...

$689.99



Intel - Core i7-13700K 13th Gen 16 cores 8 P-cores + 8 E-cores 30M Cache, 3.4... picture

Intel - Core i7-13700K 13th Gen 16 cores 8 P-cores + 8 E-cores 30M Cache, 3.4...

$489.99



AMD Ryzen 9 5950X 16-core 32-thread Desktop Processor picture

AMD Ryzen 9 5950X 16-core 32-thread Desktop Processor

$319.99



Apple Mac Pro Processor Tray 5,1 2010 2012 2.4ghz 8 core picture

Apple Mac Pro Processor Tray 5,1 2010 2012 2.4ghz 8 core

$79.99



Intel - Core i7-12700K Desktop Processor 12 (8P+4E) Cores up to 5.0 GHz Unloc... picture

Intel - Core i7-12700K Desktop Processor 12 (8P+4E) Cores up to 5.0 GHz Unloc...

$419.99



Intel - Core i9-12900K Desktop Processor 16 (8P+8E) Cores up to 5.2 GHz Unloc... picture

Intel - Core i9-12900K Desktop Processor 16 (8P+8E) Cores up to 5.2 GHz Unloc...

$619.99



Intel Xeon E5-2667 V2 LGA 2011 3.3GHz 8 Core 130W 25MB 8GT/s CPU Processor picture

Intel Xeon E5-2667 V2 LGA 2011 3.3GHz 8 Core 130W 25MB 8GT/s CPU Processor

$24.00



Lenovo Flex 7 14IRU8 14

Lenovo Flex 7 14IRU8 14" 2.2K Touch Intel Core i7-1355U 16GB 1TB SSD W11H

$529.99



Dell Precision 3630 8-Core i9-9900K 3.6GHz 32GB 512GB SSD WIN 11P picture

Dell Precision 3630 8-Core i9-9900K 3.6GHz 32GB 512GB SSD WIN 11P

$479.99