CloneZilla USB, unattended syslinux, need translation to grub-equivalent - linux

I have a bootable CloneZilla on USB. It works great with systems that boot using syslinux. Here's the menu entry in syslinux.cfg and a short description of what it does (note that I use & to imply that it's the same line, I broke it up to multiple lines for readability):
label Clone Default Image
#MENU DEFAULT
MENU LABEL Clone from \\bilbo
kernel /live/vmlinuz
append initrd=/live/initrd.img boot=live union=overlay config quiet noswap
& noeject nosplash username=user hostname=yakkety components edd=on nomodeset
& noprompt nolocales keyboard-layouts=sv locales=sv_SE.UTF-8
& ocs_live_run="ocs-sr --batch -g auto -e1 auto -e2 -r -j2
& -p poweroff restoredisk windows-10-base-clone sda" ocs_live_extra_param=""
& ocs_live_batch=no vga=791 ip= nosplash i915.blacklist=yes radeonhd.blacklist=yes
& nouveau.blacklist=yes vmwgfx.blacklist=yes
& ocs_repository="smb://administrator:**********#192.168.10.41/common/utveckling/clone"
& {lots of ocs_preruns to setup dhcp on one of two possible eth-interfaces}
It setups an eth-interface to use dhcp. It then tries to mount a samba share, as seen in ocs_repository="user:pass#path". After that, it should run the ocs_live_run="cmd" entry, which performs a clone from the samba location to the main disk of the booted device.
This is my attempt at creating an equivalent grub.cfg entry:
menuentry "Clone from \\\\bilbo"{
search --set -f /live/vmlinuz
linux /live/vmlinuz boot=live union=overlay config quiet noswap
& noeject nosplash username=user hostname=yakkety components edd=on nomodeset
& noprompt nolocales keyboard-layouts=sv locales=sv_SE.UTF-8
& ocs_live_run="ocs-sr --batch -g auto -e1 auto -e2 -r -j2
& -p poweroff restoredisk windows-10-base-clone sda" ocs_live_extra_param=""
& ocs_live_batch=no vga=791 ip= nosplash i915.blacklist=yes radeonhd.blacklist=yes
& nouveau.blacklist=yes vmwgfx.blacklist=yes
& ocs_repository="smb://administrator:**********#192.168.10.41/common/utveckling/clone"
& {same preruns, it seems to work well}
initrd /live/initrd.img
}
For whatever reasons, the grub one fails. It seems to try to do the same things, but I would wager that there's something going wrong with mounting the samba-location (I can mount it manually).
It stops with the error message "/home/partimag/windows-10-base-clone" does not exist, which certainly should exist, had it mounted the provided samba location to /home/partimag/.
Any suggestions?

I was having a very similar issue, and I noticed by adding longer 'sleep' calls that the mount command invokes the help file for mount, so I knew that there was a syntax error, but the same syntax works in the iso/syslinux.cfg and at prompt after the ocs_live_run fails.
I discovered that the ocs_prerun="Mount..." won't run without escaping the " with \.
Thus:
OCS_PRERUN5=\"Mount -o user=,pass= //host/path/ /home/partimag\"
I hope that if you are still working on this it works for you also.

Related

