Page 4 of 7

Re: Save.dat / changes confusion

Posted: 11 Aug 2016, 20:27
by Bogomips
Ed_P wrote:
Bogomips wrote:

Code: Select all

savefile $"
The single quote character at the end the cause of the error?
You are indeed right. It looks like an asterisk, and it couldn't be a typo owing to distance between keys, So must have crept in during editing, when a line was lost. :x

Anyway here it is Jack, completely tested and enhanced, so should be working mksavfile.sh:

Code: Select all

#!/bin/bash
# 11.08.2016
# sh mksavfile.sh	<[/Path/to/]savefile>	[ <Size of file in MB>  [ Block size for XFS ] ]
# sh mksavfile.sh	savefile.dat
# sh mksavfile.sh	MyPort/mysave.dat	256
# sh mksavfile.sh	savechanges			400		2048
savefile()
{
	dd if=/dev/null of=$1 bs=1M seek=${2:-512};        # Size in MB
	ls -lh $1
	/sbin/mkfs.xfs -b size=${3:-1024} -l internal $1;  # Block Size to Use
	file  $1
	ls -sh $1; du -h $1
	[[ ! -d f$$ ]] && mkdir f$$;
	sudo mount $1 f$$
	df  -h  f$$
	du -sh  f$$
	sudo umount f$$
	rmdir f$$
}
savefile $*

Re: Save.dat / changes confusion

Posted: 11 Aug 2016, 22:36
by Bogomips
After checking with linuxrc:
  • Saving Changes upon Reboot
    • Boot Info

      Code: Select all

      guest@porteus:~$ cat /etc/porteus-version
      Porteus-v3.2rc4
      guest@porteus:~$ cat /proc/cmdline
      quiet from=/dev/sda10/tmp/iso/rc4/i586/Porteus-CINNAMON-v3.2rc4-i586.iso copy2ram ramsize=30% noauto rootcopy=/dev/sda4/cin_rcp  guiexec=Prolog/pmx.sh cliexec=mount~--bind~/home/guest/p9/tmp~/tmp changes=EXIT:/dev/sda1/tmp/K3B_Space/savedchanges
      
      guest@porteus:~$ cat /var/log/porteus-livedbg
      # Recognized devices:
      ...
      /dev/sda10: LABEL="p_10" UUID="ed3f74cd-26bb-47bd-86b0-5e690663dd55" TYPE="ext2"
      /dev/sda11: UUID="6a0167f6-5cf7-412d-b85f-0076ca590371" TYPE="swap"
      /mnt/sda1/tmp/K3B_Space/savedchanges: UUID="ba126207-0d47-4a8d-85cd-033501bb995c" TYPE="xfs"
      
      # Booting device:
      /mnt/isoloop
      
      # Porteus data found in:
      /mnt/isoloop/porteus
      
      # Changes are stored in:
      memory
      
      # Non standard /rootcopy dir:
      /dev/sda4/cin_rcp
      
      # Modules activated during boot time:
      /memory/copy2ram/000-kernel.xzm
      /memory/copy2ram/001-core.xzm
      /memory/copy2ram/002-xorg.xzm
      /memory/copy2ram/003-cinnamon.xzm
      /mnt/sda1/tmp/K3B_Space/savedchanges/changes
      
      ISO=/mnt/sda10/tmp/iso/rc4/i586/Porteus-CINNAMON-v3.2rc4-i586.iso
      
    • Changes Expected Size:

      Code: Select all

      root@porteus:/home/guest# save-changes /mnt/sda1/tmp/K3B_Space/chsav.xzm
      
      Parallel mksquashfs: Using 1 processor
      Creating 4.0 filesystem on /mnt/sda1/tmp/K3B_Space/chsav.xzm, block size 262144.
      [===============================================================/] 768/768 100%
      
      Exportable Squashfs 4.0 filesystem, xz compressed, data block size 262144
      	compressed data, compressed metadata, compressed fragments, compressed xattrs
      	duplicates are removed
      Filesystem size 2664.33 Kbytes (2.60 Mbytes)
      
  • Changes Offline
    • Stats

      Code: Select all

      guest@porteus:~$ c=/mnt/sda1/tmp/K3B_Space/savedchanges
      guest@porteus:~$ ls -lh $c
      -rw-r--r-- 1 guest users 256M Aug 11 22:42 /mnt/sda1/tmp/K3B_Space/savedchanges
      
      guest@porteus:~$ ls -sh $c
      11M /mnt/sda1/tmp/K3B_Space/savedchanges
      guest@porteus:~$ du -h $c
      11M	/mnt/sda1/tmp/K3B_Space/savedchanges
      
      guest@porteus:~$ mkdir s; sudo mount $c s
      guest@porteus:~$ sudo du -sh s
      6.0M	s
      guest@porteus:~$ df -h s
      Filesystem      Size  Used Avail Use% Mounted on
      /dev/loop11     253M   20M  234M   8% /home/guest/s
      
    • Top of Tree

      Code: Select all

      guest@porteus:~$ tree -nd -L 2 s
      s
      ├── etc
      │   ├── cron.daily
      │   ├── profile.d
      │   ├── rc.d
      │   ├── udev
      │   └── usm
      ├── home
      │   └── guest
      ├── opt
      │   └── palemoon
      ├── root [error opening dir]
      ├── usr
      │   ├── bin
      │   ├── lib
      │   ├── local
      │   └── share
      └── var
          ├── cache
          ├── lib
          ├── lock
          ├── log
          └── spool
      22 directories
      
  • Approx Size of Changes

    Code: Select all

    guest@porteus:~$ sudo xzm2dir /mnt/sda1/tmp/K3B_Space/chsav.xzm ch
    Parallel unsquashfs: Using 1 processor
    789 inodes (792 blocks) to write
    
    write_file: failed to create file ch/.wh..wh.aufs, because Operation not permitted
    dir_scan: failed to make directory ch/.wh..wh.orph, because Operation not permitted
    dir_scan: failed to make directory ch/.wh..wh.plnk, because Operation not permitted
    ...
    [=============================================================/ ] 785/792  99%
    created 762 files
    created 353 directories
    created 13 symlinks
    created 1 devices
    created 3 fifos
    
    guest@porteus:~$ sudo du -sh ch
    6.0M	ch
    
