xen create new virtual machine using command line - linux

I want to create (CentOS) virtual machine using xen by virt-install command
I am using kickstart and put it in http://192.168.1.8/centos/kickstart.cfg
and put Centos 6.5 in http://192.168.1.8/centos/os/
use
[root#CentOS ~]# dd if=/dev/zero of=/var/lib/xen/images/vserver.img bs=1M count=4000
[root#CentOS ~]# virt-install -p -n vserver -r 512 -f /var/lib/xen/images/vserver.img -l http://192.168.1.8/centos/os -x ks=http://192.168.1.8/centos/kickstart.cfg -w bridge:xenbr0 --vcpus=1
the result
Starting install...
ERROR Could not find an installable distribution at 'http://192.168.1.8/centos/os'
The location must be the root directory of an install tree.
Domain installation does not appear to have been successful.
If it was, you can restart your domain by running:
virsh --connect xen:/// start vserver
otherwise, please restart your installation.

it's need the .treeinfo file,
vi /var/www/html/centos/os/.treeinfo
and add this lines:
[general]
family = CentOS
timestamp = 1341518023.56
variant =
totaldiscs = 1
version = 6.5
discnum = 1
packagedir =
arch = i386
[images-i386]
initrd = images/pxeboot/initrd.img
[images-xen]
initrd = isolinux/initrd.img
kernel = isolinux/vmlinuz
[stage2]
mainimage = images/install.img
don't copy it directly from the browser, write it by keyboard or copy it to a text file first, in order to remove any special characters.
finally give Apache ownership to the files:
chown -R apache:apache /var/www/html/*
In the virt-install command add the CentOS (URL) as string
and use --bridge=xenbr0 instead of bridge:xenbr0
[root#CentOS ~]# virt-install -p -n vserver -r 512 -f /var/lib/xen/images/vserver.img -l "http://192.168.1.8/centos/os" -x -w --bridge=xenbr0 --vcpus=1
P.S: change the arch field if you are using 64bit version to x86_64

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.

How to virt-install kvm Centos 8 using kickstart.cfg

I recently managed to install
Centos7 with kickstart.cfg file by using virt-install at my Archlinux.
However, if I simply want to use similar approach with Centos 8 - it does not work at all.
I suspect that it is because of the fact that Centos8 does not have any minimal version and you need to download like 7GB iso fiel with graphical installer.
sudo virt-install --name k8s-1 \
--description "this is my Centos 8 " \
--ram 2048 \
--vcpus 2 \
--disk path=/vm-disks/k8s-1.qcow2,size=15 \
--os-type linux \
--os-variant "centos8" \
--network bridge=virbr0 \
--graphics vnc,listen=127.0.0.1,port=5901 \
--location /cdimages/CentOS-8.1.1911-x86_64-dvd1.iso \
--noautoconsole \
--initrd-inject ks-1.cfg --extra-args="ks=file:/ks-1.cfg"
Setting input-charset to 'UTF-8' from locale.
Starting install...
Setting input-charset to 'UTF-8' from locale.
Retrieving file vmlinuz... | 7.7 MB 00:00:00
Setting input-charset to 'UTF-8' from locale.
Retrieving file initrd.img... | 59 MB 00:00:00
Domain installation still in progress. You can reconnect to
the console to complete the installation process.
Here is ks-1.cfg
# Install OS instead of upgrade
install
# Use network installation
cdrom
# Root password
rootpw Start123
# System authorization information
auth --useshadow --passalgo=sha512
# Firewall configuration
firewall --disabled
# SELinux configuration
selinux --permissive
# Installation logging level
logging --level=info
# Use text mode install
text
# Do not configure the X Window System
skipx
# System timezone, language and keyboard
timezone --utc Europe/Bratislava
lang en_US.UTF-8
# keyboard dk-latin1
# Network information
# network --bootproto=static --ip=192.168.122.110 --device=eth0 --onboot=on
# If you want to configure a static IP:
network --device eth0 --hostname k8s-1 --bootproto=static --ip=192.168.122.111 --netmask=255.255.255.0 --gateway=192.168.122.1 --nameserver 192.168.122.1
# System bootloader configuration
bootloader --location=mbr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype="ext4" --size=512
#part swap --fstype="swap" --recommended
part /var --fstype="ext4" --size=5120 --grow
part / --fstype="ext4" --size=1024 --grow
part /usr --fstype="ext4" --size=3072
part /home --fstype="ext4" --size=512
part /tmp --fstype="ext4" --size=1024
# Reboot after installation
reboot
%packages --nobase
#core
# #base
%end
%post --log=/root/ks-post.log
#---- Install packages used by kubernetes
#yum install -y socat libseccomp-devel btrfs-progs-devel util-linux nfs-utils conntrack-tools.x86_64
#---- Set bridge-nf-call
echo "net.bridge.bridge-nf-call-ip6tables=1
net.bridge.bridge-nf-call-iptables=1" > /etc/sysctl.conf
#---- Add user RKE -----
groupadd docker
adduser rke
echo "rke:praqma" | chpasswd
usermod -aG docker rke
#---- Install our SSH key ----
mkdir -m0700 /home/rke/.ssh/
cat <<EOF >/home/rke/.ssh/authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9F5hTts3U+E10PHRxViM3PX+DZPgBIcL7Uj/Py+udJWehhobnJmj2EoaUYbykm7VdpjImLpjas2Vhb/gNZ+wVWGho1mzWoCPl2fZ7oLXrGdDHXhlyocvfX3XPB6Y1kbFlfh7+4bUaA7w2Dg4x8LO/iXlF34z6IOa2xgx1R70Xc/97lkRMhsKszRBzwGVin6qUqdVmdXg3d0dRUnq039+q8NWUcKAz2w6F/HO7u3N7NhsSLnlpQ9+AztLvHEPeRP6UNex9a8sSHo5Jzc/mjVKGfInfWjp3nru88mwM4UQRbhhW5IeLXgALCa++H4qZw1ivZtVadXBHjK4JMKC1UWD1 rancher#k8s
EOF
### Disabling swap (now and permently)
swapoff -a
sed -i '/^\/swapfile/ d' /etc/fstab
### set permissions
chmod 0600 /home/rke/.ssh/authorized_keys
chown -R rke:rke /home/rke/.ssh
### fix up selinux context
restorecon -R /home/rke/.ssh/authorized_keys
### Install Docker
#yum install docker -y
#systemctl enable docker
%end
If you take a look to virtual-manager GUI you willalways see dracut shell error
I had exactly the same issue. My solution:
for some reason parameter --initrd-inject for virt-install breaks the process.
So I removed it and load kickstart file via network with --extra-args "ks=http://192.168.xxx.xxx:8000/centos8_ks.cfg"
Hint: to run simple web server for this installation you can execute python3 -m http.server 8000 in folder with your kickstart file.
Of course you need to update your kickstart for CentOS-8 according to this - a lot has been changed.
Another option is to create a small floppy image with label OEMDRV and with file ks.cfg on it and attach it as a CDROM: How to automate CentOS7 minimal kickstart installation using OEMDRV volume?

How to install wget on LFS system

I am pretty newbie to Linux and started LFS because I needed it for school. So my system is now perfectly running with an internet connection, but I still don't have any packet manager or something. The first binary I would like to have is basically wget, but I really don't know how to do...
Could someone explain to me please ?
I personally used (and would highly recommend) using the existing Linux system (the host) to download the wget package and its dependencies before booting your LFS system for the first time. However, seeing that you're already using your LFS system, if you still have the ability to log using the host, then use it to download wget as if it was one of the sources that you got when building the LFS system.
For me, I used a Linux Mint Host running in VirtualBox to build my LFS. To get wget I just had to re-add the Linux Mint host storage, and download wget and added it to the LFS sources. I then removed the Linux Mint host storage, logged in to my LFS machine, then followed the steps in BLFS.
Note: this is mainly just from parts of lfs and the wget page of blfs.
1. Boot into your host OS.
2. Enter the following commands in the command line to get into chroot(edit depending on your partitions and where you mount lfs):
sudo su -
export LFS=/mnt/lfs
mount -vt ext4 /dev/sda4 $LFS
mount -v --bind /dev $LFS/dev
mount -vt devpts devpts $LFS/dev/pts -o gid=5,mode=620
mount -vt proc proc $LFS/proc
mount -vt sysfs sysfs $LFS/sys
mount -vt tmpfs tmpfs $LFS/run
if [ -h $LFS/dev/shm ]; then
mkdir -pv $LFS/$(readlink $LFS/dev/shm)
fi
chroot "$LFS" /usr/bin/env -i \
HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
PATH=/bin:/usr/bin:/sbin:/usr/sbin \
/bin/bash --login
3. Download wget from http://ftp.gnu.org/gnu/wget/wget-1.19.1.tar.xz and copy it into /mnt/lfs/sources from your host os.
4. Unpack and cd into it with:
tar -xf wget-1.19.1.tar.xz
cd wget-1.19.1
5. Configure and install wget with:
./configure --prefix=/usr \
--sysconfdir=/etc \
--with-ssl=openssl &&
make
make install
6. Delete the wget-1.19.1 folder if you want and your done!

Testing a linux kernel in qemu [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I have just built the 3.13.3 kernel from kernel.org on my ubuntu 12.04 computer. I ran the make menuconfig command and then I did make which built the kernel and the modules. I want to run the kernel in the qemu emulator (qemu-system-x86_64) so I can start testing and building on top of it. Curently I am getting it to run with qemu-system-x86_64 -kernel bzImage however it is not booting properly. What changes should I make in order to make the kernel boot properly?
You need to have a bootable disk first of all. Have you tried booting without -kernel and specifying the disk to boot from ?
If and only if that works, then think about using -kernel as an optimization
to test out new kernels
Making a bootable disk can be a challenge unless you take the easy route and use dd to make a large empty file e.g.
sudo dd if=/dev/zero of=$OUTPUT_DISK bs=4096 count=524288
then boot qemu with the linux iso you downloaded and also tell it to use this disk (-hda) and let the installer set the disk up for you
If making a bootable disk by hand, I've done this a couple of times - not easy, but the following steps may help you. You need to format the disk, create partitions, install grub and then boot
Personally I would take the easy route and install to disk via linux installer
#!/bin/sh
#
# Change these settings
#
INPUT_ISO=mydownloadedlinux.iso
OUTPUT_DISK=mydisk
KERNEL_IMAGE_NAME=linux-kernel
QEMU=qemu-system-x86_64
#
# Stuff you should not need to change
#
TMP_BOOTDISK=/tmp/disk.$$
ISO_MOUNT_DIR=/mnt/iso
#
# Choose DOS or Linux disks
#
PARTITION_TYPE=ext2
MKFS_TYPE=ext2
#
# Mount the ISO
#
sudo mkdir -p $ISO_MOUNT_DIR
sudo umount $ISO_MOUNT_DIR 2>/dev/null
sudo mount -o loop -t iso9660 $INPUT_ISO $ISO_MOUNT_DIR
#
# Make a new disk
#
sudo dd if=/dev/zero of=$OUTPUT_DISK bs=4096 count=524288
LOOP=`sudo losetup -f --show $OUTPUT_DISK`
LOOPDEV=`echo $LOOP | sed 's/.*loop/loop/g'`
echo "Loopback device $LOOP, ($LOOPDEV)"
#
# Make two partitions on the disk
#
sudo parted -s $LOOP mktable msdos \
mkpart primary $PARTITION_TYPE 32K 50% \
mkpart primary $PARTITION_TYPE 50% 95%
#
# Make one bootable
#
sudo parted -s $LOOP set 1 boot on
sudo kpartx -l $LOOP
sudo kpartx -a $LOOP
#
# Make the filesystems
#
sudo mkfs.$MKFS_TYPE /dev/mapper/${LOOPDEV}p1
sudo mkfs.$MKFS_TYPE /dev/mapper/${LOOPDEV}p2
#
# List what we made
#
sudo kpartx -l -v $LOOP
#
# Mount this temporary disk so we can install grub on it
#
sudo mkdir -p $TMP_BOOTDISK
sudo mount /dev/mapper/${LOOPDEV}p1 $TMP_BOOTDISK
sudo grub-install --boot-directory=/$TMP_BOOTDISK $LOOP
#
# Make grub boot config
#
cat >/tmp/grub.cfg <<%%
serial
#terminal_input --append serial_com0
#terminal_output --append serial_com0
configfile /mybootfile
%%
cat >/tmp/mybootfile <<%%
set timeout=5
set default=0
menuentry 'mylinux' {
insmod ext2
set root='(hd0,1)'
linux /$KERNEL_IMAGE_NAME bigphysarea=28000
initrd /rootfs.img.gz
}
%%
#
# Just copy all the files off of the ISO into the mounted temp disk
# This would be the tricky part as you need enough so linux can boot
#
sudo cp -r $ISO_MOUNT_DIR/* $TMP_BOOTDISK
#
# But use our grub files we made above
#
sudo cp /tmp/grub.cfg $TMP_BOOTDISK/grub/grub.cfg
sudo cp /tmp/mybootfile $TMP_BOOTDISK/mybootfile
#
# Show all the files on the temp disk and then unmuont it
#
find $TMP_BOOTDISK
sudo umount $TMP_BOOTDISK
sudo losetup -d $LOOP
#
# Convert the temp disk from raw to vmdk format
#
sudo qemu-img convert $OUTPUT_DISK -O vmdk $OUTPUT_DISK.vmdk
#
# Boot the vmdk
#
sudo $QEMU -boot d -m 4096 \
-enable-kvm \
-drive file=$OUTPUT_DISK.vmdk,if=virtio,media=disk \
-serial telnet:localhost:4444,nowait,server,telnet \
-net nic,model=e1000,vlan=0 -net user \

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