I'm working on Linux OpenWrt where I have to mount and umount manually USB disks when they are attached to the router.
I'm using this script: http://wiki.openwrt.org/doc/howto/writable_ntfs#with.a.custom.hotplug.script to mount and unmount automatically USB disks the problem is that it doesn't delete the mounting directory after umount -l /dev/$device. My application on the router needs to check if the USB disk is present or not by checking if /mnt/sda1 exists or not
My question is: is it dangerous to add rm -r sda1 after umount -l /dev/$device, or is there a risk that rm -r sda1 will remove files in sda1 ?
It should be safe to delete the directory after the umount if you check for the success of the umount command before but I would suggest to change you script to check if the mountpoint it's listed in the mount table instead with mount | grep sda1
Related
I'm trying to make a fast reboot to the other Linux system. First step is kernel loading, I make it with
sudo kexec --append='$(cat /proc/cmdline)' -l new_kernel.img --reuse-cmdline
sudo kexec -e
It works fine, but loads only kernel, not entire system.
How can I mount an *.img file with OS resources, located at USB as /? Preferable during kernel loading, but afterwards mount is still suitable. *.img format is not necessary, it can be unpacked before
As stark said, pivot root() was the call I was searching for. Commands to make a USB located at /dev/sdb1 a root directory:
sudo -s
mkdir /newroot
mount /dev/sdb1 /newroot
cd /newroot
mkdir oldroot
pivot_root . oldroot/
switch_root() deletes all files at the previous root dir, also there are few other differences, this answer might be useful
As you can see /dev/sda is mounted to /. Thats where /tmp/ is located as shown image. Since It is running out of space on my / partition,I can't install caffe, and there is error: No space left on device.
Now I want to create a new partition on /dev/sdb1 (which still has 1.5tb of free space) and mount it on /tmp/.
Could you guys tell me how to create a new partition for solving this issue by linux command.
thanks
Just give the following command
To unmont the existing volume give the following
sudo umount /dev/sdb1
Note:- Make sure no process is using the particular directory
Then again mount it to /tmp
sudo mount /dev/sdb1 /tmp
or
cd /dev/ && sudo mount sdb1 /tmp
I'm trying to run a mumble server (umurmur) on my dd-wrt router (Buffalo WZR-HP-AG300H). I flashed one of the recent community versions of dd-wrt on the device (SVN Rev.: 23320), it has an Atheros CPU inside.
After that I mounted a USB pendrive into the filesystem using these guides (Guide 1, Guide 2) and created writable directories. Here is my startup-script saved to nvram (via web-gui)
EDIT: USB pendrive should be partioned before using it with DD-Wrt.
#!/bin/sh
sleep 5
insmod mbcache
insmod jbd
insmod ext3
mkdir '/mnt/part1'
mkdir '/mnt/part2'
mount -t ext3 -o noatime /dev/sda5 /mnt/part1 # /dev/sda5 -> partition on USB pendrive
mount -t ext3 -o noatime /dev/sda7 /mnt/part2 # /dev/sda7 -> partition on USB pendrive
swapon /dev/sda6 # /dev/sda6 -> partition on USB pendrive
sleep 2
if [ -f /mnt/part1/optware.enable ];then
#mount -o bind /mnt/part2 /mnt/part1/root
mount -o bind /mnt/part1 /jffs
mount -o bind /mnt/part1/etc /etc
mount -o bind /mnt/part1/opt /opt
mount -o bind /mnt/part1/root /tmp/root
else
exit
fi
if [ -d /opt/usr ]; then
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/lib:/usr/lib:/opt/lib:/opt/usr/lib:/jffs/usr/lib:/jffs/usr/local/lib
export PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin:/jffs/bin:/opt/bin:/opt/sbin:/opt/usr/bin:/opt/usr/sbin
export IPKG_INSTROOT=/opt
else
exit
fi
The script works well and I can use opkg to install packages. I can also run umurmur manually but I'm struggling on making umurmur autostart. I recognized that the umurmur startup script placed in /opt/etc/init.d/ requires arguments like start and stop but it seems they are called without any arguments.
Another way described here did not work too.
Has anyone a working solution on problems like these? Please help!
Optware runs on Broadcom routers only. Your's has an Atheros chipset.
Taken from this page: Link
Its unclear i the page you referred to has changed - and indeed my setup is fairly different to yours, but to get scripts working on startup I did the following -
mkdir -p /jffs/etc/config
copy script into /jffs/etc/config directory, renaming it to end with .startup
chmod 755 /jffs/etc/config/scriptname.startup
I am new to fuse. When I try to run a FUSE client program I get this error:
fuse: mountpoint is not empty
fuse: if you are sure this is safe, use the 'nonempty' mount option
I understand that a mountpoint is the directory where you will logically attach the FUSE filesystem. What will happen if I mount to this location? What are the dangers? Is it just that the directory will be overwritten? Basically: what will happen if you mount to a non empty directory?
You need to make sure that the files on the device mounted by fuse will not have the same paths and file names as files which already existing in the nonempty mountpoint. Otherwise this would lead to confusion. If you are sure, pass -o nonempty to the mount command.
You can try what is happening using the following commands.. (Linux rocks!) .. without destroying anything..
// create 10 MB file
dd if=/dev/zero of=partition bs=1024 count=10240
// create loopdevice from that file
sudo losetup /dev/loop0 ./partition
// create filesystem on it
sudo e2mkfs.ext3 /dev/loop0
// mount the partition to temporary folder and create a file
mkdir test
sudo mount -o loop /dev/loop0 test
echo "bar" | sudo tee test/foo
# unmount the device
sudo umount /dev/loop0
# create the file again
echo "bar2" > test/foo
# now mount the device (having file with same name on it)
# and see what happens
sudo mount -o loop /dev/loop0 test
Just add -o nonempty in command line, like this:
s3fs -o nonempty <bucket-name> </mount/point/>
Apparently nothing happens, it fails in a non-destructive way and gives you a warning.
I've had this happen as well very recently. One way you can solve this is by moving all the files in the non-empty mount point to somewhere else, e.g.:
mv /nonEmptyMountPoint/* ~/Desktop/mountPointDump/
This way your mount point is now empty, and your mount command will work.
For me the error message goes away if I unmount the old mount before mounting it again:
fusermount -u /mnt/point
If it's not already mounted you get a non-critical error:
$ fusermount -u /mnt/point
fusermount: entry for /mnt/point not found in /etc/mtab
So in my script I just put unmount it before mounting it.
Just set "nonempty" as an optional value in your /etc/fstab
For example:
## mount a bucket
/usr/local/bin/s3fs#{your_bucket_name} {local_mounted_dir} fuse _netdev,url={your_bucket_endpoint_url},allow_other,nonempty 0 0
## mount a sub-directory of bucket, Do like this:
/usr/local/bin/s3fs#{your_bucket_name}:{sub_dir} {local_mounted_dir} fuse _netdev,url={your_bucket_endpoint_url},allow_other,nonempty 0 0
force it with -l
sudo umount -l ${HOME}/mount_dir
So let's say I have a file attached to a loop device /dev/loop1 how could I mount that using fuse (filesystem in user space) ?
If you're using fuse, you don't need a loop device at all, and can directly mount the file itself. So, you can do either this:
$ sudo ext4fuse test.ext4 /mnt
Or, if for some bizarre reason you really want to use a loop device, this:
$ sudo losetup /dev/loop0 test.ext4
$ sudo ext4fuse /dev/loop0 /mnt
Once you set the permissions of the loop device so that the fuse process can access it, you can mount it the same way as any other device.