Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Ubuntu Portable Drive Installation Notes

Tech May 16 1

System Installation

Use an SSD portable drive or a high-speed USB stick (e.g., aigo U393) to install a portable Ubuntu system that can boot on different machines without risking damage to the host's internal drive data.

Install from the Ubuntu Server image instead of the Desktop image. The Server image is smaller and installs faster.

Tip: Use VirtualBox to install the system. Assign the target USB drive to the virtual machine. This allows you to install in an environment with only one disk, avoiding bootloader misplacement. Additionally, after installation, you can leverage the host's network for software updates.

Replace the default apt sources with Tsinghua mirror: https://mirrors.tuna.tsinghua.edu.cn

VirtualBox notes:

  1. Install Extension Pack.
  2. Enable EFI in VM settings and select USB 3.0 controller.

Desktop Installation and Configuration

Install the lightweight Xfce4 desktop: sudo apt install xfce4. When prompted, select lightdm as the display manager.

Power management: xfce4-power-manager Bluetooth: bluetooth and blueman Clipboard: xfce4-clipman

Ubuntu 20.04 does not require xfce4-screensaver because light-locker is present.

Configure screen lock: Settings -> Keyboard -> Shortcuts, add a shortcut for xflock4 command (e.g., Super + L).

fcitx Input Method

sudo apt install fcitx fcitx-googlepinyin

Create ~/.xprofile with:

export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS=@im=fcitx

(For Ubuntu with Gnome desktop) In Language Support, add Chinese if not present, and set the default input method to fcitx.

Right-click the keyboard icon in the system tray, select Configure, and add Google Pinyin input method. If the fcitx icon does not appear after boot, manually start it from Applications/Accessories/Fcitx, or add fcitx to startup applications via Settings/Session and Startup (or Startup Applications in Gnome).

A system restart might be neeeded to start using the input method.

Chinese Fonts

Install Chinese fonts:

sudo apt install fonts-noto fonts-wqy-microhei fonts-wqy-zenhei

To fix some Chinese characters displaying in Japanese style (e.g., "门", "关", "复", "径", "将"), modify /etc/fonts/conf.d/64-language-selector-prefer.conf to prioritize Simplified Chinese (SC):

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
    <alias>
        <family>sans-serif</family>
        <prefer>
            <family>Noto Sans CJK SC</family>
            <family>Noto Sans CJK TC</family>
            <family>Noto Sans CJK HK</family>
            <family>Noto Sans CJK JP</family>
            <family>Noto Sans CJK KR</family>
            <family>Lohit Devanagari</family>
        </prefer>
    </alias>
    <alias>
        <family>serif</family>
        <prefer>
            <family>Noto Serif CJK SC</family>
            <family>Noto Serif CJK TC</family>
            <family>Noto Serif CJK JP</family>
            <family>Noto Serif CJK KR</family>
            <family>Lohit Devanagari</family>
        </prefer>
    </alias>
    <alias>
        <family>monospace</family>
        <prefer>
            <family>Noto Sans Mono CJK SC</family>
            <family>Noto Sans Mono CJK TC</family>
            <family>Noto Sans Mono CJK JP</family>
            <family>Noto Sans Mono CJK KR</family>
            <family>Noto Sans Mono CJK HK</family>
        </prefer>
    </alias>
</fontconfig>

Network Management

In 20.04, Xfce4 includes a network manager (in 18.04 you needed to install wicd manually).

To fix "device not managed" for wired interfaces:

Edit /usr/lib/NetworkManager/conf.d/10-globally-managed-devices.conf:

[keyfile]
unmanaged-devices=none

Then set the device as managed with nmcli:

sudo nmcli device set eth0 managed yes   # replace eth0 with your interface name

Restart the network-manager service: sudo systemctl restart network-manager.service.

Mounting Local Disks

If Thunar shows permission errors when mounting local disks:

