quick backup on samba share

The following are instructions on how to backup an entire partition from a network connected machine onto a samba share. The backed up partition can be from Windows or Linux. The samba (cifs) share can also be a Windows share.

Samba machine is at 10.123.45.3 and share name is void.

  • Burn sysrescuecd on a disc
  • Boot sysrescuecd on the machine to backup
  • Press enter at boot prompt
  • dhclient eth0 (assuming it only has one network interface)
  • mount.cifs \\\\10.123.45.3\\void /mnt/backup
  • partimage
  • select appropriate partition, backup to file /mnt/backup/snit, no compression (where snit is backup file name)
  • wait

Do not disable file splitting, keep it at 2GB default. I’m not sure why but it won’t work if you don’t split files.

It may be a good idea to compress the resulting files afterwards using 7z (or whatever) if you’re short on disk space. You could use compression directly from partimage but I like to keep backups as fast as possible (and my samba server has a faster CPU than most machines I backup from).

Restoring the partition is done in a similar manner. Just choose restore instead of backup to file in partimage first menu.

partimage restore on vm

download, install and start virtualbox
make new vm with enough space to restore everything (see partimage imginfo machine.000, replace machine with backup name)
boot sysrescuecd on vm

dhclient eth0
mount.cifs \\\\10.123.45.3\\void /mnt/windows
startx
gparted

create default partition table
create new partition of appropriate filesystem type and set boot flag
exit

partimage restore /dev/sda1 /mnt/windows/machine.000

accept 100 dialog boxes
wait

remotely moving /usr

Moving /home or /usr (or /var?)

This can be done in multi-user mode. Be VERY careful NOT to use sudo (like I did). After moving /usr to /ousr, you will be doomed (I realized it the instant I pushed Enter). Instead, su. Because of this mistake I had to get off my chair to fix it locally.

