Answers 102

From LXF Wiki

Answers 102

<title>Disk division</title>

<question>I have a system with Ubuntu on a 500GB hard disk (dev/sda). I had been using Gentoo, which I like better, so I created a new partition and installed Gentoo. I used the original boot and swap partitions. Now running Gparted, I seem to have three partitions: /dev/sda1 (198.70GB) for /boot, /dev/sda3 (261.26GB) for root and /dev/sda2 (extended 5.80GB) with swap on extended /dev/sda5. Gentoo is working fine but I lost Ubuntu on /dev/sda1. I believe I didn't format when I repartitioned with Gparted, but there wasn't anything critical on the disk so I can reinstall. Can I repartition /dev/sda1, creating another partition for Ubuntu or whatever and leave a small boot partition? What size will the boot partition be and can I use the same boot partition for both distros Gentoo and whatever? Also, can I use the same swap partition for both distros? Finally, will the new partition scheme change the naming scheme in the Gentoo grub loader? </question>

<answer>Gparted creates a new file system on any new partition it creates, so you formatted sda1 without realising it. You can resize sda1, but you'll have to create another primary partition, which will mean you won't be able to create any further partitions, except by shrinking your swap partition. The x86 partition table is limited to four partitions. We get more by making one of them an extended partition and creating logical partitions within that. Resizing sda1 will leave free space outside of the extended partition. You could do this, and let Ubuntu install in the space you free up, and it's perfectly safe to share a swap partition between the two distros. However, sharing /boot is more complex and generally not a good idea, especially as Ubuntu defaults to using no separate boot partition. A separate /boot is something of an anachronism, dating back to limited PC BIOSes that could only handle small disks, so the boot files had to be at the start of the disk. Nowadays, this is no longer applicable and I don't use a boot partition on anything. You have a couple of options. The best in the long term, but the most work, is to back up your Gentoo install, using either a second drive or a pile of DVDs, and repartition the disk from scratch. As you're not running Windows, there's no need for a primary partition. By making every partition logical, you make the whole disk an extended partition to give yourself more flexibility. Then restore Gentoo from the backup before installing Ubuntu. The alternative is to shrink sda1 to around 50MB and install Ubuntu in the space this frees up. In this case, Grub's root for Gentoo will still be (hd0,0) but you'll need to change the root parameter passed to the kernel, probably to /dev/sda4. Either way, installing Ubuntu will set Grub to use its configuration: this should pick up your Gentoo installation and add it to the menu. If not, you can restore your Gentoo bootloader and add an entry to the menu to boot Ubuntu. To do this, boot from the Gentoo Live CD and run the following commands:

mount /dev/sda4 /mnt/gentoo
# assuming your Gentoo installation is now on
/dev/sda4
mount /dev/sda1 /mnt/gentoo/boot
mount --bind /dev /mnt/gentoo/dev
chroot /mnt/gentoo /bin/bash
grub
root (hd0,0)
setup (hd0)
quit
exit

You'll probably recognise most of this from the Gentoo handbook ­ all you're doing is chrooting into your Gentoo system and running Grub to set it to boot from your Gentoo /boot partition. Once Gentoo is running, you'll need to edit /boot/grub/menu.lst to add an entry to boot Ubuntu (copy it from the existing Ubuntu menu.lst file). </answer>

<title>Distro Upgrades</title>

<question>It's that time of the year again when new versions hit the download mirrors. This is all well and good but can the yearly upgrade be avoided? Each year do I have to spend a day downloading and installing a new version of my distro? Are there not distros out there that are constantly updated so all you have to do is run a command and the whole system is upgraded to the latest releases? When I say that, I don't mean every six months or whenever. I mean, when I run the command it updates to the latest release at that time. This is the only thing that annoys me about Linux, the fact I have to reinstall every year just so I can keep up to date. I then have to configure everything again. I'd just like to be able to install and configure once and then upgrade from there. Is this at all possible? </question>

