Search This Blog

Friday, December 20, 2024

[WSL] Mount ext4 disk/partition

Run power shell as administrator privilege

[Power Shell]

List all disks

 PS C:\Windows\System32> get-cimInstance -query "SELECT * from Win32_DiskDrive"

 DeviceID           Caption                       Partitions Size          Model
--------           -------                       ---------- ----          -----
\\.\PHYSICALDRIVE0 WDC WDS100T2B0A               2          1000202273280 WDC WDS100T2B0A
\\.\PHYSICALDRIVE1 WDC WD40EZRZ-00GXCB0          5          4000784417280 WDC WD40EZRZ-00GXCB0

 Mount disk in WSL

PS C:\Windows\System32> wsl --mount \\.\PHYSICALDRIVE0 --bare

 [WSL-Ubuntu]

 $ lsblk

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
sda      8:0    0 388.5M  1 disk
sdb      8:16   0     2G  0 disk [SWAP]
sdc      8:32   0     1T  0 disk /snap
                                 /mnt/wslg/distro
                                 /
sdd      8:48   0 931.5G  0 disk
├─sdd1   8:49   0  15.3G  0 part
└─sdd2   8:50   0 916.3G  0 part

$sudo mkdir /mnt/ubuntu_disk

$sudo mount /dev/sdd2 /mnt/ubuntu_disk

Thursday, November 9, 2023

[Ubuntu] Convert mp4 video to aac audio

 

#!/bin/bash

# Define the target directory
directory="."

# Check if the target is not a directory
if [ ! -d "$directory" ]; then
  exit 1
fi

# Loop through files in the target directory
for file in "$directory"/*; do
  if [ -f "$file" ]; then
    if [ "${file##*.}" == "mp4" ]; then
        echo "${file%.*}.aac"
        ffmpeg -i "$file" -c:a aac -b:a 128k -vn "${file%.*}.aac"
    fi
  fi
done

 

Wednesday, April 12, 2023

[Ubuntu] find command with grep

 find -name "*.java" -exec grep "foo" -Hn {} \;

 

-H Display filesname

-n Display line number

Monday, March 27, 2023

[Ubuntu] Create tar file exclude specified directory

Tar foo directory, and exclude "foo/.repo"  directory

─foo

   ├─.repo

   │     └─ example

   └─ 1.txt

$ tar -cvf foo.tar --exclude='foo/.repo' foo


Remove directory "foo/.repo" from tar file

$ tar --delete foo/.repo -f foo.tar

Monday, November 14, 2022

[Ubuntu] Split large file into smaller pieces

Split file into per file 1024MB

split -b 1024M -d foo.tar.xz foo.tar.xz-

foo.tar.xz-00    1024MB

foo.tar.xz-01    1024MB

...


Merge pieces to large file

cat foo.tar.xz-* > foo.tar.xz


Wednesday, November 9, 2022

[Mac OS] React Native - Environment Setting

 Trouble Shooting:

% bundle install

Your Ruby version is 2.6.3, but your Gemfile specified 2.7.4

or 

Your Ruby version is 2.6.8, but your Gemfile specified 2.7.5


Saturday, September 17, 2022

[Firefox] Youtube video decoding with hardware acceleration (GPU)

 Windows下使用Firefox看Youtube影片時,用工作管理員觀察,發現GPU的使用率都為0,但如果用Chrome則會使用到GPU。最後發現以about:config進行修改,就可以讓Firefox使用GPU 加速影片decoding。