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
  •  


H261-Z61 2U 24SFF AMD Server 8x EPYC 7551 256-Cores 256GB RAM 8x25G NIC 2x2200W picture

H261-Z61 2U 24SFF AMD Server 8x EPYC 7551 256-Cores 256GB RAM 8x25G NIC 2x2200W

$2512.18



CSE-118 Supermicro 1U 3x GPU Server  2.1Ghz 16-C 128GB CX353A 2x1600W PSU Rails picture

CSE-118 Supermicro 1U 3x GPU Server 2.1Ghz 16-C 128GB CX353A 2x1600W PSU Rails

$450.03



CSE-118 Supermicro 1U GPU Server 2.6Ghz 20-C 256GB 2x Nvidia K40 GPU 2x1600W PSU picture

CSE-118 Supermicro 1U GPU Server 2.6Ghz 20-C 256GB 2x Nvidia K40 GPU 2x1600W PSU

$674.03



Dell R730xd 12LFF 2.6Ghz 20-C 128GB H730 2x10G+2x1G NIC 2x1100W 12x Trays Rails picture

Dell R730xd 12LFF 2.6Ghz 20-C 128GB H730 2x10G+2x1G NIC 2x1100W 12x Trays Rails

$721.05



Dell PowerEdge R720XD Xeon E5-2680 V2 2.8GHz 20 Cores 256GB RAM 12x4TB picture

Dell PowerEdge R720XD Xeon E5-2680 V2 2.8GHz 20 Cores 256GB RAM 12x4TB

$510.00



DELL PowerEdge R730 Server 2x E5-2690v3 2.6GHz =24 Cores 32GB H730 4xRJ45 picture

DELL PowerEdge R730 Server 2x E5-2690v3 2.6GHz =24 Cores 32GB H730 4xRJ45

$275.00



Dell PowerEdge R730XD 28 Core Server 2X Xeon E5-2680 V4 H730 128GB RAM No HDD picture

Dell PowerEdge R730XD 28 Core Server 2X Xeon E5-2680 V4 H730 128GB RAM No HDD

$389.99



SuperMicro Server 505-2 Intel Atom 2.4GHz 8GB RAM SYS-5018A-FTN4 1U Rackmount picture

SuperMicro Server 505-2 Intel Atom 2.4GHz 8GB RAM SYS-5018A-FTN4 1U Rackmount

$224.99



Dell PowerEdge R430 3.5 1U 2x E5-2690 v3 2.6ghz 24-Cores 256gb 4x Trays 2x 550w picture

Dell PowerEdge R430 3.5 1U 2x E5-2690 v3 2.6ghz 24-Cores 256gb 4x Trays 2x 550w

$289.99



HP ProLiant DL380 Gen9 16SFF 2x E5-2680v4 2.4GHz =28 Cores 64GB P840 4xRJ45 picture

HP ProLiant DL380 Gen9 16SFF 2x E5-2680v4 2.4GHz =28 Cores 64GB P840 4xRJ45

$355.00