<answer>It is indeed possible to perform `rolling upgrades' with some distros. Probably the most complete example of this is Gentoo, which doesn't actually have versions (only the installer discs have versions). The distro is constantly updated as new versions of the various software packages are released, with the result that a machine that was first installed five years ago is as up to date as one installed last week. If you don't have the patience or inclination to learn Gentoo, Debian and its derivatives can be updated to a new release version without reinstalling. If you're running the testing or unstable version of Debian, you'll get new packages as they're released, whereas most distros only release security updates. Even if you don't use a bleeding edge version, when a new version is released, all you need to do is edit /etc/apt/sources.list and change all references to the current distro label ­ such as feisty if using Ubuntu or etch for Debian proper ­ to the new label (like gutsy or lenny, respectively). Then run:

sudo apt-get update && sudo apt-get dist-upgrade
&& sudo apt-get dist-upgrade

That's not a mistake: you do the dist-upgrade step twice as some packages may not update on the first run, and if they do then the second run will do nothing anyway. If you're using Ubuntu, there's an easier way to update to the latest release, by selecting Administration > Update Manager from the System menu. When a new distro version is available, it will tell you and give you the option to upgrade. Whichever of these methods you choose, the upgrade may still be a lengthy task, but you won't have to restore your settings and software choices afterwards, and the computer should be usable while the upgrade is running. It's also possible to perform an upgrade from the install discs of the likes of Mandriva and SUSE, although people report varying degrees of success with this and conventional wisdom is to back up your data and settings then do a clean install with the RPM-based distros; a separate home partition is a definite benefit here. </answer>

<title>Dual-booting Ubuntu</title>

<question>I have Vista Home Ultimate installed and would like to dual boot with Ubuntu 7.10. An article on apcmag.com makes it appear straightforward, and up to the point of shrinking the Vista partition this is the case. I now have 62.76MB unallocated space. Rebooting with the Ubuntu CD starts off OK ­ it loads Linux and starts loading Ubuntu ­ but after a short time the screen becomes incorrect and then goes blank with the CD stopping. The only way I can reconcile the situation is to turn off the machine and turn it on again, rescuing the CD before it boots. The answer to the problem is, no doubt, very simple. Can you enlighten me? </question>

<answer>Your problem is not unique: the same happened to me when installing on an oldish Fujitsu Siemens laptop. However, other systems also displayed a blank screen for a while before proceeding with the boot, so you may just need to leave it a minute or two. Either way, this is unconnected with your use of Vista. Note, though, that there's no need to resize your Windows partition: the Ubuntu installer can take care of that ­ although you should first defragment it in Windows. If waiting doesn't work for you, you need to use the Alternate CD, which uses a text installer without the Live CD desktop. Although the installer is text based, the installed system still has a full desktop. This is sometimes needed when the Live CD cannot handle your graphics hardware. The text installer also allows a few more choices than the Live CD and generally has a higher success rate. </answer>

<title>Giving away computers</title>

<question>I work for the University of Western Ontario in Canada and I have access to a lot of old and broken computers that I rebuild and give away to charities. I've used Windows in the past but it's a bit of a pain because of copyrights and its inability to recognise hardware. It would be a lot easier to use a Linux operating system; the problem is, I need a Linux system that's able to recognise PCI modems without having to search the net for drivers. It would be nice if you could tell me which operating system would be the best for using PCI modems, or which PCI modems would be the easiest to use so that I can make these computers internet capable. </question>

<answer>PCI modems are a sticky topic. Most internal modems are controller- less (also known as winmodems): they are missing the digital signal processor of a normal modem, offloading the work to the computer's CPU instead. Hardware modems, those that have a full controller, generally appear as a serial device so you use them exactly the same as an external modem, with no need for special drivers. These are your best choice, but you need to check the specifications carefully to make sure a particular modem is a true hardware device. Some controller-less modems will work with Linux. You'll find a list of supported models at www.linmodems.org along with a program that will identify your modem's chipset and indicate the correct driver. It's not possible for us to recommend specific makes and models, because manufacturers sometimes change the chipset of a modem without changing the model designation. This doesn't matter to Windows users (apart from the potential drop in performance) because the driver disc supplied with the modem takes care of the differences. Anything with an Intel chipset is likely to be a good bet. They supply drivers from their website at http://developer.intel.com/design/modems/support/drivers.htm. The distro is less important as most of them have excellent hardware detection nowadays. A more important consideration is how well it runs on older hardware. See this month's lead feature (page 48) for more information on that. If you find a modem that works, you should get further models from the same supplier, preferably from the same stock to ensure they're all compatible. You may also find eBay a good source for older, and often more compatible, modems as so many people no longer use them. Alternatively, if any of our readers have compatible modems they no longer use, we would be happy to put them in touch with you so they can help with your efforts. </answer>

<title>Home transfer</title>

<question>I've installed Mandriva 2008 on my new machine and the network is working so I can see the Home directory on the old machine. I now want to transfer everything to the new machine, including hidden files and config files. I'm wondering about the best way to do this. Should I back up the /home directory and reinstate it on the new machine? Or just copy files over, which may take some time? </question>

<answer>If networking is up and you have the SSH service running on the old computer, the best way to do this is with rsync. Open a terminal on the new computer, as your normal user, and run:

rsync -ax olduser@oldmachine:~/ ~/

The trailing slashes are important. If the username is the same on both computers, you can omit the olduser@ part. This will copy everything in your home directory, including hidden files, and set all permissions and timestamps correctly. Even if you use different usernames, or the same usernames with different numeric IDs, rsync user after copying. You shouldn't be logged in on the old computer when doing this, as there's the possibility that some files may be changed between the initial directory scan and the copying, which would cause rsync to exit with an error. If you have a desktop running on the old computer, close it down before running rsync. Copying everything verbatim may not be a good idea, because you may overwrite newer config files with older versions. An alternative is to create a directory in your home and copy to that, with:

mkdir ~/oldhome
rsync -ax olduser@oldmachine:~/ ~/oldhome

Then you can use your favourite file manager to copy over the files and directories you need and delete the older config files and the general cruft we all accumulate in our home directories over time. This is one of those jobs that's quicker to do from the command line, but if you prefer to use a GUI, there are alternatives. If you use KDE, the default desktop on Mandriva, open a Konqueror window, select one of the Window > Split View options, use one pane to create and show the oldhome directory and type fish://olduser@oldmachine into the location bar for the other pane. This should display olduser's home directory, from which you can select and copy files and directories. Select View >Show Hidden Files to display all your configuration files, then press Ctrl+A to select everything, followed by F7 to copy it. Midnight Commander is another file manager that can use the FISH protocol to access files on a remote computer. If you regularly need to synchronise directories on two computers, I strongly recommend Unison (www.cis.upenn.edu/~bcpierce/unison), which I use to keep my desktop and laptop in sync, but it's overkill for a one-off copy. </answer>

<title>Automated file copying</title>

<question>I want to have a folder in my home directory that automatically updates that folder from the same folder on my USB stick when I insert it. If the above description is poor then all I can compare it to is having a Microsoft Windows briefcase. I'm using KDE on a Ubuntu installation. </question>

<answer>KDE has a feature that will run an autorun script when a removable device is mounted, Unfortunately, it's aimed at optical media and doesn't (yet) work with USB devices. The good news is that, with a little scripting, you can do this directly from udev. The first step is to set up a udev rule for your device, as I outlined last month in Moving Hard Disk in LXF101 Answers on page 105. This can be specific to one USB key or general enough to match anything with a FAT filesystem (USB keys always use this by default). Add this to the end of the rule:

RUN="/usr/local/bin/synchome &"

The trailing & to detach the process running the script is important ­ udev stops processing events while the rule is being processed and you don't want your file copying to block the whole of udev. Now you just need a script to do the dirty work of copying the files, using rsync, after making sure that certain conditions are met. Save this as /usr/local/bin/synchome (or whatever name you gave the script in the udev rule) and make it executable with chmod +x /usr/local/bin/synchome.

#!/bin/sh
MYUSER="foo"
[[ ${ACTION} == "add" ]] || exit
if ! mount | grep -q ${DEVNAME}
then
  MOUNTPOINT="/media/$(basename
${DEVNAME})"
  mkdir -p ${MOUNTPOINT}
  mount ${DEVNAME} ${MOUNTPOINT} -o
uid=${MYUSER}
  MOUNTED=1
fi
if [[ -d "${MOUNTPOINT}/myfiles" ]] && [[ -d "/
home/${MYUSER}/myfiles" ]]
then
  su - ${MYUSER} -c "rsync -ax
${MOUNTPOINT}/myfiles/ /home/${MYUSER}/
myfiles/"
fi
[[ "${MOUNTED}" ]] && umount
${MOUNTPOINT}

The first line stores the name of the target user in a variable ­ an alternative approach would be to get the username from the name of the directory containing the files. Next we check that the rule has been processed because the device has been connected. Udev rules are run on addition and removal of a device, and the ACTION environment variable is set accordingly. KDE can be set up to automatically mount new devices, so the next seven lines check whether this has happened and mount it if not. Then we check for the presence of your special directory, called myfiles here, in both the USB stick and your home directory before running rsync to copy any new files from the stick. There are various other options you could use here, such as --delete to remove any files in ~/myfiles that are not on the stick. You could also use Unison (www.cis.upenn.edu/~bcpierce/unison) instead of rsync for two-way synchronisation. We use su to run rsync as the user ­ not only is it safer to run as little as possible as root, but it also avoids any permission problems later when you could find files in your home directory owned by root. Finally, we unmount the USB stick, but only if it was mounted by the script earlier. If KDE automounted it, we should let KDE take care of unmounting it. This is only one example: there are many possible variations. Read the rsync man page for options that may be useful but be wary of anything that could delete files, especially when it is run automatically in the background. </answer>

<title>Choices, choices</title>

<question>Finally, after years of saving, I'm going to get a new desktop or laptop computer. The only problem is that I want it to be able to run Linux so I have to get a lot of facts right before taking the jump. Using an old desktop with Debian for the past two years, I didn't previously notice that the following are `problems' at all.

