Virtualization = nice, convenient technology ให้ incept OS - รัน OS บน OS, computer inside computer = flexibility, legacy support, test software multiple platforms, isolation, limited fancy graphics support
ไม่กี่ปี VirtualBox มี option enable 3D acceleration ใน VMs ช่วย smoother experience graphics-intensive stuff effective ไม่มี perfect solution แต่ better than nothing ยกเว้นกรณีผิดพลาด เช่น enable Guest Additions แล้ว black screen next login ต้อง rectify tutorial นี้: work out black screen situation without reinstalling และได้ proper 3D acceleration enabled
(ภาพประกอบ black screen)
ปัญหา (Problem)
รายละเอียด: VirtualBox รัน ติดตั้ง Ubuntu-based flavor guest OS Natively Ubuntu มาพร้อม basic drivers: mouse host-guest integration, screen resizing แต่ features บางอย่าง: shared folders/clipboard sharing อาจไม่ทำงาน ต้อง install Guest Additions จาก ISO สำหรับ full capabilities reboot/restart graphical section แต่ปัญหา: ไม่ถึง next login - เห็น black screen แทน ทำยังไง?
Introduction to Linux Desktop Sessions
เริ่ม basics: สร้าง snapshot VM ก่อน install Guest Additions recover quickly/easily เหมือน backup data/system image บน physical system ก่อน big changes
(ภาพประกอบ snapshot)
ถ้ามีปัญหา desktop session login อาจต้อง familiar session management under the hood Gnome-based desktops ใช้ Gnome Desktop Manager (gdm) logins config แต่ละ user saved under:
/var/lib/AccountServices/users/(user)
ไฟล์ (แต่ละ) user จะมี declarations define user session starts:
... [User] XSession=plasma SystemAccount=false ...
ถ้าอยากให้ system start default session ใช้ blank XSession entry หรือ ubuntu ชื่อ sessions ตรงกับ desktop session files under /usr/share/xsessions/ typical file:
[Desktop Entry] Type=XSession Exec=/usr/bin/startkde TryExec=/usr/bin/startkde DesktopNames=KDE Name=Plasma ...
X11 vs Wayland Wayland อาจไม่ work well ใน VM environment test desktop behavior (black screen included) โดย edit gdm config enable/disable Wayland ผ่าน /etc/gdm/custom.conf หาบรรทัด comment/uncomment:
#WaylandEnable=falsefirst steps troubleshoot black screen/login issues พิจารณา disable automatic login เพราะถ้า session-specific issues คุณไม่ต้องการ stuck in constant login loop พยายาม reach broken session ตอนนี้รู้แล้ว กลับไป VM stuff
วิธีแก้ (Solution)
ต้อง recover desktop ก่อน เพื่อ actually work: เข้ virtual console ใน VirtualBox กด Right Ctrl (default Host button) + F1-7 ควรให้ virtual console ใน guest ไม่ conflict host Ctrl+Alt+F1-7 น่าเสียดาย อาจไม่มี virtual console tricky แต่มี ways around без reinstall จดจำ: ไม่อยาก waste time
สอง: disable 3D acceleration Power down VM open settings untick box Start machine ควรถึง desktop ไม่ black screen = working system commit repairing broken state properly โดยทั่วไป snapshots, virtual consoles, 3D acceleration toggle ให้ flexibility troubleshoot issues nature นี้ без despairing
(ภาพประกอบ disable 3D acceleration)
ติดตั้ง VirtualBox Guest Additions จาก repositories (Install VirtualBox Guest Additions from the repositories)
ถ้าเจอปัญหา drivers จาก ISO ลอง repo-provided content (aware of limitations) uninstall drivers จาก ISO โดย rerun script uninstall option:
sudo /media/(user)/(VirtualBox ISO path)/VBoxLinuxAdditions.run uninstallReboot ตอนนี้ install จาก repository รัน Wayland ต้อง:
sudo apt-get install virtualbox-guest-utilsรัน X11 (likely ใน VirtualBox) ต้อง:
sudo apt-get install virtualbox-guest-x11Power down machine toggle 3D acceleration back on Start VM ควร work well first step toward goal Settings in place desktop working expected
(ภาพประกอบ working desktop)
3D Acceleration ทำงานจริงไหม? (Is 3D acceleration actually working?)
ยังไม่รู้ 3D acceleration enabled ใน guest OS easiest way: glxinfo command (part of mesa-utils package)
sudo apt-get install mesa-utilsรัน glxinfo check direct rendering:
glxinfo | grep direct direct rendering: Yes GL_ARB_direct_state_access, GL_ARB_draw_buffers, ...ถ้า output Yes = 3D acceleration Congratulations อาจไม่ smooth/fast เท่า native drivers แต่เราไปถึงแล้ว สำคัญ: no black screen ด้วยวิธีนี้ ไม่มี shared folders advanced stuff ที่กล่าวก่อน แต่มี ways around future tutorial
สรุป (Conclusion)
มี stuff เยอะแต่มุ่งหวัง good และ fun focus: modern Linux systems manage desktop sessions เรียนรู้ toggle Wayland on/off พูดถึง differences ISO vs repo-provided drivers วิธีใช้ และ methods keep system robust ถ้าผิดพลาด recover quickly
3D acceleration slowly gradually better ใน virtualization products ทำให้ useful มากขึ้น complexity of stack may rise against you แต่ even when things look bleak - desktop busted มี nice, elegant ways work around them ต้องการ efficient non-destructive วันนี้ mission accomplished See you later, virtual gator.
Cheers.