It's interesting that with a relatively bigger file, the stats are harder to interpret.

Re: Save.dat / changes confusion

Posted: 12 Aug 2016, 03:12
by Jack
I thought you just remove " but then I reread it that why there is 2 sample one without blank and one with *.

Here is my output with savefile $.

Code: Select all

guest@porteus:~$ cd Downloads
guest@porteus:~/Downloads$ su
Password: 
root@porteus:/home/guest/Downloads# sh mksavfile.sh mysave.dat 256
0+0 records in
0+0 records out
0 bytes copied, 0.000130882 s, 0.0 kB/s
-rw-r--r-- 1 root root 512M Aug 11 22:40 $
meta-data=$                      isize=512    agcount=4, agsize=131072 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=0
data     =                       bsize=1024   blocks=524288, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=1024   blocks=2573, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
$: SGI XFS filesystem data (blksz 1024, inosz 512, v2 dirs)
2.8M $
2.8M	$
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop15     510M  8.1M  502M   2% /home/guest/Downloads/f
0	f
Here is my output with savefile $*

Code: Select all

root@porteus:/home/guest/Downloads# sh mksavfile.sh mysave.dat 256[b][/b]
0+0 records in
0+0 records out
0 bytes copied, 0.000715455 s, 0.0 kB/s
-rw-r--r-- 1 root root 256M Aug 11 22:42 mysave.dat
meta-data=mysave.dat             isize=512    agcount=4, agsize=65536 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=0
data     =                       bsize=1024   blocks=262144, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=1024   blocks=2573, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
mysave.dat: SGI XFS filesystem data (blksz 1024, inosz 512, v2 dirs)
2.8M mysave.dat
2.8M	mysave.dat
mkdir: cannot create directory ‘f’: File exists
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop15     254M  8.1M  246M   4% /home/guest/Downloads/f
0	f
root@porteus:/home/guest/Downloads# 

Save.dat / changes confusion

Posted: 12 Aug 2016, 10:19
by Bogomips
@ Jack

This time you did do wrong. :) You had to copy the updated mksavfile.sh from Re: Save.dat / changes confusion (Post by Jack #47965), then there would not be the error with mkdir. The file that was made looks fine. To use the file, it has to be moved to a real filesystem.

Clearer mksavfile.sh:

Code: Select all

#!/bin/bash
# 12.08.2016
# sh mksavfile.sh	<[/Path/to/]savefile>	[ <Size of file in MB>  [ Block size for XFS ] ]
# Invocation examples:
# 	sh mksavfile.sh	savefile.dat
# 	sh mksavfile.sh	MyPort/mysave.dat	 256
# 	sh mksavfile.sh	savechanges	400	2048
ecmd()
{
	echo $1; $1
}
savefile()
{
	dd if=/dev/null of=$1 bs=1M seek=${2:-512};        # Size in MB
	echo; ecmd "ls -lh $1"; echo
	/sbin/mkfs.xfs -b size=${3:-1024} -l internal $1;  # Block Size to Use
	echo; ecmd "file  $1"; echo
	ecmd "ls -sh $1";
	ecmd "du -h $1"
	[[ ! -d f$$ ]] && mkdir f$$;
	echo; ecmd "sudo mount $1 f$$"; echo
	ecmd "du -sh  f$$"
	echo; ecmd "df  -h  f$$"
	sudo umount f$$
	rmdir f$$
}
savefile $*

Re: Save.dat / changes confusion

Posted: 12 Aug 2016, 11:56
by Jack
Bogomips wrote:@ Jack

You had to copy the updated mksavfile.sh from http://forum.porteus.org/viewtopic.php? ... 965#p47953, then there would not be the error with mkdir. The file that was made looks fine. To use the file, it has to be moved to a real filesystem.
I did copy that file or that the one I use. The first sample was by remove the " but the 2nd sample was made by the one in this link.

Here it is again.

Code: Select all

guest@porteus:~/Documents$ su
Password: 
root@porteus:/home/guest/Documents# sh mksavfile.sh myfile.dat 256
0+0 records in
0+0 records out
0 bytes copied, 0.000928261 s, 0.0 kB/s
-rw-r--r-- 1 root root 256M Aug 12 07:36 myfile.dat
meta-data=myfile.dat             isize=512    agcount=4, agsize=65536 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=0
data     =                       bsize=1024   blocks=262144, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=1024   blocks=2573, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
myfile.dat: SGI XFS filesystem data (blksz 1024, inosz 512, v2 dirs)
2.8M myfile.dat
2.8M	myfile.dat
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop15     254M  8.1M  246M   4% /home/guest/Documents/f13350
0	f13350
root@porteus:/home/guest/Documents# 
Here what happen if it is already there.

Code: Select all

guest@porteus:~/Documents$ su
Password: 
root@porteus:/home/guest/Documents# sh mksavfile.sh myfile.dat 256
0+0 records in
0+0 records out
0 bytes copied, 0.000166292 s, 0.0 kB/s
-rw-r--r-- 1 root root 256M Aug 12 07:36 myfile.dat
mkfs.xfs: myfile.dat appears to contain an existing filesystem (xfs).
mkfs.xfs: Use the -f option to force overwrite.
myfile.dat: SGI XFS filesystem data (blksz 1024, inosz 512, v2 dirs)
3.6M myfile.dat
3.6M	myfile.dat
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop15     254M  8.1M  246M   4% /home/guest/Documents/f13277
0	f13277
root@porteus:/home/guest/Documents#

Re: Save.dat / changes confusion

Posted: 12 Aug 2016, 12:07
by Bogomips
@ Jack

That's right. You have to delete it first. Anyway try the mksavfile.sh that I put up today.

Re: Save.dat / changes confusion

Posted: 12 Aug 2016, 12:08
by Jack
Bogomips wrote:@ Jack

This time you did do wrong. :) You had to copy the updated mksavfile.sh from http://forum.porteus.org/viewtopic.php? ... 965#p47953, then there would not be the error with mkdir. The file that was made looks fine. To use the file, it has to be moved to a real filesystem.

Clearer mksavfile.sh:

Code: Select all

#!/bin/bash
# 12.08.2016
# sh mksavfile.sh	<[/Path/to/]savefile>	[ <Size of file in MB>  [ Block size for XFS ] ]
# sh mksavfile.sh	savefile.dat
# sh mksavfile.sh	MyPort/mysave.dat	256
# sh mksavfile.sh	savechanges			400		2048
ecmd()
{
	echo $1; $1
}
savefile()
{
	dd if=/dev/null of=$1 bs=1M seek=${2:-512};        # Size in MB
	echo; ecmd "ls -lh $1"; echo
	/sbin/mkfs.xfs -b size=${3:-1024} -l internal $1;  # Block Size to Use
	echo; ecmd "file  $1"; echo
	ecmd "ls -sh $1";
	ecmd "du -h $1"
	[[ ! -d f$$ ]] && mkdir f$$;
	echo; ecmd "sudo mount $1 f$$"; echo
	ecmd "du -sh  f$$"
	echo; ecmd "df  -h  f$$"
	sudo umount f$$
	rmdir f$$
}
savefile $*
This is the one I used in my last post and the one you told me to use. And now you have a new one so what is up?

Code: Select all

