Jump to content


Howto: Run filesystem check on /dev/sda1


3 replies to this topic

#1 albkwan

    ExtrEmE User

  • Members
  • 1,440 posts
  • LocationHong Kong

Posted 09 August 2008 - 09:57 AM

I have been hearing about people having difficulty to mount USB partitions but this is the first time I experienced this last night.

This occured after the system hanged up during shut down and I have to push the power button to switch off the Eeepc. When I rebooted, I found that USB devices cannot be mounted. The error message is something like: "You do not have enough permissions to read /home/user/[name of USB device]". After some checking, I found that this is due to filesystem error generated when the system power off without cleanly umount both the SYSTEM partition and the USB device.

In a full-pledged Linux distribution, the system will usually run a filesystem check during bootup and will automatically take care of such problems. But in default Xandros of the Eeepc, probably because to achieve the fast bootup speed, this feature has been sacrificed and there is no way to do this even in rescue mode.

So, to offer a solution to this problem, I have build an initramfs image with the e2fsck binary and libraries required packed into it, as well as a bootup script to run file system check on /dev/sda1 automatically.

==========================================

For those who are interested, here are the easy steps how to do it. At the end, I will also list the DIY steps.

EASY STEPS
1) Download and extract initramfs-fsck-eeepc.img.gz. [EDIT 2009/8/16: Changed download link to www.mediafire.com.] Save it somewhere easily accessible in rescue mode, e.g. /home/user.

2) Edit /boot/grub/menu.lst with the default text editor, add new entry to the boot menu you will see when you press F9 during system bootup (just copy and paste the following lines) :
title Perform Disk Scan on sda1
    root (0x80,0)
    kernel /boot/vmlinuz-2.6.21.4-eeepc quiet rw vga=785 irqpoll i8042.noloop=1 root=/dev/sda1
    initrd /boot/initramfs-fsck-eeepc.img
Then save it (Save As) again in /home/user.

3) Boot into rescue mode and copy the 2 files initramfs-fsck-eeepc.img and grub menu.lst from /dev/sda2 to corresponding locations in /dev/sda1 (Read this wiki) for detailed instructions.

The source location of the files should be: /mnt-user/home/user/, and the destination locations should be:
/mnt-system/boot/initramfs-fsck-eeepc.img
/mnt-system/boot/grub/menu.lst

4) Umount the drives, wait at least 15 secs. Then reboot and press F9 during system startup and select the menu entry "Perform Disk Scan on sda1".

DIY STEPS
I assume you have considerable Linux knowledge if you are going to build it yourself, so I just listed out the commands for each step here instead of offering detailed explanations.
mkdir /boot/temp
cd /boot/temp/
gunzip < ../initramfs-eeepc.img | cpio -i
1) check dynamic libraries required to run e2fsck (and tune2fs if you have changed to ext3) and copy them to the folder lib/ in the new initramfs image filesystem you have unpacked:
ldd /sbin/e2fsck /sbin/tune2fs
mkdir lib lib/tls
cd /lib
cp libext2fs.so.2 libcom_err.so.2 libblkid.so.1 libuuid.so.1 libdevmapper.so.1.02 libselinux.so.1 libsepol.so.1 ld-linux.so.2 libe2p.so.2 /boot/temp/lib/
cd /lib/tls
cp libpthread.so.0 libc.so.6 libdl.so.2 /boot/temp/lib/tls/
[NB. The library linux-gate.so.1 can be neglected]

2) Copy required binaries to sbin/:
- /sbin/e2fsck (to run filesystem check)
- /sbin/tune2fs (if you have changed to ext3)
- /sbin/busybox.asus (to safety reboot system)
- /sbin/scanuser.sh (script to automate filesystem scanning)
mkdir /boot/temp/sbin
cd /sbin
cp e2fsck tune2fs busybox.asus scanuser.sh /boot/temp/sbin
cd /boot/temp/sbin
mv scanuser.sh scan_system.sh
kwrite scan_system.sh &
Edit scan_system.sh, replace with this content [NB. Uncomment the line for /sbin/tune2fs if you have changed filesystem in sda1 to ext3]:
#!/bin/sh

ln -s /proc/mounts /etc/mtab

echo "Scanning system partition, please wait..."

