Sunday, November 21, 2021

HOW TO: Update VMware ESXi 6.7 GA to ESXi 6.7 P05

 References:


Here are the steps to upgrade your software:


1. Download ESXi 6.7 P05) Offline Bundle

Download the ESXi 6.7 P05 Offline Bundle from VMware here



2. Upload the offline bundle to an ESXi 6.7 datastore from Unix/Linux desktop

$ scp ESXi670-202103001.zip root@[ESXi-IP]:/vmfs/volumes/datastore1/patchs/

3. Connect to the ESXi 6.7 host server via SSH, remember to enable ssh in ESXi host

$ ssh root@[ESXi-IP]

- to confirm the ESXi version, at the console prompt, type 
# vmware -l
# esxcli system version get
# esxcli software profile get

4. Use esxcli at the console command line to update the server

- Enter maintenance mode
# esxcli system maintenanceMode set -e true

- List software profile to select the right version for update
# esxcli software sources profile list -d /vmfs/volumes/datastore1/patchs/ESXi670-202103001.zip

Name Vendor                    Acceptance Level               Creation Time       Modification Time
-------------------------------- ------------ ---------------- ------------------- -------------------
ESXi-6.7.0-20210301001s-no-tools VMware, Inc. PartnerSupported 2021-03-04T10:17:40 2021-03-04T10:17:40
ESXi-6.7.0-20210304001-no-tools VMware, Inc. PartnerSupported 2021-03-04T10:17:40 2021-03-04T10:17:40
ESXi-6.7.0-20210304001-standard VMware, Inc. PartnerSupported 2021-03-04T10:17:40 2021-03-04T10:17:40
ESXi-6.7.0-20210301001s-standard VMware, Inc. PartnerSupported 2021-03-04T10:17:40 2021-03-04T10:17:40


- update VMware ESXi software from .zip patch file.
# esxcli software profile update -p ESXi-6.7.0-20210304001-standard -d /vmfs/volumes/datastore1/patchs/ESXi670-202103001.zip

- Exit maintenance mode and reboot
# esxcli system maintenanceMode set -e false
# reboot

5. Check the ESXi 6.7 GA Host server has been updated. via ESXi physical console or command line:

# vmware -l
# esxcli system version get
# esxcli software profile get

- Install the vSphere 6.7 Update3 directly from VMware Repository


1. Allow the ESXi host to connect the Internet
# esxcli network firewall ruleset set -e true -r httpClient

2. List software profiles to get the version to update. 
# esxcli software sources profile list -d https://hostupdate.vmware.com/software/VUM/PRODUCTION/main/vmw-depot-index.xml

3. Enter mantaince mode 
# esxcli system maintenanceMode set -e true 

4. Update software
# esxcli software profile update -p ESXi-6.7.0-20210304001-standard -d https://hostupdate.vmware.com/software/VUM/PRODUCTION/main/vmw-depot-index.xml

5. Exit maintenance mode and reboot
# esxcli system maintenanceMode set -e false
# reboot

Wednesday, February 5, 2020

MySQL: backup & restore database dump without definer, update definer

- Remove DEFINER clause from MySQL Dumps (2 Methods)
$ mysqlpump -h localhost -u database-user -p database-name | sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' > dump-without-definer.sql

- Restore database dump without definer:
$ cat dump-with-definer.sql | sed 's/DEFINER=[^*]*\*/\*/' > dump-without-definer.sql
$ mysql -u database-user -p --max-allowed-packet=32M database-name < dump-without-definer.sql

- Restore database dump without definer to different schema;
$ mysql -u database-user -p --max-allowed-packet=32M database-name < dump-without-definer-schema.sql |  sed s/`database-name`/`other-database-name`/g > dump-without-definer-schema.sql

- Change database definer from user “root” to user “database-user” run below command using mysql workbench and root access
mysql> SELECT CONCAT("ALTER DEFINER=`database-user`@`%` VIEW ", table_name, " AS ", view_definition, ";") FROM information_schema.views WHERE table_schema='database-name';

- Right click with the mouse on results rows and click Copy Row (unquoted), Paste and run the results commands
- Grant user ‘database-user’ privileges and flush privileges
mysql> GRANT ALL PRIVILEGES ON *.* TO `database-user`@`%`;mysql>  GRANT CREATE, ALTER, DROP, CREATE VIEW ON *.* to 'database-user'@'%';
mysql> FLUSH PRIVILEGES;
-Verify views updates, query all result rows replace \G with ; in each sql line of results
mysql> SELECT CONCAT('SHOW CREATE VIEW ',table_schema,'.',table_name,'\\G') FROM information_schema.tables WHERE engine IS NULL;



