Ask Klaus!
Ask Klaus!
Klaus Knopper is the creator of Knoppix and co-founder of the LinuxTag expo. He currently works as a teacher, programmer, and consultant. If you have a configuration problem, or if you just want to learn more about how Linux works, send your questions to: klaus@linux-magazine.com
Live CD Tricks
Question:
I sometimes use a Live CD and dd to image a computer's internal drive to a USB drive before I do something dangerous to it:
dd if=/dev/sda of=./laptop_backup
This technique works well, but the only way I know to get at the data is to restore the whole thing to the system. If I had backed up a single partition
dd if=/dev/sda1 of=./root_filesystem
I could mount that file as a filesystem and copy data out of it. But I don't know how to do that if the image is of an entire drive with a partition table. Is this possible?
Answer:
Yes, it is. For mounting filesystems in Linux, it makes (almost) no difference whether the filesystem is located on a hard disk partition or inside a file.
If you create a partition image with dd if=/dev/sda1 of=./root_filesystem, a loopback mount:
sudo mount -o loop,ro root_filesystem /media/test
will expose the filesystem structure residing in the partition copy file. (The /media/test target directory must exist before issuing the mount command.)
The same approach is possible if partitions are located inside an entire hard disk dump; however, finding out where the partition starts and ends can be a little tricky.
For example, if laptop_backup is the file containing your complete hard disk dump (created by the first dd command you typed above), you can find out where partitions start and end with the following command:
fdisk -u -l laptop_backup
The resulting output is shown in Listing 1.
Listing 1
fdisk Output
Don't worry about different physical/logical endings right now; you just need the start values, which are given in sectors of 512 bytes when the fdisk -u option is specified, so you now calculate the start of partition 2 (of type Linux) as follows:
Lecho $((8401995 * 512)) 4301821440
Now that you know the filesystem starts at byte offset 4301821440 in the hard disk image, you can mount it with
sudo mount -t ext2 -o loop,ro,offset=4301821440 laptop_backup /media/test
which should read-only-mount the stored partition 2 content under /media/test. Usually, mount is able to find the matching filesystem, so you can leave the -t ext2 or specify a different filesystem. In theory, you also should limit the size of the mounted "virtual" partition, but because the filesystem contains the correct size in its meta information, also calculating the ending value for sizelimit is unnecessary; the offset mount option is sufficient.
PC Projectors
Question:
I just got a Lenovo T61 with Ubuntu 8.04 installed on it. It is the widescreen model and Ubuntu is great, except for one important detail. The PC projectors that I have to use when I visit businesses to make presentations are not widescreen.
I have tried to set the screen resolution to 1024x768 and other screen resolutions that are non-widescreen, but Ubuntu shows the selected resolution, which you can see from the command bar, in the center of the screen, stopping short on both the left and the right side, but the background image of the heron covers the entire widescreen beyond the border of the screen resolution I have just set. To make matters worse, when I run OpenOffice Impress in SlideShow mode, Impress fills the widescreen and leaves the PC projector only showing part of the image, even though I have the laptop set to 1024x768 (i.e., non-widescreen). How can I get the laptop to work properly with the PC projectors?
Answer:
Widescreen internal displays often cause trouble with external non-widescreen monitors and projectors. Effects vary from blank bars on the side of the screen, to cut off edges, to mostly correct projector pictures with only a partly visible picture on the internal display. (This partial visibility is the case on the EeePC when the external port is set to higher resolutions than the capabilities of the internal display.) Basically, the desktop-integrated helpers for changing screen resolution on the fly use the randr extension of the graphics chipset to get a matching resolution on internal and external ports. For KDE, this is krandrtray (which usually runs inside the desktop panel); for LXDE, this is lxrandr (a standalone application that can also be used for other Gtk+-based desktops).
For some chipsets, it is even possible to have different (virtual) internal and external resolutions. Still, the problem with widescreen (16:9) vs. standard PAL (4:3) geometry remains because the chipset in most cases cannot run different frequency divisors on the external vs. the internal port.
The best solution seems to be shutting down the internal display signal completely and using an external VGA splitter to get a picture on an external monitor and projector. In this case, the signal on the external port is not set to match a widescreen picture simultaneously on the internal display. Make sure you have an easy way to switch the internal display back on in case you lose the picture on the external ports. I use a hotkey command on my desktop to execute
xrandr --output LVDS --auto
which re-enables the signal on the internal display. In this command, xrandr is the command-line tool for changing resolutions, and LVDS is the internal display of your notebook. The external port is called VGA for the --output parameter. For getting the best result on an external 1024x768 projector, I use this sequence:
xrandr --output LVDS --off xrandr --output VGA -s 1024x768
(Try --mode instead of -s if the preceding command does not work.)
Sometimes autoconfiguation works, in which case the projector tells your graphics chipset its preferred resolution automatically, then you would use:
xrandr --output VGA --auto
Yet you still might have to disable the internal display beforehand. It could happen that the resolution change works but your desktop fails to adjust itself to the new screen resolution and gets "stuck."
In this case, it is helpful to switch to the text console with Ctrl+Alt+F1 and back to X with Ctrl+Alt+F7 (or Ctrl+Alt+F5, depending on which console the X server is running).
BIOS Boot
Question:
I have the SUSE 11.0 DVD, and the instructions say I should set the BIOS for booting via DVD. Since I don't have said booting possibility, do I have to buy a better motherboard and chip, and if so, will it run my optic drives CD-RW/DVD-ROM? My HD is 120GB with a WD500GB external HD. I am more than a bit baffled on the partitioning of the 500GB EXT HD.
Answer:
If your PC cannot boot from DVD, you still have some options for installation. If the boot menu (for many BIOSes, this is displayed by pressing F12 during startup) is missing, you might have to install to the internal hard disk. Linux runs fine from external disks and non-primary drives; however, if the computer's BIOS does not allow this, you might have to use a special boot manager or re-partition your internal hard drive to install at least the kernel part of Linux – maybe parallel to an existing OS that you want to keep – and use the external disk as an add-on for all operating systems.
With a few modifications, you can get a bootable CD or DVD to boot from a USB memory stick or hard disk, but if the BIOS does not allow booting from the DVD, you might have trouble booting to a USB stick.
Also, you might want to try using a boot manager that loads from a floppy disk – have a look at http://wiki.linuxquestions.org/wiki/Boot_Floppy, which describes different techniques for allowing an initial boot from floppy, then giving control to the DVD. An alternative method could be removing the hard disk from your PC and installing it "offline" from a different PC that is capable of booting from DVD.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Gnome Fans Everywhere Rejoice for the Latest Release
Gnome 47.2 is now available for general use but don't expect much in the way of newness, as this is all about improvements and bug fixes.
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.
-
SUSE Renames Several Products for Better Name Recognition
SUSE has been a very powerful player in the European market, but it knows it must branch out to gain serious traction. Will a name change do the trick?
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.
-
Fedora KDE Approved as an Official Spin
If you prefer the Plasma desktop environment and the Fedora distribution, you're in luck because there's now an official spin that is listed on the same level as the Fedora Workstation edition.
-
New Steam Client Ups the Ante for Linux
The latest release from Steam has some pretty cool tricks up its sleeve.