/sbin/e2fsck -c -y /dev/sda1
#/sbin/tune2fs -j /dev/sda1

echo
echo "Press <ENTER> to reboot..."

read REPLY
echo "Rebooting..."
echo
umount /proc
sleep 5
/sbin/busybox.asus reboot -f
Give this file exec permission:
chmod +x /boot/temp/sbin/scan_system.sh
3) Edit init, replace with just these few lines:
#!/bin/sh
mount -t proc proc /proc

if [ -n "$XANDROSBOOTDEBUG" ]; then
    /bin/busybox sh
    set -x
fi

exec /sbin/scan_system.sh
4) Re-pack the initramfs image:
cd /boot/temp/
find | cpio -H newc -o | gzip -9 > ../initramfs-fsck-eeepc.img
5) Continue from step 2 in EASY STEPS above.

Edited by albkwan, 16 August 2009 - 03:12 PM.

EeePC 4G white,
Default Xandros (Easy Mode + icewm start menu) on 1st SSD/2nd 16GB SSD added/SD/USB/
http://eeepc.fire.prohosting.com/
http://eeepc-albkwan.blogspot.com/

#2 Marcio Araujo

    New member

  • Members
  • 2 posts
  • LocationBrasilia - Brazil

Posted 13 August 2008 - 05:06 PM

albkwan,

coud help me understand what's going on here in my filesystem check?

"... ext2fs_check_if_mount: No such file or directory while determining whether /dev/sda1 is mounted ..."

The filesystem check is OK! My Eeepc config is XANDROS without UNIONFS, have only /dev/sda1, ext3 formated.
I edited file scan_system.sh, and replace content. My option scan was:

/sbin/e2fsck -c -y /dev/sda1
#/sbin/tune2fs -j /dev/sda1

Thanks!

Marcio Araujo
Brasilia - BRAZIL



screen messages:

************************************

Scanning systema partition, please wait...

e2fsck 1.40-WIP (14-Nov-2006)
ext2fs_check_if_mount: No such file or directory while determining whether /dev/sda1 is mounted
Superblock last write time is in the future. Fix? yes

sh: badblocks: no found
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information

SYSTEM: ***** FILE SYSTEM WAS MODIFIED *****
SYSTEM: 79589/476160 files (0.9% non-contiguous), 580529/971924 blocks

Press <ENTER> to reboot

************************************
Eeepc 4G 701 - White - SDHC 8Gb
Xandros Asus - 1Gb Memory
Brasilia - DF - Brasil

#3 albkwan

    ExtrEmE User

  • Members
  • 1,440 posts
  • LocationHong Kong

Posted 13 August 2008 - 05:31 PM

Quote

"... ext2fs_check_if_mount: No such file or directory while determining whether /dev/sda1 is mounted ..."
This is OK. Usually before running fsck, the system will first check whether the partition is mounted because running filesystem check on a mounted partition is not recommended - indeed dangerous!

In the init ram filesystem, there is no such records (in particular, I think because /etc/mtab is missing), therefore it will give such message. This is normal. Not a problem.

Quote

The filesystem check is OK! My Eeepc config is XANDROS without UNIONFS, have only /dev/sda1, ext3 formated.
I edited file scan_system.sh, and replace content. My option scan was:

/sbin/e2fsck -c -y /dev/sda1
#/sbin/tune2fs -j /dev/sda1
If you are using ext3, you should uncomment the 2nd line, so that the journals will also be checked.

Quote

Superblock last write time is in the future. Fix? yes
This means the time recorded in the filesystem is somehow not correct. Some people has this error if they have windows and Linux dual boot in the same machine because windows use local time and Linux use UTC. It can also be due to some mount options. But this is no big deal.
EeePC 4G white,
Default Xandros (Easy Mode + icewm start menu) on 1st SSD/2nd 16GB SSD added/SD/USB/
http://eeepc.fire.prohosting.com/
http://eeepc-albkwan.blogspot.com/

#4 Marcio Araujo

    New member

  • Members
  • 2 posts
  • LocationBrasilia - Brazil

Posted 13 August 2008 - 07:27 PM

albkwan,

I am very satisfied.

Many Thanks!

Marcio Araujo
Eeepc 4G 701 - White - SDHC 8Gb
Xandros Asus - 1Gb Memory
Brasilia - DF - Brasil





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users