Mount .xzm Module with Write option

Post here if you are a new Porteus member and you're looking for some help.
Post Reply
noobTeus
White ninja
White ninja
Posts: 23
Joined: 08 Nov 2013, 19:42
Distribution: Porteus
Location: earth

Mount .xzm Module with Write option

Post#1 by noobTeus » 30 Jul 2014, 12:07

Hi,

I'm using Porteus 3

I want to add files into "/opt" of 001-core.xzm

So I extracted the core.xzm from porteus's iso & I tried with:

Code: Select all

mount -o loop,rw 001-core.xzm /mnt
But it mounted as read-only :(

So, How can I mount it with write option?


Thanks.

Bogomips
Full of knowledge
Full of knowledge
Posts: 2560
Joined: 25 Jun 2014, 15:21
Distribution: 3.2.2 Cinnamon & KDE5
Location: London

Re: Mount .xzm Module with Write option

Post#2 by Bogomips » 30 Jul 2014, 12:27

Suppose, copy it all somewhere, add files and then make new core.xzm. That's first thing that springs to mind.
Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB

User avatar
francois
Contributor
Contributor
Posts: 4984
Joined: 28 Dec 2010, 14:25
Distribution: kde xfce porteus manjaro kubun
Location: Enfin l'été, le changement climatique attendu: le soleil.

Re: Mount .xzm Module with Write option

Post#3 by francois » 30 Jul 2014, 21:41

Right click on 001-core.xzm and use the contextual menu to extract xzm module into a directory. Modify it. Then use right click for contextual menu and build xzm module.
Voltaire: Le mieux est l'ennemi du bien.

User avatar
brokenman
Site Admin
Site Admin
Posts: 5503
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v3.2rcX all desktops
Location: Brazil
Contact:

Re: Mount .xzm Module with Write option

Post#4 by brokenman » 31 Jul 2014, 02:21

squashfs is a read only file system. You can do something similar using aufs.

If you are impatient and just want the answer.

Code: Select all

mount -t aufs -o br=/mnt/sda8/writable=rw:/mnt/readonly=ro -o udba=reval none /tmp/aufs-work/
Your module is mounted in /mnt/readonly (it is read only) and you created /mnt/sda8/writable (real file system) and your target working folder is /tmp/aufs-work

Let me explain so you get a better understanding of what modules are and what a union file system does.
You will need a location out of the current aufs. For this example: /mnt/sda8/writable

## Create a directory with some files in it.

Code: Select all

modprobe aufs  ## Just for fun
mkdir -p /tmp/mymodule/{one,two}
touch /tmp/mymodule/file0.txt
## Make a module from it

Code: Select all

mksquashfs /tmp/mymodule /tmp/readonly.xzm
rm -r /tmp/mymodule
## Make a folder to mount your module as read only

Code: Select all

mkdir /mnt/readonly && mount -o loop /tmp/readonly.xzm /mnt/readonly
## Check that you files are in there and read only

Code: Select all

ls /mnt/readonly
touch /mnt/readonly/this.txt
Let's summarize. You have essentially mounted a module (squashfs read only) into the folder: /mnt/readonly

## Now create your writable folder outside of aufs (on a real file system)

Code: Select all

mkdir /mnt/sda8/writable
## Lastly create a folder where you merged file systems will be. You can work in here.

Code: Select all

mkdir /tmp/aufs-work
## Now overlay the two folders together using aufs.

Code: Select all

mount -t aufs -o br=/mnt/sda8/writable=rw:/mnt/readonly=ro -o udba=reval none /tmp/aufs-work/
## If you look in /tmp/aufs you will see the files from your module!

Code: Select all

ls /tmp/aufs-work
## And it is now writeable (kind of)

Code: Select all

touch /tmp/aufs-work/file2.txt
ls /tmp/aufs-work
Explanation:
mount -t aufs --> mount as a union file system
-o --> arguments that will be passed to the mount command
br= --> the branches you will create
br=/mnt/sda8/writable=rw:/mnt/readonly=ro --> mount the first path as a writable branch and the second path (your module) as a readonly branch.
udba=reval --> this means if a file is added outside of aufs it will re-evaluate
none --> no special device are connected to this
/tmp/aufs-work --> your destination

In fact what you have is two branches mounted overlaying each other.
Think of the /tmp/aufs-work as the tree trunk, and the other two folders as branches connected to the tree.
Because /mnt/readonly is exactly that (read only), any files that you create are sent to the /mnt/sda8/writable branch. If you add a file to this directory it will also appear in your tree.

Code: Select all

touch /mnt/sda8/writable/lookmum-nohands.txt
ls /tmp/aufs-work
Last thing to do is make a module from your additions to your module in /tmp/aufs-work.
If you are still reading then you just learnt something. Perhaps it was how a union file system works. Perhaps it was that bogomips solution is way easier. :D
How do i become super user?
Wear your underpants on the outside and put on a cape.

Bogomips
Full of knowledge
Full of knowledge
Posts: 2560
Joined: 25 Jun 2014, 15:21
Distribution: 3.2.2 Cinnamon & KDE5
Location: London

Re: Mount .xzm Module with Write option

Post#5 by Bogomips » 31 Jul 2014, 12:33

Thanks for the tutorial. :evil: When I have a spare minute I intend to go over it in detail. Terribly complicated on first sight, but IMHO worth a detailed perusal. 8)

