2014-04-06 17:54

After searching a bit I could not find a simple and good howto to do that.
The following method should work for any Linux distribution (Ubuntu, Debian, Manjaro, Archlinux, Fedora…). Source and target systems must be on the same processor architecture (though transfer from 32bit to 64bit should work).

What you need:

  • 2 live USB keys (or cds)
  • To speed up data transfer: good quality ethernet cables (one cable between the 2 computers is OK), or a usb key/drive with a BIG ext4 partition. You can try over wifi, but it may be slow.

1. Boot source and target machines on live USB/CD

Any live USB/CD should be OK.
On the target computer, you will need a tool to partition your hard drive, like gparted.
rsync is also required for data transfer: it’s included in many live systems.

Ubuntu live cd is OK, Manjaro live cd too.

2. Partition your target hard drive

Use a tool like gparted to partition the target hard drive, with the same partitions as your source system (slash, swap, home…).
I recommend you to assign LABELs to your partitions: for the fstab, it’s easier than UUIDs.

3. Mount all partitions on both machines

On both systems, open a root terminal. Then, for each data partition (you can ignore swap):

mkdir /mnt/slash
mount /dev/sdaX /mnt/slash

If you have a home partition:

mkdir /mnt/home
mount /dev/sdaY /mnt/home

4. Transfer the data (network or usb)

This part may be tricky. Choose the method you prefer.

Network

  1. Setup the network. Test the connectivity with ping command.
    The easier is to plug the PCs on a DHCP network (like your ISP box) so that you get automatic IP addresses. If you linked the 2 pcs with a single cable, you’ll have to setup the IPs with NetworkManager (static ips, or adhoc network).
  2. On source system, as root, create a simple /etc/rsyncd.conf file:
    uid = root
    gid = root
    use chroot = no
    
    [all]
        path = /
    
  3. Then start the rsync daemon server: rsync --daemon
  4. On target PC, for each partition:
    rsync -avHX SOURCE_IP::all/mnt/slash/ /mnt/slash/
    

    Don’t forget ‘/’ at the end of paths. -a will preserve many file attributes like owner and permissions, -H will preserve hardlinks if any, -X will preserve extended attributes like setuid. You may also add -A if you are using acls. What is good with rsync is that you can stop and restart the transfer whenever you want.

USB

Prepare a USB drive with a BIG ext4 partition.

  1. Mount the USB partition on source system (mount /dev/sdbX /mnt/usb)
  2. For each partition:
    rsync -avHX /mnt/slash/ /mnt/usb/slash/
    
  3. umount, unplug and remount the USB disk on the target system.
  4. For each partition:
    rsync -avHX /mnt/usb/slash/ /mnt/slash/
    

5. Change fstab on target system

As root, edit /mnt/slash/etc/fstab
For each partition (including swap), replace the first field with the new UUID or LABEL (it’s straightforward with LABELs):
UUID=the-long-uuid, or LABEL=yourlabel

2 ways to get the UUIDs / LABELs:

ls -l /dev/disk/by-uuid/
blkid /dev/sdaX

6. Reinstall Grub

We will use a chroot (changed root environment) to be able to call the grub install inside the migrated system.

First, bind mount some system directories needed by grub, then chroot:

mount --bind /proc /mnt/slash/proc
mount --bind /sys /mnt/slash/sys
mount --bind /dev /mnt/slash/dev
mount --bind /run /mnt/slash/run
chroot /mnt/slash

Then install grub in the Master Boot Record of your hard drive, and update grub config file (with the new uuids…):

grub-install /dev/sda
update-grub

7. Reboot target machine

That’s it! Your system should be working on the new computer now.
Feel free to comment if you encounter problems.

2014-04-06 17:54 · Tags: , ,
2013-12-05 23:22

Bsync is a bidirectional file synchronization tool, using rsync for transfers. Moved files are also synchronized in a smart way.

It uses rsync for file transfers, find to generate filelist snapshots, and ssh for remote transfers.

bsync is an alternative to Unison, written in Python 3. A big strength of bsync: it can detect and apply moved files from one side to the other (Unison uses some copy calls to handle moved files).

I developped it to be able to synchronize my music directory from my laptop to my Raspberry Pi in an efficient way, and to sync with my girlfriend laptop too.

Bsync is released under GPL. Feel free to report any bugs/wishes in GitHub issues.

More info, Download and Install on the GitHub repo.

2013-12-05 23:22 · Tags: , , , , ,
2013-12-05 21:18

I just finished migrating my blog from Dotclear to WordPress.

