Reliable Windows Vista partition writing from Linux

The first thing to do in order to mount a windows vista partition (in a reliable read-write mode) from a Linux, is to add support for FUSE, which means to add support for filesystem in userspace

Support for FUSE was added to linux kernel from the 2.6.14 version. To enable it:
File systems  --->
<*> Filesystem in Userspace support

After recompiling and booting the kernel, it’s necessary to install NTFS-3G. In gentoo linux this means issuing a “emerge sys-fs/ntfs3g”

To mount the driver:

ntfs-3g /dev/sda2 /mnt/win

Advertisements

Gentoo Linux: how to backup to ipod and restore to vmware

England In this post I’ll show how to backup bit-by-bit an existing gentoo linux installation to an iPod classic via USB, and how to restore the image to a vmware virtual machine. Why all that? Because iPod classic can be used as a portable hard disk with 160 Gb… And what better way there is to test a backup than actually run it as if it were the real machine ? 😉

What you’ll need:

  • an Ipod classic 160 Gb, with enough free space
  • a burned ISO of Ghost for Linux (g4l)
  • a burned ISO of Gentoo Live CD
  • a running vmware server on another machine.

Prepare the kernel for vmware

Since the existing physical gentoo installation will run on vmware after the backup, it doesn’t hurt to enable in the kernel support for the “hardware” it’ll encounter. These are the features that must be enabled on the kernel to support vmware server 1.0.x:

Support for vmware NIC:

Device Drivers --->

     [*] Network device support  --->
        [*]  Ethernet (10 or 100Mbit)  --->
                 [*]   EISA, VLB, PCI and on board controllers
                 <*>     AMD PCnet32 PCI support

Support for vmware SCSI:

Device Drivers --->
         SCSI device support  --->
               <*> SCSI disk support
                [*] SCSI low-level drivers  --->
                      <*>   BusLogic SCSI support

Doing the backup

1. Connect the ipod via USB and boot the gentoo machine with the g4l CD. In the kernel list, choose the latest RELEASED one.

2. After booting, the ipod should be detected as a general USB storage device. In my machine it is seen as /dev/sdb1. To be sure, a simple mount will suffice to discover:

mount /dev/sdb1  /mnt/local

3. Type ‘g4l’ to enter the ‘graphical interface’. In the main menu, choose “RAW Mode”

4. Then choose “Local use”

5. In the local use screen, configure the following values:
A: Pick the drive: choose the ipod device, or (X) sdb1
B: Config filename: I’ve chosen vaio_bkp.img
C: Toogle split: (X) On. This is very important. Ipod is formatted as FAT32 under windows, and does not support files larger than 4Gb
D: Toogle compression: I’ve chosen (X) None, since I have plenty of free space in my ipod and thus the process can be faster and less cpu intensive
E: Backup: choose the partition on the machine to be backed up, (X) sda4, for example.

After that, G4l will show all the choices made before starting the process:

g4l2.jpg

6. Several 1Gb files will be created in the ipod root folder. The backup speed was about 18 Mb/s in my environment, so, to backup 80Gb it took aprox. 70 min.

Creating the vm

1. In another machine that has vmware server instaled, create a new virtual machine (File -> New -> Virtual Machine), choose “custom” -> “Linux” -> “Other Linux 2.6.x kernel”, and when prompted for “I/O Adpater type” choose “BusLogic”. When prompted for “Disk type”, choose “SCSI”. In the “Disk capacity” choose the same size of the partition in the original machine. Keep “allocate disk now” unchecked, to save space. In the vmware server console, add to the virtual machine a USB Controller (menu VM -> Settings) and then “Add -> USB Controller”
2. Boot the virtual machine with g4l live CD, with the ipod plugged in. Run “fdisk” and make sure that the partition layout is the same of the original gentoo, that is, if the partition was called /dev/sda4 in the source machine, create in the virtual machine the same partition name. Don’t forget to toggle the bootable flag in this partition.
3. The vm should see the ipod in the USB. If not go to menu VM -> Removable Devices -> USB Devices and mark “Apple Computer USB Device”.

Restoring the backup

1. In ghost for linux, go to the menus:
RAW Mode -> Local Use
2. Choose the options:
A: sdb1 (or where the ipod was mounted)
B: the same name used to backup
C: Toogle split (On)
D: Toogle compression (None) if compression was not used
F: Restore: choose the partition created in vmware, matching the original partition name. G4l will show a resume before restoring:

restore.jpg

The restore will take longer than the backup, since vmware server 1.0.x still does not support high speed USB (the support is coming in vmware server 2, still in beta stage). In my environment, I could get a 2.4 Mb/s speed.

Fixing the bootloader

Now that you have a clone of the physical machine under vmware, chances are that it still not bootable. This may occurs if the partition backed-up was not where the bootloader was installed. In my case, the backup was made from /dev/sda4, and the bootloader was installed in /dev/sda alongside with windows, to enable dual boot. To fix this, boot the virtual machine with gentoo install CD, and install grub again:

# mount the partition
mount /dev/sda4 /mnt/gentoo
# Remount /dev/ inside the partition
mount -o bind /dev/ /mnt/gentoo/dev

# Chroot into the partition
chroot /mnt/gentoo /bin/bash

# mount proc
mount -t proc proc /proc

# Populate /etc/mtab, so that grub-install does not get angry
cat /proc/mount >> /etc/mtab

# Install grub on the disk
grub-install /dev/sda

Now the virtual machine is bootable!

Fixing X and network

After booting, eth0 is not available, thanks to udev. As the MAC Address of the NIC changed, udev allocates eth1 and wipes eth0. To fix this, simply:

rm  /etc/udev/rules.d/70-persistent.net.rules

and reboot the system.

To fix the X server, run the command ‘xorgconfig’. Choose the following options:

Mouse Protocol:  1
Emulate3Buttons: Y
Mouse device: /dev/input/mouse0
card  database:  choose 30 (vmware)

And that’s all! Now we have a perfect running clone of the physical machine, with network and X support, in a relative easy manner.

vmware

Gentoo and Sony Vaio VGN-FZ180E – part 5: Storage

England In this post I’ll deal with this vaio’s hard disk, dvd-rom, 5-in-1 Card reader. The kernel is 2.6.24-r3 (latest official stable)

Hard Disk

lspci show the SATA controller that this model uses:

00:1f.2 SATA controller: Intel Corporation Mobile SATA AHCI Controller (rev 03)

To enable in the kernel:

Device Drivers --->
  <*> Serial ATA (prod) and Parallel ATA (experimental) drivers  --->
     <*>   AHCI SATA support

CD/DVD-ROM Drive

Device Drivers --->
   <*> ATA/ATAPI/MFM/RLL support  --->
           <*>   Enhanced IDE/MFM/RLL disk/cdrom/tape/floppy support
           <*>     Include IDE/ATAPI CDROM support
            [*]     IDE ACPI support
           <*>     generic/default IDE chipset support
           <*>     Generic PCI IDE Chipset Support

After booting, look in dmesg:

Probing IDE interface ide0...
hda: MATSHITABD-MLT UJ-220V, ATAPI CD/DVD-ROM drive
Probing IDE interface ide1...
ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
hda: ATAPI 47X DVD-ROM DVD-R-RAM CD-R/RW drive, 8192kB Cache

Multimedia Card Reader (MMC)

lspci shows:

09:03.2 Mass storage controller: Texas Instruments 5-in-1 Multimedia Card Reader (SD/MMC/MS/MS PRO/xD)

kernel flags:

Device Drivers
     --- MMC/SD card support
      <*>   MMC block device driver
       [*]     Use bounce buffer for simple hosts
      <*>   SDIO UART/GPS class support
        <*>   Secure Digital Host Controller Interface support  (EXPERIMENTAL)
        <*>     Ricoh MMC Controller Disabler  (EXPERIMENTAL)
        <*>   Winbond W83L51xD SD/MMC Card Interface support
        <*>   TI Flash Media MMC/SD Interface support  (EXPERIMENTAL)

Watching live soccer in Gentoo – part 1 – SopCast

England The portal myp2p.eu is a very interesting site where you can choose among several live sports and watching ’em live, with very good quality. The matches can be seen with a myriad of softwares, among them: windows media, real audio, sopcast, tvants. In this post I’ll focus on SopCast.

Gentoo portage does not have an ebuild for sopcast (yet), but meanwhile there is a sopcast ebuild on gentoo bugzilla. To install it, download the file http://bugs.gentoo.org/attachment.cgi?id=137461 and save it to /usr/portage/media-tv/sopcast-1.1.1.ebuild.

Edit sopcast-1.1.1.ebuild and change the URL from

   SRC_URI="http://download.sopcast.com/download/${MY_P}.tgz"

to

   SRC_URI="http://download.sopcast.cn/download/${MY_P}.tgz"