Afterthought: just what the doctor ordered, for mr_hero to be sinking teeth into. ;)
Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB

noobTeus
White ninja
White ninja
Posts: 23
Joined: 08 Nov 2013, 19:42
Distribution: Porteus
Location: earth

Re: Mount .xzm Module with Write option

Post#6 by noobTeus » 02 Aug 2014, 11:38

First, thanks all for helps.

I shall do the extract/module create if I cant mount modules as writable at all.
Mounting the module as rw can be very helpful. So I tried it:

First mounted the module as readonly

Code: Select all

root@porteus:~# mount -o loop 001-core.xzm MNT1/
root@porteus:~# df -h | grep MNT1
/dev/loop12      45M   45M     0 100% /root/MNT1
Then tried the tutorial of "aufs"

Code: Select all

root@porteus:~# mount -t aufs -o br=/root/writable/=rw:/root/MNT1=ro -o udba=reval none /root/aufs-work/
It showed this message:
mount: wrong fs type, bad option, bad superblock on none,
missing codepage or helper program, or other error
(for several filesystems (e.g. nfs, cifs) you might
need a /sbin/mount.<type> helper program)
In some cases useful info is found in syslog - try
dmesg | tail or so
dmesg | tail showed:
[ 2640.624938] aufs test_add:263:mount[4255]: unsupported filesystem, /root/writable/ (aufs)
I tried to find "aufs" using usm with no luck:
root@porteus:~# usm -u slackware
root@porteus:~# usm -k aufs

Nothing found for: aufs

root@porteus:~# usm -k mount.aufs

Nothing found for: mount.aufs
What to do now? :Search:

User avatar
fanthom
Site Admin
Site Admin
Posts: 4586
Joined: 28 Dec 2010, 02:42
Distribution: Porteus Kiosk
Location: Poland, currently - Cork, IE
Contact:

Re: Mount .xzm Module with Write option

Post#7 by fanthom » 02 Aug 2014, 13:28

module is read only by design - just like an ISO file or any other archive. you will never be able to mount it read write.
you have to unpack it -> change it's content -> pack back.
Please add [Solved] to your thread title if the solution was found.

User avatar
brokenman
Site Admin
Site Admin
Posts: 5503
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v3.2rcX all desktops
Location: Brazil
Contact:

Re: Mount .xzm Module with Write option

Post#8 by brokenman » 02 Aug 2014, 19:24

As fanthom says, the actual module branch will be read only. The first branch must be on a writable path OUTSIDE of the aufs. This means it can't be in /home /root or any of these. To test if it is aufs do: df -T /root/writable

br=/root/writable/ should be something like. /mnt/sda8/writable.

Much easier just to mount the module. Copy the files somewhere else. Make changes. Create another module.

Code: Select all

mloop /path/to/module.xzm
mkdir /tmp/newfolder
cp -a /mnt/loop/* /tmp/newfolder
## Make your changes in /tmp/newfolder
dir2xzm /tmp/newfolder /tmp/newmodule.xzm
How do i become super user?
Wear your underpants on the outside and put on a cape.

Bogomips
Full of knowledge
Full of knowledge
Posts: 2560
Joined: 25 Jun 2014, 15:21
Distribution: 3.2.2 Cinnamon & KDE5
Location: London

Re: Mount .xzm Module with Write option

Post#9 by Bogomips » 02 Aug 2014, 22:21

Or do it the painless francois way. 8)
Linux porteus 4.4.0-porteus #3 SMP PREEMPT Sat Jan 23 07:01:55 UTC 2016 i686 AMD Sempron(tm) 140 Processor AuthenticAMD GNU/Linux
NVIDIA Corporation C61 [GeForce 6150SE nForce 430] (rev a2) MemTotal: 901760 kB MemFree: 66752 kB

noobTeus
White ninja
White ninja
Posts: 23
Joined: 08 Nov 2013, 19:42
Distribution: Porteus
Location: earth

Re: Mount .xzm Module with Write option

Post#10 by noobTeus » 03 Aug 2014, 16:23

New files,folders were saved in /mnt/sda10/writable .. not in the .xzm module

Anyway I'm switching to the time-taking easy dir2xzm method.


Thanks all for helps.

Post Reply