Install Archlinux & Xfce4 on VirtualBox
Below are random notes I jotted down when I installed Archlinux and Xfce4 on VirtualBox. It has been a while so there might be errors here and there.
Guest System configuration
- EFI enabled
- GPT partition table for all disks
- GRUB bootloader
- Network setting: NAT
Install
- Basically follow this guide https://wiki.archlinux.org/index.php/installation_guide
- Article for VirtualBox: https://wiki.archlinux.org/index.php/VirtualBox
Notes for installation steps:
Partition the disks
- use gdiskto create GPT partition table for/dev/sda/
- create boot partition with EF00file system code
- mkswap /dev/sdbcreate swap partition (I created another virtual disk with GPT table for swap only)
https://wiki.archlinux.org/index.php/EFI_System_Partition#GPT_partitioned_disks
https://wiki.archlinux.org/index.php/Swap#Swap_partition  
Boot loader
Install GRUB: https://wiki.archlinux.org/index.php/GRUB#Installation_2
- grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=grub
- create a script /boot/startup.nshcontaining this line:FS0:\EFI\grub\grubx64.efi
Activate Numlock on boot
- https://wiki.archlinux.org/index.php/Activating_Numlock_on_Bootup#Extending_getty.40.service
- sudo systemctl edit getty\@.service12[Service]ExecStartPre=/bin/sh -c 'setleds +num < /dev/%I'
Enable internet on boot
- ping www.google.com
- If no internet, run systemctl enable dhcpcd@enp0s3.serviceand reboot
Create main user
- useradd -m -G wheel -s /bin/bash fsworld009
- passwd fsworld009
- add user to other groups: sudo gpasswd -a fsworld009 group_name
- current group setup:12id fsworld009uid=1000(fsworld009) gid=1000(fsworld009) groups=1000(fsworld009),10(wheel),92(audio),109(vboxsf)
Xfce4
- Install: sudo pacman -S xorg xfce4 xfce4-goodies
- start xfce4: startxfce4
- I didn’t make xfce4 run on boot, just feel like it is better to login to shell only by default
Notes for xfce4 environment:
Customize startup script
~/.config/xfce4/xinitrc
All configs need to be above the source call
Audio
- add user to audiogroup:sudo gpasswd -a fsworld009 audio
- pulseaudio is required for Firefox audio output, so I use pulseaudio as audio core
- sudo pacman -S alsa-utils pulseaudio
- detailed explanation: https://askubuntu.com/a/427036/776335
Change default app
- https://www.linuxquestions.org/questions/slackware-14/change-terminal-for-thunar-%27open-terminal-here%27-custom-action-924097/
- exo-preferred-applicationsor Applications -> Settings -> Preferred Applications
Change mouse scroll speed
- sudo pacman -S imwheel
- add imwheelto~/.config/xfce4/xinitrc
- create ~/.imwheelrc:123".*"None, Up, Button4, 6None, Down, Button5, 6
Chinese and Japanese Font
- I use Google Noto fonts
- sudo pacman -S noto-fonts noto-fonts-cjk noto-fonts-emoji
IME
- gcindoes not work properly in many applications (like Google Chrome), so I installed- fcitxinstead
- pacman -Syu fcitx-imfor installing fcitx & GUI framework supports (required)
- fcitx-chewingfor Traditional Chinese,- fcitx-mozcfor Japanese
- you need fcitx-configtoolpackage in order to config IMEs
- add the following to ~/.config/xfce4/xinitrc:123export GTK_IM_MODULE="fcitx"export QT_IM_MODULE="fcitx"export XMODIFIERS="@im=fcitx"
Thunar No Suitable Archive Manager found error
zip archives
- use peazip-gtk2
VirtualBox related topics
Install VirtualBox Guest addon
- sudo pacman -S virtualbox-guest-utils
- enable kernel module: systemctl enable vboxservice.service
- Xfce4 should automatically load guest services, if not then do VBoxClient --clipboard --draganddrop --seamless --display --checkhostversionorVBoxClient-all
- DO NOT use hibernate from archlinux, use VirtualBox host’s save state feature instead. Otherwise guest addon will break on resume and it can only be fixed by full reboot.
Mount shared folder
- Users have to be in vboxsfgroup (created after installingvirtualbox-guest-utils):sudo gpasswd -a fsworld009 vboxsf
- cd /;sudo mkdir shared
- Manual mount:mount -t vboxsf shared_folder_name mount_point_on_guest_system
- Mount in fstab:shared /shared/ vboxsf uid=1000,gid=1000,rw,dmode=700,fmode=600,noauto,x-systemd.automount
- https://blog.gtwang.org/tips/virtualbox-shared-folder/
- https://wiki.archlinux.org/index.php/VirtualBox#Enable_shared_folders
Mount other disks in fstab
- Run lsblk -fto get UUIDs
- edit /etc/fstab12# /dev/sdc1UUID=enter_uid_here mount_point ext4 defaults,nofail,x-systemd.device-timeout=1 0 2
- all options: https://help.ubuntu.com/community/Fstab#Options
SSH server
- Run a ssh server so that host machine can connect via SSH.
- setup port forwarding in VM setting (Network -> Advanced): for example TCP, host 2222 to guest 22
- sudo pacman -S openssh
- enable the following options in - /etc/ssh/sshd_config:123456ListenAddress 0.0.0.0Protocol 2PermitRootLogin noChallengeResponseAuthentication noUsePAM yesSubsystem sftp /usr/lib/ssh/sftp-server
- add - sshd:ALLto- /etc/hosts.allow
- sudo systemctrl start sshd.socket, I created another user to authorize the service, not sure if this is required.
- check sshd log: journalctl /usr/bin/sshd
- test ssh server locally: ssh fsworld009@0.0.0.0:22- If you don’t have ssh keys yet you need to generate one, refer to GitHub guides: Check fot existing SSH keys, Generating a new SSH key and adding it to the ssh-agent
 