I quickly tried some existing plugins to do the migration but none worked. My setup is a bit complicated because I was using the dc_translate plugin to translate all my posts.

Here is the migrate script. If it can be of use. Warning: you probably have to adapt the script to your needs, to remove some stuff, because it’s also reading Dotclear translation tables.

  • The script is called in command line via PHP cli
  • The script is using plain SQL to read from Dotclear database and to write to WordPress database.
  • It uses the wiki2xhtml Dotclear library to convert dotclear wiki syntax to html.
  • It uses formatting WordPress library to convert Posts url to WordPress format.
  • For each post, it also imports comments and tags.

I’m now using 3 plugins to manage my French translations in WordPress:

  • qTranslate
  • qTranslate slug
  • qTranslate Separate Comments

migrate_dc.tar

2013-12-05 21:18
2013-08-15 23:29

Thanks to:
http://vickychijwani.github.io/2012/04/15/blazing-fast-application-switching-in-linux/

I made a few improvements on the script. If you want something with more features (but also more complex).

  • Use /bin/sh so that it may use dash instead of bash (lighter)
  • Use exec to start the command so that it replaces the current script (otherwise you get unneeded bash processes in ps)
  • Raise all windows of the same class: useful to raise all terminals for example
  • “toggle mode” : when run a second time, the windows are minimized. For that I had to depend on xdotool, because wmctrl can’t do that (probably coming in a future wmctrl release. the author commited a -Y flag in github for that).

Save it to /home/USER/bin/run-or-raise, then add some keyboard shortcuts in your window manager settings and enjoy!

<Super>f /home/USER/bin/run-or-raise Navigator.Firefox firefox
#!/bin/sh
# syntax: run-or-raise WM_CLASS_name COMMAND
#   WM_CLASS_name : the WM_CALL_name of the window (from wmctrl -lx output)
#   COMMAND : the command to run if nothing to raise

#logfile=/tmp/$(basename $0).log
#exec > $logfile 2>&1

# get windows ids matching WM_CLASS_name
WINIDS=$(wmctrl -lx | awk '{ if ($3 == "'"$1"'") print $1}')

# run if nothing started. exec will end the script
[ -z "$WINIDS" ] && exec "$2"

# if the window is active, we minimize all the windows of the class
ACTIVEWIN=$(wmctrl -a :ACTIVE: -v 2>&1 | sed -n 's/^Using window: \(.*\)/\1/p')
MINIMIZE=false
if echo "$WINIDS" | grep -q "$ACTIVEWIN"; then
        MINIMIZE=true
fi

for ID in $WINIDS; do
        if $MINIMIZE; then
                xdotool windowminimize "$ID"
        else
                wmctrl -i -a "$ID"
        fi
done
2013-08-15 23:29 · Tags:
2013-07-28 18:02

To disable xfce panel and/or Thunar from starting in XFCE:

  1. Start a clean xfce session with no application started
  2. Open XFCE settings manager > Session and Startup > Session tab
  3. Set “Never” in front of xfce4-panel and Thunar
  4. Click Save Session
  5. Logout and login again to test
2013-07-28 18:02 · Tags:
2013-03-16 17:41

I’ve spent days looking for a good live Multiboot USB solution. I mean a way to include many downloaded ISO files in a single USB stick. I was looking for a system allowing to drop the ISOs in a folder on the key, just showing a menu with the ISO files to boot. Easy2Boot does exactly that!

Booting an ISO file is complex because lots of live operating systems expect to be at the root of a DOS partition. After some research I found several posts saying that generic ISO chainloading is very hard (p1 p2).

