restore centos "/" partition back problems - backup

I am facing the problems when restoring the "/" partition into the newly centos. My plan is to restore the backed-up centos (which has few packages installed like openstack) into a new machine.
The restore process goes as part of PXE boot. I have got some kind of kickstart files which does the stuff.
My PXE is in the order
Install some packages before CENT OS
Install CENT OS
Copy the backed-up "/" data into "/" on latest
Unfortunately, the new Cent OS is not starting going into Emergency mode and asking me to press Ctrl+D.
Any help is really great !!

I am using rsnapshot for backup the Cent OS stuff. I have to exclude some directories in order to make it work after restoration of Cent OS.
Here is my rsnapshot.conf file changes.
backup root#192.168.0.1:/ remote-backup/ exclude=/proc,exclude=/sys,exclude=/boot/grub,exclude=/boot/grub2,exclude=/etc/fstab,exclude=/etc/sysconfig/network-scripts/
The above backup is with root. Make sure you exclude those specified directories. Otherwise system doesn't boot up.
rsync for restore (in the Kickstart file)
echo "Restoring snapshot *TEST*"
rsync -avr --rsh="sshpass -p mypassword ssh -o StrictHostKeyChecking=no -l root" 192.168.0.2:/.snapshots/alpha.0/remote-backup/* /
Exluding them is the key here. Followed this link https://www.serverpronto.com/kb/page.php?id=Backing+Up+and+Restore+Your+Server

Related

Where are the files inside wsl2 physically stored? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 1 year ago.
The community reviewed whether to reopen this question 1 year ago and left it closed:
Original close reason(s) were not resolved
Improve this question
I've installed wsl2 on my windows machine and I was not able to figure out where the files are actually stored.
Note, that I don't mean that I wanna browse them inside the file explorer - I know it can be done by typing in the explorer \\wsl$\.
If I would have to guess I would say the files are stored in the same hard-drive that the os is stored.
So actually I have two related questions.
Where the files are stored?
If they are stored in the hard drive of my os, can I somehow relocate my wsl to another hard drive?
EDIT:
I was able to locate the installation path, in my machine the path is:
C:\Users\Eliran\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc\LocalState
Is there a way to mount this to another location?
All the files are stored in a ext4.vhd files in the installation directory, which you can't mount directly onto windows as it is in ext4 (obv)
There's two ways to change the location of the above mentioned vhd file the official, tedious way and an unofficial quick and dirty way
The official tedious way
Export the distro to a location with wsl.exe --export <Distro> <FileName> from CMD/PowerShell
Import the distro to a different location with wsl.exe --import <Distro> <InstallLocation> <FileName> [Options]
The problems with this is it's quite time consuming and after you do this, pray that it exported and imported several gigabytes worth of thousands of files without any problems
The quick and dirty way
This involes an unofficial opensource WSL manager called lxrunoffline
To install it (takes like a min at max) read through the instructions by the dev here
If you installed it by manually downloading the binaries from the release page, make sure to install it to a directory in PATH, like C:\Windows
Now the process is simple as lxrunoffline move -n <distroname> -d <destination-folder>
For example lxrunoffline move -n Ubuntu-20.04 -d G:\wsl\
Hope I helped
Edit: typo
I executed these commands in PowerShell to move my Ubuntu distro from C: to drive D:\wsl-ubuntu :
PS C:\Users\smarc> mkdir D:\wsl-ubuntu (create new location)
PS C:\Users\smarc> wsl -l -v (list wsl distros)
NAME STATE VERSION
Ubuntu Running 2
PS C:\Users\smarc> wsl --shutdown
PS C:\Users\smarc> wsl -l -v (verify if is stopped)
NAME STATE VERSION
Ubuntu Stopped 2
PS C:\Users\smarc> wsl --export Ubuntu ubuntu.tar
PS C:\Users\smarc> wsl --unregister Ubuntu
PS C:\Users\smarc> wsl --import Ubuntu D:\wsl-ubuntu\ .\ubuntu.tar --version 2
and reboot the computer at the end.
The only problem I have is that the default user when I started the Ubuntu application is the root. I need to execute $ su sergio to enter in my personal user.
You can delete the ubuntu.tar at the end of process.
#edit 2021-04-13: As pointed out in the comments, I had forgotten the "--export" command.
This is an answer to your last question: use symbolic links
open command prompt as administrator
shut down wsl vm using wsl --shutdown
change folder to C:\Users\Eliran\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc\
move the LocalState folder to another location like Z:\wsl\Ubuntu\
create symbolic link with mklink /J LocalState Z:\WSL\Ubuntu\LocalState
I would also edit/create the .wslconfig file from your user folder to move the swap file to the folder where you store your WSL vm's and maybe edit/add options for CPU cores and RAM assignment
[wsl2]
memory=4GB
processors=2
swap=1GB
swapFile=Z:\\WSL\\swap.vhdx
memory is the maximum amount your ram that WSL will use;
processors is the alocated cores to your WSL vm;
swap is the size of the swap file;
swapFile is the location of your swap and to my knowledge is used by all WSL vm's; notice the double slashes in the path, they are mandatory for the path.
Start your WSL VM as you normally would.

"Windows Subsystem for Linux has no installed distributions" even though 'Ubuntu' is installed

I recently moved my wsl directory to another drive due to low storage in C: drive. As per the answer provided in this StackOverflow post, I used lxrunoffline tool and moved my Ubuntu distribution to another drive (E:\wsl in my case). As soon as the distribution was moved successfully, I ran wsl to test and it worked like a charm.
Everything went fine until one day I accidentally renamed the E:\wsl folder to something else. Well, as expected, wsl didn't work. Then, I reverted back to the name wsl and expected it to work but to my surprise, it didn't find any installed distribution after that even though it's installed... 😕
E:> wsl
Windows Subsystem for Linux has no installed distributions.
Distributions can be installed by visiting the Microsoft Store:
https://aka.ms/wslstore
Is there any way to revert back to the old directory or make wsl point to a manual location?
EDIT: I don't want to reset Ubuntu as I want to retain the installed packages and preferences...
Well, I finally found a solution to this problem. 😊
This is as simple as registering the distribution using lxrunoffline tool using the rg or register command.
E:\LxRunOffline\LxRunOffline-v3.3.3>lxrunoffline rg
[ERROR] the option '-d' is required but missing
Options:
-n arg Name of the distribution
-d arg The directory containing the distribution.
-c arg The config file to use. This argument is optional.
After running the register command, I was able to start wsl as usual. But that would log you in as a "root" user and would thus start in "/root" directory. I ran the following command to start wsl as different user (this is for Ubuntu):
ubuntu config --default-user <user-name>

Booting raw-disk windows 10 vm in virtualbox boots to grub shell

I have a dual-boot setup with Windows 10 and Kubuntu 18. Following instructions found from here and there I managed to get the Windows to run as guest in Kubuntu host as a VM using VirtualBox.
sudo usermod -a -G disk $USER
VBoxManage internalcommands createrawvmdk -filename "/path/to/vm/win10.vmdk" -rawdisk /dev/sda -partitions 1,3,4 -relative
The first line is to avoid running VirtualBox as superuser.
When I boot the VM, I briefly see an error message
Boot Failed. EFI DVD/CDROM
SystemBootOrder not found. Initializing defaults.
Creating boot entry "Boot0003" with label "ubuntu" for file "\EFI\ubuntu\shimx64.efi"
and then end up in grub shell. Now, when I run the commands
insmod chain
set root=(hd0,gpt1)
chainloader /EFI/Microsoft/Boot/bootmgfw.efi
boot
Windows boots and works just fine but entering these every time is not exactly smooth workflow. Any idea how to permanently fix this?
Please note that I'd still like to be able to physically boot into both OS's.
Thanks,
I had the same problem. I fixed it, but then updated my kernel and so grub re-un-fixed it for me! Figuring it out for the second time was quicker, but I figured it'd be even quicker next time to find my answer on StackOverflow!
My grub.cfg file in /boot/efi/EFI/ubuntu looked like this:
search.fs_uuid 47d6233f-c0ae-4f89-bf18-184452eac803 root hd0,gpt6
set prefix=($root)'/boot/grub'
configfile $prefix/grub.cfg
Because we have setup the VirtualBox vmdk file with only the selected partitions for Windows to work, the search.fs_uuid command was failing, $root was empty and so grub can't find $prefix/grub.cfg (/boot/grub/grub.cfg in my linux rootfs which is on sda6==gpt6)
I automated it by changing the EFI grub.cfg, note my EFI System partition is 2 not 1 as in your example:
search.fs_uuid 47d6233f-c0ae-4f89-bf18-184452eac803 root hd0,gpt6
set prefix=($root)'/boot/grub'
if [ -f $prefix/grub.cfg ]
then
configfile $prefix/grub.cfg
else
insmod chain
set root=(hd0,gpt2)
chainloader /EFI/Microsoft/Boot/bootmgfw.efi
boot
fi
Now if grub can find the cfg file it will give me the menu to select the boot as before, but if it can't - when I'm in VirtualBox - it'll just boot straight into Win10.
Hope this helps!

How to install Guest addition in Mac OS as guest and Windows machine as host

I am trying to copy contents from my host machine to a guest machine, but for copying I need to install the Guest additions disk.
Or there is there another way to access host machine content on the guest machine or vice-versa?
Guest Additions are available for MacOS starting with VirtualBox 6.0.
Installing:
Boot & login into your guest macOS.
In VirtualBox UI, use menu Devices | Insert Guest Additions CD image...
CD will appear on your macOS desktop, open it.
Run VBoxDarwinAdditions.pkg.
Go through installer, it's mostly about clicking Next.
At some step, macOS will be asking about permissions for Oracle. Click the button to go to System Preferences and allow it.
If you forgot/misclicked in step 6, go to macOS System Preferences | Security & Privacy | General. In the bottom, there will be a question to allow permissions for Oracle. Allow it.
Troubleshooting
macOS 10.15 introduced new code signing requirements; Guest additions installation will fail. However, if you reboot and apply step 7 from list above, shared clipboard will still work.
VirtualBox < 6.0.12 has a bug where Guest Additions service doesn't start. Use newer VirtualBox.
In the guest Mac, open the Terminal and go for a reboot on the Recovery partition
sudo nvram "recovery-boot-mode=unused"
sudo reboot
Now you're in Recovery mode, enter the Terminal and do:
csrutil disable
spctl kext-consent add VB5E2TV963
nvram -d recovery-boot-mode
reboot
Back in "normal" mode, open the Terminal, and do:
sudo mount -uw /
sudo chown :admin /System/Library/Extensions/
sudo chmod 775 /System/Library/Extensions/
Run the Guest Additions installer and go through the end
(in principle, it goes through successfully)
Now in the terminal, do:
sudo chown :wheel /System/Library/Extensions/
sudo chmod 755 /System/Library/Extensions/
sudo nvram "recovery-boot-mode=unused"
sudo reboot
Again in Recovery mode, go into the Terminal and do:
csrutil enable
nvram -d recovery-boot-mode
reboot
You should be set.
Guest additions are not available for Mac OS X. You can get features like clipboard sync and shared folders by using VNC and SMB. Here's my answer on a similar question.
You can use SSH and SFTP as suggested here.
In the Guest OS (Mac OS X), open System Preferences > Sharing, then activate Remote Login; note the ip address specified in the Remote Login instructions, e.g. ssh user#10.0.2.15
In VirtualBox, open Devices > Network > Network Settings > Advanced > Port Forwarding and specify Host IP = 127.0.0.1, Host Port 2222, Guest IP 10.0.2.15, Guest Port 22
On the Host OS, run the following command sftp -P 2222 user#127.0.0.1; if you prefer a graphical interface, you can use FileZilla
Replace user and 10.0.2.15 with the appropriate values relevant to your configuration.
I've the same problem, and by the "trial and error" method I have the steps to install the guest additions on a MacOS guest:
insert the guest additions cd
open the cd on file manager
double click on VBoxDarwinAdditions.pkg
the installer opens, then click contine
next screen to set location of installed files, only press install
your password can be asked a couple of time while installing, write
it and continue
this is the tricky part, on my installation, macos show an message
about the driver created by oracle won't be installed because a
security issue, it has the option to enable it, so click on the
button to open security screen and click on the allow button next to
the oracle software listed at bottom of the security settings
window, it will ask your password again. Meanwhile the pkg installer
continued as if it has permissions and will say "install finished",
but I don't believe it so, once I unlocked the oracle drivers
installations I repeat the whole process from step 3, and in the
second round all installs without asking more than the first
password to install.
And it is done!
Above, someone gave a hint:
At some step, macOS will be asking about permissions for Oracle. Click the button to go to System Preferences and allow it.
If you forgot/misclicked in step 6, go to macOS System Preferences | Security & Privacy | General. In the bottom, there will be a question to allow permissions for Oracle. Allow it.
It took me a couple of hours but I did finally find what he was talking about - it's actually in the bottom of the Mac - click on the gear icon and you'll find it eventually.
You need to update your virtualbox sw. On new version, there is VBoxDarwinAdditions.pkg included in a additions iso image, in older versions is missing.
you can do it from the windows 10 terminal
step 1: open CMD in administrator mode
step 2 paste this open CMD cd "C:\Program Files\Oracle\Virtualbox"
step 3: paste this command in the open CMD, you must indicate the name you have in VirtualBox
VBoxManage setextradata "Virtual machine name" VBoxInternal2/EfiGraphicsResolution X
Example:
VBoxManage setextradata "Mac OS Sierra" VBoxInternal2/EfiGraphicsResolution 1280x720
Before you start, close VirtualBox!
After those manipulations start VB as Administrator!
Run CMD as Administrator
Use lines below one by one:
cd "C:\Program Files\Oracle\Virtualbox"
VBoxManage setextradata “macOS_Catalina” VBoxInternal2/EfiGraphicsResolution 1920x1080
Screen Resolutions: 1280x720, 1920x1080, 2048x1080, 2560x1440, 3840x2160, 1280x800, 1280x1024, 1440x900, 1600x900
Description:
macOS_Catalina - insert your VB machine name.
1920x1080 - put here your Screen Resolution.
Cheers!
Have you tried https://www.virtualbox.org/manual/ch04.html which has step-by-step instructions to help you?
Make your VM bi-directional for Clipboard and Drag & Drop
Share folders from your host to the guest VM too.

Crashplan on FreeNAS missing /var/lib/crashplan/.ui_info

So I spent a few weeks on this problem now. I've been trying to get CrashPlan running on a headless FreeNAS server. I have found lots a tutorial to do this. However the fact is that I'm missing the .un_info file on my FreeNAS server after installing CrashPlan.
I have searched the whole file system to try and find the elusive .ui_info file.
I've tried creating it manually with information copied from desktop PC but that does not help me resolve my CrashPlan Pro app connecting to the Crashplan server service on FreeNAS.
INFO:
FreeNAS 9.3 STABLE
Crashplan 3.6.3_1 Plugin
The crashplan remote access behaviour changed several times during the last updates, however with version 3.6.3_1 you should find the .ui_info file in
/var/lib/crashplan/.ui_info
Although the jail version is 3.6.3 it's possible that Crashplan updated itself, please check this with:
tail -f /usr/pbi/crashplan-amd64/share/crashplan/log/service.log.0
In the end you want your Crashplan to update itself anyway. If the update process produces an error related to bash, please run:
pkg update
pkg install bash
ln -siv /usr/local/bin/bash /bin/bash
And restart crashplan while checking the log output with the tail -f command from above:
service crashplan restart
If you finally reach a recent version (>4.4.1), its time to remotely connect to crashplan.
The only change on the server necessary for the easiest method without ssh tunnel is the serviceHost tag in /usr/pbi/crashplan-amd64/share/crashplan/conf/my.service.xml.
<serviceUIConfig>
<serviceHost>0.0.0.0</serviceHost>
Either do this everytime you want to connect, because the token will change after every crashplan restart or use my script from here (for OS X): https://gist.github.com/Phlogi/8654e353786ed1cf0858
Copy /var/lib/crashplan/.ui_info to the correct place on your desktop machine and edit the IP address at the end (to your servers address), for example:
4339,7f1d655f-*****,192.168.1.20
That's it, you can start crashplan on your remote machine and it will connect properly, there are no other changes neccessary. Latest crashplan (>4.4.1) will actually use the IP address from .ui_info.
Install JRE. You will need to add --no-check-certificate to the JRE wget line in the install.sh file