Wednesday, October 18, 2023

copying linux system and boot

mounting and copying file

mkdir s     (for source).

mkdir d     (for destination)

sudo mount /dev/sda1  s     (mounted file system to be copied to)

mount /dev/sdb1 d              (destination device formatted ext4)

sudo cp -avrf s/* d/.

....    (bunch of message copy process)

sudo umount s    (unmount source device/running OS to has been copied)

 

setting up boot on destination device

sudo mount proc d/proc/ -t proc
sudo mount sys d/sys/ -t sysfs
sudo mount -o bind /dev/ d/dev/
sudo chroot d 

find device destination uuid (sdb1)

ls -al /dev/disk/by-uuid

drwxr-xr-x 2 root root 140 Oct 19 10:50 .
drwxr-xr-x 7 root root 140 Oct 19 09:49 ..
lrwxrwxrwx 1 root root  10 Oct 19 10:50 076e1fc2-c344-49ea-95de-e1b0d3f77be5 ->
../../sdb4
lrwxrwxrwx 1 root root  10 Oct 19 09:55 1712071f-7899-4496-8a5e-881821578813 ->
../../sda1
lrwxrwxrwx 1 root root  10 Oct 19 09:49 28944C55944C2820 -> ../../sdb2
lrwxrwxrwx 1 root root  10 Oct 19 09:49 5e24b64a-1d70-46f3-b820-70fd3e8f2d4e ->
../../sdb3
lrwxrwxrwx 1 root root  10 Oct 19 09:49 84DE5634DE561EAC -> ../../sdb1

edit /etc/fstab replace the root file system UUID with UUID new device  
 
vi /etc/fstab
 
#### Static Filesystem Table File
proc    /proc   proc    defaults        0       0
# /dev/sdd1
#UUID=1712071f-7899-4496-8a5e-881821578813      /       ext4    rw,errors=remoun
t-ro    0       1
# /dev/sdb1
UUID=
84DE5634DE561EAC       /       ext4    rw,errors=remoun
t-ro    0       1

Upgrade and install grub on destination device

update-grub

grub-install /dev/sdb

exit

sudo umount d/proc

sudo umount d/sys

sudo umount d/dev

sudo umount d/

 

Done! start boot on new device



boot serial terminal

sudo vi /etc/default/grub

 # If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
#GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX_DEFAULT=""
#GRUB_CMDLINE_LINUX=""
GRUB_CMDLINE_LINUX="text console=tty0 console=ttyS0,115200n8"

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
GRUB_TERMINAL=console
#GRUB_TERMINAL=serial
#GRUB_SERIAL_COMMAND=serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"

sudo update-grub

to set piority to next os (win 7) the linux always occupy 2 lines. then the optian will be the third from zero wich is default "2"

sudo vi /boot/grub/grub.cfg

...

if [ "${next_entry}" ] ; then
   set default="${next_entry}"
   set next_entry=
   save_env next_entry
   set boot_once=true
else
   set default="2"
fi
 


boot console

to boot in concole text mode: 
sudo systemctl set-default multi-user.target
revert to normal 
sudo systemctl get-default

 

apt

 apt-get update --allow-releaseinfo-change

 

W: Failed to fetch https://deb.debian.org/debian/dists/buster-backports/InRelease  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0E98404D386FA1D9 NO_PUBKEY 6ED0E7B82643E131

sudo gpg --keyserver pgp.mit.edu --recv-keys 0E98404D386FA1D9 6ED0E7B82643E131 0E98404D386FA1D9 6ED0E7B82643E131

gpg --armor --export DC30D7C23CBBABEE | sudo apt-key add -

sudo apt intsall debian-keyring debian-archive-keyring

Sunday, October 15, 2023

create rc.local on systemd

 vi /etc/systemd/system/rc-local.service

 [Unit]
Description=/etc/rc.local
ConditionPathExists=/etc/rc.local

[Service]
#Type=forking
Type=idle
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99

[Install]
WantedBy=multi-user.target

vi /etc/rc.local

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

exit 0

chmod a+x /etc/rc.local

 sudo systemctl enable rc-local.service

done!



Thursday, October 12, 2023

samba share folder

 To share samba (windows share) with all permisson (on debian jessie) add following lines to  /etc/samba/smb.conf

...

[<name media>]
 path = <path to folder>
 public = yes
 writable = yes
 comment = smb share
 printable = no
 guest ok = yes
 read only = no
 directory mask = 0775

example:

vi /etc/samba/smb.conf

.....

[media]
 path = /media
 public = yes
 writable = yes
 comment = smb share
 printable = no
 guest ok = yes
 read only = no
 directory mask = 0775


to add password simple:

[media]
 path = /media
 public = yes
 writable = yes
 comment = smb share
 printable = no
 guest ok = no
 read only = no
 directory mask = 0775
 username = igunos

multiple user  username = igunos, jony, antony

then add password

sudo smbpasswd -a igunos

....<your passwd>

nfs share folder

To share nfs with all permission add these line to /etc/exports (on debian jesssie)

<folder> <ip/mask>  (rw,sync,no_subtree_check,no_all_squash,no_root_squash) 

to be accessedon multiple subnet

<folder> <ip/mask>  (rw,sync,no_subtree_check,no_all_squash,no_root_squash)  <ip2/mask> (rw,sync,no_subtree_check,no_all_squash,no_root_squash) 

 

examples:

 vi /etc/exports

....

 /media/data 10.1.1.0/255.255.255.0(rw,sync,no_subtree_check,no_all_squash,no_root_squash) 

/media/maindata 10.1.1.0/255.255.255.0(rw,sync,no_subtree_check,no_all_squash,no_root_squash) 10.1.2.0/255.255.255.0(rw,sync,no_subtree_check,no_all_squash,no_root_squash)