venerdì 31 dicembre 2010

How to move a partition's filesystem

Today my /usr/ partition has been overwhelmed by Texmaker required package.

I had to rapidly find a solution, but had no time to study how to redesign the lvm partition table.

Since I had and unused disk I installed system-config-lvm and created a new partition.

Than I had to find a way to move the /usr contents, preserving links and permissions.

This was the solution:
# mkdir /mnt/usr
# mount /dev/newlvm/partition /mnt/usr
# (cd /; tar cf - usr) | (cd /mnt; tar xf - )

The last line is a poem: it use a pipe between two tar commands, executed on different folders.
The first tar is executed in root and send to the standard output a backup of /usr.
The second tar is executed in /mnt and extract the backup it recieve from the standard output.

There is a great power in such a command.

Nessun commento:

Posta un commento