Wednesday 9 October 2013

Unexpected permission issues when mounting nfs shares (mainly OSX)

The Problem

Some directories are exported via nfs on a linux server. Attempting to mount from OSX produces permission-related errors (Lion), or dialog boxes that advertise a failure to mount but disappear before they can be read (Snow Leopard).

Meanwhile, on the client the command
showmount -e ip_address
correctly shows the exported directories that you expect.

The Solution

This may be down to the server having a default of "expect client to connect over a reserved port", in which case, depending on which end you have control over, modify the way the client connects, or the way the directory is served.

1) In the client: mount the share from the command line, requesting that the connection be made via a reserved port.
e.g. mount -o resvport,rw,noowners -t nfs ip_address:/path/to/share /path/to/mount/point

2) In the server: tell the server not to expect connections over reserved ports.
i.e. edit /etc/exports and add the magic word "insecure" to the relevant mount description
e.g. /path/to/share *(rw,insecure,sync,no_root_squash)

Friday 4 October 2013

How to get bash to stop escaping $ during tab-completion

Once upon a time I could type
ls $HOME/f
and bash would expand this to whatever file started with 'f', or a list of all the candidates.

Now (2013 - and for quite some long irritating time) bash has been "improved" so that the above request shows:
ls \$HOME/f
which is completely useless.
(Who did that help?   What problem did it fix?)

The old behaviour can be restored by putting this in some bashrc, or executing it within bash:
shopt -s direxpand
... presuming that you have a sufficiently recent version of bash to have both the problem and the capacity to fix it. Sigh.

Thursday 19 January 2012

Create Bootable MINT LMDE USB stick - on Linux

The problem:

I want to install from LMDE (linuxmint-201109-xfce-dvd-64bit.iso) onto a machine with no CD drive.
The iso is in iso9660 format, booted by isolinux.

First attempt, with usb stick appearing as /dev/sdX

$ SRC=linuxmint-201109-xfce-dvd-64bit.iso
$ dd if=$SRC of=/dev/sdX bs=4M

Transferred to target machine, it won't boot. Claims not to be a bootable disk.

The solution: Install syslinux on the stick.

See SysLinux HowTo but it didn't work for me when I followed the instructions in the order given.

This worked:

You are going to need a USB stick of 2GB or more.
Plug it in. Check dmesg to see which device is allocated to it.
Make sure you use the correct device name. I've indicated mine as /dev/sdX. Yours might be /dev/sdb, or something else.

Download the iso file. I refer to its location as $SRC below.
e.g SRC=/tmp/linuxmint-201109-xfce-dvd-64bit.iso

I ran all of the following as root. BE CAREFUL

Mount the iso e.g.

$ ISO=/tmp/iso
$ mkdir $ISO
$ mount -o loop $SRC $ISO
$ ls $ISO
casper/ isolinux/

Download the syslinux tarball and unpack it.
I got syslinux-4.05/
cd into there

format the stick with 1 vfat partition and make it bootable.
I used fdisk. Use whichever partition program you like
I ended up with:

$ fdisk -l /dev/sdX

Disk /dev/sdX : 4005 MB 4005527552 bytes
124 heads, 62 sectors/track, 1017 cylinders
Units = cylinders of 7688 * 512 = 3936256 bytes
Disk identifier: 0x000529cf

Device Boot Start End Blocks Id System
/dev/sdX1 * 1 1017 3909317 b W95 FAT32

copy the syslinux boot sector to it
(the second line sets the bootable flag again)

$ dd conv=notrunc bs=440 count=1 if=mbr/mbr.bin of=/dev/sdX
$ parted /dev/sdX set 1 boot on

format the usb stick (the label MINTLMDE is optional)

$ mkfs.vfat -v -n MINTLMDE /dev/sdX1

initialise the active partition on the stick for syslinux

$ ./linux/syslinux -i /dev/sdX1

mount the usb stick and copy the iso contents to it.

