/usr/sbin/filemnt

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

/usr/sbin/filemnt

Karl Godt
Administrator
Notes on filemnt :

Since kernel 3.1.x loop devices should be added automatically if needed .
http://kernelnewbies.org/Linux_3.1

#loop: add BLK_DEV_LOOP_MIN_COUNT=%i to allow distros 0 pre-allocated loop devices (commit), (commit)
#http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=d134b00b9acca3fb054d7c88a5f5d562ecbb42d1
#- max_loop= [LOOP] Maximum number of loopback devices that can
#- be mounted
#- Format: <1-256>
#+ max_loop= [LOOP] The number of loop block devices that get
#+ (loop.max_loop) unconditionally pre-created at init time. The default
#+ number is configured by BLK_DEV_LOOP_MIN_COUNT. Instead
#+ of statically allocating a predefined number, loop
#+ devices can be requested on-demand with the
#+ /dev/loop-control interface.

I was about to suggest something like :
  FREE_LOOP=`losetup -f`  # find free and create loop
  [ "$FREE_LOOP" ] || {   # for kernel 3.0 and earlier
  LOOPS_ALL=`ls -1v /dev/loop* |sed 's%[^[:digit:]]%%g'`
  LOOP_LAST=`echo "$LOOPS_ALL" | tail -n1`
  LOOP_NEW=$(( $LOOP_LAST + 1 ))
  mknod /dev/loop${LOOP_NEW} b 7 $LOOP_NEW
  }


For the file system types :
  case $Ext in
   ext2|2fs) Type=ext2 ;;
   ext3|3fs) Type=ext3 ;;
   ext4|4fs) Type=ext4 ;;
      btrfs) Type=btrfs;;
        jfs) Type=jfs;;
        xfs) Type=xfs;;
        ufs) Type=ufs;;
        zfs) Type=zfs;;
        iso) Type=iso9660; MountOpt=,ro;;
        udf) Type=udf ;;
        fat) Type=vfat;;
       ntfs) Type=ntfs;;
    squashfs|sqfs|sfs|mxz) Type=squashfs; MountOpt=,ro;;
    #squashfs UBUNTU, mxz Porteus
       *) echo -e '\033[1;31m'"$0:Unsupported img file extension '$Ext'"'\033[0;39m' >&2;;
  esac

For squashfs XZ compression :
SFSSTR='squashfs, version 4'
SFSMAJOR=4
KERNELVER="`uname -r`"
if vercmp $KERNELVER ge 3.0;then #111016
:    # if vercmp not installed would run else
else # assume 2.6
 KERNELSUBVER=`echo -n "$KERNELVER" | cut -f 3 -d '.' | cut -f 1 -d '-' | cut -f 1 -d '_'` #100831
 KERNELSUBSUBVER=`echo -n "$KERNELVER" | cut -f 4 -d '.' | cut -f 1 -d '-'`
 if [ $KERNELSUBVER -eq 27 -a $KERNELSUBSUBVER -le 46 ] || [ $KERNELSUBVER -le 26 ] || [ $KERNELSUBVER -eq 28 ];then
   SFSSTR='squashfs, version 3'
   SFSMAJOR=3
 fi
 if test $KERNELSUBVER -le 37; then
 squashXZ=NOT
 fi
fi
  else
   case $Type in
    squashfs) if test "$squashXZ" = "NOT"; then
    errMSG="$(gettext "Mounting of squashfs file failed.
    It might be that it is due to missing 'xz compression'
    support in the kernel's squashfs driver
    which is available since Kernel Version 2.6.38 .")"
     pupdialog --background orange --title "$(gettext 'ERROR')" --msgbox "$errMSG" 0 0
    fi
    ;;
   esac
   rmdir "$MntPt" #121203
  fi


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: /usr/sbin/filemnt

JakeSFR
Karl Godt wrote
Notes on filemnt :

Since kernel 3.1.x loop devices should be added automatically if needed .
http://kernelnewbies.org/Linux_3.1

