LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to umount "/" file system (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-umount-file-system-884292/)

bkarthick 06-03-2011 04:53 AM

How to umount "/" file system
 
Hi,

I want to umount root partition.

below is the o/p for df -h

Filesystem Size Used Avail Use% Mounted on
/dev/sda1 12G 3.2G 7.8G 30% /
tmpfs 506M 0 506M 0% /dev/shm

If i give #umount /dev/sda1 im getting the below error.i can't unmount the file system
umount: /: device is busy
umount: /: device is busy

thanks,

Nylex 06-03-2011 04:55 AM

You obviously can't unmount a partition that's in use. What do you want to do to that partition? You could just get a live CD and do whatever it is on the unmounted partition.

bkarthick 06-03-2011 04:57 AM

I want to run fsck command.so i need to unmount the filesystem.

Nylex 06-03-2011 04:58 AM

You can't use a live CD for this because..?

saivnoba 06-03-2011 04:58 AM

karthick,
You get that error because u are executing that command from within root partition. You cannot do that. Why would you want to unmount '/' (root) partition?! If you want to edit/troubleshoot something on your linux partition, use livecd.

(When I started typing it was a zero-reply thread. By the time I hit enter, I'm the 5th. :-P )

fsck is done automatically after certain mounts during boot. But if you want to force fsck you can try (as root user),
Code:

shutdown -rF now
. This should reboot your system and when it boots it will first run fsck.

bkarthick 06-03-2011 05:00 AM

@saivnoba

correct me if am wrong..
How do i check my file system ?

To use fsck first i need to umount the file system right ?

bkarthick 06-03-2011 05:03 AM

Greetings,

And also i'm going to change the filesystem from ext2 to ext3.

for this i need to unmount the partiton.Without unmounting i can't do it.

Nylex 06-03-2011 05:05 AM

Again, why can't you use a live CD to do this?

NM04 06-03-2011 05:13 AM

bkarthic,

first close all the running programs, and then execute umount /dev/sda1. Make sure you have a backup of data and also that you selected the correct partition.

Kind Regards.

bkarthick 06-03-2011 05:13 AM

Greetings,

All our servers are in Sweeden.And am in India.I can't use Live Cd or shutdown -rF now.Its all production servers.If it goes down,then i will get trashed.

Without live cd tell me how to check the filesystem.

TobiSGD 06-03-2011 05:17 AM

Your only option is the mentioned reboot command.
Also, if it is a production server I would recommend not to change the filesystem, unless there is a real good reason for that.

NM04 06-03-2011 05:25 AM

someone please tell me what is a production server ?

TobiSGD 06-03-2011 05:26 AM

Quote:

Originally Posted by NM04 (Post 4374961)
someone please tell me what is a production server ?

A server that is essential for a company to get their work done.

Karl Godt 06-03-2011 05:44 AM

On boot you could :
put in an exit into /etc/rc.d/rc.sysinit to drop out into a shell ro mount -o remount,ro / for a fsck -n /dev/sda1

boot with the kernel parameters " S init=bin/bash "

On a running system :

Create a or several ramdisks with
Code:

mkfs.ext2 /dev/ram[0-9]
and copy needed files from /bin /sbin /lib /etc into it and
use something like
Code:

mkdir /mnt/ram0
mount /dev/ram0 /mnt/ram0
mkdir /mnt/ram0/old_root
mkdir -p /mnt/ram0 /mnt/ram0/bin /mnt/ram0/sbin /mnt/ram0/lib /mnt/ram0/proc /mnt/ram0/etc
cp -a /bin /mnt/ram0
cp -a /sbin /mnt/ram0
cp -a /lib/lib*.so* /mnt/ram0/lib
cp -ar /etc /mnt/ram0
mount -o move /proc /mnt/ram0/proc
chdir /mnt/ram0
pivot_root . old_root
cd /
umount -l old_root
fsck /dev/sda1
mount /dev/sda1 old_root
cd old_root
pivot_root . /mnt/ram0
umount -l /mnt/ram0

This would work best with a statically compiled busybox includig ash which has got fsck.ext[2-3] and of course statically compiled fsck's for /lib/lib*.so* could become too large .
For a first better understanding try dl puppylinux 5series , which comes with a /sbin/init shellscript that contains this code .

segmentation_fault 06-03-2011 06:31 AM

Could this work?
Code:

mount / -o remount,ro
AFAIK fsck needs the partition to be mounted read-only, not unmounted. But I don't know how the network connection is affected from this. (I have only done this localy in runlevel 1).

TobiSGD 06-03-2011 06:35 AM

Quote:

Originally Posted by segmentation_fault (Post 4375017)
Could this work?
Code:

mount / -o remount,ro
AFAIK fsck needs the partition to be mounted read-only, not unmounted. But I don't know how the network connection is affected from this. (I have only done this localy in runlevel 1).

I doubt that this will work in normal use, you will have to do that in runlevel 1. But as the OP states that he can't reboot the machine because it is a production machine I doubt that switching to runlevel 1 is an option.

bkarthick 06-03-2011 09:11 PM

Greetings,

I WIll try and get back to you..

Thanks

Wim Sturkenboom 06-04-2011 12:41 AM

You don't fiddle with production servers. The risks are far too high if this is mission critical.

Do the changes on your backup server first and test; next make that one the primary server and you can now do the exercise on the old primary.


All times are GMT -5. The time now is 03:37 PM.