mkdir /mnt/nusr
mount /dev/sdb1 /mnt/nusr
cp -a /usr/* /mnt/nusr
umount /mnt/nusr
mv /usr /ousr
mkdir /usr
mount /dev/sdb1 /usr

Edit /etc/fstab, mount -a, reboot to make sure it survives it OK.

Tested remotely from putty.

moving users

Apparemment que la pratique commune pour changer le répertoire C:\Users vers un autre dossier ou partition est de faire ça tout croche, alors j’ose éclaircir la chose et faire part de ce que ça donne.

Background
On devrait y trouvé tous nos fichiers de configuration (par user) pour chaque programme, en plus des documents ou autres. Faites simplement l’analogie avec /home sous un Unix. /home est le parent pour tous les users.
Les nouveaux users s’y trouveront aussi. On ne veut pas ces fichiers sur la partition système. C’est une séparation naturelle.

Façons stupides
– Changer un par un la location de chaque “library” sous un certain user. Utile que pour faire rapidement de la place de façon ghetto.
– Essayer des cossins sans faire de backup.
– Laisser faire car c’est pas dans un menu et ça pas l’air si facile. J’ai failli succomber à cette dernière.

Il se peut très bien que mes essaies engendre l’effacement de tous mes données, soit par erreur technique ou humaine, alors j’ai pris le temps de faire un backup de mes trucs. En fait j’ai plutôt fait un backup de la partition système entière, et cela pour 2 raisons:
– Je peux scrapper le boot.
– En voulant faire une archive du dossier C:\Users, j’ai constaté l’échec. Au départ, je croyais que la copie fût extrêmement rapide, mais en vérifiant la grosseur de l’archive j’ai bien vu que c’était impossible. Moins d’1% des données s’y retrouvait. Aucun message d’erreur! On n’a simplement pas accès aux données, et ils sont ignorées. Je ne me suis pas lancé dans explorer en cliquant sur tous les fichiers pour y avoir accès.
– Car il étant temps que j’en fasse un.

Y a-t-il une façon de faire des symbolic links sous Windows, comme on l’a longtemps fait avec unix? Et bien apparemment que oui. Depuis peut-être 2000 avec des jonctions! Depuis Vista je crois qu’il y a aussi du support pour de vrais symlinks, qui fonctionneraient over network, mais je n’en vois pas l’utilité ici.

reboot
f8 avant que win load
recovery (premier choix)
log as admin (j’avais un dummy admin, je ne sais pas si c’était nécessaire)
command prompt

robocopy C:\Users D:\Users /E /COPYALL /XJ
rmdir /S /Q C:\Users
rmdir "C:\Documents and Settings"
mklink /J C:\Users D:\Users
mklink /J "C:\Documents and Settings" D:\Users
exit

alt-ctrl-del, reboot

ref: http://forums.techarena.in/vista-setup-install/620001.htm#post4477675

Pour le saké de la chose, certains modifiaient avec succès des keys sous HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList mais je ne connais pas la procédure exact; apparemment qu’on doit changer une douzaine de registres! J’aime mieux la façon mklink, qui a fonctionné sur un setup qui roulait depuis plus de 4 mois.

cmdhere on win7

Shift + right-click shows a context menu with additional entries such as Open command window here.

To add Open powershell here with and without elevated privileges:

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Directory\shell\ps]
  @="Open powershell here"
[HKEY_CLASSES_ROOT\Directory\shell\ps\command]
  @="C:\\windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe -NoExit -Command Set-Location -LiteralPath '%L'"
[HKEY_CLASSES_ROOT\Directory\shell\Runas]
  @="Open admin powershell here"
[HKEY_CLASSES_ROOT\Directory\shell\Runas\Command]
  @="C:\\windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe -NoExit -Command Set-Location -LiteralPath '%L'"
[HKEY_CLASSES_ROOT\Drive\shell\ps]
  @="Open powershell here"
[HKEY_CLASSES_ROOT\Drive\shell\ps\command]
  @="C:\\windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe -NoExit -Command Set-Location -LiteralPath '%L'"
[HKEY_CLASSES_ROOT\Drive\shell\runas]
  @="Open powershell admin here"
[HKEY_CLASSES_ROOT\Drive\shell\runas\command]
  @="C:\\windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe -NoExit -Command Set-Location -LiteralPath '%L'"

Keys having runas in their names are the ones that will trigger elevated privileges. So yes, it seems we can only map one elevated command per HKEY_CLASSES_ROOT key…

UAC, and Configuring GVim on Windows 7

With all this new stuff about user access control (UAC), I tend to use Windows much more in the same way that I would use another Unix OS. The default UAC settings let us know each time we must use admin privileges to do something crazy on the computer.

Using Windows XP, it would be a pain to switch to an admin account everytime we want to do this crazy something. Because of this, I’m logged on admin full time when using XP, and I don’t like it. (If anyone knows another way, please tell me, or not because I won’t use it anymore). I’m glad this has changed. I think Vista also has this feature, but since it was Vista, I didn’t care.

All this to talk about Gvim‘s startup settings file, located under a system folder in Program Files. Under XP, I changed the settings right in this file. Of course, I would never do that under, say, Ubuntu — I have this file hidden right in the root of my home directory, as it is with pretty much any other software. Under 7, I was quickly reminded that I needed admin privileges to change it. “Good lord”, I thought to myself, “Not only Windows became more multi-user friendly, it even tells me to behave well!”. Good. Put your config files at home, you bastards.

Anyway, to change startup settings, I copied _vimrc from vim‘s folder into my home directory. To set font to Lucida Console, height 12, width 6.5:

set guifont=Lucida_Console:h12:w6.5

Backup and swap files are annoying:

set nobackup nowritebackup noswapfile

Also,

syntax on
colorscheme darkblue

Doc: http://www.vim.org/htmldoc/options.html

focus-follows-mouse-noautoraise on win7

Ça commence à faire trop longtemps que je cherche une façon de faire ça.

Tweak UI fonctionnait sous XP, mais il fait sa chochotte et ne s’installe pas sur 7.

La case à cocher nommée Activate a window by hovering over it with the mouse dans l’Ease of Access (attention à la voix) m’a rendu souriant pendant environ 3 secondes, durant lesquelles je réalise la triste vérité; ça autoraise. AH! Tellement désagréable. J’ai failli vomir.

Je suis aussi tombé sur http://steve-yegge.blogspot.com/2008/04/settling-osx-focus-follows-mouse-debate.html qui parle de la chose pour OS X. Bien intéressant. Commentaires hilarants.

Bref, j’ai vu TXMouse à quelques reprises mais on dirait que chaque recommandation de ce software venait avec un désavantage. Je vais peut-être l’essayer quand même…

Edit 2009-11-12: J’ai utilisé TXMouse pendant quelques temps et ce n’est pas très agréable. Ça chie les menus de la barre de tâches et casse le behavior de Alt-Tab. En plus, je n’ai pas réussi à faire un “raise” en “alt-cliquant”, même avec PowerPro (qui d’ailleurs, parlant de caca, a une interface des plus merdiques).

Edit 2010-02-18: Sans trop d’effets secondaires désagréables, on peut modifier de quoi dans le registre.
Par effets secondaires j’entends, par exemple, que le joli menu contextuel qui apparaît quand on right-click sur un programme de la task bar est difficile à atteindre. Souvent je m’y prend à 2 ou 3 coup de garochage de souris vers l’avant pour pas register un déplacement dans le petit espace de quelques pixels entre la barre de tâches et le menu contextuel (qui est le desktop, qui va focusé, et le menu disparaît car il perd le focus). Ce n’est pas parfait mais c’est bien utilisable. Ça fait faire un peu de sport. Trop de choses disparaissent lors de la perte de focus (comme le start menu).
ALORS DONC:
[HKEY_CURRENT_USER\Control Panel\Desktop]
On doit ajouter 0x41 au premier (gauche) nombre de UserPreferencesMask pour avoir Full-x (pas testé) ou 0x01 pour focus-follows-mouse seulement. La valeur dans mon registre est alors devenu 9F 3E 07 80 12 00 00 00.
On pourrait mettre un délai par cette clef?: ActiveWndTrkTimeout.

ref: http://www.vistax64.com/vista-installation-setup/23538-focus-follows-mouse-possible-vista.html#post363137
http://www.jan-olof-lindqvist.se/windows7_and_vista/windows-7-and-vista-mouse-focus-on-window-without-raising-the-window/