How to determine/find UUID of a partition?

In Linux, UUID(Universally Unique Identifier) can identify media more accurately and reliable, identify media via /dev/hdxy or /dev/sdxy is not a good method because the order may be different between boots, so it was no longer preferred any more, especially in fstab or grub config.

How to find UUIDs of my hard disk partitions?

$ ls -l /dev/disk/by-uuid

total 0
lrwxrwxrwx 1 root root 11 Feb 16 03:59 1898d5ea-dcea-4959-94a9-ff21a163ba85 -> ../../zram5
lrwxrwxrwx 1 root root 11 Feb 16 03:59 41e9022c-9a91-446c-a05c-2e3cd03f2180 -> ../../zram6
lrwxrwxrwx 1 root root 11 Feb 16 03:59 4ca3ac3b-0ada-419c-8c9b-a292c3e41e43 -> ../../zram3
lrwxrwxrwx 1 root root 11 Feb 16 03:59 6165ed95-d7f2-4997-9496-9bc8df9be3d2 -> ../../zram4
lrwxrwxrwx 1 root root 11 Feb 16 03:59 7356c5f2-3379-4953-914c-ba2e598c828e -> ../../zram0
lrwxrwxrwx 1 root root 11 Feb 16 03:59 92d32f20-bc55-4698-9096-a4966061dcf8 -> ../../zram1
lrwxrwxrwx 1 root root 10 Feb 16 03:59 a6127375-d994-4cd0-ab11-5f4bf65f9f3e -> ../../sda1
lrwxrwxrwx 1 root root 11 Feb 16 03:59 af5e0104-1213-4e49-aea2-c177c97e7118 -> ../../zram7
lrwxrwxrwx 1 root root 11 Feb 16 03:59 b4f51d6c-29bd-4655-b6c9-8acb6b8a2c9f -> ../../zram2
lrwxrwxrwx 1 root root 10 Feb 16 03:59 dca199dd-3e9f-4381-8637-22354b0b11f4 -> ../../sda5

or

$ blkid

/dev/sda5: UUID=”dca199dd-3e9f-4381-8637-22354b0b11f4″ TYPE=”swap”
/dev/sda1: UUID=”a6127375-d994-4cd0-ab11-5f4bf65f9f3e” TYPE=”ext4″
/dev/zram0: UUID=”7356c5f2-3379-4953-914c-ba2e598c828e” TYPE=”swap”
/dev/zram1: UUID=”92d32f20-bc55-4698-9096-a4966061dcf8″ TYPE=”swap”
/dev/zram2: UUID=”b4f51d6c-29bd-4655-b6c9-8acb6b8a2c9f” TYPE=”swap”
/dev/zram3: UUID=”4ca3ac3b-0ada-419c-8c9b-a292c3e41e43″ TYPE=”swap”
/dev/zram4: UUID=”6165ed95-d7f2-4997-9496-9bc8df9be3d2″ TYPE=”swap”
/dev/zram5: UUID=”1898d5ea-dcea-4959-94a9-ff21a163ba85″ TYPE=”swap”
/dev/zram6: UUID=”41e9022c-9a91-446c-a05c-2e3cd03f2180″ TYPE=”swap”
/dev/zram7: UUID=”af5e0104-1213-4e49-aea2-c177c97e7118″ TYPE=”swap”

(PS: blkid may need root privilege)

How to generate a new UUID for a partition?
# tune2fs -U random /dev/sda1

tune2fs 1.42.5 (29-Jul-2012)

Use blkid /dev/sda1to check /dev/sda1’s UUID, it’ll be a new one.

Example:
UUID

And in /etc/fstab, we should tell others we are now using UUID by UUID= like this:
fstab

Building NAT on Debian GNU/Linux with iptables

interfaces:

eth0(internal):
192.168.1.254
eth1(external):
aaa.bbb.ccc.ddd

enable forwarding:

sudo sysctl net.ipv4.ip_forward=1

iptables commands(can be saved to a shell script):

clean up old rules

iptables -F
iptables -t nat -F
iptables -t mangle -F
iptables -X

accept loopback traffic

iptables -A INPUT -i lo -j ACCEPT

allow internal connections

iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i eth1 -o eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i eth0 -o eth1 -j ACCEPT

masquerade

iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE

reject connections from eth1

iptables -A FORWARD -i eth1 -o eth1 -j REJECT

Easy and fast!

backup the rules:


sudo iptables-save > /path/savedConfig

auto load the rules:


sudo sh -c "echo 'pre-up iptables-restore < /path/savedConfig' >> /etc/network/interfaces

使用 VLC 在 Linux 環境底下播影片畫面撕裂/沒垂直同步的問題…

在 LMDE 上的 Mate 環境用 VLC 看影片遇到畫面撕裂的問題

在 Youtube 找了一個影片測試:
vsync test – vsync1

很明顯直接在瀏覽器裡面播放沒什麼大問題、但把影片下載下來用 VLC 撥放就會開始出現畫面被撕裂的現象…

找了半天翻到一個滿有效的解法:

[solved]Tearing (Linux Mint 15 with Nvidia)
http://forums.linuxmint.com/viewtopic.php?p=721906&sid=f16d9225b7d92613d147c1e425d5274b#p721906

把這兩行設定:

CLUTTER_PAINT=disable-clipped-redraws:disable-culling
CLUTTER_VBLANK=True

加到系統上的這個檔案裡面 /etc/environment

看到這串裡面有提到 Cinnamon 桌面環境,看起來不是 Mate 底下才有的問題…