PDA

View Full Version : How do I fsck the fs that's on a USB key?



soubeagi
06-03-2013, 01:39 AM
Recently, I decided to create a new Knoppix USB key to use for debugging, but in the process of updating various packages, I somehow created a file which is listed as having zero links. Because of the file's (non)existence, Synaptic/dpkg can't replace it or delete it, and won't allow any more updates until I do. I've tried deleting it at a command prompt, I've tried linking it to another name, but every approach I try causes complaints either that it doesn't exist, or that it already exists. I think running fsck would fix it, but these files apparently aren't stored in an actual *nix filesystem, but rather in a file in the USB key's FAT filesystem. How can I mount this pseudo-filesystem from another CD or USB key version of Knoppix to run a fsck on it? I'd really like to avoid starting from scratch and redoing all the configuration that I've already done to this USB key.

[Note that my question has nothing to do with fixing another OS (as many people, including myself, use Knoppix USB keys for); what I'm talking about right now is fixing the Knoppix installation on the USB key itself.]

[Also, if it matters, I used pendrivelinux.com to make this USB key instead of Knoppix's own "copy to USB" scripts, so that I wouldn't have to burn a DVD as an intermediate step, when I'd only need to use the DVD once to create the USB.]

Werner P. Schulz
06-03-2013, 07:30 AM
I somehow created a file which is listed as having zero links. Because of the file's (non)existence, Synaptic/dpkg can't replace it or delete it, and won't allow any more updates until I do.Tell us all about this file.

utu
06-03-2013, 04:31 PM
@soubeagi

The directory .gvfs which may occur inside /home/knoppix is such a 'file'.
A forum search of gvfs will give you seven threads which discuss (in a few comments)
some this peculiarity of Debian-derived linuxes. Perhaps you've found something similar(?).

soubeagi
06-03-2013, 09:35 PM
Tell us all about this file.

-=-=- From package install attempt:
E: /var/cache/apt/archives/iptables_1.4.14-3.1_i386.deb: unable to make backup link of `./lib/libip4tc.so.0.1.0' before installing new version: No such file or directory
-=-=- and
Selecting previously unselected package iptables.
(Reading database ... 443739 files and directories currently installed.)
Preparing to replace iptables 1.4.14-2 (using .../iptables_1.4.14-3.1_i386.deb) ...
Unpacking replacement iptables ...
dpkg: error processing /var/cache/apt/archives/iptables_1.4.14-3.1_i386.deb (--unpack):
unable to make backup link of `./lib/libip4tc.so.0.1.0' before installing new version: No such file or directory
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Processing triggers for man-db ...
Errors were encountered while processing:
/var/cache/apt/archives/iptables_1.4.14-3.1_i386.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
A package failed to install. Trying to recover:
-=-=- From package removal attempt:
E: iptables: unable to securely remove '/sbin/xtables-multi': No such file or directory
-=-=- and
(Reading database ... 443738 files and directories currently installed.)
Removing iptables ...
dpkg: error processing iptables (--remove):
unable to securely remove '/sbin/xtables-multi': No such file or directory
Errors were encountered while processing:
iptables
E: Sub-process /usr/bin/dpkg returned an error code (1)
A package failed to install. Trying to recover:
-=-=- From terminal:
knoppix@Microknoppix:~$ su
root@Microknoppix:/home/knoppix# ls -l /sbin
lrwxrwxrwx 1 root root 13 Jun 3 14:38 /sbin -> /UNIONFS/sbin
root@Microknoppix:/home/knoppix# ls -l /UNIONFS/sbin
total 12896
-rwxr-xr-x 1 root root 3104 Dec 2 2009 acpi_available
-rwxr-xr-x 2 root root 26684 Sep 14 2012 agetty
-rwxr-xr-x 1 root root 3404 Dec 2 2009 apm_available
-=-=- . . . yadda yadda yadda
-rwxr-xr-x 1 root root 953968 Nov 17 2012 wpa_supplicant
-rwxr-xr-x 1 root root 535368 Jun 22 2012 xfs_repair
-rwxr-xr-x 0(:confused:) root root 81024 Jun 11 2012 xtables-multi
root@Microknoppix:/home/knoppix# cd /UNIONFS/sbin
root@Microknoppix:/UNIONFS/sbin# ln xtables-multi xtables-temp
ln: failed to create hard link `xtables-temp' => `xtables-multi': No such file or directory

Werner P. Schulz
06-04-2013, 09:57 AM
You can try to start Knoppix without activating the persistent memory (cheatcode: knoppix noimage)
If you have the persistent memory within knoppix-data.img start in a terminal

su
mkdir /mnt/repair
losetup /dev/loop1 /mnt-system/KNOPPIX/knoppix-data.img
mount /dev/loop1 /mnt/repair
Perhaps you can now remove the disturbing file-entry. After this proceed with

umount /dev/loop1
losetup -d /dev/loop1
reboot

soubeagi
06-04-2013, 06:08 PM
You can try to start Knoppix without activating the persistent memory (cheatcode: knoppix noimage)
That seems to have worked; I'll let you know for sure once I reboot. For now I just want to document what happened when I followed your instructions.

knoppix@Microknoppix:~$ su
root@Microknoppix:/home/knoppix# mkdir /mnt/repair
root@Microknoppix:/home/knoppix# losetup /dev/loop1 /mnt-system/KNOPPIX/knoppix-data.img
root@Microknoppix:/home/knoppix# mount /dev/loop1 /mnt/repair
root@Microknoppix:/home/knoppix# ls -l /mnt/repair/sbin
total 1340
-rwxr-xr-x 1 root root 22156 Mar 21 01:18 badblocks
-=-=- . . . yadda yadda
-rwxr-xr-x 1 root root 67648 Mar 21 01:18 tune2fs
-rwxr-xr-x 0 root root 81024 Jun 11 2012 xtables-multi
root@Microknoppix:/home/knoppix# rm /mnt/repair/sbin/xtables-multi
rm: remove regular file `/mnt/repair/sbin/xtables-multi'? y
root@Microknoppix:/home/knoppix# ls -l /mnt/repair/sbin
total 1256
-rwxr-xr-x 1 root root 22156 Mar 21 01:18 badblocks
-=-=- . . . yadda yadda
-rwxr-xr-x 1 root root 67648 Mar 21 01:18 tune2fs
root@Microknoppix:/home/knoppix# umount /dev/loop1
root@Microknoppix:/home/knoppix# losetup -d /dev/loop1
root@Microknoppix:/home/knoppix# rmdir /mnt/repair # I added this myself
root@Microknoppix:/home/knoppix#

soubeagi
06-04-2013, 07:10 PM
Well, for one thing, it took forever to reboot; I typed 'reboot', walked away to do something else for five minutes, came back, and found it still on the shutdown screen. When it finally restarted, I checked and found that the weird file was finally gone:

knoppix@Microknoppix:~$ su
root@Microknoppix:/home/knoppix# ls -l /UNIONFS/sbin
-=-=- . . . yadda
-rwxr-xr-x 1 root root 535368 Jun 22 2012 xfs_repair
root@Microknoppix:/home/knoppix#

Next, I started Synaptic and found that 'iptables' was still tagged for removal, so i let it try:

E: iptables: unable to securely remove '/sbin/nfnl_osf': No such file or directory
-=-=- and
(Reading database ... 443738 files and directories currently installed.)
Removing iptables ...
dpkg: error processing iptables (--remove):
unable to securely remove '/sbin/nfnl_osf': No such file or directory
Errors were encountered while processing:
iptables
E: Sub-process /usr/bin/dpkg returned an error code (1)
A package failed to install. Trying to recover:

Next, I tried to reinstall the package:

E: /var/cache/apt/archives/iptables_1.4.14-3.1_i386.deb: unable to make backup link of `./lib/libip4tc.so.0.1.0' before installing new version: No such file or directory
-=-=- and
Selecting previously unselected package iptables.
(Reading database ... 443739 files and directories currently installed.)
Preparing to replace iptables 1.4.14-2 (using .../iptables_1.4.14-3.1_i386.deb) ...
Unpacking replacement iptables ...
dpkg: error processing /var/cache/apt/archives/iptables_1.4.14-3.1_i386.deb (--unpack):
unable to make backup link of `./lib/libip4tc.so.0.1.0' before installing new version: No such file or directory
dpkg-deb: error: subprocess paste was killed by signal (Broken pipe)
Processing triggers for man-db ...
Errors were encountered while processing:
/var/cache/apt/archives/iptables_1.4.14-3.1_i386.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
A package failed to install. Trying to recover:

I scrolled back thru the terminal output and found this:

-rwxr-xr-x 0 root root 9672 Jun 11 2012 nfnl_osf

Argh. Looks like I'm rebooting again.

soubeagi
06-04-2013, 10:03 PM
Okay, after going through the motions again with this new messed-up file, I finally managed to get it to properly remove and reinstall the package in question.

Next question: I noticed when updating the list of packages that this info is coming from ftp.de.debian.org, which seems wrong for me (I'm in the US) - but when I select Settings | Repositories from the menu, it goes directly to a "Repositories changed" infobox, without ever giving me a chance to actually change repositories. What, if anything, am I doing wrong here?

Werner P. Schulz
06-05-2013, 08:10 AM
Wheezy is stable (http://knoppix.net/forum/threads/30502-Knoppix-CeBIT-Edition-7.1?p=129243&viewfull=1#post129243)
The packages have a ride on the merry-go-round :-)
old stable - stable - testing - experimental - squeeze -wheezy - lenny -sid

If you really need to upgrade a package, do it one by one and carefully comparing the version and version-#

Why not wait for Knoppix 7.2?

soubeagi
06-05-2013, 05:53 PM
Why not wait for Knoppix 7.2?
I wasn't aware that there was going to be a new Knoppix release in the near future; I don't follow the goings-on in the Debian world all that closely. I just looked on knopper.net, saw that the current version (http://knopper.net/knoppix/knoppix705-en.html) being offered there was significantly newer than the one I had been using, and decided to update.

-=-=-

And, for the benefit of those who might in the future see the heading of this thread and expect to get a straightforward answer to the question posed there: it's here, it's just a little buried, so here's a "no brainer" version of how to do it:

1. Boot the Knoppix installation in question by typing "knoppix noimage" at the "boot:" prompt.
2. When it's finished booting, open a terminal window and type the following series of commands, one by one:


su

losetup /dev/loop1 /mnt-system/KNOPPIX/knoppix-data.img

fsck /dev/loop1Note that this assumes that the problem you're trying to correct came into being in the process of using the USB key, and didn't already exist in the CD or DVD image that you used to make the USB key. (That is to say, this will only repair changes to the filesystem that were made while using it, and will not change anything from the way it was originally created.)