#!/bin/bash
# 11.08.2016
# sh mksavfile.sh   <[/Path/to/]savefile>   [ <Size of file in MB>  [ Block size for XFS ] ]
# sh mksavfile.sh   savefile.dat
# sh mksavfile.sh   MyPort/mysave.dat   256
# sh mksavfile.sh   savechanges         400      2048
savefile()
{
   dd if=/dev/null of=$1 bs=1M seek=${2:-512};        # Size in MB
   ls -lh $1
   /sbin/mkfs.xfs -b size=${3:-1024} -l internal $1;  # Block Size to Use
   file  $1
   ls -sh $1; du -h $1
   [[ ! -d f$$ ]] && mkdir f$$;
   sudo mount $1 f$$
   df  -h  f$$
   du -sh  f$$
   sudo umount f$$
   rmdir f$$
}
savefile $*

Re: Save.dat / changes confusion

Posted: 12 Aug 2016, 12:11
by Bogomips
Hi Jack

It is just that the output has been made clearer to read. Should make more sense with latest version.

Re: Save.dat / changes confusion

Posted: 12 Aug 2016, 12:14
by Jack
Bogomips wrote:@ Jack

This time you did do wrong. :) You had to copy the updated mksavfile.sh from http://forum.porteus.org/viewtopic.php? ... 965#p47953, then there would not be the error with mkdir. The file that was made looks fine. To use the file, it has to be moved to a real filesystem.

Clearer mksavfile.sh:

Code: Select all

#!/bin/bash
# 12.08.2016
# sh mksavfile.sh	<[/Path/to/]savefile>	[ <Size of file in MB>  [ Block size for XFS ] ]
# sh mksavfile.sh	savefile.dat
# sh mksavfile.sh	MyPort/mysave.dat	256
# sh mksavfile.sh	savechanges			400		2048
ecmd()
{
	echo $1; $1
}
savefile()
{
	dd if=/dev/null of=$1 bs=1M seek=${2:-512};        # Size in MB
	echo; ecmd "ls -lh $1"; echo
	/sbin/mkfs.xfs -b size=${3:-1024} -l internal $1;  # Block Size to Use
	echo; ecmd "file  $1"; echo
	ecmd "ls -sh $1";
	ecmd "du -h $1"
	[[ ! -d f$$ ]] && mkdir f$$;
	echo; ecmd "sudo mount $1 f$$"; echo
	ecmd "du -sh  f$$"
	echo; ecmd "df  -h  f$$"
	sudo umount f$$
	rmdir f$$
}
savefile $*
Here is the output of this version.

Code: Select all

guest@porteus:~/Documents$ su
Password: 
root@porteus:/home/guest/Documents# sh mksavfile.sh myfile.dat 256
0+0 records in
0+0 records out
0 bytes copied, 0.000175581 s, 0.0 kB/s

ls -lh myfile.dat
-rw-r--r-- 1 root root 256M Aug 12 08:03 myfile.dat

meta-data=myfile.dat             isize=512    agcount=4, agsize=65536 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=0
data     =                       bsize=1024   blocks=262144, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=1024   blocks=2573, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

file myfile.dat
myfile.dat: SGI XFS filesystem data (blksz 1024, inosz 512, v2 dirs)

ls -sh myfile.dat
2.8M myfile.dat
du -h myfile.dat
2.8M	myfile.dat

sudo mount myfile.dat f15556

du -sh f15556
0	f15556

df -h f15556
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop15     254M  8.1M  246M   4% /home/guest/Documents/f15556
umount: /home/guest/Documents/f15556: target is busy
        (In some cases useful info about processes that
         use the device is found by lsof(8) or fuser(1).)
rmdir: failed to remove 'f15556': Device or resource busy
root@porteus:/home/guest/Documents#

Re: Save.dat / changes confusion

Posted: 12 Aug 2016, 12:57
by Bogomips
@ Jack

That's just fine. You can try

Code: Select all

umount -f f15556
rmdir f15556
to get rid of f15556, if you like. Don't know why it could not be dismounted.

Re: Save.dat / changes confusion

Posted: 12 Aug 2016, 14:27
by Jack
So were on the same page. If you need me to test any thing more please post it. But it seem to me it works.

I just ran this.

Code: Select all

root@porteus:/home/guest/Documents# umount -f f15556
root@porteus:/home/guest/Documents# rmdir f15556
root@porteus:/home/guest/Documents# 
What do I need to look for?
EDIT:
Is this one the most current # 12.08.2016 and the one to use?

Re: Save.dat / changes confusion

Posted: 12 Aug 2016, 15:26
by Bogomips
Jack, you don;t need to run mksavfile.sh it as root, Now you need to move it to a real file system, and use it to save changes in. Let us know how you get on.

