Saturday, 16 August 2025
Ubuntu 24.x/25.x VMware Ultimate Optimization Script
#!/bin/bash
# Ubuntu 24.x/25.x VMware Ultimate Optimization Script
# Includes display/audio drivers, networking tools, and productivity software
# Compatible with VMware Workstation 17.x
# Check if running as root
if [ "$(id -u)" -ne 0 ]; then
echo "This script must be run as root. Use sudo." >&2
exit 1
fi
# Check if we're running in a VMware VM
if ! dmidecode -s system-product-name | grep -iq "VMware"; then
echo "This script should only be run in a VMware virtual machine." >&2
exit 1
fi
# Determine Ubuntu version
UBUNTU_VERSION=$(lsb_release -rs)
echo "Detected Ubuntu version: $UBUNTU_VERSION"
# Update system first
echo "Updating system packages..."
apt update && apt upgrade -y
# 1. Install VMware tools and drivers
echo "Installing VMware display and audio drivers..."
apt install -y --no-install-recommends open-vm-tools open-vm-tools-desktop \
open-vm-tools-dkms pulseaudio pavucontrol
# Enable services
systemctl enable vmtoolsd
systemctl enable vmware-tools
systemctl restart vmtoolsd
# 2. Install VMware Workstation 17.x specific audio components
echo "Configuring audio for VMware Workstation 17.x..."
apt install -y alsa-utils libasound2-plugins
cat > /etc/pulse/default.pa << 'EOL'
load-module module-alsa-sink device=hw:0,0
load-module module-alsa-source device=hw:0,0
load-module module-alsa-card device_id=0 name=vmware
EOL
# 3. Enhanced display configuration
echo "Optimizing display settings..."
cat > /etc/X11/xorg.conf.d/10-vmware.conf << 'EOL'
Section "Device"
Identifier "VMware SVGA"
Driver "vmware"
Option "Accel" "true"
Option "UseFBDev" "true"
Option "UseGLX" "true"
EndSection
Section "Screen"
Identifier "Default Screen"
Device "VMware SVGA"
DefaultDepth 24
SubSection "Display"
Depth 24
Modes "1920x1080" "1600x900" "1366x768"
EndSubSection
EndSection
EOL
# 4. Networking tools and utilities
echo "Installing advanced networking tools..."
apt install -y \
net-tools iproute2 nmap tcpdump wireshark iperf3 \
netcat-openbsd curl wget whois dnsutils openssh-server \
bridge-utils openvpn network-manager-openvpn \
iftop nethogs vnstat traceroute mtr-tiny
# Enable SSH
systemctl enable ssh
systemctl start ssh
# 5. Productivity tools and editors
echo "Installing productivity tools..."
apt install -y \
vim neovem micro emacs-nox \
git git-extras tig \
tmux screen byobu \
htop bashtop gotop \
tree silversearcher-ag ripgrep fzf \
jq yq csvkit xmlstarlet \
python3-pip python3-venv \
build-essential cmake gdb \
unzip p7zip-full rar unrar \
ncdu rsync
# Install Visual Studio Code (official Microsoft repo)
if [ ! -f /usr/share/keyrings/packages.microsoft.gpg ]; then
curl -sSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /usr/share/keyrings/packages.microsoft.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list
apt update
fi
apt install -y code
# 6. System monitoring and optimization
echo "Installing system monitoring tools..."
apt install -y \
sysstat iotop smartmontools lm-sensors \
cockpit cockpit-storaged cockpit-networkmanager \
earlyoom
# Configure early OOM killer
sed -i 's/EARLYOOM_ARGS="-r 60"/EARLYOOM_ARGS="-r 60 -m 5 -s 10"/g' /etc/default/earlyoom
systemctl enable earlyoom
systemctl start earlyoom
# 7. Filesystem and storage tools
echo "Installing filesystem tools..."
apt install -y \
ntfs-3g exfat-utils fuseiso \
duf baobab disk-manager \
udisks2 udiskie
# 8. Multimedia and graphics
echo "Installing multimedia support..."
apt install -y \
ffmpeg vlc gimp inkscape \
imagemagick graphicsmagick \
libavcodec-extra
# 9. Virtualization and container tools
echo "Installing container tools..."
apt install -y \
docker.io docker-compose podman \
virt-manager libvirt-daemon-system
# Add user to virtualization groups
usermod -aG docker $SUDO_USER
usermod -aG libvirt $SUDO_USER
usermod -aG kvm $SUDO_USER
# 10. Final system optimizations
echo "Applying final optimizations..."
# Enable TRIM if using SSD
systemctl enable fstrim.timer
systemctl start fstrim.timer
# Improve swapiness
echo "vm.swappiness=10" >> /etc/sysctl.conf
# Improve filesystem access
echo "vm.dirty_ratio=10" >> /etc/sysctl.conf
echo "vm.dirty_background_ratio=5" >> /etc/sysctl.conf
# Apply changes
sysctl -p
# Enable VMware shared folders (if configured)
mkdir -p /mnt/hgfs
systemctl enable vmware-vmblock-fuse
systemctl start vmware-vmblock-fuse
# Enable drag and drop
cat > /etc/vmware-tools/dnd.conf << 'EOL'
dnd.enable = true
copy.maxFileSize = "2000000000"
copy.maxBlockSize = "1000000"
EOL
# Enable clipboard
cat > /etc/vmware-tools/tools.conf << 'EOL'
[guestinfo]
primary-nics=eth0
[isolation]
busy-timeout = 300
[resolution]
perSession = TRUE
[ui]
show-dnd-tip = TRUE
show-copy-tip = TRUE
EOL
# Create desktop shortcuts for common tools
if [ -d "/home/$SUDO_USER/Desktop" ]; then
# Create VMTools restart shortcut
cat > "/home/$SUDO_USER/Desktop/Restart VMTools.desktop" << 'EOL'
[Desktop Entry]
Version=1.0
Type=Application
Name=Restart VMware Tools
Exec=sudo systemctl restart vmtoolsd
Icon=vmware
Terminal=true
Categories=System;
EOL
chown $SUDO_USER:$SUDO_USER "/home/$SUDO_USER/Desktop/Restart VMTools.desktop"
chmod +x "/home/$SUDO_USER/Desktop/Restart VMTools.desktop"
fi
echo "################################################################"
echo "# Optimization complete! #"
echo "# #"
echo "# Installed components: #"
echo "# - VMware display and audio drivers #"
echo "# - Advanced networking tools #"
echo "# - Productivity editors and utilities #"
echo "# - System monitoring tools #"
echo "# - Container and virtualization support #"
echo "# #"
echo "# Recommended actions: #"
echo "# 1. Reboot the VM #"
echo "# 2. In VMware settings, enable: #"
echo "# - 3D acceleration #"
echo "# - Clipboard sharing #"
echo "# - Drag and drop #"
echo "# - Shared folders (if needed) #"
echo "################################################################"
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment