Purpose

Do a custom install of Debian Live on a removable flash drive or hard disc with a persistent home directory or entire root filesystem, and create a partition for sharing documents or files with other operating systems.

Note: This Howto uses an Etch image containing casper. If you use a Lenny or Sid image, it uses live-initramfs instead. For the most part, if you substitute 'live' for 'casper' below, the tutorial will still work, though there may be a few other minor differences.

The install needs four things:

Formatting

This procedure will format the target drive. Please be sure you have a good backup copy of all valuable data in the drive before proceeding.

Make three partitions in the target drive:

Number

type

Description

Minimum capacity

Label

1

fat32

user files, they can be shared with other Operating Systems

all that could make available

without label

2

ext3

files that keep the persistent configuration

for the /home directory 128MB, if it is a system image, 512 MB

home-rw (/home persistent), casper-rw (/ persistent)

3

ext3 or fat32

"Live" Operating system

700MB

without label

Observe that the first partition, which will contain the files shared with other operating systems, should be the first partition; we have found some versions of Windows only recognize the first partition of a flash drive and do not generate a unit letter for the other partitions.

The second partition is the persistent partition. Write the label home-rw if it will contain the persistent /home directory and the label casper-rw if all the system should be persistent. It is not valid to create a different partition for each one of them: in this case, only casper-rw will be mounted.

In the following intructions, we refer to the target drive as /dev/sdX. Substitute the correct device name for your drive.

If you already have data in the drive you want to preserve, you can use parted to change the size of the first partition and also create the new ones (personally, I have not reached satisfactory results with parted, I prefer to make them with fdisk).

# parted /dev/sdX
GNU Parted 1.7.1
Using /dev/sdX
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) resize 1
Start?  [32.3kB]?
End?  [2056MB]?      1026MB

(parted) print

Disk /dev/sdX: 2064MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
 1      31.7kB  1026MB  1026MB  primary  fat32
 2      1026MB  1154MB  128MB   primary  ext3
 3      1154MB  1936MB  782MB   primary  ext3         boot

FixMe: adjust above to account for the removal of the swap partition.

Create the partitions with fdisk

# fdisk -l
Disk /dev/sdX: 2063 MB, 2063597568 bytes
64 heads, 62 sectors/track, 1015 cylinders
Units = cylinders of 3968 * 512 = 2031616 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdX1               1         505     1001889    b  W95 FAT32
/dev/sdX2             506         568      124992   83  Linux
/dev/sdX3   *         569         953      763840   83  Linux

FixMe: adjust the above to account for the removal of the swap partition.

Format:

# mkfs.vfat -F 32 /dev/sdX1
# mkfs.ext3 /dev/sdX2 -L home-rw
# mkfs.ext3 /dev/sdX3

Now we have the partitions ready to install the boot manager and copy the system files.

Swap and flash drives

Normally, we would include a swap partition in a GNU/Linux installation. However, since flash memories have limited write lifetimes, (typically several hundred thousand writes,) this is not a good idea. Modern systems typically have enough RAM to do without a swap partition, so it is not a big loss to omit one. However, if you are installing to a hard disc instead of a flash drive, you may wish to include one.

Boot Manager

Install the GRUB boot manager.

Again, we refer to the target drive as /dev/sdX, for which you must substitute the actual name of device on your system. Copy the configuration of GRUB from your install system:

mount /dev/sdX3 /media/sdX3/
cd /media/sdX3
mkdir -p boot/grub
cp /boot/grub/* boot/grub
echo '(hd1) /dev/sdX' > boot/grub/device.map
grub-install --root-directory=/media/sdX3 --no-floppy '(hd1)'

Assuming that in the install system there is only one disk unit, GRUB names the install system's drive as hd0 and the target drive as hd1.

Edit a file /media/sdX3/boot/grub/menu.lst with the boot configuration.

vi /media/sdX3/boot/grub/menu.lst

Boot Options

Examining the options of the file isolinux.cfg from the original CD we can see some of the available parameters. See the casper man page for a description of all parameters.

Note that the parameters shown below are the author's preferences including, for example, bootkbd=es to select a Spanish keyboard. Adjust these to suit your needs.

You may wish to personalize the hostname parameter, using, for example, your name. It can only contain letters from a to z, and hyphens between letters.

# menu.lst - See: grub(8), info grub, update-grub(8)
default         saved
timeout 5
color cyan/blue white/blue
#
title Debian live
  kernel /casper/vmlinuz bootkbd=es vga=791 ramdisk_size=100000 boot=casper username=user hostname=debian persistent
  initrd /casper/initrd.img
  boot

title Debian live nopersistent
  kernel /casper/vmlinuz bootkbd=es vga=791 ramdisk_size=100000 boot=casper username=user hostname=debian nopersistent
  initrd /casper/initrd.img
  boot

title Debian live-failsafe
  kernel /casper/vmlinuz bootkbd=es ramdisk_size=100000 boot=casper username=user hostname=debian nopersistent noapic noapm nodma nomce nolapic nosmp vga=normal
  initrd /casper/initrd.img
  boot

title Memtest
  kernel /casper/memtest
  boot

Installing the system files

We need the system files from the ISO image we have downloaded before, or from any source we have obtained that.

Now mount the ISO,

mkdir /tmp/iso
mount -o loop debian-live-40r0-rc1-i386-kde-CD.iso /tmp/iso

Copy the system files:

cp -a /tmp/iso/* /media/sdX3/

Delete the isolinux boot manager files:

cd /media/sdX3
rm -Rf isolinux

The initial configuration is ready. Unmount the target drive:

umount /dev/sdX3

Boot to the new system

To boot a USB drive, the computer needs a BIOS that supports it. Configure the BIOS to change the boot order of hard disks, making the USB drive the first in the list.

The computer will start now with the USB drive and the Debian Live Operating System.

If the whole root filesystem is persistent, start with the persistent mode and the structure of files will be automagically created.

But if we have chosen to only make the /home directory persistent, we should start first with the "no persistent" boot entry, and afterwards, copy the /home files to the persistent partition. Prepare the /home directory with the following commands.

# sudo su
# mkdir /media/sdX2
# mount /dev/sdX2 /media/sdX2
# cp -a /home/* /media/sdX2/
# umount /dev/sdX2

Home directory

We can make the first partition that contains the files shared with other Operating Systems be automagically mounted under live user's HOME directory every time the computer is started, writing in $HOME/.kde/Autostart the following script:

# shared-disc.sh
# partition /home
PART=`mount | grep /home | awk '{print $1}' | sed 's/2/1/'`
[ -z "$PART" ] && exit 1
[ -d "$HOME/Documents" ] || mkdir $HOME/Documents
sudo mount $PART $HOME/Documents \
-o rw,noexec,nosuid,nodev,noatime,uid=999,utf8,shortname=lower

Make it executable:

# chmod a+x $HOME/.kde/Autostart/shared-disc.sh

From now the first partition will be automagically mounted in the directory $HOME/Documents when KDE starts.

Comments

The ISO from the Debian Live archive site is an English language version. If we choose /home persistence, we can customize the keyboard and the desktop layout (with the Control Center: colours, themes, etc.); and if the persistence is for the whole OS, we can add also new languages or applications.

DebianLive/Howto/Custom_Install (last edited 2009-03-16 03:33:52 by localhost)