Re: Save.dat / changes confusion

Posted: 12 Aug 2016, 15:51
by Jack
I just built a USB to try it. After I ran the script I had to reboot to make it work. Here is the output.

Code: Select all

guest@porteus:~$ cd Downloads
guest@porteus:~/Downloads$ sh mksavfile.sh /mnt/sdb1/porteus/porteussave.dat 256
0+0 records in
0+0 records out
0 bytes copied, 0.000329442 s, 0.0 kB/s

ls -lh /mnt/sdb1/porteus/porteussave.dat
-rwxrwxrwx 1 root root 256M Aug 12 12:08 /mnt/sdb1/porteus/porteussave.dat

meta-data=/mnt/sdb1/porteus/porteussave.dat isize=512    agcount=4, agsize=65536 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=0
data     =                       bsize=1024   blocks=262144, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=1024   blocks=2573, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

file /mnt/sdb1/porteus/porteussave.dat
/mnt/sdb1/porteus/porteussave.dat: SGI XFS filesystem data (blksz 1024, inosz 512, v2 dirs)

ls -sh /mnt/sdb1/porteus/porteussave.dat
256M /mnt/sdb1/porteus/porteussave.dat
du -h /mnt/sdb1/porteus/porteussave.dat
256M	/mnt/sdb1/porteus/porteussave.dat

sudo mount /mnt/sdb1/porteus/porteussave.dat f1750

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

Password: 

du -sh f1750
0	f1750

df -h f1750
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop29     254M  8.1M  246M   4% /home/guest/Downloads/f1750
guest@porteus:~/Downloads$ 
How can I check how much has been used after I added info?

Re: Save.dat / changes confusion

Posted: 12 Aug 2016, 17:49
by Bogomips
Jack wrote:How can I check how much has been used after I added info?

Code: Select all

mkdir s; sudo mount /mnt/sdb1/porteus/porteussave.dat  s
du -sh s   # Amount that has been used by you
df -h  s  # Think shows used by you and the XFS filesystem. Not sure though.
In your example it is showing 246M available.

Looking at the result you had here http://forum.porteus.org/viewtopic.php? ... 987#p47978 you will see there is a difference with the one done on usb:
  • One you did earlier;

    Code: Select all

    root@porteus:/home/guest/Documents# sh mksavfile.sh myfile.dat 256
    ...
    ls -lh myfile.dat
    -rw-r--r-- 1 root root 256M Aug 12 08:03 myfile.dat
    ...
    file myfile.dat
    myfile.dat: SGI XFS filesystem data (blksz 1024, inosz 512, v2 dirs)
    
    ls -sh myfile.dat
    2.8M myfile.dat
    du -h myfile.dat
    2.8M   myfile.dat
  • One done on usb

    Code: Select all

    guest@porteus:~/Downloads$ sh mksavfile.sh /mnt/sdb1/porteus/porteussave.dat 256
    ...
    ls -lh /mnt/sdb1/porteus/porteussave.dat
    -rwxrwxrwx 1 root root 256M Aug 12 12:08 /mnt/sdb1/porteus/porteussave.dat
    ...
    file /mnt/sdb1/porteus/porteussave.dat
    /mnt/sdb1/porteus/porteussave.dat: SGI XFS filesystem data (blksz 1024, inosz 512, v2 dirs)
    
    ls -sh /mnt/sdb1/porteus/porteussave.dat
    256M /mnt/sdb1/porteus/porteussave.dat
    du -h /mnt/sdb1/porteus/porteussave.dat
    256M   /mnt/sdb1/porteus/porteussave.dat
This is all a bit strange. You should have made a file on the usb with owner guest, however it says owner is root.

Can we try something here please. Is sdb2 formatted ext4 or ntfs?

Code: Select all

sh mksavfile.sh  porteussave.dat  256
sudo mkdir /mnt/sdb2/Test
sudo chmod  a+rw  /mnt/sdb2/Test
ls -ld /mnt/sdb2/Test
mv  porteussave.dat  /mnt/sdb2/Test
ls  -lh  /mnt/sdb2/Test/porteussave.dat
ls  -sh  /mnt/sdb2/Test/porteussave.dat
du -h  /mnt/sdb2/Test/porteussave.dat
Test by using changes=/dev/sdb2/Test/porteussave.dat

Re: Save.dat / changes confusion

Posted: 13 Aug 2016, 02:58
by Jack
I can tell you I'm lost on your last message. Is there a script you ca write that will help?
Can we try something here please. Is sdb2 formatted ext4 or ntfs?
My sdb1 is formated fat32.