- Another way to backup views without definer to a .sql file and drop views and recreate views without definer from previous .sql file.
$ mysql -u root -p -A --skip-column-names -e"SELECT CONCAT('SHOW CREATE VIEW ',table_schema,'.',table_name,'\\G') FROM information_schema.tables WHERE engine IS NULL" | mysql -u root -p -A --skip-column-names > AllMyViews.sql
$ mysql -u root -p -A --skip-column-names -e"SELECT CONCAT('DROP VIEW ',table_schema,'.',table_name,';') FROM information_schema.tables WHERE engine IS NULL" | mysql -u root -p -A
$ mysql -u root -p  -A < AllMyViews.sql

$ echo "SELECT CONCAT("ALTER DEFINER=`database-user`@`%` VIEW ", table_name, " AS ", view_definition, ";") FROM information_schema.views WHERE table_schema='database-name'" | mysql -u root -p > alterView.sql
$ mysql -u root -p database-name < alterView.sql

Sunday, October 20, 2019

How to Mount a SMB Share in Ubuntu


https://wiki.ubuntu.com/MountWindowsSharesPermanently

https://tecadmin.net/mounting-samba-share-on-ubuntu/


windows IP Address: 192.168.1.7
windows user: user1
windows user password: Pa$$wd
windows share name: winshare
Ubuntu mount point: shared


Step 1: In Windows, create shared a Drive with share name for example "winshare"

Step 2: In Ubuntu, Install the CIFS Utils pkg
sudo apt -y install cifs-utils

Step 3: Create a mount point
sudo mkdir /mnt/shared

Step 4: Mount the volume, You will be prompted for windows user password
sudo mount -t cifs -o user=user1 //192.168.1.7/winshare /mnt/shared

Step 5: Mounting at boot, add to /etc/fstab file, create credentials file:
sudo vi /home/user1/.smbcredentials
username=user1
password=Pa$$wd

sudo vi /etc/fstab
//192.168.1.7/winshare /mnt/shared cifs credentials=/home/user1/.smbcredentials,users,rw,iocharset=utf8 0 0

, mount all /etc/fstab entries
sudo mount -a

, verify sharing work
ls -lh /mnt/shared

Thursday, October 17, 2019

Reinstall the GRUB boot loader to Ubuntu installation in EFI mode

Boot from the Ubuntu installation medium and select 'Try Ubuntu without installing'.
(Boot your install medium in EFI mode, select the Ubuntu entry with UEFI in front.)

Once you are on the Live desktop, open a terminal and execute these commands :

sudo mount /dev/sdXXX /mnt
sudo mount /dev/sdXX /mnt/boot/efi
for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
sudo chroot /mnt
grub-install /dev/sdX
update-grub 
Note : sdX = disk | sdXX = efi partition | sdXXX = system partition

To identify the partitions use GParted, the tool is included in the installation medium.
After having run the commands GRUB will be installed in the separate EFI partition.

Saturday, October 12, 2019

Ubuntu: Single user mode, Reset root password, Clone system image, Expand latest disk partition,



############ Ubuntu Single user mode using grub boot menu ############

Grub boot menu in kernel line

Change:
ro quiet splash $vt_handoff

TO:
rw init=/bin/bash

for emergency mode TO: [read only root file system file system without network services]
“systemd.unit=emergency.target”

for rescue mode TO: [ mount all the local file systems & try to start some important services including network]
 “systemd.unit=rescue.target“


############ Reset root password ############

- Confirm that your system partition is mounted as read/write (rw):
# mount | grep -w /

- Change root partition from read-only to read/write mode:
# mount -o remount,rw /

-  Reset user account (user1) password:
# passwd user1

- Reboot your system:
# exec /sbin/init


############ Ubuntu system image backup & restore using dd command ############

Using Ubuntu Live USB drive,

for faster clone use pv command tool, install "pv" with below command:
$ sudo apt -y install pv

- Clone disk /dev/sda to disk /dev/sdb
$ sudo pv < /dev/sda > /dev/sdb

- Backup Ubuntu system image from disk to file and compress with .7z 
sudo dd if=/dev/sda1 of=./ubuntusystem.img

- Compress Ubuntu system image file with .7z 
$ sudo apt -y install p7zip-full
$ sudo 7z a ./ubuntusystem.7z ./ubuntusystem.img

- Restore ubuntu system image from a file.
sudo 7z e ./ubuntusystem.7z 
sudo dd if=./ubuntusystem.img of=/dev/sda

- If Target system disk  is larger than the one with Ubuntu disk then try expand disk free space with below steps.


############ Expand latest partition in a disk ############

- Expand latest disk partition with extra disk space suppose it's /dev/sda3 then resize partition 3 : 
# parted /dev/sda resizepart 3 100%

- Check your partition file system
# e2fsck -f /dev/sda3

- resize file system with new partition size, and reboot
# resize2fs /dev/sda3

- Reboot your system:
# exec /sbin/init