Edit /usr/share/polkit-1/actions/org.freedesktop.UDisks2.policy and change the action org.freedesktop.udisks2.filesystem-mount-system as follows:

<defaults>
  <allow_any>auth_admin</allow_any>
  <allow_inactive>auth_admin</allow_inactive>
  <allow_active>yes</allow_active>
</defaults>

(Change allow_active from auth_admin_keep to yes.)

Root Authorization

Xfce4 may lack an authorization component for GUI applications requesting root privileges. Install:

sudo apt install policykit-1 policykit-1-gnome

Migrating Data from an Old Ubuntu System

Ubuntu Server 18.04 and 20.04 use LVM partitions by default (e.g., /dev/sdc3 with volume group ubuntu--vg and logical volume ubuntu--lv).

Useful LVM commands: vgscan, lvs, lvscan, lvmdiskscan, vgdisplay.

  1. vgdisplay to get UUIDs of existnig LVM groups.
  2. vgrename to rename the old system's volume group (avoid name conflict):
    vgrename AAAAAA-AAAA-AAAA-AAAA-AAAA-AAAA-AAAAAA ubuntu-old
    
    Replace the UUID with the actual one from the old disk.
  3. Activate the LVM group: vgchange -a y
  4. Mount the logical volume: sudo mount /dev/ubuntu-old/ubuntu-lv /mnt/ubuntu-old/

Lock Screen Freeze After Login

If the lock screen freezes after entering the password, it's due to both light-locker and xfce4-screensaver being active. Uninstall xfce4-screensaver or disable one of them in Settings/Session and Startup.

Snap Related

Snap has no domestic mirrors. Configure proxy for faster downloads:

sudo snap set system proxy.http="http://127.0.0.1:20171"
sudo snap set system proxy.https="http://127.0.0.1:20171"

The proxy.https value still uses http; adjust port according to your proxy software.

Install snap-store-proxy and client:

sudo snap install snap-store-proxy
sudo snap install snap-store-proxy-client

In Ubuntu 22.04, Firefox and Chromium are only installable via snap. Even apt commands call snap behind the scenes. If you interrupt the installation with Ctrl+C, residual snap processes may prevent reinstallation.

Cleanup:

snap changes            # find the task ID with status "Doing"
sudo snap abort $id     # replace with actual task ID; status changes to "Error"

Shell Related

Fish: sudo apt install fish – works out of the box with no configuration.

Zsh: sudo apt install zsh. Configure with oh-my-zsh:

  1. Install oh-my-zsh:
    git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh
    
  2. Copy the template .zshrc:
    cp .oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
    
  3. Download syntax highlighting and autosuggestion plugins:
    cd ~/.oh-my-zsh/custom/plugins
    git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
    git clone https://github.com/zsh-users/zsh-autosuggestions.git
    
  4. Edit ~/.zshrc to set theme and plugins:
    ZSH_THEME="candy"
    plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
    

Other Software

VSCode: Add the apt repository and import the key. For GitHub login sync, install gnome-keyring.

Docker: Add the apt repository and import the key. Add your user to the docker group to avoid using root: sudo gpasswd -a $USER docker. Reboot or run newgrp docker to refresh.

JetBrains IDEs: Install via snap:

sudo snap install intellij-idea-ultimate datagrip goland

AppImage (example with Mark Text):

  1. Make executable: chmod +x MarkText.AppImage
  2. Extract: ./MarkText.AppImage --appimage-extract -> creates squashfs-root.
  3. Copy .desktop file to system aplications:
    sudo cp squashfs-root/marktext.desktop /usr/share/applications
    
  4. Move extracted directory to /opt/ and create a symlink:
    sudo mv squashfs-root marktext && sudo cp -r marktext /opt/
    sudo ln -s /opt/marktext/AppRun /usr/bin/marktext
    
  5. If the icon is missing, edit /usr/share/applications/marktext.desktop and set:
    Icon=/opt/marktext/.DirIcon
    

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.