Processor Should I download the 32- or 64- bit version? AMD64 is quite clear, but is Intel Core 2 Duo 64-bit? I understand from the web that some users are using the 32-bit versions of Linux with them. I'm confused!
Graphics Nvidia or Intel, and which model? Most HP computers that I looked at use the Nvidia Go 6100, Nvidia Go 6150 and Intel X3100 chipsets. Are these graphics supported in Linux?
Assuming that I've got a new computer running Debian (KDE) and an old computer running Debian (Fluxbox), how do I check for the other computer that's connected to the same network? How do I share files between these two computers since they're logged in as different users?

</question>

<answer>The more choices you have, the more difficult the decision! Many laptops now have 64-bit processors ­ the Intel Core 2 Duo CPUs are 64-bit while the Core Duos are 32- bit. It looks like you'll be using this machine for a while, so I'd certainly recommend a 64-bit system. It is true that some people run a 32-bit OS on 64-bit hardware. The main reason is that they want to use closed-source software that's not available in 64-bit ­ but most 32-bit software will run on a 64-bit system anyway. Even 32-bit browser plugins can be made to run in a 64-bit browser with nspluginwrapper (www.gibix.net/projects/nspluginwrapper), so I'd advise you to use a 64-bit distro on 64-bit hardware unless you have a compelling reason to do otherwise. Both the Nvidia and Intel graphics chipsets work well. Nvidia gives better 3D performance but requires proprietary drivers. The Intel chipset gives 3D with the XOrg drivers. The Intel wireless chips `just work' with Linux in my experience too. With other chipsets, check carefully first: wireless hardware compatibility is one of the main problem areas with laptops nowadays. With a desktop, these aren't major issues because just about everything is interchangeable. Laptops are less flexible and it's worth checking www.linux-laptop.net for compatibility. If both computers are connected to the internet via the same router, the router's admin page may show the connected computers, particularly if it's acting as a DHCP server. Transferring files between the computers can be done by mounting shared drives with NFS or Samba, or by using scp to copy. As you're using KDE, the easiest way is to type:

fish://username:password@ipaddress/path/to directory

into a Konqueror window's location bar to view the contents of that directory and be able to drop files to copy them. You only need SSH running on the other computer for this to work. </answer>

<title>Internet access DENIED!</title>

<question>I installed Ubuntu some months ago from your cover disc (LXF DVD94) on a new Compaq Presario that already had Vista installed. However, I couldn't access the internet. It was suggested a router would be the answer. I tried an Edimax ADSL2+ in wired mode but still got no response. I learned how to check the status of my internet connection at the command line by entering:

/sbin/ifconfig -a

I returned the following:

eth0 Link encap:Ethernet HWaddr 00:1A:92:
B5:69:A1
       inet6 addr: fe80::21a:92ff:feb5:69a1/64
Scope:Link
       UP BROADCAST RUNNING
MULTICAST MTU:1500 Metric:1
       RX packets:38 errors:0 dropped:0
overruns:0 frame:0
       TX packets:340 errors:0 dropped:0
overruns:0 carrier:0
       collisions:0 txqueuelen:1000
        RX bytes:4014 (3.9 KB) TX bytes:37621
(36.7 KB)
        Interrupt:19 Base address:0x2000

Please advise me as to what I can do next. </question>

<answer> The advice to switch from a USB modem to a proper Ethernet modem was good: they work more efficiently, plus almost all of them include a router, so you can connect more than one computer to the internet. The output from ifconfig only covers your connection to the router, which acts as a bridge between your local network and the internet. The connection between the modem and the internet is separate. Unfortunately, it shows that you're not connected to the router ­ there is no inet addr: field showing your IP address. Make sure you're using DHCP to configure your network by going to System > Administration > Network, selecting your Ethernet interface and choosing Properties. Set Automatic Configuration (DHCP) in here, which should handle everything and enable you to connect to the router's admin page by typing http://192.168.2.1 in your browser. You'll be asked for the login and password, which will be admin and 1234 if you haven't changed them. If you can load the router's admin page, your network is correctly configured. Now you need to set up the internet side of the router. Click the Quick Start link to run the setup wizard in your browser and input the details given by your ISP. If you're unsure about any of these settings, you may need to contact your ISP for clarification. If the wizard fails for any reason, you have two choices. One is to use a Windows computer to run the wizard (once the router is set up, it will work with any OS); the other is to use the Internet section of the Interface Setup tab. Once you've successfully configured the computer, you can confidently connect other computers ­ up to four at a time ­ and have them use your internet connection. As long as they're set to use DHCP, which most distros do by default, no further setting up is required. </answer>