As the packages are masked, first we have unmask them:

    echo "=media-tv/sopcast-1.1.1" >> /etc/portage/package.keywords

Before emerging, go to the ebuild dir and generate the manifest:

    ebuild  sopcast-1.1.1.ebuild digest

and finally

    emerge sopcast

Now the fun bergins!

Under myp2p.eu/competition.php?competitionid=∂=sports&discipline=football choose the match you want to see, copy the adress (that beggins with the “protocol” sop://) and run the command:

   sp-sc sop://broker1.sopcast.com:3912/6001 1234 5678

that opens the stream from local port “1234” to player port “5678”. Player port is where you will watch the video. So, to watch with Xine (my favorite), run:

   xine http://localhost:5678

and that’s it! Nice game! 🙂

SoapCast

Gentoo and Sony Vaio VGN-FZ180E – part 4: Wireless

England The latest kernel 2.6.24-r3 support the Intel Pro Wireless 4965, so it’s not needed to manually built 3rd part modules. Mark the following kernel opts:

Networking --->  Wireless --->
 -*- Improved wireless configuration API
[*]   nl80211 new netlink interface support
-*- Wireless extensions
<*> Generic IEEE 802.11 Networking Stack (mac80211)
[ ]   Enable debugging output
< > Generic IEEE 802.11 Networking Stack

and

Device Drivers ---> [*] Network device support ---> Wireless LAN ---> [*] Wireless LAN (IEEE 802.11)
[*]   Intel Wireless WiFi Link Drivers
[*]     Enable full debugging output in iwlwifi drivers
[*]     Enable Sensitivity Calibration in iwlwifi drivers
[*]     Enable Spectrum Measurement in iwlwifi drivers
[*]     Enable Wireless QoS in iwlwifi drivers
<M>     Intel Wireless WiFi 4965AGN

After reboot, “modprobe iwl4965” and “modules-update”Emerge the packages “wpa_supplicant” and “wireless-tools”.
The wireless network can be discovery by using the command “iwlist wlan0 scan”. To connect to a network, declare it inside/etc/wpa_supplicant/wpa_supplicant.conf. Examples of networks declaration, with and without WEP:

network={
        ssid="home_network"
        key_mgmt=NONE
        wep_key0=fffffffffffffffffffff01111
        wep_tx_keyidx=0
} network={
        ssid="Delle_Province Hotel"
        key_mgmt=NONE
}

To activate wpa_supplicant as the “wireless connections manager”, the file /etc/conf.d/net must contain:

# Use dhcp for the wireless interface
config_wlan0=("dhcp")

# Declare wpa_supplicant module
modules=( "wpa_supplicant" )

# Wpa supplicant command line.
# wext referes to the wireless interface
# -dd enables verbose logging
# -c points to the configuration file
wpa_supplicant_wlan0="-Dwext -iwlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf -dd"

Ok, now we have support in the kernel, support in the net scripts. To start/stop wireless network, it’s enough to do a

/etc/init.d/net.wlan0 start

which is a symbolic link to net.lo.

Gentoo and Sony Vaio VGN-FZ180E – part 3: Connectivity with Bluetooth

England Bluetooth is the only thing that is missing in this vaio model, but with a cheap bluetooth usb adapter, it’s possible to access the internet using a cell phone that supports GPRS/EDGE/UMTS/HSDPA (and bluetooth, obviously) from anywhere.

First, as always, a little kernel playing:

Networking ---> <*> Bluetooth subsystem support
--- Bluetooth subsystem support
<*> L2CAP protocol support
<*> SCO links support
<*> RFCOMM protocol support
[*] RFCOMM TTY support
<*> BNEP protocol support
[*] Multicast filter support
[*] Protocol filter support
<*> HIDP protocol support
Bluetooth device drivers --->
<*> HCI USB driver
[*] SCO (voice) support
<*> HCI SDIO driver
<*> HCI UART driver
[*] UART (H4) protocol support
[*] BCSP protocol support
[*] HCILL protocol support

Also enable PPP:


Device Drivers --->
[*] Network device support
<*> PPP (point-to-point protocol) support
[*] PPP filtering
<*> PPP support for async serial ports
<*> PPP support for sync tty ports
<*> PPP Deflate compression
<*> PPP BSD-Compress compression

Compile the kernel, reboot, and when pluging the USB Bluetooth dongle, something like this must appear in the log:

Mar 7 17:59:37 jupter usb 5-2: new full speed USB device using uhci_hcd and address 3
Mar 7 17:59:37 jupter usb 5-2: configuration #1 chosen from 1 choice
Mar 7 17:59:38 jupter hcid[10186]: Bluetooth HCI daemon
Mar 7 17:59:38 jupter hcid[10186]: HCI dev 0 up
Mar 7 17:59:38 jupter hcid[10186]: Starting security manager 0
Mar 7 17:59:38 jupter sdpd[10197]: Bluetooth SDP daemon

Emerge the package “bluez-utils”. Edit file /etc/bluetooth/pin and put a password that will be need to pair with the laptop via bluetooth.

The file /etc/bluetooth/rfcomm.conf must be changed to match the cell phone:

rfcomm0 {
# Automatically bind the device at startup
bind yes;
# Bluetooth address of the device
device 00:1C:9A:2D:36:58;
# RFCOMM channel for the connection
channel 4;
# Description of the connection
comment "My cell phone";
}

To find the device address, turn on the bluetooth on the cell phone and run the command “hcitool scan” on gentoo to print it.

Now it’s necessary to configure ppp.

For each connection there must be um sym link in /etc/init.d. Thus, to create a called “ppp1” connection to Vodafone Italy, for example:


cd /etc/init.d
ln -s net.lo net.ppp1

The last thing is to configure the /etc/conf.d/net and declare the properties of the ppp session:


config_ppp1=("ppp")
link_ppp1="/dev/rfcomm0"
phone_number_ppp1=("*99***1#")
pppd_ppp1=(
"maxfail 10"
"noauth"
"lcp-echo-interval 5"
"lcp-echo-failure 12"
"debug"
"noipdefault"
"defaultroute"
"usepeerdns"
"ipcp-accept-remote"
"ipcp-accept-local"
"holdoff 3"
"noaccomp noccp nobsdcomp nodeflate nopcomp novj novjccomp"
"9600"
"lock"
"nocrtscts"
)
chat_ppp1=(
ABORT BUSY
ABORT 'NO CARRIER'
ABORT VOICE
ABORT 'NO DIALTONE'
ABORT 'NO DIAL TONE'
ABORT 'NO ANSWER'
'' ATZ
'OK' 'AT+CGDCONT=1,"IP","web.omnitel.it"'
OK "ATD*99***1#"
CONNECT ''
)

The IP address of the provider must be adapted depending of the country and company. The rest is pretty standard. The ones that I used so far:

TIM – BRAZIL: ‘OK’ ‘AT+CGDCONT=1,”IP”,”tim.br”‘
TIM – ITALY: ‘OK’ ‘AT+CGDCONT=1,”IP”,”ibox.tim.it”‘
VODAFONE-ITALY: ‘OK’ ‘AT+CGDCONT=1,”IP”,”web.omnitel.it”‘

Some providers requires username and password. In this case, they must be declared in pppd_ppp1 section with the keys
“username” and “password”.

Finally, to connect, start the service: /etc/init.d/net.ppp1 start

Gentoo and Sony Vaio VGN-FZ180E – part 2: Video

England This vaio comes with a Nvidia GeForce 8400M GT and is listed this way under gentoo:

01:00.0 VGA compatible controller: nVidia Corporation Unknown device 0426 (rev a1)

It works nice with gentoo 2.6.24-r3 (latest stable kernel) by emerging nvidia-drivers. Since the most recent driver is still masked in portage, it’s need to add to file /etc/portage/package.keywords:

x11-drivers/nvidia-drivers

and then “emerge nvidia-drivers”. The version 169.2 will be installed.

WARNING: be sure that your kernel has the flags CONFIG_SYSVIPC=Y and CONFIG_UNIX=Y (Support for Unix domain socket. I don’t know why this two options are disable by default in the 2.6.24-r3 kernel)

To load the driver, “modprobe nvidia”

To instruct the X server to use nvidia libraries, use the command “eselect opengl set nvidia”. After that it’s needed to change Xorg.conf. Relevant parts is show below:

Section "Device"
Identifier "Device0"
Driver "nvidia"
VendorName "NVIDIA Corporation"
Option "AddARGBGLXVisuals" "true"
Option "UseEvents" "false"
Option "RenderAccel" "true"
Option "AllowGLXWithComposite" "true"
Option "TripleBuffer" "true"
EndSection


Section "Module"
Load "dbe"
Load "extmod"
Load "type1"
Load "freetype"
Load "glx"
EndSection

The emerge that installed the drivers also installed a nice utility under gnome, the Ndivia X Server Settings, that allow to change the brightness of the screen:

Nvidia console