Install additional packages on XenServer 6.5

XenServer is a popular and reliable virtualization solution. as a system admin, I’ll like to install some useful packages to help me manage my servers, on XenServer 6.5, which is based on CentOS and using yum as its package manger.

All the CentOS repos were disabled by default, so I need to re-enable them, otherwise, I’ll keep getting some message like this, because they are not included in citrix’s repo:

No package vim-enhanced.x86_64 available.
Nothing to do

Workaround:
$sudo yum --enablerepo base,centosplus,contrib,debug,extras,updates install vim

So yum will use repo base, centosplus, contrib, debug, extras and updates during this process, but this is very inconvenience, so I want to enable them forever, try this:
$ sudo sed -i -e "s/enabled=0/enabled=1/" /etc/yum.repos.d/CentOS-Base.repo

Now it works fine now!

Hot to use share clipboard when using freerdp to connect to Windows?

Though I use GNU/Linux distros on most of my computers, I’ll still need to use Microsoft Windows sometimes, so I install Windows on an old PC, and work remotely.

Microsoft’s RDP(Remote Desktop Protocol) is a good method to work remotely with Windows if you have a real ip address(or work in LAN), I always use this method with FreeRDP and work happily, here is a usage example:

xfreerdp -u Peter 192.168.21.53

But FreeRDP didn’t share the clipboard like the default RDP client on Windows, so I just try to find a method to enable this feature, fortunately it’s very easy, just add parameters the enable cliprdr plugin like this:

xfreerdp --plugin cliprdr -u Peter 192.168.21.53

Now I can copy from my local computer and paste on a remote computer and vice versa!

PS: You may need to install package libfreerdp-plugins-standard first, and this syntax works on freerdp v1.0.2, in the newer versions, you may need to use +clipboard instead of --plugin cliprdr

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

How to check battery status in cli under Debian/Ubuntu based Linux?

You may need to install upower via sudo apt-get install upower first

Use upower with parameter -e / --enumerate to list the devices:

peter@peter-MacBookPro ~ $ upower -e
/org/freedesktop/UPower/devices/line_power_ADP1
/org/freedesktop/UPower/devices/battery_BAT0

Then use -i / --show-info with the device path to show the details

peter@peter-MacBookPro ~ $ upower --show-info /org/freedesktop/UPower/devices/battery_BAT0
native-path: BAT0
vendor: *********************************
model: *********************************
power supply: yes
updated: Sat 14 Feb 2015 04:11:52 PM CST (9 seconds ago)
has history: yes
has statistics: yes
battery
present: yes
rechargeable: yes
state: discharging
energy: 7.63 Wh
energy-empty: 0 Wh
energy-full: 55.75 Wh
energy-full-design: 57.7 Wh
energy-rate: 15.946 W
voltage: 10.9 V
time to empty: 28.7 minutes
percentage: 13%
capacity: 96.6205%
History (charge):
1423901482 13.000 discharging
History (rate):
1423901512 15.946 discharging
1423901482 14.978 discharging
1423901452 14.740 discharging
1423901422 16.179 discharging

It’s pretty easy to show all details in one line command:

$ upower -e | xargs -n 1 upower -i
native-path: ADP1
power supply: yes
updated: Sat 14 Feb 2015 09:58:27 AM CST (22532 seconds ago)
has history: no
has statistics: no
line-power
online: no

native-path: BAT0
vendor: *********************************
model: *********************************
power supply: yes
updated: Sat 14 Feb 2015 04:13:52 PM CST (7 seconds ago)
has history: yes
has statistics: yes
battery
present: yes
rechargeable: yes
state: discharging
energy: 7.08 Wh
energy-empty: 0 Wh
energy-full: 55.75 Wh
energy-full-design: 57.7 Wh
energy-rate: 18.069 W
voltage: 10.846 V
time to empty: 23.5 minutes
percentage: 12%
capacity: 96.6205%
History (charge):
1423901602 12.000 discharging
History (rate):
1423901632 18.069 discharging
1423901602 16.164 discharging
1423901572 15.799 discharging
1423901542 16.767 discharging
batteryCliStatusScreenshot
upower screenshot