$ USB=/tmp/usb
$ mkdir $USB
$ mount /dev/sdX1 $USB
$ cp -a $ISO/* $USB

Copy essential syslinux files

$ cp -a com32/menu/vesamenu.c32 $USB
$ cp -a core/ldlinux.sys $USB

Copy the isolinux configuration, renaming it for syslinux

$ cp -a $USB/isolinux/isolinux.cfg $USB/syslinux.cfg


Finish up

sync
umount $ISO
umount $USB


Unplug the USB stick, plug it into the target system, reboot - good luck.

Friday 1 July 2011

Moving Physical Linux to Virtual

The problem

My laptop contains several bootable linux distros. I often have a current distro, an old one, and one for exploring stuff.
Just now I want to replace the oldest distro - but there's quite a lot of interesting material in there - half finished projects, whatever. So I would like to clone it to a virtual machine where I can still play with it on some future rainy day.

I have windows vista, mint 7, fedora 13, and mint 10 in various stages of use. I use a master Grub (legacy) boot partition which chainloads to the /boot of whichever actual distro I want to fire up.
So each distro has at least a BOOT and a ROOT partition of its own.

At this time the mint 7 disto is scheduled for the holodeck. It lives on sda7 (BOOT1) sda8 (ROOT1) and sda11 (HOME1). It has Grub legacy installed to BOOT1. Although the /etc/fstab uses named partitions, I cant be absolutely sure that all other software in that system is free of references to /dev/sda-whatever, so I'm going to clone quite a lot of the physical disk structure (although not all of its data).

The plan is:
  • install virtual box on the laptop
  • create a virtual disk with at least 11 partitions, most of which are tiny - only a couple of MB - and the rest map directly to the physical partitions - but will be smaller where possible. I dont intend doing an immense amount of work in this virtual machine, so I'll only need a little flex on the storage.
  • copy the data mostly as files, from physical to virtual world using rsync.
  • copy boot sectors to the virtual disk.
  • install grub into /dev/sda virtually - no need for a separate chain loader.
  • boot into the virtual machine and install guest additions.
  • shutdown and copy the virtual machine image to ... wherever I need it - initially, storage.
  • install something new in the partitions previously allocated to mint7
Details

"Host" = laptop booted into into Fedora 13.
"Target" = virtual machine
Unless otherwise stated, run all commands as root.

On the host:

Use gparted to confirm disk structure and to learn how much of each is in use.

Mount the mint7 partitions and learn how much space is used.

mkdir /mnt/sda7
mkdir/mnt/sda8
mkdir /mnt/sda11
mount /dev/sda7 /mnt/sda7
mount /dev/sda8 /mnt/sda8
mount /dev/sda11 /mnt/sda11
df -h

Check which partition labels are actually used - look in /mnt/sda8/etc/fstab

To get the bridged networking to operate correctly, ensure the laptop is connected to ethernet and to a DHCP server. Note the IP address of the host (referred to as $HOST below)

Install VirtualBox 4

Create a virtual disk of 40GB with expanding rather than fixed storage (I probably won't use all of that.)
The rest of the machine : 512 MB RAM, Bridged networking, 3d graphics enabled.

Download an iso of SystemRescueDisk. Allocate it to the DVD drive of the virtual machine.

Boot the virtual machine, choosing "start graphics mode"

On the target:

Create a password for root - will be needed later for rsync

Use gparted to create 11 partitions, 3 physical and the remained logical.
Set all partition sizes to 10MB except for sda1, sda7, sda8, sda11:
sda1 can be 30M, while the size for the others depend on what we learned from the "df" on the host.
Align all partitions to MB values, except for sda7+ which are aligned to cylinders - matching the physical layout.
sda1 and sda7 of type ext2, sda8 and sda11 of type ext3.
For sda7,8,11 set the labels to match the physical partitions.

Apply all changes to gparted and exit.

Note the IP address of the virtual machine, referred to as $TARGET below.

mkdir /target
mount /dev/sda8 /target
mount /dev/sda7 /target/boot
mount /dev/sda11 /target/home


On the host:

Copy files from physical to virtual (give root password on demand):

rsync -va --progress /mnt/sda8 root@$TARGET:/target
rsync -va --progress /mnt/sda7 root@$TARGET:/target/boot
rsync -va --progress /mnt/sda11 root@TARGET:/target/home

On the target:

Install grub via chroot:

# install grub
# assuming /target/boot/grub contains the right stuff - staging files etc - which it does because that's how mint7 booted.

mount -t proc proc /target/proc
mount -t sysfs sys /target/sys
mount -o bind /dev /target/dev
chroot /target /bin/bash
grub
root (hd0,6)
setup (hd0)
quit

Yes, that says hd0 and 6, not sda and 7. That's just the way grub works.

sync
exit

shutdown and halt the virtual machine.

On the host:

Disconnect the SystemRescueCD iso from the virtual cd drive.
Reboot the virtual machine.
Login and install Guest Additions.

Enjoy.


Sunday 17 April 2011

restoring vanilla Google in Mint Firefox

In all versions of Mint to date, the default search results from Google in Firefox appear in a format I find disturbing and seriously inconvenient on small screens - sponsored links occupy quite a large area at the top of the page.

See here for an early description of the "problem", from April 2008; and the "problem" persists 3 years later, so from this page, here is a summary of the fix:

Go to https://addons.mozilla.org/en-US/firefox/addon/3682
Install the addon and restart Firefox
Go to google http://www.google.com
Right click in google search bar and select “add to search bar”
Left-click arrow at left side of firefox search combo
Select “manage search engine”
You should find google at the bottom of the list
Move it to the top
Along the way you might need to refer to an icon: In mint10 you can find one at
/usr/share/deskbar-applet/art/google.png

Saturday 15 January 2011

testing

ignore me I'm only a test

this is an update

Sunday 25 July 2010

Resume from encrypted swap in Fedora 13 (solved)

Problem: Install Fedora 13 with / and swap on encrypted partitions. Hibernate appears to work, but resume does not: it asks for password and then carries on with normal boot.

Fix: the kernel boot parameters need to include
  • resume=UUID=(uuid of file system device supporting the encrypted swap)
Although Fedora's installer easily and nicely sets up the encrypted partitions, and adds lvm- and luks-related activation parameters to the kernel stanza in grub, it does not add the resume= parameter.

Initially I tried
  • resume=/dev/mapper/swap0
which seemed reasonable, since root=/dev/mapper/luks-whatever is automatically added by anaconda.
However, that doesn't work: the resume boot fails, with a message like "Could not open root filesystem", and it sleeps forever.

Here is an example from a working /boot/grub/menu.lst:

# names and UUIDs
#
#root luks luks-fe45fa34-fbcc-4b0e-e556-3cb453e454f5

#root lv vg_lex/LogVol01
#root /dev/mapper/luks-
fe45fa34-fbcc-4b0e-e556-3cb453e454f5

#swap luks luks-23d23dea-8732-42d2-c319-4568973a74373
#swap lv vg_main/LogVol00
#swap /dev/mapper/swap0
#swap Filesystem 34deffd5-2328-4702-45e5-4532a1fd45e2

# failed:
# resume=/dev/mapper/swap0
# ok:
# resume=UUID=
34deffd5-2328-4702-45e5-4532a1fd45e2

title Fedora (2.6.33.6-147.fc13.i686.PAE)
root (hd0,5)
kernel /vmlinuz-2.6.33.6-147.fc13.i686.PAE ro root=/dev/mapper/
luks-fe45fa34-fbcc-4b0e-e556-3cb453e454f5 rd_LUKS_UUID=luks-fe45fa34-fbcc-4b0e-e556-3cb453e454f5 rd_LVM_LV=vg_main/LogVol01 rd_LUKS_UUID=luks-23d23dea-8732-42d2-c319-4568973a74373 rd_LVM_LV=vg_main/LogVol00 rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYTABLE=uk rhgb resume=UUID=34deffd5-2328-4702-45e5-4532a1fd45e2 quiet
initrd /initramfs-2.6.33.6-147.fc13.i686.PAE.img