I found solutions like YUMI (Your Universal Multiboot Installer (windows) or MultiSystem. At this time, the problem of those programs is that they use specific “tricks” for each distribution to build a menu that will load directly the Linux kernel. It’s not as simple as dropping your ISOs in a folder: you have to use the software to build the multiboot usb key. Another drawback is that you will loose the SYSLINUX boot menus of the distros, because it loads directly the Linux kernels.

You also have hardware usb disk drives emulating a cdrom device. It’s probably the most reliable solution, but it’s not cheap, and bigger that a small USB key.

Easy2Boot, with grub4dos scripting, uses a nice trick (described here): when the iso file is chosen from the boot menu, a DOS partition (number 4) is created starting and ending at the position of the .iso file on the FAT filesystem. This method is more “ISO generic” and can boot many ISO files (99% of Live Linuxes). The drawbacks is that you have a partition overlapping the other (this is not a problem, at least under Linux), and you have to make sure that the FAT filesystem will not fragment your ISO files when you copy them on the key.

Under Windows, you can use the RMPrepUSB software (freeware/not opensource) to prepare your USB key.

Under Linux/Ubuntu, this is simple too:

  1. Format your USB key with a single FAT partition (I recommend gparted).
  2. Download Easy2Boot (v1 Beta06 works fine) and put all the files at the root of the partition.
  3. Download grub4dos (take the last Featured version) and extract the archive on your PC (not on the usb stick)
  4. From the grub4dos folder, run sudo ./bootlace.com --time-out=0 /dev/sdX to install grub4dos MBR (make sure you use the right device!).
  5. Put some ISOs directly in the /MAINMENU directory
  6. Here you go. Reboot and enjoy!

Thanks to RMPrepUSB and to the reboot.pro forum guys!

Hints:

Links:

2013-03-16 17:41 · Tags: , , ,
2012-09-08 23:59

A small script to listen to mouse events with the mev command using gpm (General Purpose Mouse).

Can be used for example on the Raspberry Pi to run mpd commands, to use a mouse as a remote control.

I didn’t find how to isolate the wheel events in order to control the volume. Any idea somebody?

In Archlinux, you can add the following command in /etc/rc.local to start it at boot time:

nohup /usr/local/bin/mpd_mouse.sh > /tmp/mpd_mouse.log 2>&1 &
#!/bin/sh
# This script listen to mouse events with the mev command using gpm.
# Can be used for example on the Raspberry Pi to run mpd commands, to use a mouse as a remote control.
# You can start it as a daemon with:
# nohup /usr/local/bin/mpd_mouse.sh > /tmp/mpd_mouse.log 2>&1 &

# start gpm if not already started
gpm -m /dev/input/mice -t imps2

# unset TERM variable, otherwise mev refuses to start when detecting xterm
unset TERM

echo "Listening to mouse events..."

# we use script to fake a tty for mev, otherwise it exits (note: mev logs errors in syslog)
script -qc "mev -E" /dev/null </dev/null | grep --line-buffered -v "mouse-movement" | while read LINE
do
        echo
        echo "$LINE"

        EVENT=$(echo "$LINE" | cut -d' ' -f1 | cut -d'(' -f2)

        if [ "$EVENT" = "down-mouse-1" ]
        then
                echo mpc stop
                mpc stop
        elif [ "$EVENT" = "down-mouse-2" ]
        then
                echo mpc toggle
                mpc toggle
        elif [ "$EVENT" = "down-mouse-3" ]
        then
                echo mpc next
                mpc next
        else
                echo "nothing"
        fi

done
2012-09-08 23:59 · Tags: , ,
2012-09-08 23:40

Several desktop environments (Gnome, KDE) automatically start an SSH agent at startup. However, you have to think of running ssh-add before connecting to a server.

Waiting for automatic ssh-add in OpenSSH, you can add this to your .bashrc:

ssh-add -l >/dev/null || alias ssh='ssh-add -l >/dev/null || ssh-add && unalias ssh; ssh'

The alias is created only if the identity is not added, and the alias destroys itself once run.

This way the regular ssh command is used after the identity has been added.

http://superuser.com/questions/325662/how-to-make-ssh-agent-automatically-add-the-key-on-demand/471640#471640

2012-09-08 23:40 · Tags:
2012-05-11 13:22

The server hosting this blog respond on all ipv4 TCP ports from 1 to 65535.

See: http://portquiz.net

The following URLs should also work if you are not filtered :

This allows you to test what TCP ports are filtered by your local network.

Command line example with netcat:

$ nc -v portquiz.net 1
Connection to portquiz.net 1 port [tcp/http-alt] succeeded!

$ nc -v -w2 portquiz.net 65535
nc: connect to portquiz.net port 65535 (tcp) timed out: Operation now in progress
2012-05-11 13:22 · Tags:
2012-04-29 15:53

I’m looking for a new laptop. My old T42p Thinkpad is becoming old. I’m looking for a laptop with a good screen…

However… finding a laptop with a resolution similar to my T42p is impossible on today’s market. The T42p has been released for more than 8 years now!! When I’m speaking resolution, I mean pixel density in PPI. My resolution is of 1400×1050 for 14.1 inches, which is good! it gives a density of 124 PPI.

Nowadays, all laptops have the same unique 1366×768 resolution. The last thinkpad X1 from Lenovo with 13.3 inches is only 118 PPI.

It’s revolting! I want my pixels!

Apparently I’m not the only one in this situation…

It’s sad. Maybe it will be better in the future… with our cell phones screens having far better resolutions…

Other usefull links :

2012-04-29 15:53