Can`t mount cifs shares in Parrot 4.10 after boot

Parrot is based on debian. All I do in Ubunto 18.04 lts and 20.04 lts works fine. In Parrot - not (at least not in my env). This is fresh installation, default, static IP, fully patched and after few reboots.
Windows is 8.1 pro in domain (2012R2 forest level), fully patched, no antivirus, firewall enables traffic. User is domain admin with no special chars in name and password, just to make it work.
So, to make it easier I do everything in command line as root (sudo -i).
nano /scripts/creds
username=user1
password=Password1
domain=test.local
The command:
mount -t cifs //192.168.1.10/d$ /mnt/disk_d -o credentials=/scripts/creds
In new Linux installations highest SBM version is taken by default, like other things (yey), so forcing these don`t change much (it works).
It works from command line (sudo). No errors and there are windows files and folders in /mnt/disk_d
It works from bash file: "./mount_windows.sh" with this line inside.
It doesn`t work in /etc/fstab. Command
mount -a -v
generates "parse error at line 19 -- ignored", this line is for mount. Physical disks are "already mounted".
So I tried to add one or more of them:
"file_mode=0777,dir_mode=0777", "serverino" or "noserverino", "sec=ntlmv2", "perm", "auto", "vers=3.0", " 0 0"
or just mix everything with different position with no success. Please remember it works from command line with no additional options.
It doesn`t work from /etc/crontab.
mount.cifs sits in /sbin so everything is ok.
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
added:
* * * * * root mount -t cifs //192.168.1.10/d$ /mnt/disk_d -o credentials=/scripts/creds
53 * * * * * root mount -t cifs //192.168.1.10/d$ /mnt/disk_d -o credentials=/scripts/creds
#reboot mount -t cifs //192.168.1.10/d$ /mnt/disk_d -o credentials=/scripts/creds
#reboot root mount -t cifs //192.168.1.10/d$ /mnt/disk_d -o credentials=/scripts/creds
#reboot sudo bash -x /scripts/mount_windows.sh
Restart cron shows no errors:
"systemctl restart cron"
None of these mounted disk after a full reboot.
So I added
echo "1" >> /scripts/log.txt
to check if anything is proccessed. File is created and "1" is added.
After each reboot there is nothing in /var/log/messages.
I don`t know why is this so hard to make it work. It works from command line and from sh.

Howto change Clonezilla default menu selection items

I am using clonezilla-live-2.6.1-11-amd64.iso
I would like to change the default section when booting off the live USB to perform full backups of the whole drive. for example:
on screen "Mount Clonezilla image directory" I would like to change the default from local_dev to use samba_server
on screen "Mount Samba server" I would like to change the default from 192.168.1.1 to 192.168.1.2
on screen "Mount Samba server" account change the default administrator to clonezilla
When I enter the items in
/syslinux/syslinux.cfg
.
ocs_repository="smb://clonezilla:password#192.168.1.2/zilla/
the menu's still ask me the default address of 192.18.1.1 and username administrator
so it appears I am not understanding the documentation. Does anyone have an example cfg?
I have delved into customizing "LiveISO's" and CloneZilla specifically so I will give a general idea of how I would attack this.
Looking at my notes this is all I had. To enable SSH Deamon I would unpack the ISO, edit the following and repack the iso using mksquashfs.
Eg:
Preparing to unpack ISO:
sudo apt-get install -y squashfs-tools
Copy iso to /tmp & rename live.iso
mkdir /tmp/mnt
sudo mount -o loop /tmp/live.iso /tmp/mnt
sudo find /tmp/mnt \( -name '*.squashfs' -o -name "*.SQFS" \) -exec unsquashfs -d /tmp/squashfs-root/ {} \;
sudo umount /tmp/mnt
sudo rm /tmp/mnt -R
cd /tmp/squashfs-root
This leaves you with:
/tmp/live.iso
/tmp/squashfs-root/FilesFromSquashedFS
Make Changes…..
sudo nano /tmp/squashfs-root/etc/ocs/ocs-live.conf
scroll to bottom & add:
ocs_daemon=\"ssh\"
Then Repack ISO:
cd /tmp
sudo mksquashfs /tmp/squashfs-root filesystem.squashfs
sudo rm /tmp/squashfs-root -R
This leaves you with:
/tmp/live.iso
/tmp/filesystem.squashfs
Now use an ISO editing Program to insert the filesystem.squashfs into the original ISO making sure to use the same name as the original ISO "squasedfs" used. Sometimes it's a different extension.
The above method is quite "General" but I found some LiveOS creators have scripts for booting the OS, making changes and then creating an ISO from the running OS.
For CloneZilla this is what I have found after a quick google.
https://clonezilla.org/advanced/customized-clonezilla-live.php
Simple Version of that Link:
Create Custom Script named custom-ocs ( A sample script file /usr/share/drbl/samples/custom-ocs)
Mount /home/partimag/
Copy script to /home/partimag/ and cd to /home/partimag/
Run the following to generate ISO
ocs-iso -g en_US.UTF-8 -k NONE -s -m ./custom-ocs
For other options, please run ocs-iso -h or ocs-live-dev -h to get more info.
Another Link (https://clonezilla.org/related-articles/012_Automated_USB_thumb_drive_using_Custom/Automated_USB_thumb_drive_using_Custom.html) shows this method which seems to indicate to me that if you place a script inside the ISO and then point to it via an edited syslinux.cfg (You could edit it using either of the above methods) you can auto-run it that way. The link says to boot USB and select first menu option, but I would want it to be fully automated where if you do nothing that option is selected regardless.
Here is the edit to syslinux.cfg that he uses:
kernel /live/vmlinuz1
append initrd=/live/initrd1.img boot=live union=aufs noprompt noprompt ocs_live_run="/live/image/live/custom-ocs" ocs_live_extra_param="" ocs_live_keymap="NONE" ocs_live_batch="yes" ocs_lang="en_US.UTF-8" vga=791 ip=frommedia nolocales
Note: ocs_live_run="/live/image/live/custom-ocs" This to me means run this script after booting, but I haven't tested/messed with CloneZilla in a while.
Personal Opinion: I love Parted Magic but some people don't like that it has some weird licensing now and isn't really free, but old 2013 version can be found and/or buy it for like $10. It has CloneZilla built in and also an MKISO script for making an ISO out of the booted/edited/LiveOS, but again, I generally would unpack the ISO using squashfs and then repack and inject into ISO.
Here are my links to what I've done customizing "LiveISO's". My final project years ago was a "Parted Magic" LiveISO that booted, started a PWD protected VNC sessions + ssh and e-mailed me the DHCP IP address. (I had hit and miss results with the e-mail portion, but depending on your setup you could use static IP or check router for DHCP IP address)
https://www.freesoftwareservers.com/display/FREES/Customize+LiveISO%27s
You can indeed have your Samba share automatically pre-mounted by using ocs_repository= in your vmlinuz kernel boot arguments.
However, it needs to be in the right boot file.
According to the boot parameters documentation, the relevant file is one of:
/syslinux/isolinux.cfg when booting from CD on a MBR machine
/syslinux/syslinux.cfg when booting from USB flash drive on a MBR machine
/boot/grub/grub.cfg when booting from a uEFI machine
/tftpboot/pxelinux.cfg/default or similar on your PXE server, when booting from PXE on a MBR machine
/tftpboot/grub/grub.cfg or similar on your PXE server, when booting from a uEFI netboot machine
Depending on your Samba server, you might also need to specify the SMB version to be used. From the same documentation page:
To assign the image repository via URI (Uniform Resource Identifier),
use "ocs_repository". URI supported in Clonezilla live:
[dev|smb|smb1|smb1.0|smb2|smb2.0|smb2.1|smb3|smb3.0|smb3.11|smb3.1.1|ssh|nfs|nfs4|http|https|ram]:[//[user:password#]host[:port]][/]path

clonezilla copy log-file(s) to usb-device

i want to create/restore an image of a system completely unattended with an clonezilla-live usb-stick. So far the unattended backup/restore works fine. I just plug in the stick, boot up the pc and after the work is done the pc shut down.
Now i need an confirmation that the backup/restore was successfull.
For this purpose i want to execute an shell script which copy the log-file into an specific file to a other partition on the usb-stick after the work is done.
I tried to execute the script as postrun-method in the syslinux.cfg but this always led to an error.
Furthermore i tried it with drbl-ocs but i'm not sure if i did it right.
here is the shell script i want to execute:
#!/bin/sh
#############
/opt/drbl/sbin/ocs-sr -q2 -j2 -z1p -i 4096 -p true savedisk img sda
#############
dir=/home/partimag/logs/
time=$(date +"%H-%M-%S") # current time
i=$(ls -l $dir | wc -l) # index
# create log-directory if it didn't exist
if [ ! -e $dir ]
then
sudo mkdir $dir
fi
# create new log-directory (
sudo mkdir $dir/$i"_"#$time
# copy all log-files to the created directory
sudo cp /var/log/* $dir/$i"_"#$time
# shut-down the machine
sudo shutdown -h now
the first instruction (after the shebang) was my attempt to use the drbl-ocs but i have not really an idea what this is. I believe it's another interpreter which can handle shell scripts too.. Am i right ?
an here is the syslinux.cfg i use:
append initrd=/live/initrd.img boot=live username=user config quiet noswap edd=on nomodeset nodmraid noeject locales=en_US.UTF-8 keyboard-layouts=NONE ocs_prerun="mount /dev/sdb2 /mnt/" ocs_prerun1="mount --bind /mnt/ /home/partimag/" ocs_live_run="/lib/live/mount/medium/syslinux/clonezilla.sh" ocs_live_extra_param="" ocs_live_batch="yes" vga=788 ip= nosplash i915.blacklist=yes radeonhd.blacklist=yes nouveau.blacklist=yes vmwgfx.enable_fbdev=1
please help !
Thanks :)
ok got it :)
the only thing to do was to add the interpreter in front of the ocs_live_run method.
Now the syslinux.cfg looks like this:
append initrd=/live/initrd.img boot=live username=user config quiet noswap edd=on nomodeset nodmraid noeject locales=en_US.UTF-8 keyboard-layouts=NONE ocs_prerun="mount /dev/sdb2 /mnt/" ocs_prerun1="mount --bind /mnt/ /home/partimag/" ocs_live_run="bash /lib/live/mount/medium/syslinux/clonezilla.sh" ocs_live_extra_param="" ocs_live_batch="yes" vga=788 ip= nosplash i915.blacklist=yes radeonhd.blacklist=yes nouveau.blacklist=yes vmwgfx.enable_fbdev=1
please rate if this was usefull for you :)

Using Optware packages and startup scripts on dd-wrt router

I'm trying to run a mumble server (umurmur) on my dd-wrt router (Buffalo WZR-HP-AG300H). I flashed one of the recent community versions of dd-wrt on the device (SVN Rev.: 23320), it has an Atheros CPU inside.
After that I mounted a USB pendrive into the filesystem using these guides (Guide 1, Guide 2) and created writable directories. Here is my startup-script saved to nvram (via web-gui)
EDIT: USB pendrive should be partioned before using it with DD-Wrt.
#!/bin/sh
sleep 5
insmod mbcache
insmod jbd
insmod ext3
mkdir '/mnt/part1'
mkdir '/mnt/part2'
mount -t ext3 -o noatime /dev/sda5 /mnt/part1 # /dev/sda5 -> partition on USB pendrive
mount -t ext3 -o noatime /dev/sda7 /mnt/part2 # /dev/sda7 -> partition on USB pendrive
swapon /dev/sda6 # /dev/sda6 -> partition on USB pendrive
sleep 2
if [ -f /mnt/part1/optware.enable ];then
#mount -o bind /mnt/part2 /mnt/part1/root
mount -o bind /mnt/part1 /jffs
mount -o bind /mnt/part1/etc /etc
mount -o bind /mnt/part1/opt /opt
mount -o bind /mnt/part1/root /tmp/root
else
exit
fi
if [ -d /opt/usr ]; then
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/lib:/usr/lib:/opt/lib:/opt/usr/lib:/jffs/usr/lib:/jffs/usr/local/lib
export PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin:/jffs/bin:/opt/bin:/opt/sbin:/opt/usr/bin:/opt/usr/sbin
export IPKG_INSTROOT=/opt
else
exit
fi
The script works well and I can use opkg to install packages. I can also run umurmur manually but I'm struggling on making umurmur autostart. I recognized that the umurmur startup script placed in /opt/etc/init.d/ requires arguments like start and stop but it seems they are called without any arguments.
Another way described here did not work too.
Has anyone a working solution on problems like these? Please help!
Optware runs on Broadcom routers only. Your's has an Atheros chipset.
Taken from this page: Link
Its unclear i the page you referred to has changed - and indeed my setup is fairly different to yours, but to get scripts working on startup I did the following -
mkdir -p /jffs/etc/config
copy script into /jffs/etc/config directory, renaming it to end with .startup
chmod 755 /jffs/etc/config/scriptname.startup

Beaglebone inittab issue

I am developing an application in beaglebone.
I want to add start up scripts to my Beaglebone but I can not find /etc/inittab.
I am using the image : Angstrom-Cloud9-IDE-GNOME-eglibc-ipk-v2012.05-beaglebone-2012.06.18.img.xz
I think in the previous versions of image there is /etc/initab but for the new distributions I could not find the inittab :/
I want to apply this : Automatic login on Angstrom Linux
but I can not because there is no /etc/inittab.
Where is the inittab in new distributions.
When I write uname -r it gives:
3.2.23
Regards
inittab has been replaced by systemd
This is how I did it for the serial console. You can probably adapt it easily for tty1 by replacing "serial-getty#..." by "getty#...", but I haven't tested it.
cp /lib/systemd/system/serial-getty#.service /etc/systemd/system/autologin#.service
rm /etc/systemd/system/getty.target.wants/serial-getty#ttyO0.service
ln -s /etc/systemd/system/autologin#.service /etc/systemd/system/getty.target.wants/serial-getty#ttyO0.service
Create the following script file in any location (/home/root/autologin.sh in my case)
#!/bin/sh
exec /bin/login -f root
Make it executable
chmod a+x autologin.sh
Edit /etc/systemd/system/autologin#.service and update the ExecStart command by adding the -n (Do not prompt the user for a login name) and -l (Invoke the specified login_program instead of /bin/login) options.
ExecStart=-/sbin/agetty -n -l /home/root/autologin.sh -s %I 115200

Resources