#loop: add BLK_DEV_LOOP_MIN_COUNT=%i to allow distros 0 pre-allocated loop devices (commit), (commit)
#http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=d134b00b9acca3fb054d7c88a5f5d562ecbb42d1
#- max_loop= [LOOP] Maximum number of loopback devices that can
#- be mounted
#- Format: <1-256>
#+ max_loop= [LOOP] The number of loop block devices that get
#+ (loop.max_loop) unconditionally pre-created at init time. The default
#+ number is configured by BLK_DEV_LOOP_MIN_COUNT. Instead
#+ of statically allocating a predefined number, loop
#+ devices can be requested on-demand with the
#+ /dev/loop-control interface.
Hmm, I cannot confirm this (k3.10.32) - new loop devices are not being created on-the-fly (or I'm missing how to use that /dev/loop-control interface).
In order to be able to mount with no limits, I had to add this at the very beginning of filemnt:

# SFR: always provide free loop device
if [ ! "`losetup-FULL -f`" ] || [ "`losetup-FULL -f`" = "/dev/loop3" ]; then
  NEWLOOP=$((`losetup-FULL -a | cut -f1 -d ' ' | tail -n1 | tr -cd '[:digit:]'` + 1 ))
  mknod /dev/loop${NEWLOOP} b 7 ${NEWLOOP}
fi

Btw, the additional check for /dev/loop3, because this loop is usually unused and, even if it's unused, but there's lack of other free loops, ISO images can't be mounted.
It seems to be something wrong with 'mount' itself. See this, in this case the one and only free loop is loop11:

# losetup -f
/dev/loop11
# 
# mount-FULL -t iso9660 slacko-5.7.0-PAE.iso /root/temp
mount: block device /initrd/mnt/dev_save/Users/SFR/Desktop/Slacko-5.7/slacko-5.7.0-PAE.iso is write-protected, mounting read-only
mount: failed to found free loop device
# 
# # WTF???
# # Ok, so let's have *two* free loop devices (11 & 12) then.
# 
# mknod /dev/loop12 b 7 12
# 
# losetup -f
/dev/loop11
# 
# mount-FULL -t iso9660 slacko-5.7.0-PAE.iso /root/temp
mount: block device /initrd/mnt/dev_save/Users/SFR/Desktop/Slacko-5.7/slacko-5.7.0-PAE.iso is write-protected, mounting read-only
# 
# # Now it's ok...

Greetings!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: /usr/sbin/filemnt

Karl Godt
Administrator
HeHe ..

Looks like they have reverted some code in k3.10.32 ?

Or, your kernel has not

CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y

configured to let the kernel maintain the device nodes in /dev ?

Or is it some udev rule ?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: /usr/sbin/filemnt

JakeSFR
Dunno, kernel's config seems ok:
# zgrep 'DEVTMPFS' /proc/config.gz 
CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y
Hmm, in a fact, there's no such thing as /dev/loop-control at all!

However, I just compiled, just for fun, k3.15.1 (basing on DOTconfig-3.12.21-FD324G from kernel-kit) and it has /dev/loop-control and dynamic creating works there as advertised!
Can't upload animated GIFs here, so: http://oi58.tinypic.com/osu8oo.jpg (.jpg? really? lol)

Btw, I love that kernels' swapping is so simple now! :)

Greetings!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: /usr/sbin/filemnt

Karl Godt
Administrator
Then it would be

test -e /dev/loop-control || _make_newloopdevice

_mk_free_loop() is in my private functions4puppy5 ...

JakeSFR wrote
Hmm, in a fact, there's no such thing as /dev/loop-control at all!

Btw, I love that kernels' swapping is so simple now! :)

Greetings!
Do you mean the new zdrv feature of slacko-6 ? Is it  different from the old zdrv feature ?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: /usr/sbin/filemnt

JakeSFR
Do you mean the new zdrv feature of slacko-6 ? Is it  different from the old zdrv feature ?
Yes, but I'm not familiar with the old zdrv. I stepped in to the Puppyland ~ when Lupu-525 has been released and I don't think this feature was utilized there, IIRC.

Greetings!
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: /usr/sbin/filemnt

01micko
Administrator
JakeSFR wrote
Do you mean the new zdrv feature of slacko-6 ? Is it  different from the old zdrv feature ?
Yes, but I'm not familiar with the old zdrv. I stepped in to the Puppyland ~ when Lupu-525 has been released and I don't think this feature was utilized there, IIRC.

Greetings!
Not all that different. Although drastically different from the original intended design. I really don't know how BK's mind works but maybe he dreamed that stuffing all the modules in a z drive would one day enable him to dispense with having an initrd stuffed with modules. It is clear from reading init he had many ideas, including the huge initrd which FatDog64 uses now.

FatDog has been using the kernel-modules.sfs for a while now and as soon as I really took a look at it (in FatDog-Arm) I knew it was the direction we should head. With great help from jamesbond it is now reality, It's been an age old problem to update the kernel. Now it is a easy as build it, stuff it in!

Actually, soon I will do (already started) a full rewrite of kernel-kit, more modular, less procedural, and accompanying it will be a kernel switcheroo script.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: /usr/sbin/filemnt

Karl Godt
Administrator
OK, so /init tries to
find and mount the zdrv_
now before loading of modules ?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: /usr/sbin/filemnt

01micko
Administrator
Karl Godt wrote
OK, so /init tries to
find and mount the zdrv_
now before loading of modules ?
Be aware, that vmlinuz needs the filesystem and other necessary drivers built in (kbd, mouse, aufs) , so no modules need to be loaded to get a system running.  The thing will boot even without zdrv, but of course depends on your hardware setup as is to built ins.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: /usr/sbin/filemnt

Karl Godt
Administrator
In reply to this post by JakeSFR
Macpup Foxy3 derivate uses Puppy-430 with zdrv_ .sfs  -- which is still my main OS ( with upgraded kernels ) . But I use full install .

While examining remasterpup2, I always choose the zdrv_ option .

Though I don't use the remasters .

Will have to add something like DATE to .iso and .sfs , to be able to distinguish remasters .
OR,
Was thinking of something like adding

REMASTER_NAME=NONE
REMASTER_VERSION=00
REMASTER_DATE=

to /etc/DISTRO_SPECS .

Instead or additionally of/to these hidden and unusable *IDSTRING* variables .

So there could be a weekly remaster available , instead of increasing DISTRO_VERSION numbers all the time just for a couple of simple bugfixes .

remasterpu2 has the funny gettext about creating /initrd/pup_ro2 if PUPMODE 2 , then it would run though .
But it does not remind you to remove /initrd folder ... , which then would confuse rc.sysinit very much  .. next boot .
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: /usr/sbin/filemnt : util-linux does not support encryption of loopdevices ?

Karl Godt
Administrator
In reply to this post by Karl Godt
from git log --grep encrypt in util-linux :

commit 9d57f184cfe7abd2e046463f867bcfb93a313f43
Author: Karel Zak <kzak@redhat.com>
Date:   Wed Sep 12 14:49:49 2012 +0200

    tests: remove encryption loopdev test
    
    Reported-by: Bernhard Voelker <mail@bernhard-voelker.de>
    Signed-off-by: Karel Zak <kzak@redhat.com>

commit 5cf05c71472bf7230075cbdcd5cd6eb12b1d3654
Author: Ludwig Nussel <ludwig.nussel@suse.de>
Date:   Tue Sep 11 10:46:11 2012 +0200

    mount: losetup: remove obsolete encryption support
    
    kernel cryptoloop is deprecated since ages and support for cryptoloop
    in util-linux is incomplete/broken.
    - no password hashing
    - last 8 bit of key are always set to zero
    - no binary keys possible (stops reading key at \n and \0)
    
    In the past some Distros added the above features with patches. So
    remove cryptoloop support from util-linux completely to make sure
    people won't try using it.
    
    Signed-off-by: Ludwig Nussel <ludwig.nussel@suse.de>
    Signed-off-by: Karel Zak <kzak@redhat.com>

commit 72297be6c70cb0f8ea9c1d89e2f7bcceeda9fd92
Author: Karel Zak <kzak@redhat.com>
Date:   Mon May 28 13:44:55 2012 +0200

    tests: add losetup/mount encryption test
    
    Signed-off-by: Karel Zak <kzak@redhat.com>

commit 3fc480b952aa925710f9f869add09563e2c47787
Author: Karel Zak <kzak@redhat.com>
Date:   Mon May 28 11:37:36 2012 +0200

    mount: (old) fix encryption= usage
    
    Addresses: https://github.com/karelzak/util-linux/issues/12
    Signed-off-by: Karel Zak <kzak@redhat.com>

Since two years util-linux does not support crypted loop-devices -- apparently .

I myself have created empty dummy crypted save files with these compressions :

#-e twofish
#-e blowfish
#-e arc4
#-e anubis
#-E serpent
#-E camellia

and added code to filemnt to mount them ( same way as 'heavy' aes encryption ) .

All mount with the corresponding crypt driver loaded ( if enabled in kernel DOTconfig > Cryptographic API *** Ciphers *** section ) -- except arc4 .

Loading...