Based on what I have desscribed in the two previous posts, I have now made a Linux distribution with an install CD.
It is called Bachata Linux, check it out here.
Based on what I have desscribed in the two previous posts, I have now made a Linux distribution with an install CD.
It is called Bachata Linux, check it out here.
When booting a regular Linux system, it just mounts some partition with a nice file system (such as ext4) on your HDD on / read/write and there you go.
When booting from a CD-ROM, it’s not that simple. The CD-ROM file system, ISO 9660, does not support the file names and attributes that a Linux system normally needs. And the CD-ROM is read only.
There are ways to work around these issues. You can use the Rock Ridge extension to ISO 9660 to get the file names and attributes needed. And the read only issue can be handled either as I have described in an earlier post, or by using unionfs.
There is also a different approach which I will describe here. Have an image file of the root file system on the CD which you mount in RAM. This will bypass the restrictions of ISO 9660 since you can use any file system in the image, and it can be read/write after being read into RAM. The obvious disadvantage is that this will consume RAM proportional to the size of the root file system, which can be a problem since you will not have any swap space available. But in several use cases, the size of the root file system can be kept small enough for this to work.
The easiest, and probably best, way to do this is to simply use the initramfs mechanism built into the Linux kernel.
In the initramfs, the Linux kernel will start executing /init as the first process, and this process is not expected to exit. This /init can be (and usually is) a shell script. In a regular root file system, /sbin/init will be executed first. So you can convert a regular root file system into an initramfs by adding an /init like this (don’t forget to make it executable):
#!/bin/sh exec /sbin/init $@
Then you need to package it as a gzipped cpio archive with these slightly awkward commands (${ROOT_FS} is where you have prepared the root file system, ${ISO_FS} is where you are preparing the file system for the CD-ROM, don’t forget to create the directory ${ISO_FS}/isolinux first):
(cd ${ROOT_FS} && find . -type l -printf '%p %Y\n' | sed -n 's/ [LN]$//p' | xargs -rL1 rm -f)
(cd ${ROOT_FS} && find . | cpio --quiet -o -H newc | gzip -9 >${ISO_FS}/isolinux/initrd.img)
Then put this initramfs image along with the kernel image and pass it to the bootloader. Given that you use isolinux as bootloader, put the kernel image in ${ISO_FS}/isolinux/vmlinuz, copy isolinux.bin to ${ISO_FS}/isolinux/ and create a config file ${ISO_FS}/isolinux/isolinux.cfg:
default linux
label linux
kernel vmlinuz
append initrd=initrd.img quiet
Finally build an CD-ROM ISO image with this command:
genisoimage -b isolinux/isolinux.bin -c isolinux/boot.cat \
-no-emul-boot -boot-load-size 4 -boot-info-table \
-l -input-charset default -V MyLinuxBoot -A "My Linux Boot" \
-o ${ISO_IMAGE} ${ISO_FS}
Then you can burn the ISO image on a CD-ROM, or use the image directly to test it in a virtual machine.
You can reduce the size of the root file system by placing some large auxiliary files (such as the files to install if you are building an installer) outside, directly on the CD-ROM. Then you need to mount the CD-ROM after boot, which can be a bit tricky. Given that you know that a file install.cgz should be on the CD-ROM, you can do like this to mount the CD-ROM on /media:
mount_cdrom() {
for CD in /dev/cdrom /dev/cdrom[0-9] /dev/sr[0-9]; do
if [ -b ${CD} ] ; then
if mount -t iso9660 -o ro ${CD} /media 2>/dev/null ; then
if [ -f ${1}/install.cgz ] ; then
return
else
umount /media
fi
fi
fi
done
echo "Failed to mount CD!"
}
This is inspired from this article. However, that article uses the older and less efficient initrd instead of initramfs. It also mounts the root file system in a two-step bootstrap process which seems redundant to me. So I have made it simpler and more efficient. The procedure with boot menus and different run levels described in the section Customizing and Adding Scripts can be useful though, I recommend reading that section if you need some kind of menu.
To build a minimal Debian based Linux system with a fully functional bash shell, TCP/IP networking with DHCP client and apt setup to be able to install any package from the Debian repositories. The resulting system will use about 157 MB disk space and consume less than 10 MB RAM.
This is now implemented in Bachata Linux.
A Debian based Linux system to work from (e.g. Ubuntu desktop) with the debootstrap and extlinux packages installed. Some virtualization environment is highly recommended for testing, such as KVM/QEMU.
This will install the system on a disk mounted at mnt. Choose a hostname for the instance to create, substitute it for ${HOSTNAME}. Substitute the URL to your nearest Debian mirror for ${MIRROR}.
sudo debootstrap --variant=minbase --include=localepurge,netbase,ifupdown,net-tools,isc-dhcp-client,linux-base,linux-image-2.6-686,linux-image-2.6.32-5-686 squeeze mnt ${MIRROR}
sudo extlinux --install mnt/boot/extlinux
default linux
label linux
kernel /boot/vmlinuz-2.6.32-5-686
append initrd=/boot/initrd.img-2.6.32-5-686 root=UUID=${UUID} ro quiet
Only for KVM/QEMU: add console=ttyS0 to the “append” line
auto lo iface lo inet loopback allow-hotplug eth0 iface eth0 inet dhcp
# /etc/fstab: static file system information.
#
# Use 'blkid -o value -s UUID' to print the universally unique identifier
# for a device; this may be used with UUID= as a more robust way to name
# devices that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc nodev,noexec,nosuid 0 0
UUID=${UUID} / ext2 errors=remount-ro 0 1
${HOSTNAME}
MANDELETE DONTBOTHERNEWLOCALE SHOWFREEDSPACE #QUICKNDIRTYCALC #VERBOSE en
deb ${MIRROR} squeeze main
deb-src ${MIRROR} squeeze main
deb http://security.debian.org/ squeeze/updates main
deb-src http://security.debian.org/ squeeze/updates main
# squeeze-updates, previously known as 'volatile'
deb ${MIRROR} squeeze-updates main
deb-src ${MIRROR} squeeze-updates main
Dir::Cache {
srcpkgcache "";
pkgcache "";
}
Acquire::GzipIndexes "true"; Acquire::CompressionTypes::Order:: "gz";
fdiskvirt-install --connect qemu:///system -n ${HOSTNAME} -r 256 --os-type linux --os-variant debiansqueeze --import --disk path=${HOSTNAME}.img --network=network:default --graphics none --virt-type kvm
Use --virt-type qemu if your CPU doesn’t support virtualization.
Then you can start it with virsh start ${HOSTNAME} and connect to it with virsh console ${HOSTNAME}
For some reason, doing reboot from inside the guest doesn’t seem to work properly. virsh reboot and virsh shutdown doesn’t work either (you might get that to work by installing some ACPI stuff in the guest). Use halt from inside the guest to have a clean shutdown, and then restart it with virsh start.
First create a virtual machine in VirtualBox with an empty VDI disk ${VDI_FILE} of least 288 MB.
Install VDI mounting tool according to this description.
Then start the virtual machine in VirtualBox.
Please tell me how!
By default, the MySQL data is placed in /var/lib/mysql, which is a reasonable default. However, sometimes you want to place it somewhere else, such as on an other file system. Using a symlink doesn’t seem to work, so you have follow this procedure.
To move the MySQL data directory from /var/lib to /mnt/mydata, run these commands as root:
apt-get install mysql-serverservice mysql stopmv /var/lib/mysql /mnt/mydata//var/lib/mysql with /mnt/mydata/mysql in
/etc/passwd – mysql/etc/mysql/my.cnf – [mysqld] datadir/etc/apparmor.d/usr.sbin.mysqld (twice)service mysql startUsing a ZTE Blade Android phone connected with USB is a bit tricky with Ubuntu 11.10.
First you need to apply the patch in this bug, after doing that you should get USB storage to work.
After doing that, it is also possible to get development and debugging to work over USB. Create a group androiddev (addgroup --system androiddev), and add yourself to it (gpasswd -a yourUsername androiddev). Then create a file /etc/udev/rules.d/11-android.rules with this content (4 lines, watch the line breaks):
SUBSYSTEMS==”usb”, ATTRS{idVendor}==”19d2″, ATTRS{idProduct}==”1353″, MODE=”0666″, OWNER=”root”, GROUP=”androiddev” #Normal Blade
SUBSYSTEMS==”usb”, ATTRS{idVendor}==”19d2″, ATTRS{idProduct}==”1350″, MODE=”0666″, OWNER=”root”, GROUP=”androiddev” #Debug Blade
SUBSYSTEMS==”usb”, ATTRS{idVendor}==”19d2″, ATTRS{idProduct}==”1354″, MODE=”0666″, OWNER=”root”, GROUP=”androiddev” #Recovery Blade
SUBSYSTEMS==”usb”, ATTRS{idVendor}==”18d1″, ATTRS{idProduct}==”d00d”, MODE=”0666″, OWNER=”root”, GROUP=”androiddev” #Fastboot Blade
Finally logout and login again. Don’t forget to enable USB debugging on the phone before connecting it.
Depending on the exact model you have, you might need to adjust the file. See what the lsusb command says about your phone and put that product id in the second line.
Ubuntu has mechanism to log user activity such as used documents. This is used to facilitate searching, but can also be intrusive to your privacy.
Here is a way to disable this logging without breaking Unity or any other part of the system, execute these commands in a terminal:
sudo mv /etc/xdg/autostart/zeitgeist-datahub.desktop /etc/xdg/autostart/zeitgeist-datahub.desktop-inactiverm ~/.local/share/recently-used.xbelmkdir ~/.local/share/recently-used.xbelrm -rf ~/.local/share/zeitgeistthen log out and log in again.
To backup data from a non-smart SonyEricsson mobile phone (such as W890i) in Linux, use the gammu utility.
gammu package.~/.gammurc file with the following content:
[gammu]
port = /dev/ttyACM0
connection = at
Phone modegammu backup <filename>.vcf -yes
to backup your phone book to a vCard file
gammu geteachsms
to get all SMS stored in the phone (both sent and received), they will be written to STDOUT
The developers of PHP has, in their infinite wisdom, decided that the default session timeout should be 24 minutes (1440 seconds).
This means that if you have a MediaWiki wiki and are editing a single page for half an hour and then click the save button, you are logged out and all your changes are lost. I just learned this the hard way.
Fortunately, you can change this with the session.gc_maxlifetime parameter in php.ini. So set this to a higher – more sane – value, such as 86400 (24 hours).
The new Ubuntu release 11.04 Natty contains the new Unity desktop environment which is quite controversal. I have tried it for a while and I think it is neat but too buggy and immature. However, it is easy to revert to the old Gnome 2 desktop environment and have things working almost as in 10.10.
First do a normal distribution upgrade to 11.04, then go to System Settings -> Login Screen and select Ubuntu Classic as default session and reboot.
I just brought an Sveon SNT1020 WiFi USB adapter.
It works very well with Ubuntu Linux 10.10, just connect it to an USB 2 port and you can start using it with NetworkManager right away, no drivers or setup necessary. You should possibly disable any built-in WiFi adapters first though.
It cost €35.