- Ssh from host machine: ssh 0.0.0.0 -p 2222
- Other refs: http://smalldd.pixnet.net/blog/post/24627330-arch-linux-%E5%AE%89%E8%A3%9D-openssh (Traditional Chinese)
Xorg over SSH
NOT RECOMMEND as the performance is generally worse and there are many UI bugs when running over SSH
- In SSH sessions, run GUI applications with - &at the end to start the application in another process, for example:- firefox &
- enable the following settings in - /etc/ssh/sshd_config:123X11Forwarding yesX11DisplayOffset 10X11UseLocalhost yes
Windows
- You need a X Server such as VcXsrv
- Use puttyto connect to the guest machine, with the following setting enabled:- Connection -> SSH -> X11 -> Enable X11 forwarding
- X display location: localhost:0
 
- If $DISPLAY = localhost:10.0after you login via ssh, then you are all set.12echo $DISPLAYlocalhost:10.0
- Other notes:- If you want to use ssh from msys2 or Bash on Windows in windows 10, refer to below. (I believe you still need to run VcXsrv as X Server)
- The change IME short cut for fcitxmay conflict with Windows host
 
Unix based OS (not tested )
| 
 | 
 | 
- http://cypresslin.web.fc2.com/Memo/M-SSH.html
- https://askubuntu.com/questions/432255/what-is-display-environment-variable
Pacman and AUR packages
Refer to my other article.
Enable Hibernate
DO NOT USE systemd hibernate when running as a VM guest, use VirtualBox host’s save state feature instead. Otherwise guest addon will break on resume and it can only be fixed by full reboot.
- Edit - /etc/default/grub: add resume kernel parameter- have seen many reports on /dev/sdx not working, but I didn’t try.1GRUB_CMDLINE_LINUX_DEFAULT="quiet resume=UUID=swap_uuid"
 
- have seen many reports on /dev/sdx not working, but I didn’t try.
- grub-mkconfig -o /boot/grub/grub.cfg
- Edit - /etc/mkinitcpio.conf: add- resumeto HOOKS option1HOOKS=(base udev autodetect modconf block filesystems keyboard fsck resume)
- sudo mkinitcpio -p linux
- xfce4-power-manager-settings: change sleep mode to hibernate
Other refs: